39 #define BSP_ENABLED true
46 #if defined(__cplusplus)
51 #define BLOCK_SIZE GCM_BLOCK_SIZE
52 #define BLK_ADR_MASK (BLOCK_SIZE - 1)
56 { int i = BLOCK_SIZE; while(i-- > CTR_POS && !++(ui8_ptr(x)[i])) ; }
59 const unsigned char key[],
60 unsigned long key_len,
71 #if defined( TABLES_64K )
73 #elif defined( TABLES_8K )
75 #elif defined( TABLES_4K )
77 #elif defined( TABLES_256 )
83 #if defined( TABLES_64K )
84 #define gf_mul_hh(a, ctx, scr) gf_mul_64k(a, ctx->gf_t64k, scr)
85 #elif defined( TABLES_8K )
86 #define gf_mul_hh(a, ctx, scr) gf_mul_8k(a, ctx->gf_t8k, scr)
87 #elif defined( TABLES_4K )
88 #define gf_mul_hh(a, ctx, scr) gf_mul_4k(a, ctx->gf_t4k, scr)
89 #elif defined( TABLES_256 )
90 #define gf_mul_hh(a, ctx, scr) gf_mul_256(a, ctx->gf_t256, scr)
92 #define gf_mul_hh(a, ctx, scr) gf_mul(a, ui8_ptr(ctx->ghash_h))
96 const unsigned char iv[],
124 n_pos = (iv_len << 3);
125 for(i =
BLOCK_SIZE - 1; n_pos; --i, n_pos >>= 8)
140 const unsigned char hdr[],
141 unsigned long hdr_len,
155 if(!(b_pos & BUF_ADRMASK) && !((hdr + cnt -
ui8_ptr(ctx->
hdr_ghv)) & BUF_ADRMASK))
198 const unsigned char data[],
199 unsigned long data_len,
213 if(!(b_pos & BUF_ADRMASK) && !((data + cnt -
ui8_ptr(ctx->
txt_ghv)) & BUF_ADRMASK))
241 while(cnt < data_len)
256 unsigned char data[],
257 unsigned long data_len,
273 if(!(b_pos & BUF_ADRMASK) && !((data + cnt -
ui8_ptr(ctx->
enc_ctr)) & BUF_ADRMASK))
303 while(cnt < data_len)
320 unsigned long tag_len,
338 if(!(ln >>= 1))
break;
345 i = ln | ln >> 1; i |= i >> 2; i |= i >> 4;
346 i |= i >> 8; i |= i >> 16; i = i & ~(i >> 1);
363 ln = (i == 8 ? (uint_32t)(ctx->
hdr_cnt << 3) : ln >> 8);
370 for(i = 0; i < (
unsigned int)tag_len; ++i)
379 memset(ctx, 0,
sizeof(
gcm_ctx));
384 unsigned char data[],
385 unsigned long data_len,
395 unsigned char data[],
396 unsigned long data_len,
405 const unsigned char iv[],
406 unsigned long iv_len,
407 const unsigned char hdr[],
408 unsigned long hdr_len,
410 unsigned long msg_len,
412 unsigned long tag_len,
422 const unsigned char iv[],
423 unsigned long iv_len,
424 const unsigned char hdr[],
425 unsigned long hdr_len,
427 unsigned long msg_len,
428 const unsigned char tag[],
429 unsigned long tag_len,
441 #if defined(__cplusplus)