42 const void *
iv,
size_t ivlen,
65#define CBC_CIPHER( _cbc_name, _cbc_cipher, _raw_cipher, _raw_context, \
67struct _cbc_name ## _context { \
68 _raw_context raw_ctx; \
69 uint8_t cbc_ctx[_blocksize]; \
71static int _cbc_name ## _setkey ( void *ctx, const void *key, \
73 struct _cbc_name ## _context * _cbc_name ## _ctx = ctx; \
74 return cbc_setkey ( &_cbc_name ## _ctx->raw_ctx, key, keylen, \
75 &_raw_cipher, &_cbc_name ## _ctx->cbc_ctx );\
77static void _cbc_name ## _setiv ( void *ctx, const void *iv, \
79 struct _cbc_name ## _context * _cbc_name ## _ctx = ctx; \
80 cbc_setiv ( &_cbc_name ## _ctx->raw_ctx, iv, ivlen, \
81 &_raw_cipher, &_cbc_name ## _ctx->cbc_ctx ); \
83static void _cbc_name ## _encrypt ( void *ctx, const void *src, \
84 void *dst, size_t len ) { \
85 struct _cbc_name ## _context * _cbc_name ## _ctx = ctx; \
86 cbc_encrypt ( &_cbc_name ## _ctx->raw_ctx, src, dst, len, \
87 &_raw_cipher, &_cbc_name ## _ctx->cbc_ctx ); \
89static void _cbc_name ## _decrypt ( void *ctx, const void *src, \
90 void *dst, size_t len ) { \
91 struct _cbc_name ## _context * _cbc_name ## _ctx = ctx; \
92 cbc_decrypt ( &_cbc_name ## _ctx->raw_ctx, src, dst, len, \
93 &_raw_cipher, &_cbc_name ## _ctx->cbc_ctx ); \
95struct cipher_algorithm _cbc_cipher = { \
97 .ctxsize = sizeof ( struct _cbc_name ## _context ), \
98 .blocksize = _blocksize, \
99 .alignsize = _blocksize, \
101 .setkey = _cbc_name ## _setkey, \
102 .setiv = _cbc_name ## _setiv, \
103 .encrypt = _cbc_name ## _encrypt, \
104 .decrypt = _cbc_name ## _decrypt, \
105 .auth = cipher_null_auth, \
union @162305117151260234136356364136041353210355154177 key
Sense key.
struct golan_eq_context ctx
#define assert(condition)
Assert a condition at run-time.
void cbc_encrypt(void *ctx, const void *src, void *dst, size_t len, struct cipher_algorithm *raw_cipher, void *cbc_ctx)
Encrypt data.
static int cbc_setkey(void *ctx, const void *key, size_t keylen, struct cipher_algorithm *raw_cipher, void *cbc_ctx __unused)
Set key.
void cbc_decrypt(void *ctx, const void *src, void *dst, size_t len, struct cipher_algorithm *raw_cipher, void *cbc_ctx)
Decrypt data.
static void cbc_setiv(void *ctx __unused, const void *iv, size_t ivlen, struct cipher_algorithm *raw_cipher, void *cbc_ctx)
Set initialisation vector.
#define __unused
Declare a variable or data structure as unused.
#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.
static int cipher_setkey(struct cipher_algorithm *cipher, void *ctx, const void *key, size_t keylen)
void * memcpy(void *dest, const void *src, size_t len) __nonnull
size_t blocksize
Block size.
u8 iv[16]
Initialization vector.