Don't use implementation-specific functions to expose sizes

This commit is contained in:
Frank Denis 2015-10-11 11:58:34 +02:00
parent 1dddd63a19
commit 16beebb2ec
2 changed files with 21 additions and 21 deletions

View File

@ -479,7 +479,7 @@ do { \
} while(0) } while(0)
int int
crypto_aead_aes256gcm_aesni_beforenm(crypto_aead_aes256gcm_aesni_state *ctx_, crypto_aead_aes256gcm_aesni_beforenm(crypto_aead_aes256gcm_state *ctx_,
const unsigned char *k) const unsigned char *k)
{ {
context *ctx = (context *) ctx_; context *ctx = (context *) ctx_;
@ -500,7 +500,7 @@ crypto_aead_aes256gcm_aesni_encrypt_afternm(unsigned char *c, unsigned long long
const unsigned char *ad, unsigned long long adlen, const unsigned char *ad, unsigned long long adlen,
const unsigned char *nsec, const unsigned char *nsec,
const unsigned char *npub, const unsigned char *npub,
const crypto_aead_aes256gcm_aesni_state *ctx_) const crypto_aead_aes256gcm_state *ctx_)
{ {
unsigned char H[16]; unsigned char H[16];
const __m128i rev = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); const __m128i rev = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
@ -616,7 +616,7 @@ crypto_aead_aes256gcm_aesni_decrypt_afternm(unsigned char *m, unsigned long long
const unsigned char *c, unsigned long long clen, const unsigned char *c, unsigned long long clen,
const unsigned char *ad, unsigned long long adlen, const unsigned char *ad, unsigned long long adlen,
const unsigned char *npub, const unsigned char *npub,
const crypto_aead_aes256gcm_aesni_state *ctx_) const crypto_aead_aes256gcm_state *ctx_)
{ {
unsigned char H[16]; unsigned char H[16];
const __m128i rev = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); const __m128i rev = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
@ -770,7 +770,7 @@ crypto_aead_aes256gcm_aesni_encrypt(unsigned char *c,
const unsigned char *npub, const unsigned char *npub,
const unsigned char *k) const unsigned char *k)
{ {
crypto_aead_aes256gcm_aesni_state ctx; crypto_aead_aes256gcm_state ctx;
crypto_aead_aes256gcm_aesni_beforenm(&ctx, k); crypto_aead_aes256gcm_aesni_beforenm(&ctx, k);
@ -789,9 +789,9 @@ crypto_aead_aes256gcm_aesni_decrypt(unsigned char *m,
const unsigned char *npub, const unsigned char *npub,
const unsigned char *k) const unsigned char *k)
{ {
crypto_aead_aes256gcm_aesni_state ctx; crypto_aead_aes256gcm_state ctx;
crypto_aead_aes256gcm_aesni_beforenm((crypto_aead_aes256gcm_aesni_state *) crypto_aead_aes256gcm_aesni_beforenm((crypto_aead_aes256gcm_state *)
&ctx, k); &ctx, k);
return crypto_aead_aes256gcm_aesni_decrypt_afternm return crypto_aead_aes256gcm_aesni_decrypt_afternm
@ -799,30 +799,30 @@ crypto_aead_aes256gcm_aesni_decrypt(unsigned char *m,
} }
size_t size_t
crypto_aead_aes256gcm_aesni_keybytes(void) crypto_aead_aes256gcm_keybytes(void)
{ {
return crypto_aead_aes256gcm_KEYBYTES; return crypto_aead_aes256gcm_KEYBYTES;
} }
size_t size_t
crypto_aead_aes256gcm_aesni_nsecbytes(void) crypto_aead_aes256gcm_nsecbytes(void)
{ {
return crypto_aead_aes256gcm_NSECBYTES; return crypto_aead_aes256gcm_NSECBYTES;
} }
size_t crypto_aead_aes256gcm_aesni_npubbytes(void) size_t crypto_aead_aes256gcm_npubbytes(void)
{ {
return crypto_aead_aes256gcm_NPUBBYTES; return crypto_aead_aes256gcm_NPUBBYTES;
} }
size_t crypto_aead_aes256gcm_aesni_abytes(void) size_t crypto_aead_aes256gcm_abytes(void)
{ {
return crypto_aead_aes256gcm_ABYTES; return crypto_aead_aes256gcm_ABYTES;
} }
size_t crypto_aead_aes256gcm_aesni_statebytes(void) size_t crypto_aead_aes256gcm_statebytes(void)
{ {
return sizeof(crypto_aead_aes256gcm_aesni_state); return sizeof(crypto_aead_aes256gcm_state);
} }
#endif #endif

View File

@ -13,23 +13,23 @@ extern "C" {
#define crypto_aead_aes256gcm_KEYBYTES 32U #define crypto_aead_aes256gcm_KEYBYTES 32U
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_aead_aes256gcm_aesni_keybytes(void); size_t crypto_aead_aes256gcm_keybytes(void);
#define crypto_aead_aes256gcm_NSECBYTES 0U #define crypto_aead_aes256gcm_NSECBYTES 0U
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_aead_aes256gcm_aesni_nsecbytes(void); size_t crypto_aead_aes256gcm_nsecbytes(void);
#define crypto_aead_aes256gcm_NPUBBYTES 12U #define crypto_aead_aes256gcm_NPUBBYTES 12U
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_aead_aes256gcm_aesni_npubbytes(void); size_t crypto_aead_aes256gcm_pubbytes(void);
#define crypto_aead_aes256gcm_ABYTES 16U #define crypto_aead_aes256gcm_ABYTES 16U
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_aead_aes256gcm_aesni_abytes(void); size_t crypto_aead_aes256gcm_abytes(void);
typedef CRYPTO_ALIGN(16) unsigned char crypto_aead_aes256gcm_aesni_state[272]; typedef CRYPTO_ALIGN(16) unsigned char crypto_aead_aes256gcm_state[512];
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_aead_aes256gcm_aesni_statebytes(void); size_t crypto_aead_aes256gcm_statebytes(void);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_aead_aes256gcm_aesni_encrypt(unsigned char *c, int crypto_aead_aes256gcm_aesni_encrypt(unsigned char *c,
@ -54,7 +54,7 @@ int crypto_aead_aes256gcm_aesni_decrypt(unsigned char *m,
const unsigned char *k); const unsigned char *k);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_aead_aes256gcm_aesni_beforenm(crypto_aead_aes256gcm_aesni_state *ctx_, int crypto_aead_aes256gcm_aesni_beforenm(crypto_aead_aes256gcm_state *ctx_,
const unsigned char *k); const unsigned char *k);
SODIUM_EXPORT SODIUM_EXPORT
@ -66,7 +66,7 @@ int crypto_aead_aes256gcm_aesni_encrypt_afternm(unsigned char *c,
unsigned long long adlen, unsigned long long adlen,
const unsigned char *nsec, const unsigned char *nsec,
const unsigned char *npub, const unsigned char *npub,
const crypto_aead_aes256gcm_aesni_state *ctx_); const crypto_aead_aes256gcm_state *ctx_);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_aead_aes256gcm_aesni_decrypt_afternm(unsigned char *m, int crypto_aead_aes256gcm_aesni_decrypt_afternm(unsigned char *m,
@ -77,7 +77,7 @@ int crypto_aead_aes256gcm_aesni_decrypt_afternm(unsigned char *m,
const unsigned char *ad, const unsigned char *ad,
unsigned long long adlen, unsigned long long adlen,
const unsigned char *npub, const unsigned char *npub,
const crypto_aead_aes256gcm_aesni_state *ctx_); const crypto_aead_aes256gcm_state *ctx_);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif