iPXE
Data Structures | Macros | Functions | Variables
crypto.h File Reference

Cryptographic API. More...

#include <stdint.h>
#include <stddef.h>
#include <assert.h>

Go to the source code of this file.

Data Structures

struct  digest_algorithm
 A message digest algorithm. More...
 
struct  cipher_algorithm
 A cipher algorithm. More...
 
struct  pubkey_algorithm
 A public key algorithm. More...
 
struct  elliptic_curve
 An elliptic curve. More...
 

Macros

#define cipher_encrypt(cipher, ctx, src, dst, len)
 
#define cipher_decrypt(cipher, ctx, src, dst, len)
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
static __attribute__ ((always_inline)) void digest_init(struct digest_algorithm *digest
 
void digest_null_init (void *ctx)
 
void digest_null_update (void *ctx, const void *src, size_t len)
 
void digest_null_final (void *ctx, void *out)
 
int cipher_null_setkey (void *ctx, const void *key, size_t keylen)
 
void cipher_null_setiv (void *ctx, const void *iv, size_t ivlen)
 
void cipher_null_encrypt (void *ctx, const void *src, void *dst, size_t len)
 
void cipher_null_decrypt (void *ctx, const void *src, void *dst, size_t len)
 
void cipher_null_auth (void *ctx, void *auth)
 
int pubkey_null_init (void *ctx, const void *key, size_t key_len)
 
size_t pubkey_null_max_len (void *ctx)
 
int pubkey_null_encrypt (void *ctx, const void *plaintext, size_t plaintext_len, void *ciphertext)
 
int pubkey_null_decrypt (void *ctx, const void *ciphertext, size_t ciphertext_len, void *plaintext)
 
int pubkey_null_sign (void *ctx, struct digest_algorithm *digest, const void *value, void *signature)
 
int pubkey_null_verify (void *ctx, struct digest_algorithm *digest, const void *value, const void *signature, size_t signature_len)
 

Variables

static void * ctx
 
static void const void * data
 
static void const void size_t len
 
static void void * out
 
static void const void * key
 
static void const void size_t keylen
 
static void const void * iv
 
static void const void size_t ivlen
 
static void const void * src
 
static void const void void * dst
 
static void void * auth
 
static void const void size_t key_len
 
static void struct digest_algorithmdigest
 HMAC-MD5 digest. More...
 
static void struct digest_algorithm const void * value
 
static void struct digest_algorithm const void void * signature
 
static void struct digest_algorithm const void const void size_t signature_len
 
static const void * private_key
 Private key. More...
 
static const void size_t private_key_len
 
static const void size_t const void * public_key
 
static const void size_t const void size_t public_key_len
 
static const void * base
 Base address. More...
 
static const void const void * scalar
 
static const void const void void * result
 
struct digest_algorithm digest_null
 
struct cipher_algorithm cipher_null
 
struct pubkey_algorithm pubkey_null
 

Detailed Description

Cryptographic API.

Definition in file crypto.h.

Macro Definition Documentation

◆ cipher_encrypt

#define cipher_encrypt (   cipher,
  ctx,
  src,
  dst,
  len 
)
Value:
do { \
assert ( ( (len) & ( (cipher)->blocksize - 1 ) ) == 0 ); \
cipher_encrypt ( (cipher), (ctx), (src), (dst), (len) ); \
} while ( 0 )
static void const void void * dst
Definition: crypto.h:244
static void const void * src
Definition: crypto.h:244
static void const void size_t len
Definition: crypto.h:222
static void * ctx
Definition: crypto.h:216

Definition at line 248 of file crypto.h.

◆ cipher_decrypt

#define cipher_decrypt (   cipher,
  ctx,
  src,
  dst,
  len 
)
Value:
do { \
assert ( ( (len) & ( (cipher)->blocksize - 1 ) ) == 0 ); \
cipher_decrypt ( (cipher), (ctx), (src), (dst), (len) ); \
} while ( 0 )
static void const void void * dst
Definition: crypto.h:244
static void const void * src
Definition: crypto.h:244
static void const void size_t len
Definition: crypto.h:222
static void * ctx
Definition: crypto.h:216

Definition at line 258 of file crypto.h.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ __attribute__()

static __attribute__ ( (always_inline)  )
inlinestatic

Definition at line 268 of file crypto.h.

269  {
270  return ( cipher->blocksize == 1 );
271 }

References cipher_algorithm::blocksize.

◆ digest_null_init()

void digest_null_init ( void *  ctx)

◆ digest_null_update()

void digest_null_update ( void *  ctx,
const void *  src,
size_t  len 
)

◆ digest_null_final()

void digest_null_final ( void *  ctx,
void *  out 
)

◆ cipher_null_setkey()

