MCPcopy Create free account
hub / github.com/AGWA/git-crypt / process

Method process

crypto.cpp:49–67  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47}
48
49void Aes_ctr_encryptor::process (const unsigned char* in, unsigned char* out, size_t len)
50{
51 for (size_t i = 0; i < len; ++i) {
52 if (byte_counter % BLOCK_LEN == 0) {
53 // Set last 4 bytes of CTR to the (big-endian) block number (sequentially increasing with each block)
54 store_be32(ctr_value + NONCE_LEN, byte_counter / BLOCK_LEN);
55
56 // Generate a new pad
57 ecb.encrypt(ctr_value, pad);
58 }
59
60 // encrypt one byte
61 out[i] = in[i] ^ pad[byte_counter++ % BLOCK_LEN];
62
63 if (byte_counter == 0) {
64 throw Crypto_error("Aes_ctr_encryptor::process", "Too much data to encrypt securely");
65 }
66 }
67}
68
69// Encrypt/decrypt an entire input stream, writing to the given output stream
70void Aes_ctr_encryptor::process_stream (std::istream& in, std::ostream& out, const unsigned char* key, const unsigned char* nonce)

Callers 3

process_streamMethod · 0.80
cleanFunction · 0.80
decrypt_file_to_stdoutFunction · 0.80

Calls 3

store_be32Function · 0.85
Crypto_errorClass · 0.85
encryptMethod · 0.80

Tested by

no test coverage detected