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

Cryptographic API. More...

#include <stdint.h>
#include <stddef.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...

Defines

#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 void digest_init (struct digest_algorithm *digest, void *ctx)
static void digest_update (struct digest_algorithm *digest, void *ctx, const void *data, size_t len)
static void digest_final (struct digest_algorithm *digest, void *ctx, void *out)
static int cipher_setkey (struct cipher_algorithm *cipher, void *ctx, const void *key, size_t keylen)
static void cipher_setiv (struct cipher_algorithm *cipher, void *ctx, const void *iv)
static void cipher_encrypt (struct cipher_algorithm *cipher, void *ctx, const void *src, void *dst, size_t len)
static void cipher_decrypt (struct cipher_algorithm *cipher, void *ctx, const void *src, void *dst, size_t len)
static int is_stream_cipher (struct cipher_algorithm *cipher)
static int pubkey_init (struct pubkey_algorithm *pubkey, void *ctx, const void *key, size_t key_len)
static size_t pubkey_max_len (struct pubkey_algorithm *pubkey, void *ctx)
static int pubkey_encrypt (struct pubkey_algorithm *pubkey, void *ctx, const void *data, size_t len, void *out)
static int pubkey_decrypt (struct pubkey_algorithm *pubkey, void *ctx, const void *data, size_t len, void *out)
static int pubkey_sign (struct pubkey_algorithm *pubkey, void *ctx, struct digest_algorithm *digest, const void *value, void *signature)
static int pubkey_verify (struct pubkey_algorithm *pubkey, void *ctx, struct digest_algorithm *digest, const void *value, const void *signature, size_t signature_len)
static void pubkey_final (struct pubkey_algorithm *pubkey, void *ctx)
static int pubkey_match (struct pubkey_algorithm *pubkey, const void *private_key, size_t private_key_len, const void *public_key, size_t public_key_len)

Variables

struct digest_algorithm __attribute__
struct digest_algorithm digest_null
struct cipher_algorithm cipher_null
struct pubkey_algorithm pubkey_null

Detailed Description

Cryptographic API.

Definition in file crypto.h.


Define Documentation

#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 )

Definition at line 202 of file crypto.h.

Referenced by aes_wrap(), cbc_encrypt(), ccmp_cbc_mac(), ccmp_ctr_xor(), ccmp_feed_cbc_mac(), cipher_cost_encrypt(), cipher_encrypt_okx(), ecb_encrypt(), tkip_encrypt(), tls_send_plaintext(), and wep_encrypt().

#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 )

Definition at line 212 of file crypto.h.

Referenced by aes_unwrap(), cbc_decrypt(), cipher_cost_decrypt(), cipher_decrypt_okx(), ecb_decrypt(), peerblk_decrypt(), tkip_decrypt(), tls_new_ciphertext(), and wep_decrypt().


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )
static void digest_init ( struct digest_algorithm digest,
void *  ctx 
) [inline, static]
static void digest_update ( struct digest_algorithm digest,
void *  ctx,
const void *  data,
size_t  len 
) [inline, static]
static void digest_final ( struct digest_algorithm digest,
void *  ctx,
void *  out 
) [inline, static]
static int cipher_setkey ( struct cipher_algorithm cipher,
void *  ctx,
const void *  key,
size_t  keylen 
) [inline, static]
static void cipher_setiv ( struct cipher_algorithm cipher,
void *  ctx,
const void *  iv 
) [inline, static]

Definition at line 192 of file crypto.h.

References cipher_algorithm::setiv.

Referenced by cipher_cost(), cipher_decrypt_okx(), cipher_encrypt_okx(), peerblk_parse_iv(), and tls_generate_keys().

                                                              {
        cipher->setiv ( ctx, iv );
}
static void cipher_encrypt ( struct cipher_algorithm cipher,
void *  ctx,
const void *  src,
void *  dst,
size_t  len 
) [inline, static]

Definition at line 197 of file crypto.h.

References cipher_algorithm::encrypt.

                                                 {
        cipher->encrypt ( ctx, src, dst, len );
}
static void cipher_decrypt ( struct cipher_algorithm cipher,
void *  ctx,
const void *  src,
void *  dst,
size_t  len 
) [inline, static]

Definition at line 207 of file crypto.h.

References cipher_algorithm::decrypt.

                                                 {
        cipher->decrypt ( ctx, src, dst, len );
}
static int is_stream_cipher ( struct cipher_algorithm cipher) [inline, static]

Definition at line 217 of file crypto.h.

References cipher_algorithm::blocksize.

Referenced by tls_new_ciphertext(), and tls_send_plaintext().

                                                                       {
        return ( cipher->blocksize == 1 );
}
static int pubkey_init ( struct pubkey_algorithm pubkey,
void *  ctx,
const void *  key,
size_t  key_len 
) [inline, static]

Definition at line 221 of file crypto.h.

References pubkey_algorithm::init.

Referenced by cms_verify_digest(), ocsp_check_signature(), tls_send_certificate_verify(), tls_validator_done(), and x509_check_signature().

                                                                  {
        return pubkey->init ( ctx, key, key_len );
}
static size_t pubkey_max_len ( struct pubkey_algorithm pubkey,
void *  ctx 
) [inline, static]

Definition at line 226 of file crypto.h.

References pubkey_algorithm::max_len.

Referenced by tls_send_certificate_verify(), and tls_send_client_key_exchange().

                                                  {
        return pubkey->max_len ( ctx );
}
static int pubkey_encrypt ( struct pubkey_algorithm pubkey,
void *  ctx,
const void *  data,
size_t  len,
void *  out 
) [inline, static]

Definition at line 231 of file crypto.h.

References pubkey_algorithm::encrypt.

Referenced by tls_send_client_key_exchange().

                                                                             {
        return pubkey->encrypt ( ctx, data, len, out );
}
static int pubkey_decrypt ( struct pubkey_algorithm pubkey,
void *  ctx,
const void *  data,
size_t  len,
void *  out 
) [inline, static]

Definition at line 236 of file crypto.h.

References pubkey_algorithm::decrypt.

                                                                             {
        return pubkey->decrypt ( ctx, data, len, out );
}
static int pubkey_sign ( struct pubkey_algorithm pubkey,
void *  ctx,
struct digest_algorithm digest,
const void *  value,
void *  signature 
) [inline, static]

Definition at line 241 of file crypto.h.

References pubkey_algorithm::sign.

Referenced by tls_send_certificate_verify().

                                                                     {
        return pubkey->sign ( ctx, digest, value, signature );
}
static int pubkey_verify ( struct pubkey_algorithm pubkey,
void *  ctx,
struct digest_algorithm digest,
const void *  value,
const void *  signature,
size_t  signature_len 
) [inline, static]

Definition at line 247 of file crypto.h.

References pubkey_algorithm::verify.

Referenced by cms_verify_digest(), ocsp_check_signature(), and x509_check_signature().

                                                         {
        return pubkey->verify ( ctx, digest, value, signature, signature_len );
}
static void pubkey_final ( struct pubkey_algorithm pubkey,
void *  ctx 
) [inline, static]
static int pubkey_match ( struct pubkey_algorithm pubkey,
const void *  private_key,
size_t  private_key_len,
const void *  public_key,
size_t  public_key_len 
) [inline, static]

Definition at line 258 of file crypto.h.

References pubkey_algorithm::match.

Referenced by certstore_find_key().

                                                         {
        return pubkey->match ( private_key, private_key_len, public_key,
                               public_key_len );
}

Variable Documentation

Definition at line 48 of file crypto_null.c.

Definition at line 79 of file crypto_null.c.

Definition at line 131 of file crypto_null.c.