summaryrefslogtreecommitdiff
path: root/src/libstrongswan/plugins/gcm/gcm_aead.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstrongswan/plugins/gcm/gcm_aead.c')
-rw-r--r--src/libstrongswan/plugins/gcm/gcm_aead.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/libstrongswan/plugins/gcm/gcm_aead.c b/src/libstrongswan/plugins/gcm/gcm_aead.c
index 79ee65d98..ba5f2e4b3 100644
--- a/src/libstrongswan/plugins/gcm/gcm_aead.c
+++ b/src/libstrongswan/plugins/gcm/gcm_aead.c
@@ -16,6 +16,7 @@
#include "gcm_aead.h"
#include <limits.h>
+#include <crypto/iv/iv_gen_seq.h>
#define BLOCK_SIZE 16
#define NONCE_SIZE 12
@@ -40,6 +41,11 @@ struct private_gcm_aead_t {
crypter_t *crypter;
/**
+ * IV generator.
+ */
+ iv_gen_t *iv_gen;
+
+ /**
* Size of the integrity check value
*/
size_t icv_size;
@@ -337,6 +343,12 @@ METHOD(aead_t, get_iv_size, size_t,
return IV_SIZE;
}
+METHOD(aead_t, get_iv_gen, iv_gen_t*,
+ private_gcm_aead_t *this)
+{
+ return this->iv_gen;
+}
+
METHOD(aead_t, get_key_size, size_t,
private_gcm_aead_t *this)
{
@@ -356,6 +368,7 @@ METHOD(aead_t, destroy, void,
private_gcm_aead_t *this)
{
this->crypter->destroy(this->crypter);
+ this->iv_gen->destroy(this->iv_gen);
free(this);
}
@@ -405,12 +418,14 @@ gcm_aead_t *gcm_aead_create(encryption_algorithm_t algo, size_t key_size)
.get_block_size = _get_block_size,
.get_icv_size = _get_icv_size,
.get_iv_size = _get_iv_size,
+ .get_iv_gen = _get_iv_gen,
.get_key_size = _get_key_size,
.set_key = _set_key,
.destroy = _destroy,
},
},
.crypter = lib->crypto->create_crypter(lib->crypto, algo, key_size),
+ .iv_gen = iv_gen_seq_create(),
.icv_size = icv_size,
);