curve: use sizeof instead of hard coded value
authorDaniel Borkmann <dborkman@redhat.com>
Tue, 29 Jan 2013 17:15:25 +0000 (29 18:15 +0100)
committerDaniel Borkmann <dborkman@redhat.com>
Tue, 29 Jan 2013 17:15:25 +0000 (29 18:15 +0100)
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
curve.c

diff --git a/curve.c b/curve.c
index 5d033c9..6d04266 100644 (file)
--- a/curve.c
+++ b/curve.c
@@ -33,7 +33,7 @@
 #define crypto_box_afternm             crypto_box_curve25519xsalsa20poly1305_afternm
 #define crypto_box_open_afternm                crypto_box_curve25519xsalsa20poly1305_open_afternm
 
-#define NONCE_LENGTH                   16 /* size of taia */
+#define NONCE_LENGTH                   (sizeof(struct taia))
 #define NONCE_OFFSET                   (crypto_box_curve25519xsalsa20poly1305_NONCEBYTES - NONCE_LENGTH)
 
 void curve25519_selftest(void)
@@ -102,6 +102,8 @@ void curve25519_selftest(void)
                0xe3, 0x55, 0xa5
        };
 
+       bug_on(NONCE_LENGTH != 16);
+
        crypto_box_curve25519xsalsa20poly1305(c, m, 163, nonce, bobpk, alicesk);
 
        for (i = 16; i < 163; ++i) {