Loading crypto/modes/gcm128.c +88 −0 Original line number Diff line number Diff line Loading @@ -844,7 +844,11 @@ void CRYPTO_gcm128_setiv(GCM128_CONTEXT *ctx,const unsigned char *iv,size_t len) GCM_MUL(ctx,Yi); if (is_endian.little) #ifdef BSWAP4 ctr = BSWAP4(ctx->Yi.d[3]); #else ctr = GETU32(ctx->Yi.c+12); #endif else ctr = ctx->Yi.d[3]; } Loading @@ -852,7 +856,11 @@ void CRYPTO_gcm128_setiv(GCM128_CONTEXT *ctx,const unsigned char *iv,size_t len) (*ctx->block)(ctx->Yi.c,ctx->EK0.c,ctx->key); ++ctr; if (is_endian.little) #ifdef BSWAP4 ctx->Yi.d[3] = BSWAP4(ctr); #else PUTU32(ctx->Yi.c+12,ctr); #endif else ctx->Yi.d[3] = ctr; } Loading Loading @@ -947,7 +955,11 @@ int CRYPTO_gcm128_encrypt(GCM128_CONTEXT *ctx, } if (is_endian.little) #ifdef BSWAP4 ctr = BSWAP4(ctx->Yi.d[3]); #else ctr = GETU32(ctx->Yi.c+12); #endif else ctr = ctx->Yi.d[3]; Loading Loading @@ -981,7 +993,11 @@ int CRYPTO_gcm128_encrypt(GCM128_CONTEXT *ctx, (*block)(ctx->Yi.c,ctx->EKi.c,key); ++ctr; if (is_endian.little) #ifdef BSWAP4 ctx->Yi.d[3] = BSWAP4(ctr); #else PUTU32(ctx->Yi.c+12,ctr); #endif else ctx->Yi.d[3] = ctr; for (i=0; i<16/sizeof(size_t); ++i) Loading @@ -1003,7 +1019,11 @@ int CRYPTO_gcm128_encrypt(GCM128_CONTEXT *ctx, (*block)(ctx->Yi.c,ctx->EKi.c,key); ++ctr; if (is_endian.little) #ifdef BSWAP4 ctx->Yi.d[3] = BSWAP4(ctr); #else PUTU32(ctx->Yi.c+12,ctr); #endif else ctx->Yi.d[3] = ctr; for (i=0; i<16/sizeof(size_t); ++i) Loading @@ -1022,7 +1042,11 @@ int CRYPTO_gcm128_encrypt(GCM128_CONTEXT *ctx, (*block)(ctx->Yi.c,ctx->EKi.c,key); ++ctr; if (is_endian.little) #ifdef BSWAP4 ctx->Yi.d[3] = BSWAP4(ctr); #else PUTU32(ctx->Yi.c+12,ctr); #endif else ctx->Yi.d[3] = ctr; for (i=0; i<16/sizeof(size_t); ++i) Loading @@ -1038,7 +1062,11 @@ int CRYPTO_gcm128_encrypt(GCM128_CONTEXT *ctx, (*block)(ctx->Yi.c,ctx->EKi.c,key); ++ctr; if (is_endian.little) #ifdef BSWAP4 ctx->Yi.d[3] = BSWAP4(ctr); #else PUTU32(ctx->Yi.c+12,ctr); #endif else ctx->Yi.d[3] = ctr; while (len--) { Loading @@ -1056,7 +1084,11 @@ int CRYPTO_gcm128_encrypt(GCM128_CONTEXT *ctx, (*block)(ctx->Yi.c,ctx->EKi.c,key); ++ctr; if (is_endian.little) #ifdef BSWAP4 ctx->Yi.d[3] = BSWAP4(ctr); #else PUTU32(ctx->Yi.c+12,ctr); #endif else ctx->Yi.d[3] = ctr; } Loading Loading @@ -1100,7 +1132,11 @@ int CRYPTO_gcm128_decrypt(GCM128_CONTEXT *ctx, } if (is_endian.little) #ifdef BSWAP4 ctr = BSWAP4(ctx->Yi.d[3]); #else ctr = GETU32(ctx->Yi.c+12); #endif else ctr = ctx->Yi.d[3]; Loading Loading @@ -1137,7 +1173,11 @@ int CRYPTO_gcm128_decrypt(GCM128_CONTEXT *ctx, (*block)(ctx->Yi.c,ctx->EKi.c,key); ++ctr; if (is_endian.little) #ifdef BSWAP4 ctx->Yi.d[3] = BSWAP4(ctr); #else PUTU32(ctx->Yi.c+12,ctr); #endif else ctx->Yi.d[3] = ctr; for (i=0; i<16/sizeof(size_t); ++i) Loading @@ -1157,7 +1197,11 @@ int CRYPTO_gcm128_decrypt(GCM128_CONTEXT *ctx, (*block)(ctx->Yi.c,ctx->EKi.c,key); ++ctr; if (is_endian.little) #ifdef BSWAP4 ctx->Yi.d[3] = BSWAP4(ctr); #else PUTU32(ctx->Yi.c+12,ctr); #endif else ctx->Yi.d[3] = ctr; for (i=0; i<16/sizeof(size_t); ++i) Loading @@ -1175,7 +1219,11 @@ int CRYPTO_gcm128_decrypt(GCM128_CONTEXT *ctx, (*block)(ctx->Yi.c,ctx->EKi.c,key); ++ctr; if (is_endian.little) #ifdef BSWAP4 ctx->Yi.d[3] = BSWAP4(ctr); #else PUTU32(ctx->Yi.c+12,ctr); #endif else ctx->Yi.d[3] = ctr; for (i=0; i<16/sizeof(size_t); ++i) { Loading @@ -1193,7 +1241,11 @@ int CRYPTO_gcm128_decrypt(GCM128_CONTEXT *ctx, (*block)(ctx->Yi.c,ctx->EKi.c,key); ++ctr; if (is_endian.little) #ifdef BSWAP4 ctx->Yi.d[3] = BSWAP4(ctr); #else PUTU32(ctx->Yi.c+12,ctr); #endif else ctx->Yi.d[3] = ctr; while (len--) { Loading @@ -1214,7 +1266,11 @@ int CRYPTO_gcm128_decrypt(GCM128_CONTEXT *ctx, (*block)(ctx->Yi.c,ctx->EKi.c,key); ++ctr; if (is_endian.little) #ifdef BSWAP4 ctx->Yi.d[3] = BSWAP4(ctr); #else PUTU32(ctx->Yi.c+12,ctr); #endif else ctx->Yi.d[3] = ctr; } Loading Loading @@ -1259,7 +1315,11 @@ int CRYPTO_gcm128_encrypt_ctr32(GCM128_CONTEXT *ctx, } if (is_endian.little) #ifdef BSWAP4 ctr = BSWAP4(ctx->Yi.d[3]); #else ctr = GETU32(ctx->Yi.c+12); #endif else ctr = ctx->Yi.d[3]; Loading @@ -1281,7 +1341,11 @@ int CRYPTO_gcm128_encrypt_ctr32(GCM128_CONTEXT *ctx, (*stream)(in,out,GHASH_CHUNK/16,key,ctx->Yi.c); ctr += GHASH_CHUNK/16; if (is_endian.little) #ifdef BSWAP4 ctx->Yi.d[3] = BSWAP4(ctr); #else PUTU32(ctx->Yi.c+12,ctr); #endif else ctx->Yi.d[3] = ctr; GHASH(ctx,out,GHASH_CHUNK); Loading @@ -1296,7 +1360,11 @@ int CRYPTO_gcm128_encrypt_ctr32(GCM128_CONTEXT *ctx, (*stream)(in,out,j,key,ctx->Yi.c); ctr += (unsigned int)j; if (is_endian.little) #ifdef BSWAP4 ctx->Yi.d[3] = BSWAP4(ctr); #else PUTU32(ctx->Yi.c+12,ctr); #endif else ctx->Yi.d[3] = ctr; in += i; Loading @@ -1316,7 +1384,11 @@ int CRYPTO_gcm128_encrypt_ctr32(GCM128_CONTEXT *ctx, (*ctx->block)(ctx->Yi.c,ctx->EKi.c,key); ++ctr; if (is_endian.little) #ifdef BSWAP4 ctx->Yi.d[3] = BSWAP4(ctr); #else PUTU32(ctx->Yi.c+12,ctr); #endif else ctx->Yi.d[3] = ctr; while (len--) { Loading Loading @@ -1358,7 +1430,11 @@ int CRYPTO_gcm128_decrypt_ctr32(GCM128_CONTEXT *ctx, } if (is_endian.little) #ifdef BSWAP4 ctr = BSWAP4(ctx->Yi.d[3]); #else ctr = GETU32(ctx->Yi.c+12); #endif else ctr = ctx->Yi.d[3]; Loading @@ -1383,7 +1459,11 @@ int CRYPTO_gcm128_decrypt_ctr32(GCM128_CONTEXT *ctx, (*stream)(in,out,GHASH_CHUNK/16,key,ctx->Yi.c); ctr += GHASH_CHUNK/16; if (is_endian.little) #ifdef BSWAP4 ctx->Yi.d[3] = BSWAP4(ctr); #else PUTU32(ctx->Yi.c+12,ctr); #endif else ctx->Yi.d[3] = ctr; out += GHASH_CHUNK; Loading @@ -1409,7 +1489,11 @@ int CRYPTO_gcm128_decrypt_ctr32(GCM128_CONTEXT *ctx, (*stream)(in,out,j,key,ctx->Yi.c); ctr += (unsigned int)j; if (is_endian.little) #ifdef BSWAP4 ctx->Yi.d[3] = BSWAP4(ctr); #else PUTU32(ctx->Yi.c+12,ctr); #endif else ctx->Yi.d[3] = ctr; out += i; Loading @@ -1420,7 +1504,11 @@ int CRYPTO_gcm128_decrypt_ctr32(GCM128_CONTEXT *ctx, (*ctx->block)(ctx->Yi.c,ctx->EKi.c,key); ++ctr; if (is_endian.little) #ifdef BSWAP4 ctx->Yi.d[3] = BSWAP4(ctr); #else PUTU32(ctx->Yi.c+12,ctr); #endif else ctx->Yi.d[3] = ctr; while (len--) { Loading Loading
crypto/modes/gcm128.c +88 −0 Original line number Diff line number Diff line Loading @@ -844,7 +844,11 @@ void CRYPTO_gcm128_setiv(GCM128_CONTEXT *ctx,const unsigned char *iv,size_t len) GCM_MUL(ctx,Yi); if (is_endian.little) #ifdef BSWAP4 ctr = BSWAP4(ctx->Yi.d[3]); #else ctr = GETU32(ctx->Yi.c+12); #endif else ctr = ctx->Yi.d[3]; } Loading @@ -852,7 +856,11 @@ void CRYPTO_gcm128_setiv(GCM128_CONTEXT *ctx,const unsigned char *iv,size_t len) (*ctx->block)(ctx->Yi.c,ctx->EK0.c,ctx->key); ++ctr; if (is_endian.little) #ifdef BSWAP4 ctx->Yi.d[3] = BSWAP4(ctr); #else PUTU32(ctx->Yi.c+12,ctr); #endif else ctx->Yi.d[3] = ctr; } Loading Loading @@ -947,7 +955,11 @@ int CRYPTO_gcm128_encrypt(GCM128_CONTEXT *ctx, } if (is_endian.little) #ifdef BSWAP4 ctr = BSWAP4(ctx->Yi.d[3]); #else ctr = GETU32(ctx->Yi.c+12); #endif else ctr = ctx->Yi.d[3]; Loading Loading @@ -981,7 +993,11 @@ int CRYPTO_gcm128_encrypt(GCM128_CONTEXT *ctx, (*block)(ctx->Yi.c,ctx->EKi.c,key); ++ctr; if (is_endian.little) #ifdef BSWAP4 ctx->Yi.d[3] = BSWAP4(ctr); #else PUTU32(ctx->Yi.c+12,ctr); #endif else ctx->Yi.d[3] = ctr; for (i=0; i<16/sizeof(size_t); ++i) Loading @@ -1003,7 +1019,11 @@ int CRYPTO_gcm128_encrypt(GCM128_CONTEXT *ctx, (*block)(ctx->Yi.c,ctx->EKi.c,key); ++ctr; if (is_endian.little) #ifdef BSWAP4 ctx->Yi.d[3] = BSWAP4(ctr); #else PUTU32(ctx->Yi.c+12,ctr); #endif else ctx->Yi.d[3] = ctr; for (i=0; i<16/sizeof(size_t); ++i) Loading @@ -1022,7 +1042,11 @@ int CRYPTO_gcm128_encrypt(GCM128_CONTEXT *ctx, (*block)(ctx->Yi.c,ctx->EKi.c,key); ++ctr; if (is_endian.little) #ifdef BSWAP4 ctx->Yi.d[3] = BSWAP4(ctr); #else PUTU32(ctx->Yi.c+12,ctr); #endif else ctx->Yi.d[3] = ctr; for (i=0; i<16/sizeof(size_t); ++i) Loading @@ -1038,7 +1062,11 @@ int CRYPTO_gcm128_encrypt(GCM128_CONTEXT *ctx, (*block)(ctx->Yi.c,ctx->EKi.c,key); ++ctr; if (is_endian.little) #ifdef BSWAP4 ctx->Yi.d[3] = BSWAP4(ctr); #else PUTU32(ctx->Yi.c+12,ctr); #endif else ctx->Yi.d[3] = ctr; while (len--) { Loading @@ -1056,7 +1084,11 @@ int CRYPTO_gcm128_encrypt(GCM128_CONTEXT *ctx, (*block)(ctx->Yi.c,ctx->EKi.c,key); ++ctr; if (is_endian.little) #ifdef BSWAP4 ctx->Yi.d[3] = BSWAP4(ctr); #else PUTU32(ctx->Yi.c+12,ctr); #endif else ctx->Yi.d[3] = ctr; } Loading Loading @@ -1100,7 +1132,11 @@ int CRYPTO_gcm128_decrypt(GCM128_CONTEXT *ctx, } if (is_endian.little) #ifdef BSWAP4 ctr = BSWAP4(ctx->Yi.d[3]); #else ctr = GETU32(ctx->Yi.c+12); #endif else ctr = ctx->Yi.d[3]; Loading Loading @@ -1137,7 +1173,11 @@ int CRYPTO_gcm128_decrypt(GCM128_CONTEXT *ctx, (*block)(ctx->Yi.c,ctx->EKi.c,key); ++ctr; if (is_endian.little) #ifdef BSWAP4 ctx->Yi.d[3] = BSWAP4(ctr); #else PUTU32(ctx->Yi.c+12,ctr); #endif else ctx->Yi.d[3] = ctr; for (i=0; i<16/sizeof(size_t); ++i) Loading @@ -1157,7 +1197,11 @@ int CRYPTO_gcm128_decrypt(GCM128_CONTEXT *ctx, (*block)(ctx->Yi.c,ctx->EKi.c,key); ++ctr; if (is_endian.little) #ifdef BSWAP4 ctx->Yi.d[3] = BSWAP4(ctr); #else PUTU32(ctx->Yi.c+12,ctr); #endif else ctx->Yi.d[3] = ctr; for (i=0; i<16/sizeof(size_t); ++i) Loading @@ -1175,7 +1219,11 @@ int CRYPTO_gcm128_decrypt(GCM128_CONTEXT *ctx, (*block)(ctx->Yi.c,ctx->EKi.c,key); ++ctr; if (is_endian.little) #ifdef BSWAP4 ctx->Yi.d[3] = BSWAP4(ctr); #else PUTU32(ctx->Yi.c+12,ctr); #endif else ctx->Yi.d[3] = ctr; for (i=0; i<16/sizeof(size_t); ++i) { Loading @@ -1193,7 +1241,11 @@ int CRYPTO_gcm128_decrypt(GCM128_CONTEXT *ctx, (*block)(ctx->Yi.c,ctx->EKi.c,key); ++ctr; if (is_endian.little) #ifdef BSWAP4 ctx->Yi.d[3] = BSWAP4(ctr); #else PUTU32(ctx->Yi.c+12,ctr); #endif else ctx->Yi.d[3] = ctr; while (len--) { Loading @@ -1214,7 +1266,11 @@ int CRYPTO_gcm128_decrypt(GCM128_CONTEXT *ctx, (*block)(ctx->Yi.c,ctx->EKi.c,key); ++ctr; if (is_endian.little) #ifdef BSWAP4 ctx->Yi.d[3] = BSWAP4(ctr); #else PUTU32(ctx->Yi.c+12,ctr); #endif else ctx->Yi.d[3] = ctr; } Loading Loading @@ -1259,7 +1315,11 @@ int CRYPTO_gcm128_encrypt_ctr32(GCM128_CONTEXT *ctx, } if (is_endian.little) #ifdef BSWAP4 ctr = BSWAP4(ctx->Yi.d[3]); #else ctr = GETU32(ctx->Yi.c+12); #endif else ctr = ctx->Yi.d[3]; Loading @@ -1281,7 +1341,11 @@ int CRYPTO_gcm128_encrypt_ctr32(GCM128_CONTEXT *ctx, (*stream)(in,out,GHASH_CHUNK/16,key,ctx->Yi.c); ctr += GHASH_CHUNK/16; if (is_endian.little) #ifdef BSWAP4 ctx->Yi.d[3] = BSWAP4(ctr); #else PUTU32(ctx->Yi.c+12,ctr); #endif else ctx->Yi.d[3] = ctr; GHASH(ctx,out,GHASH_CHUNK); Loading @@ -1296,7 +1360,11 @@ int CRYPTO_gcm128_encrypt_ctr32(GCM128_CONTEXT *ctx, (*stream)(in,out,j,key,ctx->Yi.c); ctr += (unsigned int)j; if (is_endian.little) #ifdef BSWAP4 ctx->Yi.d[3] = BSWAP4(ctr); #else PUTU32(ctx->Yi.c+12,ctr); #endif else ctx->Yi.d[3] = ctr; in += i; Loading @@ -1316,7 +1384,11 @@ int CRYPTO_gcm128_encrypt_ctr32(GCM128_CONTEXT *ctx, (*ctx->block)(ctx->Yi.c,ctx->EKi.c,key); ++ctr; if (is_endian.little) #ifdef BSWAP4 ctx->Yi.d[3] = BSWAP4(ctr); #else PUTU32(ctx->Yi.c+12,ctr); #endif else ctx->Yi.d[3] = ctr; while (len--) { Loading Loading @@ -1358,7 +1430,11 @@ int CRYPTO_gcm128_decrypt_ctr32(GCM128_CONTEXT *ctx, } if (is_endian.little) #ifdef BSWAP4 ctr = BSWAP4(ctx->Yi.d[3]); #else ctr = GETU32(ctx->Yi.c+12); #endif else ctr = ctx->Yi.d[3]; Loading @@ -1383,7 +1459,11 @@ int CRYPTO_gcm128_decrypt_ctr32(GCM128_CONTEXT *ctx, (*stream)(in,out,GHASH_CHUNK/16,key,ctx->Yi.c); ctr += GHASH_CHUNK/16; if (is_endian.little) #ifdef BSWAP4 ctx->Yi.d[3] = BSWAP4(ctr); #else PUTU32(ctx->Yi.c+12,ctr); #endif else ctx->Yi.d[3] = ctr; out += GHASH_CHUNK; Loading @@ -1409,7 +1489,11 @@ int CRYPTO_gcm128_decrypt_ctr32(GCM128_CONTEXT *ctx, (*stream)(in,out,j,key,ctx->Yi.c); ctr += (unsigned int)j; if (is_endian.little) #ifdef BSWAP4 ctx->Yi.d[3] = BSWAP4(ctr); #else PUTU32(ctx->Yi.c+12,ctr); #endif else ctx->Yi.d[3] = ctr; out += i; Loading @@ -1420,7 +1504,11 @@ int CRYPTO_gcm128_decrypt_ctr32(GCM128_CONTEXT *ctx, (*ctx->block)(ctx->Yi.c,ctx->EKi.c,key); ++ctr; if (is_endian.little) #ifdef BSWAP4 ctx->Yi.d[3] = BSWAP4(ctr); #else PUTU32(ctx->Yi.c+12,ctr); #endif else ctx->Yi.d[3] = ctr; while (len--) { Loading