iPXE
|
Cipher-block chaining. More...
#include <ipxe/crypto.h>
Go to the source code of this file.
Macros | |
#define | CBC_CIPHER(_cbc_name, _cbc_cipher, _raw_cipher, _raw_context, _blocksize) |
Create a cipher-block chaining mode of behaviour of an existing cipher. More... | |
Functions | |
FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
static int | cbc_setkey (void *ctx, const void *key, size_t keylen, struct cipher_algorithm *raw_cipher, void *cbc_ctx __unused) |
Set key. More... | |
static void | cbc_setiv (void *ctx __unused, const void *iv, size_t ivlen, struct cipher_algorithm *raw_cipher, void *cbc_ctx) |
Set initialisation vector. More... | |
void | cbc_encrypt (void *ctx, const void *src, void *dst, size_t len, struct cipher_algorithm *raw_cipher, void *cbc_ctx) |
Encrypt data. More... | |
void | cbc_decrypt (void *ctx, const void *src, void *dst, size_t len, struct cipher_algorithm *raw_cipher, void *cbc_ctx) |
Decrypt data. More... | |
Cipher-block chaining.
Definition in file cbc.h.
#define CBC_CIPHER | ( | _cbc_name, | |
_cbc_cipher, | |||
_raw_cipher, | |||
_raw_context, | |||
_blocksize | |||
) |
Create a cipher-block chaining mode of behaviour of an existing cipher.
_cbc_name | Name for the new CBC cipher |
_cbc_cipher | New cipher algorithm |
_raw_cipher | Underlying cipher algorithm |
_raw_context | Context structure for the underlying cipher |
_blocksize | Cipher block size |
FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
|
inlinestatic |
Set key.
ctx | Context |
key | Key |
keylen | Key length |
raw_cipher | Underlying cipher algorithm |
cbc_ctx | CBC context |
rc | Return status code |
Definition at line 24 of file cbc.h.
References cipher_setkey(), ctx, and key.
|
inlinestatic |
Set initialisation vector.
ctx | Context |
iv | Initialisation vector |
ivlen | Initialisation vector length |
raw_cipher | Underlying cipher algorithm |
cbc_ctx | CBC context |
Definition at line 40 of file cbc.h.
References assert(), cipher_algorithm::blocksize, iv, and memcpy().
void cbc_encrypt | ( | void * | ctx, |
const void * | src, | ||
void * | dst, | ||
size_t | len, | ||
struct cipher_algorithm * | raw_cipher, | ||
void * | cbc_ctx | ||
) |
Encrypt data.
ctx | Context |
src | Data to encrypt |
dst | Buffer for encrypted data |
len | Length of data |
raw_cipher | Underlying cipher algorithm |
cbc_ctx | CBC context |
Definition at line 66 of file cbc.c.
References assert(), cipher_algorithm::blocksize, cbc_xor(), cipher_encrypt, ctx, len, memcpy(), and src.
void cbc_decrypt | ( | void * | ctx, |
const void * | src, | ||
void * | dst, | ||
size_t | len, | ||
struct cipher_algorithm * | raw_cipher, | ||
void * | cbc_ctx | ||
) |
Decrypt data.
ctx | Context |
src | Data to decrypt |
dst | Buffer for decrypted data |
len | Length of data |
raw_cipher | Underlying cipher algorithm |
cbc_ctx | CBC context |
Definition at line 92 of file cbc.c.
References assert(), cipher_algorithm::blocksize, cbc_xor(), cipher_decrypt, ctx, len, memcpy(), and src.