|
| | FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) |
| | FILE_SECBOOT (PERMITTED) |
| int | gcm_setkey (struct cipher_algorithm *cipher, void *ctx, const void *key, size_t keylen) |
| | Set key.
|
| int | gcm_setiv (struct cipher_algorithm *cipher, void *ctx, const void *iv, size_t ivlen) |
| | Set initialisation vector.
|
| void | gcm_encrypt (struct cipher_algorithm *cipher, void *ctx, const void *src, void *dst, size_t len) |
| | Encrypt data.
|
| void | gcm_decrypt (struct cipher_algorithm *cipher, void *ctx, const void *src, void *dst, size_t len) |
| | Decrypt data.
|
| void | gcm_auth (struct cipher_algorithm *cipher, void *ctx, void *auth) |
| | Generate authentication tag.
|
Galois/Counter Mode (GCM).
Definition in file gcm.h.
Set key.
- Parameters
-
| cipher | Cipher algorithm |
| ctx | Context |
| key | Key |
| keylen | Key length |
- Return values
-
Definition at line 418 of file gcm.c.
419 {
423
424
425 memset ( &context->gcm, 0, sizeof ( context->gcm ) );
426
427
429 keylen ) ) != 0 )
431
432
434 &context->gcm.key, sizeof ( context->gcm.key ) );
435 DBGC2 ( context,
"GCM %p H:\n", context );
436 DBGC2_HDA ( context, 0, &context->gcm.key,
437 sizeof ( context->gcm.key ) );
438
439
441
442
444
445 return 0;
446}
struct golan_eq_context ctx
union @162305117151260234136356364136041353210355154177 key
struct arbelprm_rc_send_wqe rc
static void gcm_cache(const union gcm_block *key)
Construct cached tables.
#define gcm_context_t(ctxsize)
A GCM mode context.
#define cpu_to_be32(value)
static int cipher_setkey(struct cipher_algorithm *cipher, void *ctx, const void *key, size_t keylen)
#define cipher_encrypt(cipher, ctx, src, dst, len)
void * memset(void *dest, int character, size_t len) __nonnull
void * priv
Algorithm private data.
size_t ctxsize
Context size.
References cipher_encrypt, cipher_setkey(), cpu_to_be32, ctx, cipher_algorithm::ctxsize, DBGC2, DBGC2_HDA, gcm_cache(), gcm_context_t, key, memset(), cipher_algorithm::priv, and rc.
Set initialisation vector.
- Parameters
-
| cipher | Cipher algorithm |
| ctx | Context |
| iv | Initialisation vector |
| ivlen | Initialisation vector length |
- Return values
-
Definition at line 457 of file gcm.c.
458 {
460
461
466
467
469
470
471 if ( ivlen == sizeof ( context->gcm.ctr.ctr.iv ) ) {
472
473
474 memcpy ( context->gcm.ctr.ctr.iv,
iv, ivlen );
475
476 } else {
477
478
481 gcm_hash ( &context->gcm, &context->gcm.ctr );
482 assert ( context->gcm.len.len.add == 0 );
483
484
489 }
490
491 DBGC2 ( context,
"GCM %p Y[0]:\n", context );
492 DBGC2_HDA ( context, 0, &context->gcm.ctr,
493 sizeof ( context->gcm.ctr ) );
494 return 0;
495}
#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.
static void gcm_hash(struct gcm_context *context, union gcm_block *hash)
Construct hash.
#define gcm_offset(field)
Offset of a field within GCM context.
static void gcm_process(struct cipher_algorithm *cipher, void *ctx, const void *src, void *dst, size_t len)
Encrypt/decrypt/authenticate data.
#define GCM_FL_IV
Calculate hash over an initialisation vector value.
void * memcpy(void *dest, const void *src, size_t len) __nonnull
u8 iv[16]
Initialization vector.
References assert, build_assert, cpu_to_be32, ctx, cipher_algorithm::ctxsize, DBGC2, DBGC2_HDA, gcm_context_t, GCM_FL_IV, gcm_hash(), gcm_offset, gcm_process(), hash, iv, key, len, memcpy(), memset(), and NULL.
Generate authentication tag.
- Parameters
-
| cipher | Cipher algorithm |
| ctx | Context |
| auth | Authentication tag |
Definition at line 540 of file gcm.c.
540 {
546
547
549
550
552 offset = ( ( -context->gcm.len.len.data ) / ( 8 *
sizeof (
tmp ) ) );
556 DBGC2 ( context,
"GCM %p E(K,Y[0]):\n", context );
558
559
561 DBGC2 ( context,
"GCM %p T:\n", context );
563}
uint16_t offset
Offset to command line.
uint64_t tag
Identity tag.
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.
References cipher_encrypt, ctx, cipher_algorithm::ctxsize, DBGC2, DBGC2_HDA, gcm_context_t, gcm_count(), gcm_hash(), gcm_xor_block(), memcpy(), offset, cipher_algorithm::priv, tag, and tmp.