iPXE
rsa.h
Go to the documentation of this file.
1 #ifndef _IPXE_RSA_H
2 #define _IPXE_RSA_H
3 
4 /** @file
5  *
6  * RSA public-key cryptography
7  */
8 
9 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
10 FILE_SECBOOT ( PERMITTED );
11 
12 #include <stdarg.h>
13 #include <ipxe/crypto.h>
14 #include <ipxe/bigint.h>
15 #include <ipxe/asn1.h>
16 #include <ipxe/tables.h>
17 
18 /** RSA digestAlgorithm sequence contents */
19 #define RSA_DIGESTALGORITHM_CONTENTS( ... ) \
20  ASN1_OID, VA_ARG_COUNT ( __VA_ARGS__ ), __VA_ARGS__, \
21  ASN1_NULL, 0x00
22 
23 /** RSA digestAlgorithm sequence */
24 #define RSA_DIGESTALGORITHM( ... ) \
25  ASN1_SEQUENCE, \
26  VA_ARG_COUNT ( RSA_DIGESTALGORITHM_CONTENTS ( __VA_ARGS__ ) ), \
27  RSA_DIGESTALGORITHM_CONTENTS ( __VA_ARGS__ )
28 
29 /** RSA digest prefix */
30 #define RSA_DIGEST_PREFIX( digest_size ) \
31  ASN1_OCTET_STRING, digest_size
32 
33 /** RSA digestInfo prefix */
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 )
41 
42 /** An RSA digestInfo prefix */
44  /** Digest algorithm */
46  /** Prefix */
47  const void *data;
48  /** Length of prefix */
49  size_t len;
50 };
51 
52 /** RSA digestInfo prefix table */
53 #define RSA_DIGESTINFO_PREFIXES \
54  __table ( struct rsa_digestinfo_prefix, "rsa_digestinfo_prefixes" )
55 
56 /** Declare an RSA digestInfo prefix */
57 #define __rsa_digestinfo_prefix __table_entry ( RSA_DIGESTINFO_PREFIXES, 01 )
58 
59 extern struct pubkey_algorithm rsa_algorithm;
60 
61 #endif /* _IPXE_RSA_H */
FILE_SECBOOT(PERMITTED)
Cryptographic API.
Big integer support.
struct pubkey_algorithm rsa_algorithm
RSA public-key algorithm.
Definition: rsa.c:661
ASN.1 encoding.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
const void * data
Prefix.
Definition: rsa.h:47
An RSA digestInfo prefix.
Definition: rsa.h:43
size_t len
Length of prefix.
Definition: rsa.h:49
A message digest algorithm.
Definition: crypto.h:19
Linker tables.
struct digest_algorithm * digest
Digest algorithm.
Definition: rsa.h:45
A public key algorithm.
Definition: crypto.h:122