+2014-12-12 Niels Möller <nisse@lysator.liu.se>
+
+ * cbc.h (CBC_ENCRYPT, CBC_DECRYPT): Make type-checking hack
+ stricter, warn if type of length argument is smaller than size_t.
+ * ctr.h (CTR_CRYPT): Likewise.
+ * eax.h (EAX_SET_KEY, EAX_SET_NONCE, EAX_UPDATE, EAX_ENCRYPT)
+ (EAX_DECRYPT, EAX_DIGEST): Likewise.
+ * gcm.h (GCM_SET_KEY, GCM_ENCRYPT, GCM_DECRYPT, GCM_DIGEST):
+ Likewise.
+
2014-11-24 Niels Möller <nisse@lysator.liu.se>
* gcm.h (GCM_SET_KEY): Rename macro argument KEY to avoid
/* NOTE: Avoid using NULL, as we don't include anything defining it. */
#define CBC_ENCRYPT(self, f, length, dst, src) \
-(0 ? ((f)(&(self)->ctx, 0, (void *)0, (void *)0)) \
+ (0 ? ((f)(&(self)->ctx, ~(size_t) 0, \
+ (uint8_t *) 0, (const uint8_t *) 0)) \
: cbc_encrypt((void *) &(self)->ctx, \
(nettle_cipher_func *) (f), \
sizeof((self)->iv), (self)->iv, \
(length), (dst), (src)))
#define CBC_DECRYPT(self, f, length, dst, src) \
-(0 ? ((f)(&(self)->ctx, 0, (void *)0, (void *)0)) \
+ (0 ? ((f)(&(self)->ctx, ~(size_t) 0, \
+ (uint8_t *) 0, (const uint8_t *) 0)) \
: cbc_decrypt((void *) &(self)->ctx, \
(nettle_cipher_func *) (f), \
sizeof((self)->iv), (self)->iv, \
memcpy((ctx)->ctr, (data), sizeof((ctx)->ctr))
#define CTR_CRYPT(self, f, length, dst, src) \
-(0 ? ((f)(&(self)->ctx, 0, NULL, NULL)) \
+ (0 ? ((f)(&(self)->ctx, ~(size_t) 0, \
+ (uint8_t *) 0, (const uint8_t *) 0)) \
: ctr_crypt((void *) &(self)->ctx, \
(nettle_cipher_func *) (f), \
sizeof((self)->ctr), (self)->ctr, \
#define EAX_SET_KEY(ctx, set_key, encrypt, data) \
do { \
(set_key)(&(ctx)->cipher, (data)); \
- if (0) (encrypt) (&(ctx)->cipher, 0, (void *) 0, (void *) 0); \
+ if (0) (encrypt) (&(ctx)->cipher, ~(size_t) 0, \
+ (uint8_t *) 0, (const uint8_t *) 0); \
eax_set_key (&(ctx)->key, &(ctx)->cipher, (nettle_cipher_func *) encrypt); \
} while (0)
-#define EAX_SET_NONCE(ctx, encrypt, length, nonce) \
- (0 ? (encrypt) (&(ctx)->cipher, 0, (void *) 0, (void *) 0) \
+#define EAX_SET_NONCE(ctx, encrypt, length, nonce) \
+ (0 ? (encrypt) (&(ctx)->cipher, ~(size_t) 0, \
+ (uint8_t *) 0, (const uint8_t *) 0) \
: eax_set_nonce (&(ctx)->eax, &(ctx)->key, \
&(ctx)->cipher, (nettle_cipher_func *) (encrypt), \
(length), (nonce)))
#define EAX_UPDATE(ctx, encrypt, length, data) \
- (0 ? (encrypt) (&(ctx)->cipher, 0, (void *) 0, (void *) 0) \
+ (0 ? (encrypt) (&(ctx)->cipher, ~(size_t) 0, \
+ (uint8_t *) 0, (const uint8_t *) 0) \
: eax_update (&(ctx)->eax, &(ctx)->key, \
&(ctx)->cipher, (nettle_cipher_func *) (encrypt), \
(length), (data)))
#define EAX_ENCRYPT(ctx, encrypt, length, dst, src) \
- (0 ? (encrypt) (&(ctx)->cipher, 0, (void *) 0, (void *) 0) \
+ (0 ? (encrypt) (&(ctx)->cipher, ~(size_t) 0, \
+ (uint8_t *) 0, (const uint8_t *) 0) \
: eax_encrypt (&(ctx)->eax, &(ctx)->key, \
&(ctx)->cipher, (nettle_cipher_func *) (encrypt), \
(length), (dst), (src)))
#define EAX_DECRYPT(ctx, encrypt, length, dst, src) \
- (0 ? (encrypt) (&(ctx)->cipher, 0, (void *) 0, (void *) 0) \
+ (0 ? (encrypt) (&(ctx)->cipher, ~(size_t) 0, \
+ (uint8_t *) 0, (const uint8_t *) 0) \
: eax_decrypt (&(ctx)->eax, &(ctx)->key, \
&(ctx)->cipher, (nettle_cipher_func *) (encrypt), \
(length), (dst), (src)))
#define EAX_DIGEST(ctx, encrypt, length, digest) \
- (0 ? (encrypt) (&(ctx)->cipher, 0, (void *) 0, (void *) 0) \
+ (0 ? (encrypt) (&(ctx)->cipher, ~(size_t) 0, \
+ (uint8_t *) 0, (const uint8_t *) 0) \
: eax_digest (&(ctx)->eax, &(ctx)->key, \
&(ctx)->cipher, (nettle_cipher_func *) (encrypt), \
(length), (digest)))
{ struct gcm_key key; struct gcm_ctx gcm; type cipher; }
/* NOTE: Avoid using NULL, as we don't include anything defining it. */
-#define GCM_SET_KEY(ctx, set_key, encrypt, gcm_key) \
+#define GCM_SET_KEY(ctx, set_key, encrypt, gcm_key) \
do { \
- (set_key)(&(ctx)->cipher, (gcm_key)); \
- if (0) (encrypt)(&(ctx)->cipher, 0, (void *)0, (void *)0); \
+ (set_key)(&(ctx)->cipher, (gcm_key)); \
+ if (0) (encrypt)(&(ctx)->cipher, ~(size_t) 0, \
+ (uint8_t *) 0, (const uint8_t *) 0); \
gcm_set_key(&(ctx)->key, &(ctx)->cipher, \
(nettle_cipher_func *) (encrypt)); \
} while (0)
gcm_update(&(ctx)->gcm, &(ctx)->key, (length), (data))
#define GCM_ENCRYPT(ctx, encrypt, length, dst, src) \
- (0 ? (encrypt)(&(ctx)->cipher, 0, (void *)0, (void *)0) \
+ (0 ? (encrypt)(&(ctx)->cipher, ~(size_t) 0, \
+ (uint8_t *) 0, (const uint8_t *) 0) \
: gcm_encrypt(&(ctx)->gcm, &(ctx)->key, &(ctx)->cipher, \
(nettle_cipher_func *) (encrypt), \
(length), (dst), (src)))
#define GCM_DECRYPT(ctx, encrypt, length, dst, src) \
- (0 ? (encrypt)(&(ctx)->cipher, 0, (void *)0, (void *)0) \
+ (0 ? (encrypt)(&(ctx)->cipher, ~(size_t) 0, \
+ (uint8_t *) 0, (const uint8_t *) 0) \
: gcm_decrypt(&(ctx)->gcm, &(ctx)->key, &(ctx)->cipher, \
(nettle_cipher_func *) (encrypt), \
(length), (dst), (src)))
#define GCM_DIGEST(ctx, encrypt, length, digest) \
- (0 ? (encrypt)(&(ctx)->cipher, 0, (void *)0, (void *)0) \
+ (0 ? (encrypt)(&(ctx)->cipher, ~(size_t) 0, \
+ (uint8_t *) 0, (const uint8_t *) 0) \
: gcm_digest(&(ctx)->gcm, &(ctx)->key, &(ctx)->cipher, \
(nettle_cipher_func *) (encrypt), \
(length), (digest)))