diff options
Diffstat (limited to 'src/include/gpxe')
| -rw-r--r-- | src/include/gpxe/cbc.h | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/include/gpxe/cbc.h b/src/include/gpxe/cbc.h new file mode 100644 index 000000000..e2d57764e --- /dev/null +++ b/src/include/gpxe/cbc.h @@ -0,0 +1,50 @@ +#ifndef _GPXE_CBC_H +#define _GPXE_CBC_H + +/** @file + * + * Cipher-block chaining + * + */ + +#include <gpxe/crypto.h> + +/** + * Set key + * + * @v ctx Context + * @v key Key + * @v keylen Key length + * @v cipher Underlying cipher algorithm + * @v cbc_ctx CBC context + * @ret rc Return status code + */ +static inline int cbc_setkey ( void *ctx, const void *key, size_t keylen, + struct cipher_algorithm *cipher, + void *cbc_ctx __unused ) { + + return cipher_setkey ( cipher, ctx, key, keylen ); +} + +/** + * Set initialisation vector + * + * @v ctx Context + * @v iv Initialisation vector + * @v cipher Underlying cipher algorithm + * @v cbc_ctx CBC context + */ +static inline void cbc_setiv ( void *ctx __unused, const void *iv, + struct cipher_algorithm *cipher, + void *cbc_ctx ) { + memcpy ( cbc_ctx, iv, cipher->blocksize ); +} + +extern void cbc_encrypt ( void *ctx, const void *src, void *dst, + size_t len, struct cipher_algorithm *cipher, + void *cbc_ctx ); +extern void cbc_decrypt ( void *ctx, const void *src, void *dst, + size_t len, struct cipher_algorithm *cipher, + void *cbc_ctx ); + +#endif /* _GPXE_CBC_H */ |
