|
| | FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) |
| | FILE_SECBOOT (PERMITTED) |
| void | gcm_tag (struct gcm_context *context, union gcm_block *tag) |
| | Construct tag.
|
| int | gcm_setkey (struct gcm_context *context, const void *key, size_t keylen, struct cipher_algorithm *raw_cipher) |
| | Set key.
|
| void | gcm_setiv (struct gcm_context *context, const void *iv, size_t ivlen) |
| | Set initialisation vector.
|
| void | gcm_encrypt (struct gcm_context *context, const void *src, void *dst, size_t len) |
| | Encrypt data.
|
| void | gcm_decrypt (struct gcm_context *context, const void *src, void *dst, size_t len) |
| | Decrypt data.
|
Galois/Counter Mode (GCM)
Definition in file gcm.h.
Construct tag.
- Parameters
-
Definition at line 409 of file gcm.c.
409 {
412
413
415
416
422 DBGC2 ( context,
"GCM %p E(K,Y[0]):\n", context );
424
425
427 DBGC2 ( context,
"GCM %p T:\n", context );
429}
uint16_t offset
Offset to command line.
uint64_t tag
Identity tag.
static void gcm_hash(struct gcm_context *context, union gcm_block *hash)
Construct hash.
static void gcm_xor_block(const union gcm_block *src, union gcm_block *dst)
XOR whole data block in situ.
static void gcm_count(union gcm_block *ctr, uint32_t delta)
Update GCM counter.
#define cipher_encrypt(cipher, ctx, src, dst, len)
void * memcpy(void *dest, const void *src, size_t len) __nonnull
struct cipher_algorithm * raw_cipher
Underlying block cipher.
uint8_t raw_ctx[0]
Underlying block cipher context.
union gcm_block ctr
Counter (Y)
union gcm_block len
Accumulated lengths.
uint64_t data
Data length.
struct gcm_lengths len
Lengths.
References cipher_encrypt, gcm_context::ctr, gcm_lengths::data, DBGC2, DBGC2_HDA, gcm_count(), gcm_hash(), gcm_xor_block(), gcm_block::len, gcm_context::len, memcpy(), offset, gcm_context::raw_cipher, gcm_context::raw_ctx, tag, and tmp.
Set key.
- Parameters
-
| context | Context |
| key | Key |
| keylen | Key length |
| raw_cipher | Underlying cipher |
- Return values
-
Definition at line 440 of file gcm.c.
441 {
443
444
445 memset ( context, 0,
sizeof ( *context ) );
447
448
450 keylen ) ) != 0 )
452
453
455 &context->
key, sizeof ( context->
key ) );
456 DBGC2 ( context,
"GCM %p H:\n", context );
458
459
461
462
464
465 return 0;
466}
union @162305117151260234136356364136041353210355154177 key
Sense key.
struct arbelprm_rc_send_wqe rc
static void gcm_cache(const union gcm_block *key)
Construct cached tables.
#define cpu_to_be32(value)
static int cipher_setkey(struct cipher_algorithm *cipher, void *ctx, const void *key, size_t keylen)
void * memset(void *dest, int character, size_t len) __nonnull
union gcm_block key
Hash key (H)
uint32_t value
Counter value.
struct gcm_counter ctr
Counter.
References cipher_encrypt, cipher_setkey(), cpu_to_be32, gcm_block::ctr, gcm_context::ctr, DBGC2, DBGC2_HDA, gcm_cache(), gcm_context::key, key, memset(), gcm_context::raw_cipher, gcm_context::raw_ctx, rc, and gcm_counter::value.
Set initialisation vector.
- Parameters
-
| ctx | Context |
| iv | Initialisation vector |
| ivlen | Initialisation vector length |
Definition at line 475 of file gcm.c.
475 {
476
477
484
485
487
488
489 if ( ivlen ==
sizeof ( context->
ctr.
ctr.
iv ) ) {
490
491
493
494 } else {
495
496
500
501
508 }
509
510 DBGC2 ( context,
"GCM %p Y[0]:\n", context );
512}
#define NULL
NULL pointer (VOID *)
pseudo_bit_t hash[0x00010]
#define build_assert(condition)
Assert a condition at build time (after dead code elimination)
#define assert(condition)
Assert a condition at run-time.
#define gcm_offset(field)
Offset of a field within GCM context.
static void gcm_process(struct gcm_context *context, const void *src, void *dst, size_t len, unsigned int flags)
Encrypt/decrypt/authenticate data.
#define GCM_FL_IV
Calculate hash over an initialisation vector value.
uint8_t iv[12]
Initialisation vector.
uint64_t add
Additional data length.
u8 iv[16]
Initialization vector.
References gcm_lengths::add, assert, build_assert, cpu_to_be32, gcm_block::ctr, gcm_context::ctr, DBGC2, DBGC2_HDA, GCM_FL_IV, gcm_hash(), gcm_offset, gcm_process(), hash, gcm_counter::iv, iv, key, gcm_block::len, gcm_context::len, len, memcpy(), memset(), NULL, and gcm_counter::value.