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