aboutsummaryrefslogtreecommitdiffstats
path: root/src/include/ipxe/cbc.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/ipxe/cbc.h')
-rw-r--r--src/include/ipxe/cbc.h10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/include/ipxe/cbc.h b/src/include/ipxe/cbc.h
index 18a94e144..5c8740365 100644
--- a/src/include/ipxe/cbc.h
+++ b/src/include/ipxe/cbc.h
@@ -33,12 +33,15 @@ static inline int cbc_setkey ( void *ctx, const void *key, size_t keylen,
*
* @v ctx Context
* @v iv Initialisation vector
+ * @v ivlen Initialisation vector length
* @v raw_cipher Underlying cipher algorithm
* @v cbc_ctx CBC context
*/
-static inline void cbc_setiv ( void *ctx __unused, const void *iv,
+static inline void cbc_setiv ( void *ctx __unused,
+ const void *iv, size_t ivlen,
struct cipher_algorithm *raw_cipher,
void *cbc_ctx ) {
+ assert ( ivlen == raw_cipher->blocksize );
memcpy ( cbc_ctx, iv, raw_cipher->blocksize );
}
@@ -70,9 +73,10 @@ static int _cbc_name ## _setkey ( void *ctx, const void *key, \
return cbc_setkey ( &_cbc_name ## _ctx->raw_ctx, key, keylen, \
&_raw_cipher, &_cbc_name ## _ctx->cbc_ctx );\
} \
-static void _cbc_name ## _setiv ( void *ctx, const void *iv ) { \
+static void _cbc_name ## _setiv ( void *ctx, const void *iv, \
+ size_t ivlen ) { \
struct _cbc_name ## _context * _cbc_name ## _ctx = ctx; \
- cbc_setiv ( &_cbc_name ## _ctx->raw_ctx, iv, \
+ cbc_setiv ( &_cbc_name ## _ctx->raw_ctx, iv, ivlen, \
&_raw_cipher, &aes_cbc_ctx->cbc_ctx ); \
} \
static void _cbc_name ## _encrypt ( void *ctx, const void *src, \