iPXE
cbc.h
Go to the documentation of this file.
1#ifndef _IPXE_CBC_H
2#define _IPXE_CBC_H
3
4/** @file
5 *
6 * Cipher-block chaining
7 *
8 */
9
10FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11FILE_SECBOOT ( PERMITTED );
12
13#include <ipxe/crypto.h>
14
15/** A cipher-block chaining mode context */
16#define cbc_context_t( blocksize, ctxsize ) \
17 struct { \
18 uint8_t cbc[ (blocksize) ]; \
19 uint8_t raw[ (ctxsize) - (blocksize) ]; \
20 }
21
22extern int cbc_setkey ( struct cipher_algorithm *cipher, void *ctx,
23 const void *key, size_t keylen );
24extern int cbc_setiv ( struct cipher_algorithm *cipher, void *ctx,
25 const void *iv, size_t ivlen );
26extern void cbc_encrypt ( struct cipher_algorithm *cipher, void *ctx,
27 const void *src, void *dst, size_t len );
28extern void cbc_decrypt ( struct cipher_algorithm *cipher, void *ctx,
29 const void *src, void *dst, size_t len );
30
31/**
32 * Create a cipher-block chaining mode of behaviour of an existing cipher
33 *
34 * @v _cbc_name Name for the new CBC cipher
35 * @v _cbc_cipher New cipher algorithm
36 * @v _raw_cipher Underlying cipher algorithm
37 * @v _raw_context Context structure for the underlying cipher
38 * @v _blocksize Cipher block size
39 */
40#define CBC_CIPHER( _cbc_name, _cbc_cipher, _raw_cipher, _raw_context, \
41 _blocksize ) \
42struct cipher_algorithm _cbc_cipher = { \
43 .name = #_cbc_name, \
44 .ctxsize = ( _blocksize + sizeof ( _raw_context ) ), \
45 .blocksize = _blocksize, \
46 .alignsize = _blocksize, \
47 .authsize = 0, \
48 .confidential = 1, \
49 .setkey = cbc_setkey, \
50 .setiv = cbc_setiv, \
51 .encrypt = cbc_encrypt, \
52 .decrypt = cbc_decrypt, \
53 .auth = cipher_null_auth, \
54 .priv = &_raw_cipher, \
55};
56
57#endif /* _IPXE_CBC_H */
struct golan_eq_context ctx
Definition CIB_PRM.h:0
union @162305117151260234136356364136041353210355154177 key
static const void * src
Definition string.h:48
void cbc_encrypt(struct cipher_algorithm *cipher, void *ctx, const void *src, void *dst, size_t len)
Encrypt data.
Definition cbc.c:111
int cbc_setkey(struct cipher_algorithm *cipher, void *ctx, const void *key, size_t keylen)
Set key.
Definition cbc.c:48
void cbc_decrypt(struct cipher_algorithm *cipher, void *ctx, const void *src, void *dst, size_t len)
Decrypt data.
Definition cbc.c:140
int cbc_setiv(struct cipher_algorithm *cipher, void *ctx, const void *iv, size_t ivlen)
Set initialisation vector.
Definition cbc.c:67
ring len
Length.
Definition dwmac.h:226
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:921
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
Definition compiler.h:951
Cryptographic API.
A cipher algorithm.
Definition crypto.h:58
u8 iv[16]
Initialization vector.
Definition wpa.h:33