diff options
Diffstat (limited to 'src/libcharon/encoding/payloads/encryption_payload.c')
-rw-r--r-- | src/libcharon/encoding/payloads/encryption_payload.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/libcharon/encoding/payloads/encryption_payload.c b/src/libcharon/encoding/payloads/encryption_payload.c index 6ba1b23a0..6a9f9c3bd 100644 --- a/src/libcharon/encoding/payloads/encryption_payload.c +++ b/src/libcharon/encoding/payloads/encryption_payload.c @@ -309,10 +309,11 @@ static chunk_t append_header(private_encryption_payload_t *this, chunk_t assoc) } METHOD(encryption_payload_t, encrypt, status_t, - private_encryption_payload_t *this, chunk_t assoc) + private_encryption_payload_t *this, u_int64_t mid, chunk_t assoc) { chunk_t iv, plain, padding, icv, crypt; generator_t *generator; + iv_gen_t *iv_gen; rng_t *rng; size_t bs; @@ -329,6 +330,13 @@ METHOD(encryption_payload_t, encrypt, status_t, return NOT_SUPPORTED; } + iv_gen = this->aead->get_iv_gen(this->aead); + if (!iv_gen) + { + DBG1(DBG_ENC, "encrypting encryption payload failed, no IV generator"); + return NOT_SUPPORTED; + } + assoc = append_header(this, assoc); generator = generator_create(); @@ -356,7 +364,7 @@ METHOD(encryption_payload_t, encrypt, status_t, crypt = chunk_create(plain.ptr, plain.len + padding.len); generator->destroy(generator); - if (!rng->get_bytes(rng, iv.len, iv.ptr) || + if (!iv_gen->get_iv(iv_gen, mid, iv.len, iv.ptr) || !rng->get_bytes(rng, padding.len - 1, padding.ptr)) { DBG1(DBG_ENC, "encrypting encryption payload failed, no IV or padding"); @@ -388,7 +396,7 @@ METHOD(encryption_payload_t, encrypt, status_t, } METHOD(encryption_payload_t, encrypt_v1, status_t, - private_encryption_payload_t *this, chunk_t iv) + private_encryption_payload_t *this, u_int64_t mid, chunk_t iv) { generator_t *generator; chunk_t plain, padding; |