6 * RSA public-key cryptography
9 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
12 #include <ipxe/crypto.h>
13 #include <ipxe/bigint.h>
14 #include <ipxe/asn1.h>
15 #include <ipxe/tables.h>
17 /** RSA digestAlgorithm sequence contents */
18 #define RSA_DIGESTALGORITHM_CONTENTS( ... ) \
19 ASN1_OID, VA_ARG_COUNT ( __VA_ARGS__ ), __VA_ARGS__, \
22 /** RSA digestAlgorithm sequence */
23 #define RSA_DIGESTALGORITHM( ... ) \
25 VA_ARG_COUNT ( RSA_DIGESTALGORITHM_CONTENTS ( __VA_ARGS__ ) ), \
26 RSA_DIGESTALGORITHM_CONTENTS ( __VA_ARGS__ )
28 /** RSA digest prefix */
29 #define RSA_DIGEST_PREFIX( digest_size ) \
30 ASN1_OCTET_STRING, digest_size
32 /** RSA digestInfo prefix */
33 #define RSA_DIGESTINFO_PREFIX( digest_size, ... ) \
35 ( VA_ARG_COUNT ( RSA_DIGESTALGORITHM ( __VA_ARGS__ ) ) + \
36 VA_ARG_COUNT ( RSA_DIGEST_PREFIX ( digest_size ) ) + \
38 RSA_DIGESTALGORITHM ( __VA_ARGS__ ), \
39 RSA_DIGEST_PREFIX ( digest_size )
41 /** An RSA digestInfo prefix */
42 struct rsa_digestinfo_prefix {
43 /** Digest algorithm */
44 struct digest_algorithm *digest;
47 /** Length of prefix */
51 /** RSA digestInfo prefix table */
52 #define RSA_DIGESTINFO_PREFIXES \
53 __table ( struct rsa_digestinfo_prefix, "rsa_digestinfo_prefixes" )
55 /** Declare an RSA digestInfo prefix */
56 #define __rsa_digestinfo_prefix __table_entry ( RSA_DIGESTINFO_PREFIXES, 01 )
60 /** Allocated memory */
63 bigint_element_t *modulus0;
69 bigint_element_t *exponent0;
71 unsigned int exponent_size;
73 bigint_element_t *input0;
75 bigint_element_t *output0;
76 /** Temporary working space for modular exponentiation */
80 extern struct pubkey_algorithm rsa_algorithm;
82 #endif /* _IPXE_RSA_H */