iPXE
rsa.h File Reference

RSA public-key cryptography. More...

#include <stdarg.h>
#include <ipxe/crypto.h>
#include <ipxe/bigint.h>
#include <ipxe/asn1.h>
#include <ipxe/tables.h>

Go to the source code of this file.

Data Structures

struct  rsa_digestinfo_prefix
 An RSA digestInfo prefix. More...

Macros

#define RSA_DIGESTALGORITHM_CONTENTS(...)
 RSA digestAlgorithm sequence contents.
#define RSA_DIGESTALGORITHM(...)
 RSA digestAlgorithm sequence.
#define RSA_DIGEST_PREFIX(digest_size)
 RSA digest prefix.
#define RSA_DIGESTINFO_PREFIX(digest_size, ...)
 RSA digestInfo prefix.
#define RSA_DIGESTINFO_PREFIXES   __table ( struct rsa_digestinfo_prefix, "rsa_digestinfo_prefixes" )
 RSA digestInfo prefix table.
#define __rsa_digestinfo_prefix   __table_entry ( RSA_DIGESTINFO_PREFIXES, 01 )
 Declare an RSA digestInfo prefix.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 FILE_SECBOOT (PERMITTED)

Variables

struct pubkey_algorithm rsa_algorithm
 RSA public-key algorithm.
struct pubkey_algorithm rsa_pss_algorithm
 RSA-PSS public-key algorithm.
int(* rsa_get_random )(void *data, size_t len)
 Generate random data.

Detailed Description

RSA public-key cryptography.

Definition in file rsa.h.

Macro Definition Documentation

◆ RSA_DIGESTALGORITHM_CONTENTS

#define RSA_DIGESTALGORITHM_CONTENTS ( ...)
Value:
ASN1_OID, VA_ARG_COUNT ( __VA_ARGS__ ), __VA_ARGS__, \
ASN1_NULL, 0x00
#define ASN1_NULL
ASN.1 null.
Definition asn1.h:72
#define ASN1_OID
ASN.1 object identifier.
Definition asn1.h:75
#define VA_ARG_COUNT(...)
Definition stdarg.h:28

RSA digestAlgorithm sequence contents.

Definition at line 19 of file rsa.h.

19#define RSA_DIGESTALGORITHM_CONTENTS( ... ) \
20 ASN1_OID, VA_ARG_COUNT ( __VA_ARGS__ ), __VA_ARGS__, \
21 ASN1_NULL, 0x00

◆ RSA_DIGESTALGORITHM

#define RSA_DIGESTALGORITHM ( ...)
Value:
VA_ARG_COUNT ( RSA_DIGESTALGORITHM_CONTENTS ( __VA_ARGS__ ) ), \
RSA_DIGESTALGORITHM_CONTENTS ( __VA_ARGS__ )
#define ASN1_SEQUENCE
ASN.1 sequence.
Definition asn1.h:90
#define RSA_DIGESTALGORITHM_CONTENTS(...)
RSA digestAlgorithm sequence contents.
Definition rsa.h:19

RSA digestAlgorithm sequence.

Definition at line 24 of file rsa.h.

24#define RSA_DIGESTALGORITHM( ... ) \
25 ASN1_SEQUENCE, \
26 VA_ARG_COUNT ( RSA_DIGESTALGORITHM_CONTENTS ( __VA_ARGS__ ) ), \
27 RSA_DIGESTALGORITHM_CONTENTS ( __VA_ARGS__ )

◆ RSA_DIGEST_PREFIX

#define RSA_DIGEST_PREFIX ( digest_size)
Value:
ASN1_OCTET_STRING, digest_size
#define ASN1_OCTET_STRING
ASN.1 octet string.
Definition asn1.h:69

RSA digest prefix.

Definition at line 30 of file rsa.h.

30#define RSA_DIGEST_PREFIX( digest_size ) \
31 ASN1_OCTET_STRING, digest_size

◆ RSA_DIGESTINFO_PREFIX

#define RSA_DIGESTINFO_PREFIX ( digest_size,
... )
Value:
( VA_ARG_COUNT ( RSA_DIGESTALGORITHM ( __VA_ARGS__ ) ) + \
VA_ARG_COUNT ( RSA_DIGEST_PREFIX ( digest_size ) ) + \
digest_size ), \
RSA_DIGESTALGORITHM ( __VA_ARGS__ ), \
RSA_DIGEST_PREFIX ( digest_size )
#define RSA_DIGEST_PREFIX(digest_size)
RSA digest prefix.
Definition rsa.h:30
#define RSA_DIGESTALGORITHM(...)
RSA digestAlgorithm sequence.
Definition rsa.h:24

RSA digestInfo prefix.

Definition at line 34 of file rsa.h.

34#define RSA_DIGESTINFO_PREFIX( digest_size, ... ) \
35 ASN1_SEQUENCE, \
36 ( VA_ARG_COUNT ( RSA_DIGESTALGORITHM ( __VA_ARGS__ ) ) + \
37 VA_ARG_COUNT ( RSA_DIGEST_PREFIX ( digest_size ) ) + \
38 digest_size ), \
39 RSA_DIGESTALGORITHM ( __VA_ARGS__ ), \
40 RSA_DIGEST_PREFIX ( digest_size )