int cipher_null_setkey ( void *  ctx,
const void *  key,
size_t  keylen 
)

◆ cipher_null_setiv()

void cipher_null_setiv ( void *  ctx,
const void *  iv,
size_t  ivlen 
)

◆ cipher_null_encrypt()

void cipher_null_encrypt ( void *  ctx,
const void *  src,
void *  dst,
size_t  len 
)

◆ cipher_null_decrypt()

void cipher_null_decrypt ( void *  ctx,
const void *  src,
void *  dst,
size_t  len 
)

◆ cipher_null_auth()

void cipher_null_auth ( void *  ctx,
void *  auth 
)

◆ pubkey_null_init()

int pubkey_null_init ( void *  ctx,
const void *  key,
size_t  key_len 
)

◆ pubkey_null_max_len()

size_t pubkey_null_max_len ( void *  ctx)

◆ pubkey_null_encrypt()

int pubkey_null_encrypt ( void *  ctx,
const void *  plaintext,
size_t  plaintext_len,
void *  ciphertext 
)

◆ pubkey_null_decrypt()

int pubkey_null_decrypt ( void *  ctx,
const void *  ciphertext,
size_t  ciphertext_len,
void *  plaintext 
)

◆ pubkey_null_sign()

int pubkey_null_sign ( void *  ctx,
struct digest_algorithm digest,
const void *  value,
void *  signature 
)

◆ pubkey_null_verify()

int pubkey_null_verify ( void *  ctx,
struct digest_algorithm digest,
const void *  value,
const void *  signature,
size_t  signature_len 
)

Variable Documentation

◆ ctx

