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

Class Aes_ctr_encryptor

crypto.hpp:68–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

66};
67
68class Aes_ctr_encryptor {
69public:
70 enum {
71 NONCE_LEN = 12,
72 KEY_LEN = AES_KEY_LEN,
73 BLOCK_LEN = 16,
74 MAX_CRYPT_BYTES = (1ULL<<32)*16 // Don't encrypt more than this or the CTR value will repeat itself
75 };
76
77private:
78 Aes_ecb_encryptor ecb;
79 unsigned char ctr_value[BLOCK_LEN]; // Current CTR value (used as input to AES to derive pad)
80 unsigned char pad[BLOCK_LEN]; // Current encryption pad (output of AES)
81 uint32_t byte_counter; // How many bytes processed so far?
82
83public:
84 Aes_ctr_encryptor (const unsigned char* key, const unsigned char* nonce);
85 ~Aes_ctr_encryptor ();
86
87 void process (const unsigned char* in, unsigned char* out, size_t len);
88
89 // Encrypt/decrypt an entire input stream, writing to the given output stream
90 static void process_stream (std::istream& in, std::ostream& out, const unsigned char* key, const unsigned char* nonce);
91};
92
93typedef Aes_ctr_encryptor Aes_ctr_decryptor;
94

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected