68 void *dst,
size_t len );
70 void *dst,
size_t len );
81#define GCM_CIPHER( _gcm_name, _gcm_cipher, _raw_cipher, _raw_context, \
83struct _gcm_name ## _context { \
85 struct gcm_context gcm; \
89static int _gcm_name ## _setkey ( void *ctx, const void *key, \
91 struct _gcm_name ## _context *context = ctx; \
92 build_assert ( _blocksize == sizeof ( context->gcm.key ) ); \
93 build_assert ( offsetof ( typeof ( *context ), gcm ) == 0 ); \
94 build_assert ( offsetof ( typeof ( *context ), raw ) == \
95 offsetof ( typeof ( *context ), gcm.raw_ctx ) ); \
96 return gcm_setkey ( &context->gcm, key, keylen, &_raw_cipher ); \
98static void _gcm_name ## _setiv ( void *ctx, const void *iv, \
100 struct _gcm_name ## _context *context = ctx; \
101 gcm_setiv ( &context->gcm, iv, ivlen ); \
103static void _gcm_name ## _encrypt ( void *ctx, const void *src, \
104 void *dst, size_t len ) { \
105 struct _gcm_name ## _context *context = ctx; \
106 gcm_encrypt ( &context->gcm, src, dst, len ); \
108static void _gcm_name ## _decrypt ( void *ctx, const void *src, \
109 void *dst, size_t len ) { \
110 struct _gcm_name ## _context *context = ctx; \
111 gcm_decrypt ( &context->gcm, src, dst, len ); \
113static void _gcm_name ## _auth ( void *ctx, void *auth ) { \
114 struct _gcm_name ## _context *context = ctx; \
115 union gcm_block *tag = auth; \
116 gcm_tag ( &context->gcm, tag ); \
118struct cipher_algorithm _gcm_cipher = { \
119 .name = #_gcm_name, \
120 .ctxsize = sizeof ( struct _gcm_name ## _context ), \
122 .alignsize = sizeof ( union gcm_block ), \
123 .authsize = sizeof ( union gcm_block ), \
124 .setkey = _gcm_name ## _setkey, \
125 .setiv = _gcm_name ## _setiv, \
126 .encrypt = _gcm_name ## _encrypt, \
127 .decrypt = _gcm_name ## _decrypt, \
128 .auth = _gcm_name ## _auth, \
union @162305117151260234136356364136041353210355154177 key
Sense key.
unsigned long long uint64_t
uint64_t tag
Identity tag.
void gcm_tag(struct gcm_context *context, union gcm_block *tag)
Construct tag.
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.
int gcm_setkey(struct gcm_context *context, const void *key, size_t keylen, struct cipher_algorithm *raw_cipher)
Set key.
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
union gcm_block key
Hash key (H)
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 hash
Accumulated hash (X)
union gcm_block len
Accumulated lengths.
uint8_t iv[12]
Initialisation vector.
uint32_t value
Counter value.
uint64_t data
Data length.
uint64_t add
Additional data length.
struct gcm_counter ctr
Counter.
uint32_t dword[4]
Raw dwords.
struct gcm_lengths len
Lengths.
uint16_t word[8]
Raw words.
u8 iv[16]
Initialization vector.