80 #define GCM_CIPHER( _gcm_name, _gcm_cipher, _raw_cipher, _raw_context, \ 82 struct _gcm_name ## _context { \ 84 struct gcm_context gcm; \ 88 static int _gcm_name ## _setkey ( void *ctx, const void *key, \ 90 struct _gcm_name ## _context *context = ctx; \ 91 build_assert ( _blocksize == sizeof ( context->gcm.key ) ); \ 92 build_assert ( offsetof ( typeof ( *context ), gcm ) == 0 ); \ 93 build_assert ( offsetof ( typeof ( *context ), raw ) == \ 94 offsetof ( typeof ( *context ), gcm.raw_ctx ) ); \ 95 return gcm_setkey ( &context->gcm, key, keylen, &_raw_cipher ); \ 97 static void _gcm_name ## _setiv ( void *ctx, const void *iv, \ 99 struct _gcm_name ## _context *context = ctx; \ 100 gcm_setiv ( &context->gcm, iv, ivlen ); \ 102 static void _gcm_name ## _encrypt ( void *ctx, const void *src, \ 103 void *dst, size_t len ) { \ 104 struct _gcm_name ## _context *context = ctx; \ 105 gcm_encrypt ( &context->gcm, src, dst, len ); \ 107 static void _gcm_name ## _decrypt ( void *ctx, const void *src, \ 108 void *dst, size_t len ) { \ 109 struct _gcm_name ## _context *context = ctx; \ 110 gcm_decrypt ( &context->gcm, src, dst, len ); \ 112 static void _gcm_name ## _auth ( void *ctx, void *auth ) { \ 113 struct _gcm_name ## _context *context = ctx; \ 114 union gcm_block *tag = auth; \ 115 gcm_tag ( &context->gcm, tag ); \ 117 struct cipher_algorithm _gcm_cipher = { \ 118 .name = #_gcm_name, \ 119 .ctxsize = sizeof ( struct _gcm_name ## _context ), \ 121 .alignsize = sizeof ( union gcm_block ), \ 122 .authsize = sizeof ( union gcm_block ), \ 123 .setkey = _gcm_name ## _setkey, \ 124 .setiv = _gcm_name ## _setiv, \ 125 .encrypt = _gcm_name ## _encrypt, \ 126 .decrypt = _gcm_name ## _decrypt, \ 127 .auth = _gcm_name ## _auth, \
union gcm_block len
Accumulated lengths.
uint8_t raw_ctx[0]
Underlying block cipher context.
struct gcm_lengths len
Lengths.
uint8_t iv[12]
Initialisation vector.
static void const void void * dst
static void const void * src
void gcm_setiv(struct gcm_context *context, const void *iv, size_t ivlen)
Set initialisation vector.
struct gcm_lengths len
Lengths.
unsigned long long uint64_t
union gcm_block hash
Accumulated hash (X)
uint32_t value
Counter value.
struct cipher_algorithm * raw_cipher
Underlying block cipher.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
static void const void size_t ivlen
static void const void size_t keylen
union gcm_block key
Hash key (H)
uint64_t data
Data length.
struct gcm_counter ctr
Counter.
void gcm_tag(struct gcm_context *context, union gcm_block *tag)
Construct tag.
union gcm_block ctr
Counter (Y)
uint8_t iv[12]
Initialisation vector.
void gcm_decrypt(struct gcm_context *context, const void *src, void *dst, size_t len)
Decrypt data.
struct gcm_context __attribute__
uint64_t add
Additional data length.
void gcm_encrypt(struct gcm_context *context, const void *src, void *dst, size_t len)
Encrypt data.
uint64_t tag
Identity tag.
int gcm_setkey(struct gcm_context *context, const void *key, size_t keylen, struct cipher_algorithm *raw_cipher)
Set key.