packages feed

cipher-aes128 0.2.3 → 0.2.4

raw patch · 8 files changed

+56/−58 lines, 8 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

Crypto/Cipher/AES128/Internal.hs view
@@ -54,7 +54,7 @@                   -> Ptr Word8 -> Ptr Word8 -- ^ Result PT and TAG                   -> IO () -foreign import ccall unsafe "aes/aes.h aes_encrypt_ctr"+foreign import ccall unsafe "aes/aes.h encrypt_ctr"     c_encrypt_ctr :: AESKeyPtr                   -> Ptr Word8 -- ^ 128 bit IV                   -> Ptr Word8 -- ^ Result
cbits/aes/aes.c view
@@ -8,13 +8,13 @@ #include "aes_x86ni.h" #endif #include "bitfn.h"-void gf_mul(block128 *a, block128 *b);+static void gf_mul(block128 *a, block128 *b);  #ifdef TRY_NI /**  * Returns zero if false, non-zero otherwise  */-int cpu_has_ni()+static int cpu_has_ni() {        uint32_t ax,bx,cx,dx,func=1; @@ -34,8 +34,8 @@  /* Generate Key */ #ifdef TRY_NI-void detect_and_generate_key128(AESKey *k, const uint8_t *bytes);-void (*generate_key128_ptr)(AESKey *,const uint8_t *) = &detect_and_generate_key128;+static void detect_and_generate_key128(AESKey *k, const uint8_t *bytes);+static void (*generate_key128_ptr)(AESKey *,const uint8_t *) = &detect_and_generate_key128;  /**  * Expand a 128 bit AES key.@@ -45,17 +45,17 @@     (*generate_key128_ptr)(k,bytes); } -void generate_key128_generic(AESKey *k, const uint8_t *bytes)+static void generate_key128_generic(AESKey *k, const uint8_t *bytes) {-    aes_generic_init(k, bytes, 16);+    aes128_generic_init(k, bytes, 16); } -void generate_key128_ni(AESKey *k, const uint8_t *bytes)+static void generate_key128_ni(AESKey *k, const uint8_t *bytes) {-    aes_ni_init((aes_key *)k, bytes, 16);+    aes128_ni_init((aes_key *)k, bytes, 16); } -void detect_and_generate_key128(AESKey *k, const uint8_t *bytes)+static void detect_and_generate_key128(AESKey *k, const uint8_t *bytes) {     if(cpu_has_ni()) {             generate_key128_ptr = &generate_key128_ni;@@ -68,7 +68,7 @@ #else void generate_key128(AESKey *k, const uint8_t *bytes) {-    aes_generic_init(k, bytes, 16);+    aes128_generic_init(k, bytes, 16); } #endif @@ -80,19 +80,19 @@  /* ECB Encrypt */ #ifdef TRY_NI-void detect_and_encrypt_ecb(const AESKey *k, uint8_t *dst, const uint8_t *src, const uint32_t nr);-void (*encrypt_ecb_ptr)(const AESKey *, uint8_t *, const uint8_t *, const uint32_t) = &detect_and_encrypt_ecb;+static void detect_and_encrypt_ecb(const AESKey *k, uint8_t *dst, const uint8_t *src, const uint32_t nr);+static void (*encrypt_ecb_ptr)(const AESKey *, uint8_t *, const uint8_t *, const uint32_t) = &detect_and_encrypt_ecb; -void encrypt_ecb_ni(const AESKey *k, uint8_t *dst, const uint8_t *src, const uint32_t nr)+static void encrypt_ecb_ni(const AESKey *k, uint8_t *dst, const uint8_t *src, const uint32_t nr) {-        aes_ni_encrypt_ecb(dst, (aes_key *)k, src, nr);+        aes128_ni_encrypt_ecb(dst, (aes_key *)k, src, nr); } -void encrypt_ecb_generic(const AESKey *k, uint8_t *dst, const uint8_t *src, const uint32_t nr)+static void encrypt_ecb_generic(const AESKey *k, uint8_t *dst, const uint8_t *src, const uint32_t nr) {     int i;     for(i = 0; i<nr*16; i+=16) {-        aes_generic_encrypt_block+        aes128_generic_encrypt_block                        ( (aes_block*) dst+i                        , k                        , (const aes_block*)src+i);@@ -104,7 +104,7 @@         (*encrypt_ecb_ptr)(k,dst,src,nr); } -void detect_and_encrypt_ecb(const AESKey *k, uint8_t *dst, const uint8_t *src, const uint32_t nr)+static void detect_and_encrypt_ecb(const AESKey *k, uint8_t *dst, const uint8_t *src, const uint32_t nr) {         if(cpu_has_ni()) encrypt_ecb_ptr = &encrypt_ecb_ni;         else encrypt_ecb_ptr = &encrypt_ecb_generic;@@ -115,7 +115,7 @@ {     int i;     for(i = 0; i<nr*16; i+=16) {-        aes_generic_encrypt_block+        aes128_generic_encrypt_block                        ( (aes_block*) dst+i                        , k                        , (const aes_block*)src+i);@@ -125,30 +125,30 @@  /* ECB Decrypt */ #ifdef TRY_NI-void detect_and_decrypt_ecb(const AESKey *k, uint8_t *dst, const uint8_t *src, const uint32_t nr);-void (*decrypt_ecb_ptr)(const AESKey *k, uint8_t *dst, const uint8_t *src, const uint32_t nr) = &detect_and_decrypt_ecb;+static void detect_and_decrypt_ecb(const AESKey *k, uint8_t *dst, const uint8_t *src, const uint32_t nr);+static void (*decrypt_ecb_ptr)(const AESKey *k, uint8_t *dst, const uint8_t *src, const uint32_t nr) = &detect_and_decrypt_ecb;  void decrypt_ecb(const AESKey *k, uint8_t *dst, const uint8_t *src, const uint32_t nr) {         (*decrypt_ecb_ptr)(k,dst,src,nr); } -void decrypt_ecb_ni(const AESKey *k, uint8_t *dst, const uint8_t *src, const uint32_t nr)+static void decrypt_ecb_ni(const AESKey *k, uint8_t *dst, const uint8_t *src, const uint32_t nr) {-        aes_ni_decrypt_ecb(dst, (aes_key *)k, src, nr);+        aes128_ni_decrypt_ecb(dst, (aes_key *)k, src, nr); } -void decrypt_ecb_generic(const AESKey *k, uint8_t *dst, const uint8_t *src, const uint32_t nr)+static void decrypt_ecb_generic(const AESKey *k, uint8_t *dst, const uint8_t *src, const uint32_t nr) {     int i;     for(i = 0; i<nr*16; i+=16) {-        aes_generic_decrypt_block ( (aes_block*) dst+i+        aes128_generic_decrypt_block ( (aes_block*) dst+i                                   , k                                   , (const aes_block*)src+i);     } } -void detect_and_decrypt_ecb(const AESKey *k, uint8_t *dst, const uint8_t *src, const uint32_t nr)+static void detect_and_decrypt_ecb(const AESKey *k, uint8_t *dst, const uint8_t *src, const uint32_t nr) {         if(cpu_has_ni()) decrypt_ecb_ptr = &decrypt_ecb_ni;         else decrypt_ecb_ptr = &decrypt_ecb_generic;@@ -159,7 +159,7 @@ {     int i;     for(i = 0; i<nr*16; i+=16) {-        aes_generic_decrypt_block ( (aes_block*) dst+i+        aes128_generic_decrypt_block ( (aes_block*) dst+i                                   , k                                   , (const aes_block*)src+i);     }@@ -174,7 +174,7 @@         gf_mul(&gcm->tag, &gcm->h); } -void aes_gcm_init(aes_gcm *gcm, const aes_key *key, uint8_t *iv, uint32_t len)+static void aes_gcm_init(aes_gcm *gcm, const aes_key *key, uint8_t *iv, uint32_t len) {         gcm->length_aad = 0;         gcm->length_input = 0;@@ -210,7 +210,7 @@         block128_copy(&gcm->civ, &gcm->iv); } -void aes_gcm_aad(aes_gcm *gcm, uint8_t *input, uint32_t length)+static void aes_gcm_aad(aes_gcm *gcm, uint8_t *input, uint32_t length) {         gcm->length_aad += length;         for (; length >= 16; input += 16, length -= 16) {@@ -225,7 +225,7 @@  } -void aes_gcm_encrypt(uint8_t *output, aes_gcm *gcm, uint8_t *input, uint32_t length)+static void aes_gcm_encrypt(uint8_t *output, aes_gcm *gcm, uint8_t *input, uint32_t length) {         aes_block out; @@ -258,7 +258,7 @@         } } -void aes_gcm_decrypt(uint8_t *output, aes_gcm *gcm, uint8_t *input, uint32_t length)+static void aes_gcm_decrypt(uint8_t *output, aes_gcm *gcm, uint8_t *input, uint32_t length) {         aes_block out; @@ -290,7 +290,7 @@         } } -void aes_gcm_finish(uint8_t *tag, aes_gcm *gcm)+static void aes_gcm_finish(uint8_t *tag, aes_gcm *gcm) {         aes_block lblock;         int i;@@ -340,7 +340,7 @@  * to speed up the multiplication.  * TODO: optimise with tables  */-void gf_mul(block128 *a, block128 *b)+static void gf_mul(block128 *a, block128 *b) {         uint64_t a0, a1, v0, v1;         int i, j;@@ -362,7 +362,7 @@         a->q[1] = cpu_to_be64(a1); } -void aes_encrypt_ctr(AESKey *key, uint8_t *iv, uint8_t *output, uint8_t *input, uint32_t len)+void encrypt_ctr(AESKey *key, uint8_t *iv, uint8_t *output, uint8_t *input, uint32_t len) {         aes_block block, o;         uint32_t nb_blocks = len / 16;
cbits/aes/generic/aes_generic.c view
@@ -89,7 +89,7 @@ };  #define G(a,b,c,d,e,f) { a,b,c,d,e,f }-uint8_t gmtab[256][6] =+static uint8_t gmtab[256][6] = { 	G(0x00, 0x00, 0x00, 0x00, 0x00, 0x00), G(0x02, 0x03, 0x09, 0x0b, 0x0d, 0x0e), 	G(0x04, 0x06, 0x12, 0x16, 0x1a, 0x1c), G(0x06, 0x05, 0x1b, 0x1d, 0x17, 0x12),@@ -403,7 +403,7 @@ 	t[2] = f[8]; t[6] = f[9]; t[10] = f[10]; t[14] = f[11]; \ 	t[3] = f[12]; t[7] = f[13]; t[11] = f[14]; t[15] = f[15] -void aes_generic_encrypt_block(aes_block *output, const aes_key *key, const aes_block *input)+void aes128_generic_encrypt_block(aes_block *output, const aes_key *key, const aes_block *input) { 	uint8_t block[16]; 	uint8_t *iptr, *optr;@@ -415,7 +415,7 @@ 	swap_block(optr, block); } -void aes_generic_decrypt_block(aes_block *output, const aes_key *key, const aes_block *input)+void aes128_generic_decrypt_block(aes_block *output, const aes_key *key, const aes_block *input) { 	uint8_t block[16]; 	uint8_t *iptr, *optr;@@ -427,7 +427,7 @@ 	swap_block(optr, block); } -void aes_generic_init(aes_key *key, const uint8_t *origkey, uint8_t size)+void aes128_generic_init(aes_key *key, const uint8_t *origkey, uint8_t size) { 	int esz; 
cbits/aes/ni/aes_x86ni.c view
@@ -84,7 +84,7 @@ 		_mm_storeu_si128(((__m128i *) out) + i, k[i]); } -void aes_ni_init(aes_key *key, const uint8_t *origkey, uint8_t size)+void aes128_ni_init(aes_key *key, const uint8_t *origkey, uint8_t size) { 	switch (size) { 	case 16: aes_generate_key128(key, origkey); break;@@ -145,7 +145,7 @@ 	m = _mm_aesdec_si128(m, K9); \ 	m = _mm_aesdeclast_si128(m, K10); -void aes_ni_encrypt_ecb(uint8_t *out, aes_key *key, const uint8_t *in, uint32_t blocks)+void aes128_ni_encrypt_ecb(uint8_t *out, aes_key *key, const uint8_t *in, uint32_t blocks) { 	__m128i *k = (__m128i *) key->data; @@ -162,7 +162,7 @@ 	} } -void aes_ni_decrypt_ecb(uint8_t *out, aes_key *key, const uint8_t *in, uint32_t blocks)+void aes128_ni_decrypt_ecb(uint8_t *out, aes_key *key, const uint8_t *in, uint32_t blocks) { 	__m128i *k = (__m128i *) key->data; @@ -179,7 +179,7 @@ 	} } -void aes_ni_encrypt_cbc(uint8_t *out, aes_key *key, uint8_t *_iv, uint8_t *in, uint32_t blocks)+void aes128_ni_encrypt_cbc(uint8_t *out, aes_key *key, uint8_t *_iv, uint8_t *in, uint32_t blocks) { 	__m128i *k = (__m128i *) key->data; 	__m128i iv = _mm_loadu_si128((__m128i *) _iv);@@ -200,7 +200,7 @@ 	} } -void aes_ni_decrypt_cbc(uint8_t *out, aes_key *key, uint8_t *_iv, uint8_t *in, uint32_t blocks)+void aes128_ni_decrypt_cbc(uint8_t *out, aes_key *key, uint8_t *_iv, uint8_t *in, uint32_t blocks) { 	__m128i *k = (__m128i *) key->data; 	__m128i iv = _mm_loadu_si128((__m128i *) _iv);@@ -238,7 +238,7 @@ 	return v; } -void aes_ni_encrypt_xts(uint8_t *out, aes_key *key1, aes_key *key2,+void aes128_ni_encrypt_xts(uint8_t *out, aes_key *key1, aes_key *key2,                         uint8_t *_tweak, uint32_t spoint, uint8_t *in, uint32_t blocks) { 	__m128i tweak = _mm_loadu_si128((__m128i *) _tweak);
cbits/include/aes.h view
@@ -20,7 +20,7 @@                          , uint8_t *aad, uint32_t aadLen                          , uint8_t *ct, uint32_t ctLen                          , uint8_t *pt, uint8_t *tag);-void aes_encrypt_ctr( AESKey *key+void encrypt_ctr( AESKey *key                     , uint8_t *iv                     , uint8_t *dst                     , uint8_t *src
cbits/include/aes_generic.h view
@@ -31,6 +31,6 @@ #include "block128.h" #include <stdint.h> -void aes_generic_encrypt_block(aes_block *output, const aes_key *key, const aes_block *input);-void aes_generic_decrypt_block(aes_block *output, const aes_key *key, const aes_block *input);-void aes_generic_init(aes_key *key, const uint8_t *origkey, uint8_t size);+void aes128_generic_encrypt_block(aes_block *output, const aes_key *key, const aes_block *input);+void aes128_generic_decrypt_block(aes_block *output, const aes_key *key, const aes_block *input);+void aes128_generic_init(aes_key *key, const uint8_t *origkey, uint8_t size);
cbits/include/aes_x86ni.h view
@@ -38,15 +38,13 @@ #include "aes_types.h" #include "block128.h" -void aes_ni_init(aes_key *key, const uint8_t *origkey, uint8_t size);-void aes_ni_encrypt_ecb(uint8_t *out, aes_key *key, const uint8_t *in, uint32_t blocks);-void aes_ni_decrypt_ecb(uint8_t *out, aes_key *key, const uint8_t *in, uint32_t blocks);-void aes_ni_encrypt_cbc(uint8_t *out, aes_key *key, uint8_t *_iv, uint8_t *in, uint32_t blocks);-void aes_ni_decrypt_cbc(uint8_t *out, aes_key *key, uint8_t *_iv, uint8_t *in, uint32_t blocks);-void aes_ni_encrypt_xts(uint8_t *out, aes_key *key1, aes_key *key2,-                        uint8_t *_tweak, uint32_t spoint, uint8_t *in, uint32_t blocks);--void gf_mul_x86ni(block128 *res, block128 *a_, block128 *b_);+void aes128_ni_init(aes_key *key, const uint8_t *origkey, uint8_t size);+void aes128_ni_encrypt_ecb(uint8_t *out, aes_key *key, const uint8_t *in, uint32_t blocks);+void aes128_ni_decrypt_ecb(uint8_t *out, aes_key *key, const uint8_t *in, uint32_t blocks);+void aes128_ni_encrypt_cbc(uint8_t *out, aes_key *key, uint8_t *_iv, uint8_t *in, uint32_t blocks);+void aes128_ni_decrypt_cbc(uint8_t *out, aes_key *key, uint8_t *_iv, uint8_t *in, uint32_t blocks);+void aes128_ni_encrypt_xts(uint8_t *out, aes_key *key1, aes_key *key2,+                           uint8_t *_tweak, uint32_t spoint, uint8_t *in, uint32_t blocks);  #endif 
cipher-aes128.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                cipher-aes128-version:             0.2.3+version:             0.2.4 synopsis:            AES128 using AES-NI when available. description:         AES128 with crypto-api instances and a trampoline between Vincent Hanquez's C-based and x86 NI-based AES.  Patches welcome to add additional high-performance backends (ARM?) license:             BSD3