iPXE
ecb.h
Go to the documentation of this file.
1#ifndef _IPXE_ECB_H
2#define _IPXE_ECB_H
3
4/** @file
5 *
6 * Electronic codebook (ECB)
7 *
8 */
9
10FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11FILE_SECBOOT ( PERMITTED );
12
13#include <ipxe/crypto.h>
14
15extern int ecb_setkey ( struct cipher_algorithm *cipher, void *ctx,
16 const void *key, size_t keylen );
17extern void ecb_encrypt ( struct cipher_algorithm *cipher, void *ctx,
18 const void *src, void *dst, size_t len );
19extern void ecb_decrypt ( struct cipher_algorithm *cipher, void *ctx,
20 const void *src, void *dst, size_t len );
21
22/**
23 * Create an electronic codebook mode of behaviour of an existing cipher
24 *
25 * @v _ecb_name Name for the new ECB cipher
26 * @v _ecb_cipher New cipher algorithm
27 * @v _raw_cipher Underlying cipher algorithm
28 * @v _raw_context Context structure for the underlying cipher
29 * @v _blocksize Cipher block size
30 */
31#define ECB_CIPHER( _ecb_name, _ecb_cipher, _raw_cipher, _raw_context, \
32 _blocksize ) \
33struct cipher_algorithm _ecb_cipher = { \
34 .name = #_ecb_name, \
35 .ctxsize = sizeof ( _raw_context ), \
36 .blocksize = _blocksize, \
37 .alignsize = _blocksize, \
38 .authsize = 0, \
39 .confidential = 1, \
40 .setkey = ecb_setkey, \
41 .setiv = cipher_null_setiv, \
42 .encrypt = ecb_encrypt, \
43 .decrypt = ecb_decrypt, \
44 .auth = cipher_null_auth, \
45 .priv = &_raw_cipher, \
46};
47
48#endif /* _IPXE_ECB_H */
struct golan_eq_context ctx
Definition CIB_PRM.h:0
union @162305117151260234136356364136041353210355154177 key
static const void * src
Definition string.h:48
ring len
Length.
Definition dwmac.h:226
int ecb_setkey(struct cipher_algorithm *cipher, void *ctx, const void *key, size_t keylen)
Set key.
Definition ecb.c:46
void ecb_decrypt(struct cipher_algorithm *cipher, void *ctx, const void *src, void *dst, size_t len)
Decrypt data.
Definition ecb.c:86
void ecb_encrypt(struct cipher_algorithm *cipher, void *ctx, const void *src, void *dst, size_t len)
Encrypt data.
Definition ecb.c:62
#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