]> git.ipfire.org Git - thirdparty/openssl.git/blame - providers/implementations/serializers/serializer_local.h
PROV & SERIALIZER: Adapt the RSA serializers for PSS-parameters
[thirdparty/openssl.git] / providers / implementations / serializers / serializer_local.h
CommitLineData
cb58d81e 1/*
33388b44 2 * Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
cb58d81e
RL
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/core.h>
11#include <openssl/core_numbers.h>
12#include <openssl/bn.h>
13#include <openssl/asn1.h> /* i2d_of_void */
14#include <openssl/x509.h> /* X509_SIG */
15#include <openssl/types.h>
8efc4a9c 16#include <crypto/ecx.h>
b03ec3b5 17#include "internal/ffc.h"
cb58d81e
RL
18
19struct pkcs8_encrypt_ctx_st {
20 /* Set to 1 if intending to encrypt/decrypt, otherwise 0 */
21 int cipher_intent;
22
23 EVP_CIPHER *cipher;
24 int pbe_nid; /* For future variation */
25
26 /* Passphrase that was passed by the caller */
27 void *cipher_pass;
28 size_t cipher_pass_length;
29
30 /* This callback is only used of |cipher_pass| is NULL */
31 OSSL_PASSPHRASE_CALLBACK *cb;
32 void *cbarg;
33};
34
32b0645c
RL
35OSSL_OP_keymgmt_new_fn *ossl_prov_get_keymgmt_new(const OSSL_DISPATCH *fns);
36OSSL_OP_keymgmt_free_fn *ossl_prov_get_keymgmt_free(const OSSL_DISPATCH *fns);
37OSSL_OP_keymgmt_import_fn *ossl_prov_get_keymgmt_import(const OSSL_DISPATCH *fns);
38
39OSSL_OP_keymgmt_new_fn *ossl_prov_get_keymgmt_rsa_new(void);
40OSSL_OP_keymgmt_free_fn *ossl_prov_get_keymgmt_rsa_free(void);
41OSSL_OP_keymgmt_import_fn *ossl_prov_get_keymgmt_rsa_import(void);
42OSSL_OP_keymgmt_new_fn *ossl_prov_get_keymgmt_dh_new(void);
43OSSL_OP_keymgmt_free_fn *ossl_prov_get_keymgmt_dh_free(void);
44OSSL_OP_keymgmt_import_fn *ossl_prov_get_keymgmt_dh_import(void);
45OSSL_OP_keymgmt_new_fn *ossl_prov_get_keymgmt_dsa_new(void);
46OSSL_OP_keymgmt_free_fn *ossl_prov_get_keymgmt_dsa_free(void);
47OSSL_OP_keymgmt_import_fn *ossl_prov_get_keymgmt_dsa_import(void);
045e51cb 48
f552d900
SL
49void ec_get_new_free_import(OSSL_OP_keymgmt_new_fn **ec_new,
50 OSSL_OP_keymgmt_free_fn **ec_free,
51 OSSL_OP_keymgmt_import_fn **ec_import);
52
53int ossl_prov_prepare_ec_params(const void *eckey, int nid,
54 void **pstr, int *pstrtype);
55int ossl_prov_ec_pub_to_der(const void *eckey, unsigned char **pder);
56int ossl_prov_ec_priv_to_der(const void *eckey, unsigned char **pder);
57
b03ec3b5 58int ffc_params_prov_print(BIO *out, const FFC_PARAMS *ffc);
045e51cb 59int ossl_prov_prepare_dh_params(const void *dh, int nid,
f552d900 60 void **pstr, int *pstrtype);
045e51cb
RL
61int ossl_prov_dh_pub_to_der(const void *dh, unsigned char **pder);
62int ossl_prov_dh_priv_to_der(const void *dh, unsigned char **pder);
677add38 63
244bc297 64#ifndef OPENSSL_NO_EC
8efc4a9c
MC
65void ecx_get_new_free_import(ECX_KEY_TYPE type,
66 OSSL_OP_keymgmt_new_fn **ecx_new,
67 OSSL_OP_keymgmt_free_fn **ecx_free,
68 OSSL_OP_keymgmt_import_fn **ecx_import);
69int ossl_prov_ecx_pub_to_der(const void *ecxkey, unsigned char **pder);
70int ossl_prov_ecx_priv_to_der(const void *ecxkey, unsigned char **pder);
244bc297 71#endif
8efc4a9c 72
264b789b 73int ossl_prov_prepare_dsa_params(const void *dsa, int nid,
f552d900 74 void **pstr, int *pstrtype);
264b789b
RL
75/*
76 * Special variant of ossl_prov_prepare_dsa_params() that requires all
77 * three parameters (P, Q and G) to be set. This is used when serializing
78 * the public key.
79 */
80int ossl_prov_prepare_all_dsa_params(const void *dsa, int nid,
f552d900 81 void **pstr, int *pstrtype);
264b789b
RL
82int ossl_prov_dsa_pub_to_der(const void *dsa, unsigned char **pder);
83int ossl_prov_dsa_priv_to_der(const void *dsa, unsigned char **pder);
84
ea297dca
RL
85/*
86 * ossl_prov_prepare_rsa_params() is designed to work with the ossl_prov_write_
87 * functions, hence 'void *rsa' rather than 'RSA *rsa'.
88 */
89int ossl_prov_prepare_rsa_params(const void *rsa, int nid,
90 void **pstr, int *pstrtype);
91int ossl_prov_rsa_type_to_evp(const RSA *rsa);
92
cb58d81e 93int ossl_prov_print_labeled_bignum(BIO *out, const char *label,
a88aef32 94 const BIGNUM *bn);
8efc4a9c
MC
95int ossl_prov_print_labeled_buf(BIO *out, const char *label,
96 const unsigned char *buf, size_t buflen);
677add38 97int ossl_prov_print_rsa(BIO *out, RSA *rsa, int priv);
cb58d81e 98
045e51cb
RL
99enum dh_print_type {
100 dh_print_priv,
101 dh_print_pub,
102 dh_print_params
103};
104
105int ossl_prov_print_dh(BIO *out, DH *dh, enum dh_print_type type);
106
f552d900
SL
107#ifndef OPENSSL_NO_EC
108enum ec_print_type {
109 ec_print_priv,
110 ec_print_pub,
111 ec_print_params
112};
113
114int ossl_prov_print_eckey(BIO *out, EC_KEY *eckey, enum ec_print_type type);
115#endif /* OPENSSL_NO_EC */
116
264b789b
RL
117enum dsa_print_type {
118 dsa_print_priv,
119 dsa_print_pub,
120 dsa_print_params
121};
122
123int ossl_prov_print_dsa(BIO *out, DSA *dsa, enum dsa_print_type type);
124
8efc4a9c
MC
125enum ecx_print_type {
126 ecx_print_priv,
127 ecx_print_pub
128};
129
130#ifndef OPENSSL_NO_EC
131int ossl_prov_print_ecx(BIO *out, ECX_KEY *ecxkey, enum ecx_print_type type);
132#endif
133
cb58d81e
RL
134int ossl_prov_write_priv_der_from_obj(BIO *out, const void *obj, int obj_nid,
135 int (*p2s)(const void *obj, int nid,
f552d900 136 void **str,
cb58d81e
RL
137 int *strtype),
138 int (*k2d)(const void *obj,
139 unsigned char **pder),
140 struct pkcs8_encrypt_ctx_st *ctx);
141int ossl_prov_write_priv_pem_from_obj(BIO *out, const void *obj, int obj_nid,
142 int (*p2s)(const void *obj, int nid,
f552d900 143 void **str,
cb58d81e
RL
144 int *strtype),
145 int (*k2d)(const void *obj,
146 unsigned char **pder),
147 struct pkcs8_encrypt_ctx_st *ctx);
148int ossl_prov_write_pub_der_from_obj(BIO *out, const void *obj, int obj_nid,
149 int (*p2s)(const void *obj, int nid,
f552d900 150 void **str,
cb58d81e
RL
151 int *strtype),
152 int (*k2d)(const void *obj,
153 unsigned char **pder));
154int ossl_prov_write_pub_pem_from_obj(BIO *out, const void *obj, int obj_nid,
155 int (*p2s)(const void *obj, int nid,
f552d900 156 void **str,
cb58d81e
RL
157 int *strtype),
158 int (*k2d)(const void *obj,
159 unsigned char **pder));