24 #include <openssl/rand.h>
25 #include <netinet/in.h>
37 _gcm_iv.salt = htonl(salt);
40 if (!RAND_bytes(_gcm_iv.initialisation_vector,
iv_len))
44 for (
unsigned int i = 0; i <
iv_len; ++i)
45 _used_initialisation_vector[i] = _gcm_iv.initialisation_vector[i];
48 gcm_init_message(reinterpret_cast<unsigned char *>(&_gcm_iv),
sizeof(gcm_iv), &_ctx);
59 _gcm_iv.salt = htonl(salt);
62 for (
unsigned int i = 0; i <
iv_len; ++i)
64 _gcm_iv.initialisation_vector[i] = iv[i];
65 _used_initialisation_vector[i] = iv[i];
69 gcm_init_message(reinterpret_cast<unsigned char *>(&_gcm_iv),
sizeof(gcm_iv), &_ctx);
80 for (
unsigned int i = 0; i <
iv_len; ++i)
81 to_iv[i] = _used_initialisation_vector[i];
99 return (::memcmp(tag, verify_tag, tag_len) == 0);
107 gcm_encrypt(reinterpret_cast<unsigned char *>(buf), size, &_ctx);
112 gcm_decrypt(reinterpret_cast<unsigned char *>(buf), size, &_ctx);