]>
git.proxmox.com Git - efi-boot-shim.git/blob - Cryptlib/OpenSSL/crypto/rsa/rsa_asn1.c
2 * Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the OpenSSL license (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
11 #include "internal/cryptlib.h"
12 #include <openssl/bn.h>
13 #include <openssl/x509.h>
14 #include <openssl/asn1t.h>
17 /* Override the default free and new methods */
18 static int rsa_cb(int operation
, ASN1_VALUE
**pval
, const ASN1_ITEM
*it
,
21 if (operation
== ASN1_OP_NEW_PRE
) {
22 *pval
= (ASN1_VALUE
*)RSA_new();
26 } else if (operation
== ASN1_OP_FREE_PRE
) {
27 RSA_free((RSA
*)*pval
);
34 ASN1_SEQUENCE_cb(RSAPrivateKey
, rsa_cb
) = {
35 ASN1_SIMPLE(RSA
, version
, LONG
),
36 ASN1_SIMPLE(RSA
, n
, BIGNUM
),
37 ASN1_SIMPLE(RSA
, e
, BIGNUM
),
38 ASN1_SIMPLE(RSA
, d
, CBIGNUM
),
39 ASN1_SIMPLE(RSA
, p
, CBIGNUM
),
40 ASN1_SIMPLE(RSA
, q
, CBIGNUM
),
41 ASN1_SIMPLE(RSA
, dmp1
, CBIGNUM
),
42 ASN1_SIMPLE(RSA
, dmq1
, CBIGNUM
),
43 ASN1_SIMPLE(RSA
, iqmp
, CBIGNUM
)
44 } ASN1_SEQUENCE_END_cb(RSA
, RSAPrivateKey
)
47 ASN1_SEQUENCE_cb(RSAPublicKey
, rsa_cb
) = {
48 ASN1_SIMPLE(RSA
, n
, BIGNUM
),
49 ASN1_SIMPLE(RSA
, e
, BIGNUM
),
50 } ASN1_SEQUENCE_END_cb(RSA
, RSAPublicKey
)
52 ASN1_SEQUENCE(RSA_PSS_PARAMS
) = {
53 ASN1_EXP_OPT(RSA_PSS_PARAMS
, hashAlgorithm
, X509_ALGOR
,0),
54 ASN1_EXP_OPT(RSA_PSS_PARAMS
, maskGenAlgorithm
, X509_ALGOR
,1),
55 ASN1_EXP_OPT(RSA_PSS_PARAMS
, saltLength
, ASN1_INTEGER
,2),
56 ASN1_EXP_OPT(RSA_PSS_PARAMS
, trailerField
, ASN1_INTEGER
,3)
57 } ASN1_SEQUENCE_END(RSA_PSS_PARAMS
)
59 IMPLEMENT_ASN1_FUNCTIONS(RSA_PSS_PARAMS
)
61 ASN1_SEQUENCE(RSA_OAEP_PARAMS
) = {
62 ASN1_EXP_OPT(RSA_OAEP_PARAMS
, hashFunc
, X509_ALGOR
, 0),
63 ASN1_EXP_OPT(RSA_OAEP_PARAMS
, maskGenFunc
, X509_ALGOR
, 1),
64 ASN1_EXP_OPT(RSA_OAEP_PARAMS
, pSourceFunc
, X509_ALGOR
, 2),
65 } ASN1_SEQUENCE_END(RSA_OAEP_PARAMS
)
67 IMPLEMENT_ASN1_FUNCTIONS(RSA_OAEP_PARAMS
)
69 IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(RSA
, RSAPrivateKey
, RSAPrivateKey
)
71 IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(RSA
, RSAPublicKey
, RSAPublicKey
)
73 RSA
*RSAPublicKey_dup(RSA
*rsa
)
75 return ASN1_item_dup(ASN1_ITEM_rptr(RSAPublicKey
), rsa
);
78 RSA
*RSAPrivateKey_dup(RSA
*rsa
)
80 return ASN1_item_dup(ASN1_ITEM_rptr(RSAPrivateKey
), rsa
);