void* ctx
Initial value:
{
void(* init)(void *ctx)
Initialise digest.
Definition: crypto.h:30
static void struct digest_algorithm * digest
HMAC-MD5 digest.
Definition: crypto.h:308
static void * ctx
Definition: crypto.h:216

Definition at line 216 of file crypto.h.

◆ data

void const void* data

Definition at line 221 of file crypto.h.

◆ len

void const void size_t len
Initial value:
{
static void const void size_t len
Definition: crypto.h:222
static void struct digest_algorithm * digest
HMAC-MD5 digest.
Definition: crypto.h:308
void(* update)(void *ctx, const void *src, size_t len)
Update digest with new data.
Definition: crypto.h:39
static void * ctx
Definition: crypto.h:216
static void const void * data
Definition: crypto.h:221

Definition at line 222 of file crypto.h.

◆ out

void const void size_t void* out
Initial value:
{
void(* final)(void *ctx, void *out)
Finalise digest.
Definition: crypto.h:45
static void struct digest_algorithm * digest
HMAC-MD5 digest.
Definition: crypto.h:308
static void * ctx
Definition: crypto.h:216
static void void * out
Definition: crypto.h:227

Definition at line 227 of file crypto.h.

◆ key

void const void* key

Definition at line 232 of file crypto.h.

◆ keylen

void const void size_t keylen
Initial value:
{
return cipher->setkey ( ctx, key, keylen )
static void const void * key
Definition: crypto.h:232
static void const void size_t keylen
Definition: crypto.h:233
static void * ctx
Definition: crypto.h:216

Definition at line 233 of file crypto.h.

Referenced by aes_setkey(), aes_test_exec(), arc4_setkey(), arc4_skip(), cbc_setkey(), ccmp_init(), des_setkey(), gcm_setkey(), gcm_test_exec(), peerblk_parse_header(), tkip_init(), and wep_init().

◆ iv

void const void* iv

◆ ivlen

void const void size_t ivlen
Initial value:
{
cipher->setiv ( ctx, iv, ivlen )
static void const void size_t ivlen
Definition: crypto.h:239
static void const void * iv
Definition: crypto.h:238
static void * ctx
Definition: crypto.h:216

Definition at line 239 of file crypto.h.

Referenced by cbc_setiv(), and gcm_setiv().

◆ src

static __always_inline void off_t userptr_t src

Definition at line 244 of file crypto.h.

Referenced by __attribute__(), __memmove(), aes_decrypt(), aes_encrypt(), aes_unwrap(), aes_wrap(), arc4_skip(), arc4_xor(), bnxt_add_vlan(), bnxt_get_pkt_vlan(), bzimage_parse_header(), cbc_decrypt(), cbc_encrypt(), cbc_xor(), ccmp_ctr_xor(), cipher_null_decrypt(), cipher_null_encrypt(), copy_from_user(), copy_to_real(), copy_to_user(), crc32_le(), des_decrypt(), des_encrypt(), dhcpv6_rx(), dns_copy(), ecb_decrypt(), ecb_encrypt(), efi_paths(), efi_pxe_udp_write(), efi_undi_fill_header(), efi_undi_receive(), eth_pio_read(), eth_pio_write(), exanic_transmit(), fbcon_draw(), fc_els_rx(), fc_xchg_rx(), gcc_implicit_memcpy(), gcm_decrypt(), gcm_encrypt(), gcm_process(), gcm_xor_block(), gdbstub_from_hex_buf(), gdbstub_to_hex_buf(), generic_memcpy(), generic_memcpy_reverse(), generic_memmove(), hv_wait_for_message(), ipv4_rx(), ipv6_route_okx(), ipv6_rx(), ipv6_tx(), memchr(), memcpy_0(), memcpy_1(), memcpy_10(), memcpy_11(), memcpy_12(), memcpy_13(), memcpy_14(), memcpy_15(), memcpy_16(), memcpy_17(), memcpy_18(), memcpy_19(), memcpy_2(), memcpy_20(), memcpy_21(), memcpy_22(), memcpy_23(), memcpy_24(), memcpy_25(), memcpy_26(), memcpy_27(), memcpy_28(), memcpy_29(), memcpy_3(), memcpy_30(), memcpy_31(), memcpy_4(), memcpy_5(), memcpy_6(), memcpy_7(), memcpy_8(), memcpy_9(), memcpy_test_speed(), memcpy_var(), mschapv2_expand_hash(), nii_sync(), shuffle(), strcat(), strchr(), strcpy(), strdup(), string_copy(), string_test_exec(), strlen(), strncpy(), strndup(), strnlen(), strrchr(), trivial_memcpy_user(), trivial_memmove_user(), udp_tx(), and uri_copy_fields().

◆ dst

static void const void void * dst

◆ auth

void void* auth

◆ key_len

void const void size_t key_len
Initial value:
{
return pubkey->init ( ctx, key, key_len )
static void const void * key
Definition: crypto.h:232
static void const void size_t key_len
Definition: crypto.h:285
static void * ctx
Definition: crypto.h:216

Definition at line 285 of file crypto.h.

Referenced by add_parameter(), cipher_cost(), cipher_cost_decrypt(), cipher_cost_encrypt(), efi_snp_hii_process(), hmac_init(), iscsi_handle_string(), pbkdf2_sha1(), prf_sha1(), rsa_init(), and xenbus_probe_device().

◆ digest

uint8_t digest

◆ value

void struct digest_algorithm const void* value

Definition at line 308 of file crypto.h.

◆ signature

void struct digest_algorithm const void const void* signature
Initial value:
{
return pubkey->sign ( ctx, digest, value, signature )
static void struct digest_algorithm const void * value
Definition: crypto.h:308
static void struct digest_algorithm const void void * signature
Definition: crypto.h:309
static void struct digest_algorithm * digest
HMAC-MD5 digest.
Definition: crypto.h:308
static void * ctx
Definition: crypto.h:216

Definition at line 309 of file crypto.h.

◆ signature_len

void struct digest_algorithm const void const void size_t signature_len
Initial value:
{
return pubkey->verify ( ctx, digest, value, signature, signature_len )
static void struct digest_algorithm const void * value
Definition: crypto.h:308
static void struct digest_algorithm const void void * signature
Definition: crypto.h:309
static void struct digest_algorithm * digest
HMAC-MD5 digest.
Definition: crypto.h:308
static void struct digest_algorithm const void const void size_t signature_len
Definition: crypto.h:316
static void * ctx
Definition: crypto.h:216

Definition at line 316 of file crypto.h.

Referenced by rsa_verify(), tls_send_certificate_verify(), and tls_verify_dh_params().

◆ private_key

const void* private_key

Private key.

Definition at line 327 of file crypto.h.

◆ private_key_len

const void size_t private_key_len

Definition at line 327 of file crypto.h.

Referenced by rsa_match().

◆ public_key

const void size_t const void* public_key

◆ public_key_len

const void size_t const void size_t public_key_len
Initial value:
{
return pubkey->match ( private_key, private_key_len, public_key,
static const void size_t const void * public_key
Definition: crypto.h:327
static const void size_t private_key_len
Definition: crypto.h:327
A private key.
Definition: privkey.h:16
static const void size_t const void size_t public_key_len
Definition: crypto.h:328

Definition at line 328 of file crypto.h.

Referenced by rsa_match().

◆ base

uint64_t base

◆ scalar

const void const void* scalar

◆ result

return result

◆ digest_null

struct digest_algorithm digest_null

Definition at line 48 of file crypto_null.c.

Referenced by tls_clear_handshake().

◆ cipher_null

struct cipher_algorithm cipher_null

Definition at line 83 of file crypto_null.c.

◆ pubkey_null

struct pubkey_algorithm pubkey_null

Definition at line 135 of file crypto_null.c.