41 const void *
iv,
size_t ivlen,
64 #define CBC_CIPHER( _cbc_name, _cbc_cipher, _raw_cipher, _raw_context, \ 66 struct _cbc_name ## _context { \ 67 _raw_context raw_ctx; \ 68 uint8_t cbc_ctx[_blocksize]; \ 70 static int _cbc_name ## _setkey ( void *ctx, const void *key, \ 72 struct _cbc_name ## _context * _cbc_name ## _ctx = ctx; \ 73 return cbc_setkey ( &_cbc_name ## _ctx->raw_ctx, key, keylen, \ 74 &_raw_cipher, &_cbc_name ## _ctx->cbc_ctx );\ 76 static void _cbc_name ## _setiv ( void *ctx, const void *iv, \ 78 struct _cbc_name ## _context * _cbc_name ## _ctx = ctx; \ 79 cbc_setiv ( &_cbc_name ## _ctx->raw_ctx, iv, ivlen, \ 80 &_raw_cipher, &_cbc_name ## _ctx->cbc_ctx ); \ 82 static void _cbc_name ## _encrypt ( void *ctx, const void *src, \ 83 void *dst, size_t len ) { \ 84 struct _cbc_name ## _context * _cbc_name ## _ctx = ctx; \ 85 cbc_encrypt ( &_cbc_name ## _ctx->raw_ctx, src, dst, len, \ 86 &_raw_cipher, &_cbc_name ## _ctx->cbc_ctx ); \ 88 static void _cbc_name ## _decrypt ( void *ctx, const void *src, \ 89 void *dst, size_t len ) { \ 90 struct _cbc_name ## _context * _cbc_name ## _ctx = ctx; \ 91 cbc_decrypt ( &_cbc_name ## _ctx->raw_ctx, src, dst, len, \ 92 &_raw_cipher, &_cbc_name ## _ctx->cbc_ctx ); \ 94 struct cipher_algorithm _cbc_cipher = { \ 96 .ctxsize = sizeof ( struct _cbc_name ## _context ), \ 97 .blocksize = _blocksize, \ 98 .alignsize = _blocksize, \ 100 .setkey = _cbc_name ## _setkey, \ 101 .setiv = _cbc_name ## _setiv, \ 102 .encrypt = _cbc_name ## _encrypt, \ 103 .decrypt = _cbc_name ## _decrypt, \ 104 .auth = cipher_null_auth, \ size_t blocksize
Block size.
void cbc_encrypt(void *ctx, const void *src, void *dst, size_t len, struct cipher_algorithm *raw_cipher, void *cbc_ctx)
Encrypt data.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
struct golan_eq_context ctx
u8 iv[16]
Initialization vector.
void * memcpy(void *dest, const void *src, size_t len) __nonnull
#define __unused
Declare a variable or data structure as unused.
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
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.
static int cbc_setkey(void *ctx, const void *key, size_t keylen, struct cipher_algorithm *raw_cipher, void *cbc_ctx __unused)
Set key.
static int cipher_setkey(struct cipher_algorithm *cipher, void *ctx, const void *key, size_t keylen)