iPXE
gcm.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2022 Michael Brown <mbrown@fensystems.co.uk>.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 * 02110-1301, USA.
18 *
19 * You can also choose to distribute this program under the terms of
20 * the Unmodified Binary Distribution Licence (as given in the file
21 * COPYING.UBDL), provided that you have satisfied its requirements.
22 */
23
24FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
25FILE_SECBOOT ( PERMITTED );
26
27/** @file
28 *
29 * Galois/Counter Mode (GCM)
30 *
31 * The GCM algorithm is specified in
32 *
33 * https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf
34 * https://csrc.nist.rip/groups/ST/toolkit/BCM/documents/proposedmodes/gcm/gcm-spec.pdf
35 *
36 */
37
38#include <stdint.h>
39#include <string.h>
40#include <errno.h>
41#include <byteswap.h>
42#include <ipxe/crypto.h>
43#include <ipxe/gcm.h>
44
45/**
46 * Perform encryption
47 *
48 * This value is chosen to allow for ANDing with a fragment length.
49 */
50#define GCM_FL_ENCRYPT 0x00ff
51
52/**
53 * Calculate hash over an initialisation vector value
54 *
55 * The hash calculation for a non 96-bit initialisation vector is
56 * identical to the calculation used for additional data, except that
57 * the non-additional data length counter is used.
58 */
59#define GCM_FL_IV 0x0100
60
61/**
62 * GCM field polynomial
63 *
64 * GCM treats 128-bit blocks as polynomials in GF(2^128) with the
65 * field polynomial f(x) = 1 + x + x^2 + x^7 + x^128.
66 *
67 * In a somewhat bloody-minded interpretation of "big-endian", the
68 * constant term (with degree zero) is arbitrarily placed in the
69 * leftmost bit of the big-endian binary representation (i.e. the most
70 * significant bit of byte 0), thereby failing to correspond to the
71 * bit ordering in any CPU architecture in existence. This
72 * necessitates some wholly gratuitous byte reversals when
73 * constructing the multiplication tables, since all CPUs will treat
74 * bit 0 as being the least significant bit within a byte.
75 *
76 * The field polynomial maps to the 128-bit constant
77 * 0xe1000000000000000000000000000000 (with the x^128 term outside the
78 * 128-bit range), and can therefore be treated as a single-byte
79 * value.
80 */
81#define GCM_POLY 0xe1
82
83/**
84 * Hash key for which multiplication tables are cached
85 *
86 * GCM operates much more efficiently with a cached multiplication
87 * table, which costs 4kB per hash key. Since this exceeds the
88 * available stack space, we place a single 4kB cache in .bss and
89 * recalculate the cached values as required. In the common case of a
90 * single HTTPS connection being used to download a (relatively) large
91 * file, the same key will be used repeatedly for almost all GCM
92 * operations, and so the overhead of recalculation is negligible.
93 */
94static const union gcm_block *gcm_cached_key;
95
96/**
97 * Cached multiplication table (M0) for Shoup's method
98 *
99 * Each entry within this table represents the result of multiplying
100 * the cached hash key by an arbitrary 8-bit polynomial.
101 */
102static union gcm_block gcm_cached_mult[256];
103
104/**
105 * Cached reduction table (R) for Shoup's method
106 *
107 * Each entry within this table represents the result of multiplying
108 * the fixed polynomial x^128 by an arbitrary 8-bit polynomial. Only
109 * the leftmost 16 bits are stored, since all other bits within the
110 * result will always be zero.
111 */
113
114/** Offset of a field within GCM context */
115#define gcm_offset( field ) offsetof ( struct gcm_context, field )
116
117/**
118 * Reverse bits in a byte
119 *
120 * @v byte Byte
121 * @ret etyb Bit-reversed byte
122 */
123static inline __attribute__ (( always_inline )) uint8_t
124gcm_reverse ( const uint8_t byte ) {
125 uint8_t etyb = etyb;
126 uint8_t mask;
127
128 for ( mask = 1 ; mask ; mask <<= 1 ) {
129 etyb <<= 1;
130 if ( byte & mask )
131 etyb |= 1;
132 }
133 return etyb;
134}
135
136/**
137 * Update GCM counter
138 *
139 * @v ctr Counter
140 * @v delta Amount to add to counter
141 */
142static inline __attribute__ (( always_inline )) void
143gcm_count ( union gcm_block *ctr, uint32_t delta ) {
144 uint32_t *value = &ctr->ctr.value;
145
146 /* Update counter modulo 2^32 */
147 *value = cpu_to_be32 ( be32_to_cpu ( *value ) + delta );
148}
149
150/**
151 * XOR partial data block
152 *
153 * @v src1 Source buffer 1
154 * @v src2 Source buffer 2
155 * @v dst Destination buffer
156 * @v len Length
157 */
158static inline void gcm_xor ( const void *src1, const void *src2, void *dst,
159 size_t len ) {
160 uint8_t *dst_bytes = dst;
161 const uint8_t *src1_bytes = src1;
162 const uint8_t *src2_bytes = src2;
163
164 /* XOR one byte at a time */
165 while ( len-- )
166 *(dst_bytes++) = ( *(src1_bytes++) ^ *(src2_bytes++) );
167}
168
169/**
170 * XOR whole data block in situ
171 *
172 * @v src Source block
173 * @v dst Destination block
174 */
175static inline void gcm_xor_block ( const union gcm_block *src,
176 union gcm_block *dst ) {
177
178 /* XOR whole dwords */
179 dst->dword[0] ^= src->dword[0];
180 dst->dword[1] ^= src->dword[1];
181 dst->dword[2] ^= src->dword[2];
182 dst->dword[3] ^= src->dword[3];
183}
184
185/**
186 * Multiply polynomial by (x)
187 *
188 * @v mult Multiplicand
189 * @v res Result
190 */
191static void gcm_multiply_x ( const union gcm_block *mult,
192 union gcm_block *res ) {
193 unsigned int i;
196
197 /* Multiply by (x) by shifting all bits rightward */
198 for ( i = 0, carry = 0 ; i < sizeof ( res->byte ) ; i++ ) {
199 byte = mult->byte[i];
200 res->byte[i] = ( ( carry << 7 ) | ( byte >> 1 ) );
201 carry = ( byte & 0x01 );
202 }
203
204 /* If result overflows, reduce modulo the field polynomial */
205 if ( carry )
206 res->byte[0] ^= GCM_POLY;
207}
208
209/**
210 * Construct cached tables
211 *
212 * @v key Hash key
213 * @v context Context
214 */
215static void gcm_cache ( const union gcm_block *key ) {
216 union gcm_block *mult;
217 uint16_t reduce;
218 unsigned int this;
219 unsigned int other;
220 unsigned int i;
221
222 /* Calculate M0[1..255] and R[1..255]
223 *
224 * The R[] values are independent of the key, but the overhead
225 * of recalculating them here is negligible and saves on
226 * overall code size since the calculations are related.
227 */
228 for ( i = 1 ; i < 256 ; i++ ) {
229
230 /* Reverse bit order to compensate for poor life choices */
231 this = gcm_reverse ( i );
232
233 /* Construct entries */
234 mult = &gcm_cached_mult[this];
235 if ( this & 0x80 ) {
236
237 /* Odd number: entry[i] = entry[i - 1] + poly */
238 other = ( this & 0x7f ); /* bit-reversed (i - 1) */
239 gcm_xor ( key, &gcm_cached_mult[other], mult,
240 sizeof ( *mult ) );
241 reduce = gcm_cached_reduce[other];
242 reduce ^= be16_to_cpu ( GCM_POLY << 8 );
243 gcm_cached_reduce[this] = reduce;
244
245 } else {
246
247 /* Even number: entry[i] = entry[i/2] * (x) */
248 other = ( this << 1 ); /* bit-reversed (i / 2) */
249 gcm_multiply_x ( &gcm_cached_mult[other], mult );
250 reduce = be16_to_cpu ( gcm_cached_reduce[other] );
251 reduce >>= 1;
252 gcm_cached_reduce[this] = cpu_to_be16 ( reduce );
253 }
254 }
255
256 /* Record cached key */
258}
259
260/**
261 * Multiply polynomial by (x^8) in situ
262 *
263 * @v poly Multiplicand and result
264 */
265static void gcm_multiply_x_8 ( union gcm_block *poly ) {
266 uint8_t *byte;
267 uint8_t msb;
268
269 /* Reduction table must already have been calculated */
271
272 /* Record most significant byte */
273 byte = &poly->byte[ sizeof ( poly->byte ) - 1 ];
274 msb = *byte;
275
276 /* Multiply least significant bytes by shifting */
277 for ( ; byte > &poly->byte[0] ; byte-- )
278 *byte = *( byte - 1 );
279 *byte = 0;
280
281 /* Multiply most significant byte via reduction table */
282 poly->word[0] ^= gcm_cached_reduce[msb];
283}
284
285/**
286 * Multiply polynomial by hash key in situ
287 *
288 * @v key Hash key
289 * @v poly Multiplicand and result
290 */
291static void gcm_multiply_key ( const union gcm_block *key,
292 union gcm_block *poly ) {
293 union gcm_block res;
294 uint8_t *byte;
295
296 /* Construct tables, if necessary */
297 if ( gcm_cached_key != key )
298 gcm_cache ( key );
299
300 /* Multiply using Shoup's algorithm */
301 byte = &poly->byte[ sizeof ( poly->byte ) - 1 ];
302 memcpy ( &res, &gcm_cached_mult[ *byte ], sizeof ( res ) );
303 for ( byte-- ; byte >= &poly->byte[0] ; byte-- ) {
304 gcm_multiply_x_8 ( &res );
305 gcm_xor_block ( &gcm_cached_mult[ *byte ], &res );
306 }
307
308 /* Overwrite result */
309 memcpy ( poly, &res, sizeof ( *poly ) );
310}
311
312/**
313 * Construct hash
314 *
315 * @v context Context
316 * @v hash Hash to fill in
317 */
318static void gcm_hash ( struct gcm_context *context, union gcm_block *hash ) {
319
320 /* Construct big-endian lengths block */
321 hash->len.add = cpu_to_be64 ( context->len.len.add );
322 hash->len.data = cpu_to_be64 ( context->len.len.data );
323 DBGC2 ( context, "GCM %p len(A)||len(C):\n", context );
324 DBGC2_HDA ( context, 0, hash, sizeof ( *hash ) );
325
326 /* Update hash */
327 gcm_xor_block ( &context->hash, hash );
328 gcm_multiply_key ( &context->key, hash );
329 DBGC2 ( context, "GCM %p GHASH(H,A,C):\n", context );
330 DBGC2_HDA ( context, 0, hash, sizeof ( *hash ) );
331}
332
333/**
334 * Encrypt/decrypt/authenticate data
335 *
336 * @v cipher Cipher algorithm
337 * @v ctx Context
338 * @v src Input data
339 * @v dst Output data, or NULL to process additional data
340 * @v len Length of data
341 * @v flags Operation flags
342 */
343static void gcm_process ( struct cipher_algorithm *cipher, void *ctx,
344 const void *src, void *dst, size_t len ) {
345 struct cipher_algorithm *raw_cipher = cipher->priv;
346 gcm_context_t ( cipher->ctxsize ) *context = ctx;
347 unsigned int flags = context->gcm.flags;
348 union gcm_block tmp;
349 uint64_t *total;
350 size_t frag_len;
351 unsigned int block;
352
353 /* Calculate block number (for debugging) */
354 block = ( ( ( context->gcm.len.len.add + 8 * sizeof ( tmp ) - 1 ) /
355 ( 8 * sizeof ( tmp ) ) ) +
356 ( ( context->gcm.len.len.data + 8 * sizeof ( tmp ) - 1 ) /
357 ( 8 * sizeof ( tmp ) ) ) + 1 );
358
359 /* Update total length (in bits) */
360 total = ( ( dst || ( flags & GCM_FL_IV ) ) ?
361 &context->gcm.len.len.data : &context->gcm.len.len.add );
362 *total += ( len * 8 );
363
364 /* Process data */
365 for ( ; len ; src += frag_len, len -= frag_len, block++ ) {
366
367 /* Calculate fragment length */
368 frag_len = len;
369 if ( frag_len > sizeof ( tmp ) )
370 frag_len = sizeof ( tmp );
371
372 /* Update hash with input data */
373 gcm_xor ( src, &context->gcm.hash, &context->gcm.hash,
374 frag_len );
375
376 /* Encrypt/decrypt block, if applicable */
377 if ( dst ) {
378
379 /* Increment counter */
380 gcm_count ( &context->gcm.ctr, 1 );
381
382 /* Encrypt counter */
383 DBGC2 ( context, "GCM %p Y[%d]:\n", context, block );
384 DBGC2_HDA ( context, 0, &context->gcm.ctr,
385 sizeof ( context->gcm.ctr ) );
386 cipher_encrypt ( raw_cipher, &context->raw,
387 &context->gcm.ctr, &tmp,
388 sizeof ( tmp ) );
389 DBGC2 ( context, "GCM %p E(K,Y[%d]):\n",
390 context, block );
391 DBGC2_HDA ( context, 0, &tmp, sizeof ( tmp ) );
392
393 /* Encrypt/decrypt data */
394 gcm_xor ( src, &tmp, dst, frag_len );
395 dst += frag_len;
396
397 /* Update hash with encrypted data, if applicable */
398 gcm_xor ( &tmp, &context->gcm.hash, &context->gcm.hash,
399 ( frag_len & flags ) );
400 }
401
402 /* Update hash */
403 gcm_multiply_key ( &context->gcm.key, &context->gcm.hash );
404 DBGC2 ( context, "GCM %p X[%d]:\n", context, block );
405 DBGC2_HDA ( context, 0, &context->gcm.hash,
406 sizeof ( context->gcm.hash ) );
407 }
408}
409
410/**
411 * Set key
412 *
413 * @v cipher Cipher algorithm
414 * @v ctx Context
415 * @v key Key
416 * @v keylen Key length
417 * @ret rc Return status code
418 */
419int gcm_setkey ( struct cipher_algorithm *cipher, void *ctx,
420 const void *key, size_t keylen ) {
421 struct cipher_algorithm *raw_cipher = cipher->priv;
422 gcm_context_t ( cipher->ctxsize ) *context = ctx;
423 int rc;
424
425 /* Initialise GCM context */
426 memset ( &context->gcm, 0, sizeof ( context->gcm ) );
427
428 /* Set underlying block cipher key */
429 if ( ( rc = cipher_setkey ( raw_cipher, context->raw, key,
430 keylen ) ) != 0 )
431 return rc;
432
433 /* Construct GCM hash key */
434 cipher_encrypt ( raw_cipher, context->raw, &context->gcm.ctr,
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 /* Reset counter */
441 context->gcm.ctr.ctr.value = cpu_to_be32 ( 1 );
442
443 /* Construct cached tables */
444 gcm_cache ( &context->gcm.key );
445
446 return 0;
447}
448
449/**
450 * Set initialisation vector
451 *
452 * @v cipher Cipher algorithm
453 * @v ctx Context
454 * @v iv Initialisation vector
455 * @v ivlen Initialisation vector length
456 * @ret rc Return status code
457 */
458int gcm_setiv ( struct cipher_algorithm *cipher, void *ctx,
459 const void *iv, size_t ivlen ) {
460 gcm_context_t ( cipher->ctxsize ) *context = ctx;
461
462 /* Reset non-key state */
463 memset ( &context->gcm, 0, gcm_offset ( key ) );
466 build_assert ( gcm_offset ( key ) > gcm_offset ( ctr ) );
467
468 /* Reset counter */
469 context->gcm.ctr.ctr.value = cpu_to_be32 ( 1 );
470
471 /* Process initialisation vector */
472 if ( ivlen == sizeof ( context->gcm.ctr.ctr.iv ) ) {
473
474 /* Initialisation vector is exactly 96 bits, use it as-is */
475 memcpy ( context->gcm.ctr.ctr.iv, iv, ivlen );
476
477 } else if ( ivlen ) {
478
479 /* Calculate hash over initialisation vector */
480 context->gcm.flags = GCM_FL_IV;
481 gcm_process ( cipher, ctx, iv, NULL, ivlen );
482 gcm_hash ( &context->gcm, &context->gcm.ctr );
483 assert ( context->gcm.len.len.add == 0 );
484
485 /* Reset non-key, non-counter state */
486 memset ( &context->gcm, 0, gcm_offset ( ctr ) );
487 build_assert ( gcm_offset ( ctr ) > gcm_offset ( hash ) );
488 build_assert ( gcm_offset ( ctr ) > gcm_offset ( len ) );
489 build_assert ( gcm_offset ( ctr ) < gcm_offset ( key ) );
490
491 } else {
492
493 /* Zero-length IVs are not permitted */
494 return -ENOTSUP;
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}
502
503/**
504 * Encrypt data
505 *
506 * @v cipher Cipher algorithm
507 * @v ctx Context
508 * @v src Data to encrypt
509 * @v dst Buffer for encrypted data, or NULL for additional data
510 * @v len Length of data
511 */
512void gcm_encrypt ( struct cipher_algorithm *cipher, void *ctx,
513 const void *src, void *dst, size_t len ) {
514 gcm_context_t ( cipher->ctxsize ) *context = ctx;
515
516 /* Process data */
517 context->gcm.flags = GCM_FL_ENCRYPT;
518 gcm_process ( cipher, ctx, src, dst, len );
519}
520
521/**
522 * Decrypt data
523 *
524 * @v cipher Cipher algorithm
525 * @v ctx Context
526 * @v src Data to decrypt
527 * @v dst Buffer for decrypted data, or NULL for additional data
528 * @v len Length of data
529 */
530void gcm_decrypt ( struct cipher_algorithm *cipher, void *ctx,
531 const void *src, void *dst, size_t len ) {
532 gcm_context_t ( cipher->ctxsize ) *context = ctx;
533
534 /* Process data */
535 context->gcm.flags = 0;
536 gcm_process ( cipher, ctx, src, dst, len );
537}
538
539/**
540 * Generate authentication tag
541 *
542 * @v cipher Cipher algorithm
543 * @v ctx Context
544 * @v auth Authentication tag
545 */
546void gcm_auth ( struct cipher_algorithm *cipher, void *ctx, void *auth ) {
547 struct cipher_algorithm *raw_cipher = cipher->priv;
548 gcm_context_t ( cipher->ctxsize ) *context = ctx;
549 union gcm_block *tag = auth;
550 union gcm_block tmp;
552
553 /* Construct hash */
554 gcm_hash ( &context->gcm, tag );
555
556 /* Construct encrypted initial counter value */
557 memcpy ( &tmp, &context->gcm.ctr, sizeof ( tmp ) );
558 offset = ( ( -context->gcm.len.len.data ) / ( 8 * sizeof ( tmp ) ) );
559 gcm_count ( &tmp, offset );
560 cipher_encrypt ( raw_cipher, &context->raw, &tmp, &tmp,
561 sizeof ( tmp ) );
562 DBGC2 ( context, "GCM %p E(K,Y[0]):\n", context );
563 DBGC2_HDA ( context, 0, &tmp, sizeof ( tmp ) );
564
565 /* Construct tag */
566 gcm_xor_block ( &tmp, tag );
567 DBGC2 ( context, "GCM %p T:\n", context );
568 DBGC2_HDA ( context, 0, tag, sizeof ( *tag ) );
569}
#define NULL
NULL pointer (VOID *).
Definition Base.h:321
struct golan_eq_context ctx
Definition CIB_PRM.h:0
union @162305117151260234136356364136041353210355154177 key
struct arbelprm_rc_send_wqe rc
Definition arbel.h:3
pseudo_bit_t value[0x00020]
Definition arbel.h:2
pseudo_bit_t hash[0x00010]
Definition arbel.h:2
unsigned short uint16_t
Definition stdint.h:11
unsigned int uint32_t
Definition stdint.h:12
unsigned long long uint64_t
Definition stdint.h:13
unsigned char uint8_t
Definition stdint.h:10
int carry
Definition bigint.h:33
static const void * src
Definition string.h:48
#define build_assert(condition)
Assert a condition at build time (after dead code elimination).
Definition assert.h:88
#define assert(condition)
Assert a condition at run-time.
Definition assert.h:61
uint16_t offset
Offset to command line.
Definition bzimage.h:3
ring len
Length.
Definition dwmac.h:226
uint64_t tag
Identity tag.
Definition edd.h:1
uint8_t flags
Flags.
Definition ena.h:7
Error codes.
static void gcm_hash(struct gcm_context *context, union gcm_block *hash)
Construct hash.
Definition gcm.c:318
int gcm_setiv(struct cipher_algorithm *cipher, void *ctx, const void *iv, size_t ivlen)
Set initialisation vector.
Definition gcm.c:458
static union gcm_block gcm_cached_mult[256]
Cached multiplication table (M0) for Shoup's method.
Definition gcm.c:102
void gcm_decrypt(struct cipher_algorithm *cipher, void *ctx, const void *src, void *dst, size_t len)
Decrypt data.
Definition gcm.c:530
static const union gcm_block * gcm_cached_key
Hash key for which multiplication tables are cached.
Definition gcm.c:94
static uint8_t gcm_reverse(const uint8_t byte)
Reverse bits in a byte.
Definition gcm.c:124
static void gcm_xor_block(const union gcm_block *src, union gcm_block *dst)
XOR whole data block in situ.
Definition gcm.c:175
static void gcm_cache(const union gcm_block *key)
Construct cached tables.
Definition gcm.c:215
#define GCM_FL_ENCRYPT
Perform encryption.
Definition gcm.c:50
static void gcm_multiply_key(const union gcm_block *key, union gcm_block *poly)
Multiply polynomial by hash key in situ.
Definition gcm.c:291
void gcm_auth(struct cipher_algorithm *cipher, void *ctx, void *auth)
Generate authentication tag.
Definition gcm.c:546
#define gcm_offset(field)
Offset of a field within GCM context.
Definition gcm.c:115
static void gcm_xor(const void *src1, const void *src2, void *dst, size_t len)
XOR partial data block.
Definition gcm.c:158
static void gcm_count(union gcm_block *ctr, uint32_t delta)
Update GCM counter.
Definition gcm.c:143
void gcm_encrypt(struct cipher_algorithm *cipher, void *ctx, const void *src, void *dst, size_t len)
Encrypt data.
Definition gcm.c:512
static void gcm_process(struct cipher_algorithm *cipher, void *ctx, const void *src, void *dst, size_t len)
Encrypt/decrypt/authenticate data.
Definition gcm.c:343
static uint16_t gcm_cached_reduce[256]
Cached reduction table (R) for Shoup's method.
Definition gcm.c:112
static void gcm_multiply_x_8(union gcm_block *poly)
Multiply polynomial by (x^8) in situ.
Definition gcm.c:265
#define GCM_POLY
GCM field polynomial.
Definition gcm.c:81
#define GCM_FL_IV
Calculate hash over an initialisation vector value.
Definition gcm.c:59
int gcm_setkey(struct cipher_algorithm *cipher, void *ctx, const void *key, size_t keylen)
Set key.
Definition gcm.c:419
static void gcm_multiply_x(const union gcm_block *mult, union gcm_block *res)
Multiply polynomial by (x).
Definition gcm.c:191
Galois/Counter Mode (GCM).
#define gcm_context_t(ctxsize)
A GCM mode context.
Definition gcm.h:61
#define DBGC2(...)
Definition compiler.h:547
#define DBGC2_HDA(...)
Definition compiler.h:548
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:921
#define ENOTSUP
Operation not supported.
Definition errno.h:633
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
Definition compiler.h:951
#define be32_to_cpu(value)
Definition byteswap.h:117
#define cpu_to_be16(value)
Definition byteswap.h:110
#define cpu_to_be32(value)
Definition byteswap.h:111
#define cpu_to_be64(value)
Definition byteswap.h:112
#define be16_to_cpu(value)
Definition byteswap.h:116
#define __attribute__(x)
Definition compiler.h:10
Cryptographic API.
static int cipher_setkey(struct cipher_algorithm *cipher, void *ctx, const void *key, size_t keylen)
Definition crypto.h:310
#define cipher_encrypt(cipher, ctx, src, dst, len)
Definition crypto.h:326
String functions.
void * memcpy(void *dest, const void *src, size_t len) __nonnull
void * memset(void *dest, int character, size_t len) __nonnull
unsigned long tmp
Definition linux_pci.h:65
uint8_t block[3][8]
DES-encrypted blocks.
Definition mschapv2.h:1
unsigned char byte
Definition smc9000.h:38
A cipher algorithm.
Definition crypto.h:58
void * priv
Algorithm private data.
Definition crypto.h:138
size_t ctxsize
Context size.
Definition crypto.h:62
void(* auth)(struct cipher_algorithm *cipher, void *ctx, void *auth)
Generate authentication tag.
Definition crypto.h:135
GCM context.
Definition gcm.h:47
union gcm_block key
Hash key (H).
Definition gcm.h:55
union gcm_block hash
Accumulated hash (X).
Definition gcm.h:49
union gcm_block len
Accumulated lengths.
Definition gcm.h:51
uint32_t value
Counter value.
Definition gcm.h:21
uint64_t data
Data length.
Definition gcm.h:29
uint64_t add
Additional data length.
Definition gcm.h:27
A GCM block.
Definition gcm.h:33
uint8_t byte[16]
Raw bytes.
Definition gcm.h:35
struct gcm_counter ctr
Counter.
Definition gcm.h:41
uint32_t dword[4]
Raw dwords.
Definition gcm.h:39
struct gcm_lengths len
Lengths.
Definition gcm.h:43
uint16_t word[8]
Raw words.
Definition gcm.h:37
u8 iv[16]
Initialization vector.
Definition wpa.h:33