All Questions
Tagged with cryptography c
40
questions
1
vote
3
answers
126
views
Sign a message with a Bitcoin private key
I am writing code in C, and I need to do various operations with Bitcoin, from generating key pairs, to sign messages to post transactions. I found libraries for C++, but nothing in C that does all ...
11
votes
3
answers
2k
views
SHA-256 Implementation
I've been working on a byte-oriented SHA-256 implementation for educational purposes. I then tested it using the NIST CAVP tests found here.
All tests pass but I would appreciate some feedback from a ...
-3
votes
1
answer
298
views
Simplistic C program to encrypt and decrypt a string [closed]
I wanted to improve a crypter from internet. I found it poor and modified it.
Do you like it?
...
0
votes
2
answers
954
views
Encryption and Decryption in C
I have written a program in C, which encrypts and decrypts a c-styled string (const char *) and print the result to stdout. It ...
2
votes
0
answers
69
views
Simple CLI File Encryption
This program is designed to work on the command line by piping stdin to stdout and encrypting or decrypting the input using a symmetric key.
Any suggestions for improvement would be greatly ...
2
votes
1
answer
193
views
encrypt files using a variant of Vernam Cipher in C language
I'm coding this program that allows you to encrypt files using vernam cipher in C language. I would be glad if you could inspect my code and tell me if I can make some improvements to it or if there ...
1
vote
1
answer
42
views
tokenize char array with PolarSSL library
I'm trying to perform a decryption operation using RSA. I'm using the PolarSSl library. I have a char array key[] that contains RSA private key like the following,
<...
6
votes
4
answers
2k
views
Vigenere cipher C program
I implemented a Vigenere cipher that preserves case and can also decrypt if you pass the -d argument. Usage is ...
3
votes
3
answers
2k
views
Substitution Cipher in C
I was directed here from Stack Overflow.
I completed my recent programming assignment for developing a substitution cipher in C. Below is what I came up with after reading many tutorials, googling ...
6
votes
2
answers
5k
views
Xor encryption in C
Based on this code found on github and the advice given to me on stackoverflow I made this code for the xor in c.
...
4
votes
2
answers
104
views
Encrypting file from source AEAD
I am trying to encrypt/decrypt file using source code directly. The issue is how to properly do it after reading the file.
...
0
votes
3
answers
71
views
Implement state eraser for NIST DRBG and other crypto primitives using macro
As a spare-time personal project, I'm implementing a set of symmetric-key cryptographic primitives.
One thing I've left vacant for a long time, is the key/state eraser, which I decide to add right ...
11
votes
2
answers
2k
views
Implementation of the Jacobi Symbol in C
I am new to C programming and wrote the following algorithm for the calculation of the Jacobi Symbol. Though there are some faster versions of this algorithm available I am only looking for some ...
5
votes
1
answer
72
views
High performance wrapper for CSPRNG arc4random(3)
This function is a wrapper for arc4random(3), a cryptographic pseudo-random number generator on macOS and BSDs, but you can also get it by installing ...
9
votes
2
answers
921
views
RSA c implementation
This is my first attempt to implement a crypto algorithm.
I am using C and gmp to interact with big numbers.
I am basing my implementation of the RSA algorithm from the book "A handbook of ...
6
votes
2
answers
816
views
OpenSSL AES GCM Convenience Wrapper in C
I wrote this code for inclusion in a repository of encryption code examples. The cryptographic primitives in use are required for compatibility with the other code samples.
It's been a long while ...
14
votes
5
answers
3k
views
Cryptographically Secure Password Generation in C
I am looking for ways to improve my password generation code written in C. This is in the same vein as my code in C++ and Python with many improvements.
I am using ...
4
votes
1
answer
2k
views
Tiny Encryption Algorithm implementation in C
I was just looking for a general feedback about this code, which encrypts a file with the Tiny Encryption Algorithm. I'm currently studying C, and I wanted to know if there was anything I could ...
2
votes
2
answers
584
views
Incremental sha256sum computation
I ran across an interesting computation for a sha256sum that did not rely on the openssl or crypto libraries pdfcrack/sha256.c. The only difficulty with either of the functions (...
19
votes
1
answer
32k
views
Self-contained SHA-256 implementation in C
I have been looking for a SHA-256 implementation in C with no dependencies (preferably self-contained in a single C-file) with a permissive license but found none to my liking.
Since the Wikipedia ...
6
votes
1
answer
567
views
Encryption/decryption by matrix multiplication in C
I need to encrypt and decrypt text, image and video with a program in C with a matrix.
My program is working but it's really slow, how can I improve its speed ?
specially for the decrypt part.
Each ...
2
votes
0
answers
821
views
Wrapper/abstraction for encryption and decryption using OpenSSL
I am a beginner when it comes to cryptography and OpenSSL. I have written a short wrapper of some functions in OpenSSL as well as a test of this wrapper, copied below.
Specifically, this code is ...
6
votes
1
answer
239
views
"Cryptographic" hash function
I don't know much about the design of cryptographic hash functions but despite that I made an attempt for the sake of learning. This is what I got:
...
5
votes
1
answer
3k
views
Using SHA-512 for encryption/decryption
It occurred to me that if SHA2 can be used to derive keys from passwords, then it might as well be good enough to generate random data that can be xored with a plaintext to encrypt and the other way ...
3
votes
2
answers
450
views
Intel® TinyCrypt: AES-128/CTR to encryption/decryption of 2D arrays
I need to encrypt/decrypt 2D arrays (double pointers) using AES-128/CTR using Intel TinyCrypt (written in C). The following are two helper methods to simplify the library usage. Any comments would be ...
4
votes
1
answer
68
views
AES Wrap function
This code is supposed to implement RFC 3394 which also described in this PDF at page 11.
Are there any weak places or formatting issues in attached source? Or maybe some places are not explicit enough?...
5
votes
5
answers
3k
views
XOR encryption program in C
I've written a program that encrypts files (or stdin) with a user-specified key from 1 to 255. This "encryption" is very insecure, but still a bit better than ROT13 ...
10
votes
3
answers
395
views
What an Enigma! (Machine Simulator)
I've made this some time ago for an assignment and I was wondering how it could be improved both in terms of performance and best practices for C code.
...
6
votes
3
answers
2k
views
Cryptoanalysis of Vigenere-ciphered text with Kasiski test
I am creating a program that will analyse encrypted text using Kasiski examination in order to find possible key length:
...
3
votes
1
answer
792
views
Recreating binary counter for arbitrary length arrays
After weeks of slaving over FIPS-197, I finally have my own working C/C# implementation of AES-128 which I'm quite happy about.
The next thing I'm looking to do is implement a ...
3
votes
1
answer
562
views
Structure and style of Enigma Machine
I took a little time and wrote the following code to produce enigma encryption. I don't normally write code in C so I would like to get feedback on the way it has been structured and any issues a ...
7
votes
2
answers
3k
views
Dictionary brute force on DES encrypted passwords
For a school project I am tasked to decrypt DES passwords. I have sample code provided below and I want to know if this is the best method. Also should I code in error handling for the dictionary ...
8
votes
2
answers
3k
views
OpenSSL PBKDF2-HMAC-SHAx proof of concept
I have regrettably been away from C programming for a very long time, so I'd like to get a quick code review of a first proof of concept, before I get too far into adding capabilities, using the ...
15
votes
6
answers
11k
views
Small one time pad encryption program
This one time pad encryption program I have written (basically just an XOR "encryption" program) seems to be working fine, compiling nicely (gcc -o ./OTP.c), and doing what it's supposed to. However I ...
7
votes
1
answer
120
views
Embed MD5 digest in a directory path name
My boss needs me to embed the MD5 digest in a file path, but the problem is MD5 contains escape characters.
I've already taught about a uc%duc%d... format, but it ...
8
votes
1
answer
17k
views
6
votes
2
answers
7k
views
HMAC-SHA1 implementation
I am trying out a small piece of code that would generate HMAC-SHA1. I have been asked to code the HMAC implementation myself using the OpenSSL libs for SHA1 calculation.
After 'wiki'ing for the ...
6
votes
1
answer
474
views
Forming word combinations from file
I am looking for ideas to optimize the below code for speed. I'm also looking for some good improvement in execution time.
This code reads a text file. The text file has many lines of ASCII text. ...
32
votes
5
answers
24k
views
Tiny Encryption Algorithm (TEA) for arbitrary sized data
The TEA is a very simple encryption algorithm requiring little time and space - perfect for embedded systems. There are extensions to it, and every version has its flaws (WEP was based on it), but ...