From: Niels Möller Date: Thu, 1 Dec 2022 18:17:24 +0000 (+0100) Subject: Improve consistency with other message functions. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5b6890f779a4e03a44819993c1319c0d00e2b967;p=thirdparty%2Fnettle.git Improve consistency with other message functions. --- 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); } diff --git a/ocb.c b/ocb.c index 6e3b3bb3..c2b524cd 100644 --- a/ocb.c +++ b/ocb.c @@ -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); } diff --git a/ocb.h b/ocb.h index 4bc12ad2..a5bc93ec 100644 --- a/ocb.h +++ b/ocb.h @@ -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 }