]>
Commit | Line | Data |
---|---|---|
6f5837dc RL |
1 | /* |
2 | * Copyright 2020 The OpenSSL Project Authors. All Rights Reserved. | |
3 | * | |
4 | * Licensed under the Apache License 2.0 (the "License"). You may not use | |
5 | * this file except in compliance with the License. You can obtain a copy | |
6 | * in the file LICENSE in the source distribution or at | |
7 | * https://www.openssl.org/source/license.html | |
8 | */ | |
9 | ||
10 | #include <openssl/bn.h> | |
11 | #include <openssl/obj_mac.h> | |
12 | #include "prov/der_rsa.h" | |
13 | ||
14 | /* Well known OIDs precompiled */ | |
15 | {- | |
16 | $OUT = oids_to_c::process_leaves('providers/common/der/RSA.asn1', | |
17 | { dir => $config{sourcedir}, | |
18 | filter => \&oids_to_c::filter_to_C }); | |
19 | -} | |
20 | ||
21 | int DER_w_algorithmIdentifier_RSA(WPACKET *pkt, int tag, RSA *rsa) | |
22 | { | |
23 | return DER_w_begin_sequence(pkt, tag) | |
24 | /* No parameters (yet?) */ | |
25 | && DER_w_precompiled(pkt, -1, der_oid_rsaEncryption, | |
26 | sizeof(der_oid_rsaEncryption)) | |
27 | && DER_w_end_sequence(pkt, tag); | |
28 | } | |
29 | ||
30 | /* Aliases so we can have a uniform MD_CASE */ | |
31 | #define der_oid_sha3_224WithRSAEncryption \ | |
32 | der_oid_id_rsassa_pkcs1_v1_5_with_sha3_224 | |
33 | #define der_oid_sha3_256WithRSAEncryption \ | |
34 | der_oid_id_rsassa_pkcs1_v1_5_with_sha3_256 | |
35 | #define der_oid_sha3_384WithRSAEncryption \ | |
36 | der_oid_id_rsassa_pkcs1_v1_5_with_sha3_384 | |
37 | #define der_oid_sha3_512WithRSAEncryption \ | |
38 | der_oid_id_rsassa_pkcs1_v1_5_with_sha3_512 | |
39 | ||
40 | #define MD_CASE(name) \ | |
41 | case NID_##name: \ | |
42 | precompiled = der_oid_##name##WithRSAEncryption; \ | |
43 | precompiled_sz = sizeof(der_oid_##name##WithRSAEncryption); \ | |
44 | break; | |
45 | ||
46 | int DER_w_algorithmIdentifier_RSA_with(WPACKET *pkt, int tag, | |
47 | RSA *rsa, int mdnid) | |
48 | { | |
49 | const unsigned char *precompiled = NULL; | |
50 | size_t precompiled_sz = 0; | |
51 | ||
52 | switch (mdnid) { | |
53 | #ifndef FIPS_MODE | |
54 | MD_CASE(md2); | |
55 | MD_CASE(md5); | |
56 | #endif | |
57 | MD_CASE(sha1); | |
58 | MD_CASE(sha224); | |
59 | MD_CASE(sha256); | |
60 | MD_CASE(sha384); | |
61 | MD_CASE(sha512); | |
62 | MD_CASE(sha3_224); | |
63 | MD_CASE(sha3_256); | |
64 | MD_CASE(sha3_384); | |
65 | MD_CASE(sha3_512); | |
66 | default: | |
67 | return 0; | |
68 | } | |
69 | ||
70 | return DER_w_begin_sequence(pkt, tag) | |
71 | /* No parameters (yet?) */ | |
72 | && DER_w_precompiled(pkt, -1, precompiled, precompiled_sz) | |
73 | && DER_w_end_sequence(pkt, tag); | |
74 | } |