iPXE
des.h
Go to the documentation of this file.
1#ifndef _IPXE_DES_H
2#define _IPXE_DES_H
3
4/** @file
5 *
6 * DES algorithm
7 *
8 */
9
10FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11FILE_SECBOOT ( PERMITTED );
12
13#include <ipxe/crypto.h>
14
15/** A DES 32-bit dword value
16 *
17 * DES views data as 64-bit big-endian values, typically handled as a
18 * most-significant "left" half and a least-significant "right" half.
19 */
20union des_dword {
21 /** Raw bytes */
22 uint8_t byte[4];
23 /** 32-bit big-endian dword */
25};
26
27/** A DES 64-bit block */
28union des_block {
29 /** Raw bytes */
30 uint8_t byte[8];
31 /** 32-bit big-endian dwords */
33 /** Named left and right halves */
34 struct {
35 /** Left (most significant) half */
37 /** Right (least significant) half */
39 };
40 /** Named "C" and "D" halves */
41 struct {
42 /** "C" (most significant) half */
43 union des_dword c;
44 /** "D" (least significant) half */
45 union des_dword d;
46 };
47};
48
49/** DES blocksize */
50#define DES_BLOCKSIZE sizeof ( union des_block )
51
52/** A DES round key
53 *
54 * A DES round key is a 48-bit value, consumed as 8 groups of 6 bits.
55 * We store these as 8 separate bytes, for simplicity of consumption.
56 */
58 /** Raw bytes */
59 uint8_t byte[8];
60 /** 32-bit big-endian dwords */
62 /** 6-bit step key byte
63 *
64 * There are 8 steps within a DES round (one step per S-box).
65 * Each step requires six bits of the round key.
66 *
67 * As an optimisation, we store the least significant of the 6
68 * bits in the sign bit of a signed 8-bit value, and the
69 * remaining 5 bits in the least significant 5 bits of the
70 * 8-bit value. See the comments in des_sbox() for further
71 * details.
72 */
74};
75
76/** Number of DES rounds */
77#define DES_ROUNDS 16
78
79/** DES context */
81 /** Round keys */
83};
84
85/** DES context size */
86#define DES_CTX_SIZE sizeof ( struct des_context )
87
91
92#endif /* _IPXE_DES_H */
unsigned int uint32_t
Definition stdint.h:12
unsigned char uint8_t
Definition stdint.h:10
signed char int8_t
Definition stdint.h:15
struct cipher_algorithm des_algorithm
Basic DES algorithm.
Definition des.c:678
#define DES_ROUNDS
Number of DES rounds.
Definition des.h:77
struct cipher_algorithm des_cbc_algorithm
struct cipher_algorithm des_ecb_algorithm
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
Definition compiler.h:926
Cryptographic API.
A cipher algorithm.
Definition crypto.h:51
DES context.
Definition des.h:80
union des_round_key rkey[DES_ROUNDS]
Round keys.
Definition des.h:82
A DES 64-bit block.
Definition des.h:28
union des_dword left
Left (most significant) half.
Definition des.h:36
union des_dword right
Right (least significant) half.
Definition des.h:38
union des_dword d
"D" (least significant) half
Definition des.h:45
union des_dword c
"C" (most significant) half
Definition des.h:43
uint32_t dword[2]
32-bit big-endian dwords
Definition des.h:32
A DES 32-bit dword value.
Definition des.h:20
uint32_t dword
32-bit big-endian dword
Definition des.h:24
A DES round key.
Definition des.h:57
uint32_t dword[2]
32-bit big-endian dwords
Definition des.h:61
int8_t step[8]
6-bit step key byte
Definition des.h:73