iPXE
include
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
10
FILE_LICENCE
( GPL2_OR_LATER_OR_UBDL );
11
FILE_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
*/
20
union
des_dword
{
21
/** Raw bytes */
22
uint8_t
byte
[4];
23
/** 32-bit big-endian dword */
24
uint32_t
dword
;
25
};
26
27
/** A DES 64-bit block */
28
union
des_block
{
29
/** Raw bytes */
30
uint8_t
byte
[8];
31
/** 32-bit big-endian dwords */
32
uint32_t
dword
[2];
33
/** Named left and right halves */
34
struct
{
35
/** Left (most significant) half */
36
union
des_dword
left
;
37
/** Right (least significant) half */
38
union
des_dword
right
;
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
*/
57
union
des_round_key
{
58
/** Raw bytes */
59
uint8_t
byte
[8];
60
/** 32-bit big-endian dwords */
61
uint32_t
dword
[2];
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
*/
73
int8_t
step
[8];
74
};
75
76
/** Number of DES rounds */
77
#define DES_ROUNDS 16
78
79
/** DES context */
80
struct
des_context
{
81
/** Round keys */
82
union
des_round_key
rkey
[
DES_ROUNDS
];
83
};
84
85
/** DES context size */
86
#define DES_CTX_SIZE sizeof ( struct des_context )
87
88
extern
struct
cipher_algorithm
des_algorithm
;
89
extern
struct
cipher_algorithm
des_ecb_algorithm
;
90
extern
struct
cipher_algorithm
des_cbc_algorithm
;
91
92
#endif
/* _IPXE_DES_H */
uint32_t
unsigned int uint32_t
Definition
stdint.h:12
uint8_t
unsigned char uint8_t
Definition
stdint.h:10
int8_t
signed char int8_t
Definition
stdint.h:15
des_algorithm
struct cipher_algorithm des_algorithm
Basic DES algorithm.
Definition
des.c:678
DES_ROUNDS
#define DES_ROUNDS
Number of DES rounds.
Definition
des.h:77
des_cbc_algorithm
struct cipher_algorithm des_cbc_algorithm
des_ecb_algorithm
struct cipher_algorithm des_ecb_algorithm
FILE_LICENCE
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition
compiler.h:896
FILE_SECBOOT
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
Definition
compiler.h:926
crypto.h
Cryptographic API.
cipher_algorithm
A cipher algorithm.
Definition
crypto.h:51
des_context
DES context.
Definition
des.h:80
des_context::rkey
union des_round_key rkey[DES_ROUNDS]
Round keys.
Definition
des.h:82
des_block
A DES 64-bit block.
Definition
des.h:28
des_block::left
union des_dword left
Left (most significant) half.
Definition
des.h:36
des_block::right
union des_dword right
Right (least significant) half.
Definition
des.h:38
des_block::d
union des_dword d
"D" (least significant) half
Definition
des.h:45
des_block::c
union des_dword c
"C" (most significant) half
Definition
des.h:43
des_block::dword
uint32_t dword[2]
32-bit big-endian dwords
Definition
des.h:32
des_dword
A DES 32-bit dword value.
Definition
des.h:20
des_dword::dword
uint32_t dword
32-bit big-endian dword
Definition
des.h:24
des_round_key
A DES round key.
Definition
des.h:57
des_round_key::dword
uint32_t dword[2]
32-bit big-endian dwords
Definition
des.h:61
des_round_key::step
int8_t step[8]
6-bit step key byte
Definition
des.h:73
Generated by
1.14.0