6 * RSA public-key cryptography
9 FILE_LICENCE ( GPL2_OR_LATER );
11 #include <ipxe/crypto.h>
12 #include <ipxe/bigint.h>
13 #include <ipxe/asn1.h>
14 #include <ipxe/tables.h>
16 /** RSA digestAlgorithm sequence contents */
17 #define RSA_DIGESTALGORITHM_CONTENTS( ... ) \
18 ASN1_OID, VA_ARG_COUNT ( __VA_ARGS__ ), __VA_ARGS__, \
21 /** RSA digestAlgorithm sequence */
22 #define RSA_DIGESTALGORITHM( ... ) \
24 VA_ARG_COUNT ( RSA_DIGESTALGORITHM_CONTENTS ( __VA_ARGS__ ) ), \
25 RSA_DIGESTALGORITHM_CONTENTS ( __VA_ARGS__ )
27 /** RSA digest prefix */
28 #define RSA_DIGEST_PREFIX( digest_size ) \
29 ASN1_OCTET_STRING, digest_size
31 /** RSA digestInfo prefix */
32 #define RSA_DIGESTINFO_PREFIX( digest_size, ... ) \
34 ( VA_ARG_COUNT ( RSA_DIGESTALGORITHM ( __VA_ARGS__ ) ) + \
35 VA_ARG_COUNT ( RSA_DIGEST_PREFIX ( digest_size ) ) + \
37 RSA_DIGESTALGORITHM ( __VA_ARGS__ ), \
38 RSA_DIGEST_PREFIX ( digest_size )
40 /** An RSA digestInfo prefix */
41 struct rsa_digestinfo_prefix {
42 /** Digest algorithm */
43 struct digest_algorithm *digest;
46 /** Length of prefix */
50 /** RSA digestInfo prefix table */
51 #define RSA_DIGESTINFO_PREFIXES \
52 __table ( struct rsa_digestinfo_prefix, "rsa_digestinfo_prefixes" )
54 /** Declare an RSA digestInfo prefix */
55 #define __rsa_digestinfo_prefix __table_entry ( RSA_DIGESTINFO_PREFIXES, 01 )
59 /** Allocated memory */
62 bigint_element_t *modulus0;
68 bigint_element_t *exponent0;
70 unsigned int exponent_size;
72 bigint_element_t *input0;
74 bigint_element_t *output0;
75 /** Temporary working space for modular exponentiation */
79 extern struct pubkey_algorithm rsa_algorithm;
81 #endif /* _IPXE_RSA_H */