diff options
Diffstat (limited to 'src/libcharon')
-rw-r--r-- | src/libcharon/encoding/message.c | 2 | ||||
-rw-r--r-- | src/libcharon/encoding/payloads/encryption_payload.c | 6 | ||||
-rw-r--r-- | src/libcharon/encoding/payloads/encryption_payload.h | 4 |
3 files changed, 7 insertions, 5 deletions
diff --git a/src/libcharon/encoding/message.c b/src/libcharon/encoding/message.c index 9fc108b40..11e735a37 100644 --- a/src/libcharon/encoding/message.c +++ b/src/libcharon/encoding/message.c @@ -1622,7 +1622,7 @@ METHOD(message_t, generate, status_t, htoun32(lenpos, chunk.len + encryption->get_length(encryption)); } this->payloads->insert_last(this->payloads, encryption); - if (encryption->encrypt(encryption, chunk) != SUCCESS) + if (encryption->encrypt(encryption, this->message_id, chunk) != SUCCESS) { generator->destroy(generator); return INVALID_STATE; diff --git a/src/libcharon/encoding/payloads/encryption_payload.c b/src/libcharon/encoding/payloads/encryption_payload.c index 302c4a45a..6a9f9c3bd 100644 --- a/src/libcharon/encoding/payloads/encryption_payload.c +++ b/src/libcharon/encoding/payloads/encryption_payload.c @@ -309,7 +309,7 @@ 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; @@ -364,7 +364,7 @@ METHOD(encryption_payload_t, encrypt, status_t, crypt = chunk_create(plain.ptr, plain.len + padding.len); generator->destroy(generator); - if (!iv_gen->get_iv(iv_gen, 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"); @@ -396,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; diff --git a/src/libcharon/encoding/payloads/encryption_payload.h b/src/libcharon/encoding/payloads/encryption_payload.h index 5c6069339..f4fc7d667 100644 --- a/src/libcharon/encoding/payloads/encryption_payload.h +++ b/src/libcharon/encoding/payloads/encryption_payload.h @@ -71,13 +71,15 @@ struct encryption_payload_t { /** * Generate, encrypt and sign contained payloads. * + * @param mid message ID * @param assoc associated data * @return * - SUCCESS if encryption successful * - FAILED if encryption failed * - INVALID_STATE if aead not supplied, but needed */ - status_t (*encrypt) (encryption_payload_t *this, chunk_t assoc); + status_t (*encrypt) (encryption_payload_t *this, u_int64_t mid, + chunk_t assoc); /** * Decrypt, verify and parse contained payloads. |