◆ RSA_DIGESTINFO_PREFIXES

#define RSA_DIGESTINFO_PREFIXES   __table ( struct rsa_digestinfo_prefix, "rsa_digestinfo_prefixes" )

RSA digestInfo prefix table.

Definition at line 53 of file rsa.h.

53#define RSA_DIGESTINFO_PREFIXES \
54 __table ( struct rsa_digestinfo_prefix, "rsa_digestinfo_prefixes" )

Referenced by rsa_find_prefix().

◆ __rsa_digestinfo_prefix

#define __rsa_digestinfo_prefix   __table_entry ( RSA_DIGESTINFO_PREFIXES, 01 )

Declare an RSA digestInfo prefix.

Definition at line 57 of file rsa.h.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED )

Variable Documentation

◆ rsa_algorithm

struct pubkey_algorithm rsa_algorithm
extern

RSA public-key algorithm.

Definition at line 833 of file rsa.c.

833 {
834 .name = "rsa",
835 .encrypt = rsa_pkcs1_encrypt,
836 .decrypt = rsa_pkcs1_decrypt,
837 .sign = rsa_sign,
838 .verify = rsa_verify,
839 .match = rsa_match,
840 .priv = rsa_pkcs1_encode,
841};
static int rsa_pkcs1_encrypt(struct pubkey_algorithm *pubkey __unused, const struct asn1_cursor *key, const struct asn1_cursor *plaintext, struct asn1_builder *ciphertext)
Encrypt using RSA PKCS#1.
Definition rsa.c:332
static int rsa_match(struct pubkey_algorithm *pubkey __unused, const struct asn1_cursor *private_key, const struct asn1_cursor *public_key)
Check for matching RSA public/private key pair.
Definition rsa.c:808
static int rsa_pkcs1_decrypt(struct pubkey_algorithm *pubkey __unused, const struct asn1_cursor *key, const struct asn1_cursor *ciphertext, struct asn1_builder *plaintext)
Decrypt using RSA PKCS#1.
Definition rsa.c:409
static int rsa_sign(struct pubkey_algorithm *pubkey, const struct asn1_cursor *key, struct digest_algorithm *digest, const void *value, struct asn1_builder *signature)
Sign digest value using RSA.
Definition rsa.c:679
static int rsa_pkcs1_encode(struct rsa_context *context, struct digest_algorithm *digest, const void *value, const void *reference __unused, void *encoded)
Encode digest using RSA PKCS#1.
Definition rsa.c:496
static int rsa_verify(struct pubkey_algorithm *pubkey, const struct asn1_cursor *key, struct digest_algorithm *digest, const void *value, const struct asn1_cursor *signature)
Verify signed digest value using RSA.
Definition rsa.c:731

Referenced by __tls_cipher_suite(), __tls_cipher_suite(), __tls_cipher_suite(), __tls_cipher_suite(), __tls_cipher_suite(), __tls_cipher_suite(), __tls_cipher_suite(), __tls_cipher_suite(), __tls_cipher_suite(), __tls_cipher_suite(), __tls_cipher_suite(), __tls_cipher_suite(), __tls_cipher_suite(), __tls_cipher_suite(), __tls_cipher_suite(), __tls_cipher_suite(), __tls_cipher_suite(), __tls_cipher_suite(), icert_cert(), PUBKEY_SIGN_TEST(), PUBKEY_SIGN_TEST(), PUBKEY_SIGN_TEST(), PUBKEY_TEST(), PUBKEY_TEST(), and REQUIRING_SYMBOL().

◆ rsa_pss_algorithm

struct pubkey_algorithm rsa_pss_algorithm
extern

RSA-PSS public-key algorithm.

Definition at line 844 of file rsa.c.

844 {
845 .name = "rsa_pss",
846 .encrypt = pubkey_null_encrypt,
847 .decrypt = pubkey_null_decrypt,
848 .sign = rsa_sign,
849 .verify = rsa_verify,
850 .match = rsa_match,
851 .priv = rsa_pss_encode,
852};
int pubkey_null_decrypt(struct pubkey_algorithm *pubkey __unused, const struct asn1_cursor *key __unused, const struct asn1_cursor *ciphertext __unused, struct asn1_builder *plaintext __unused)
int pubkey_null_encrypt(struct pubkey_algorithm *pubkey __unused, const struct asn1_cursor *key __unused, const struct asn1_cursor *plaintext __unused, struct asn1_builder *ciphertext __unused)
static int rsa_pss_encode(struct rsa_context *context, struct digest_algorithm *digest, const void *value, const void *reference, void *encoded)
Encode digest using RSA PSS.
Definition rsa.c:594

Referenced by PUBKEY_SIGN_TEST(), PUBKEY_SIGN_TEST(), and PUBKEY_SIGN_TEST().

◆ rsa_get_random

int(* rsa_get_random) (void *data, size_t len) ( void * data,
size_t len )
extern

Generate random data.

Definition at line 93 of file rsa.c.

Referenced by rsa_pkcs1_encrypt(), rsa_pss_encode(), and rsa_test_exec().