diff options
author | Niels Möller <nisse@lysator.liu.se> | 2022-12-01 19:17:24 +0100 |
---|---|---|
committer | Niels Möller <nisse@lysator.liu.se> | 2023-02-06 20:20:01 +0100 |
commit | 5b6890f779a4e03a44819993c1319c0d00e2b967 (patch) | |
tree | c1439a6ca190cab28f8d96c7a19c5d506fac369a | |
parent | 9a1f31c5bf9a4bef5cd06c56d1575886fc2347b1 (diff) | |
download | nettle-5b6890f779a4e03a44819993c1319c0d00e2b967.tar.gz |
Improve consistency with other message functions.
-rw-r--r-- | ocb-aes128.c | 12 | ||||
-rw-r--r-- | ocb.c | 10 | ||||
-rw-r--r-- | ocb.h | 13 |
3 files changed, 18 insertions, 17 deletions
diff --git a/ocb-aes128.c b/ocb-aes128.c index a24649fe..6c1b70dc 100644 --- a/ocb-aes128.c +++ b/ocb-aes128.c @@ -85,23 +85,23 @@ ocb_aes128_digest(struct ocb_aes128_ctx *ctx, size_t length, uint8_t *digest) void ocb_aes128_encrypt_message (const struct aes128_ctx *cipher, - size_t tlength, size_t nlength, const uint8_t *nonce, size_t alength, const uint8_t *adata, + size_t tlength, size_t clength, uint8_t *dst, const uint8_t *src) { struct ocb_key key; ocb_set_key (&key, cipher, (nettle_cipher_func *) aes128_encrypt); ocb_encrypt_message (&key, cipher, (nettle_cipher_func *) aes128_encrypt, - tlength, nlength, nonce, alength, adata, clength, dst, src); + nlength, nonce, alength, adata, tlength, clength, dst, src); } int ocb_aes128_decrypt_message (const struct aes128_ctx *cipher, - size_t tlength, size_t nlength, const uint8_t *nonce, size_t alength, const uint8_t *adata, - size_t plength, uint8_t *dst, const uint8_t *src) + size_t tlength, + size_t mlength, uint8_t *dst, const uint8_t *src) { struct ocb_key key; struct aes128_ctx decrypt_ctx; @@ -109,6 +109,6 @@ ocb_aes128_decrypt_message (const struct aes128_ctx *cipher, ocb_set_key (&key, cipher, (nettle_cipher_func *) aes128_encrypt); return ocb_decrypt_message (&key, cipher, (nettle_cipher_func *) aes128_encrypt, &decrypt_ctx, (nettle_cipher_func *) aes128_decrypt, - tlength, nlength, nonce, alength, adata, - plength, dst, src); + nlength, nonce, alength, adata, + tlength, mlength, dst, src); } @@ -246,9 +246,9 @@ ocb_digest (const struct ocb_ctx *ctx, const struct ocb_key *key, void ocb_encrypt_message (const struct ocb_key *key, const void *cipher, nettle_cipher_func *f, - size_t tlength, size_t nlength, const uint8_t *nonce, size_t alength, const uint8_t *adata, + size_t tlength, size_t clength, uint8_t *dst, const uint8_t *src) { struct ocb_ctx ctx; @@ -263,17 +263,17 @@ int ocb_decrypt_message (const struct ocb_key *key, const void *encrypt_ctx, nettle_cipher_func *encrypt, const void *decrypt_ctx, nettle_cipher_func *decrypt, - size_t tlength, size_t nlength, const uint8_t *nonce, size_t alength, const uint8_t *adata, - size_t plength, uint8_t *dst, const uint8_t *src) + size_t tlength, + size_t mlength, uint8_t *dst, const uint8_t *src) { struct ocb_ctx ctx; union nettle_block16 digest; ocb_set_nonce (&ctx, encrypt_ctx, encrypt, tlength, nlength, nonce); ocb_update (&ctx, key, encrypt_ctx, encrypt, alength, adata); ocb_decrypt (&ctx, key, encrypt_ctx, encrypt, decrypt_ctx, decrypt, - plength, dst, src); + mlength, dst, src); ocb_digest (&ctx, key, encrypt_ctx, encrypt, tlength, digest.b); - return memeql_sec(digest.b, src + plength, tlength); + return memeql_sec(digest.b, src + mlength, tlength); } @@ -51,6 +51,7 @@ extern "C" { #define ocb_encrypt_message nettle_ocb_encrypt_message #define ocb_decrypt_message nettle_ocb_decrypt_message #define ocb_aes128_set_key nettle_ocb_aes128_set_key +#define ocb_aes128_set_nonce nettle_ocb_aes128_set_nonce #define ocb_aes128_update nettle_ocb_aes128_update #define ocb_aes128_encrypt nettle_ocb_aes128_encrypt #define ocb_aes128_decrypt nettle_ocb_aes128_decrypt @@ -124,19 +125,19 @@ ocb_digest (const struct ocb_ctx *ctx, const struct ocb_key *key, void ocb_encrypt_message (const struct ocb_key *ocb_key, const void *cipher, nettle_cipher_func *f, - size_t tlength, size_t nlength, const uint8_t *nonce, size_t alength, const uint8_t *adata, + size_t tlength, size_t clength, uint8_t *dst, const uint8_t *src); int ocb_decrypt_message (const struct ocb_key *ocb_key, const void *encrypt_ctx, nettle_cipher_func *encrypt, const void *decrypt_ctx, nettle_cipher_func *decrypt, - size_t tlength, size_t nlength, const uint8_t *nonce, size_t alength, const uint8_t *adata, - size_t plength, uint8_t *dst, const uint8_t *src); + size_t tlength, + size_t mlength, uint8_t *dst, const uint8_t *src); /* OCB-AES */ struct ocb_aes128_ctx @@ -171,17 +172,17 @@ ocb_aes128_digest(struct ocb_aes128_ctx *ctx, size_t length, uint8_t *digest); void ocb_aes128_encrypt_message (const struct aes128_ctx *cipher, - size_t tlength, size_t nlength, const uint8_t *nonce, size_t alength, const uint8_t *adata, + size_t tlength, size_t clength, uint8_t *dst, const uint8_t *src); int ocb_aes128_decrypt_message (const struct aes128_ctx *cipher, - size_t tlength, size_t nlength, const uint8_t *nonce, size_t alength, const uint8_t *adata, - size_t clength, uint8_t *dst, const uint8_t *src); + size_t tlength, + size_t mlength, uint8_t *dst, const uint8_t *src); #ifdef __cplusplus } |