|
| | 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 419 of file gcm.c.
420 {
424
425
426 memset ( &context->gcm, 0, sizeof ( context->gcm ) );
427
428
430 keylen ) ) != 0 )
432
433
435 &context->gcm.key, sizeof ( context->gcm.key ) );
436 DBGC2 ( context,
"GCM %p H:\n", context );
437 DBGC2_HDA ( context, 0, &context->gcm.key,
438 sizeof ( context->gcm.key ) );
439
440
442
443
445
446 return 0;
447}
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 458 of file gcm.c.
459 {
461
462
467
468
470
471
472 if ( ivlen == sizeof ( context->gcm.ctr.ctr.iv ) ) {
473
474
475 memcpy ( context->gcm.ctr.ctr.iv,
iv, ivlen );
476
477 } else if ( ivlen ) {
478
479
482 gcm_hash ( &context->gcm, &context->gcm.ctr );
483 assert ( context->gcm.len.len.add == 0 );
484
485
490
491 } else {
492
493
495 }
496
497 DBGC2 ( context,
"GCM %p Y[0]:\n", context );
498 DBGC2_HDA ( context, 0, &context->gcm.ctr,
499 sizeof ( context->gcm.ctr ) );
500 return 0;
501}
#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.
#define ENOTSUP
Operation not supported.
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, ENOTSUP, 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 546 of file gcm.c.
546 {
552
553
555
556
558 offset = ( ( -context->gcm.len.len.data ) / ( 8 *
sizeof (
tmp ) ) );
562 DBGC2 ( context,
"GCM %p E(K,Y[0]):\n", context );
564
565
567 DBGC2 ( context,
"GCM %p T:\n", context );
569}
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.