#include <stdlib.h>
#include <string.h>
#include <ipxe/crypto.h>
#include <ipxe/aes.h>
Go to the source code of this file.
◆ FILE_LICENCE()
FILE_LICENCE |
( |
GPL2_OR_LATER |
| ) |
|
◆ aes_wrap()
int aes_wrap |
( |
const void * |
kek, |
|
|
const void * |
src, |
|
|
void * |
dest, |
|
|
int |
nblk |
|
) |
| |
Wrap a key or other data using AES Key Wrap (RFC 3394)
- Parameters
-
kek | Key Encryption Key, 16 bytes |
src | Data to encrypt |
nblk | Number of 8-byte blocks in data |
- Return values
-
dest | Encrypted data (8 bytes longer than input) |
The algorithm is implemented such that src and dest may point to the same buffer.
Definition at line 38 of file aes_wrap.c.
56 for ( j = 0; j < 6; j++ ) {
58 for ( i = 1; i <= nblk; i++ ) {
63 A[7] ^= ( nblk * j ) + i;
#define AES_CTX_SIZE
AES context size.
struct cipher_algorithm aes_algorithm
Basic AES algorithm.
#define cipher_encrypt(cipher, ctx, src, dst, len)
void * memcpy(void *dest, const void *src, size_t len) __nonnull
static void(* free)(struct refcnt *refcnt))
u8 kek[WPA_KEK_LEN]
EAPOL-Key Key Encryption Key (KEK)
void * malloc(size_t size)
Allocate memory.
void * memmove(void *dest, const void *src, size_t len) __nonnull
if(len >=6 *4) __asm__ __volatile__("movsl" if(len >=5 *4) __asm__ __volatile__("movsl" if(len >=4 *4) __asm__ __volatile__("movsl" if(len >=3 *4) __asm__ __volatile__("movsl" if(len >=2 *4) __asm__ __volatile__("movsl" if(len >=1 *4) __asm__ __volatile__("movsl" if((len % 4) >=2) __asm__ __volatile__("movsw" if((len % 2) >=1) __asm__ __volatile__("movsb" return dest
static int cipher_setkey(struct cipher_algorithm *cipher, void *ctx, const void *key, size_t keylen)
void * memset(void *dest, int character, size_t len) __nonnull
References aes_algorithm, AES_CTX_SIZE, cipher_encrypt, cipher_setkey(), dest, free, kek, malloc(), memcpy(), memmove(), memset(), and src.
◆ aes_unwrap()
int aes_unwrap |
( |
const void * |
kek, |
|
|
const void * |
src, |
|
|
void * |
dest, |
|
|
int |
nblk |
|
) |
| |
Unwrap a key or other data using AES Key Wrap (RFC 3394)
- Parameters
-
kek | Key Encryption Key, 16 bytes |
src | Data to decrypt |
nblk | Number of 8-byte blocks in plaintext key |
- Return values
-
dest | Decrypted data (8 bytes shorter than input) |
rc | Zero on success, nonzero on IV mismatch |
The algorithm is implemented such that src and dest may point to the same buffer.
Definition at line 85 of file aes_wrap.c.
102 for ( j = 5; j >= 0; j-- ) {
103 R =
dest + ( nblk - 1 ) * 8;
104 for ( i = nblk; i >= 1; i-- ) {
107 B[7] ^= ( nblk * j ) + i;
118 for ( i = 0; i < 8; i++ ) {
#define AES_CTX_SIZE
AES context size.
struct cipher_algorithm aes_algorithm
Basic AES algorithm.
void * memcpy(void *dest, const void *src, size_t len) __nonnull
static void(* free)(struct refcnt *refcnt))
u8 kek[WPA_KEK_LEN]
EAPOL-Key Key Encryption Key (KEK)
#define cipher_decrypt(cipher, ctx, src, dst, len)
void * malloc(size_t size)
Allocate memory.
void * memmove(void *dest, const void *src, size_t len) __nonnull
if(len >=6 *4) __asm__ __volatile__("movsl" if(len >=5 *4) __asm__ __volatile__("movsl" if(len >=4 *4) __asm__ __volatile__("movsl" if(len >=3 *4) __asm__ __volatile__("movsl" if(len >=2 *4) __asm__ __volatile__("movsl" if(len >=1 *4) __asm__ __volatile__("movsl" if((len % 4) >=2) __asm__ __volatile__("movsw" if((len % 2) >=1) __asm__ __volatile__("movsb" return dest
static int cipher_setkey(struct cipher_algorithm *cipher, void *ctx, const void *key, size_t keylen)
References aes_algorithm, AES_CTX_SIZE, cipher_decrypt, cipher_setkey(), dest, free, kek, malloc(), memcpy(), memmove(), and src.
Referenced by ccmp_kie_decrypt().