diff options
-rw-r--r-- | src/lib/libcrypto/asn1/ameth_lib.c | 78 |
1 files changed, 13 insertions, 65 deletions
diff --git a/src/lib/libcrypto/asn1/ameth_lib.c b/src/lib/libcrypto/asn1/ameth_lib.c index ccde1e8ecb..35fcb8ea08 100644 --- a/src/lib/libcrypto/asn1/ameth_lib.c +++ b/src/lib/libcrypto/asn1/ameth_lib.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ameth_lib.c,v 1.41 2023/12/29 19:00:31 tb Exp $ */ | 1 | /* $OpenBSD: ameth_lib.c,v 1.42 2024/01/04 16:50:53 tb Exp $ */ |
2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
3 | * project 2006. | 3 | * project 2006. |
4 | */ | 4 | */ |
@@ -71,60 +71,20 @@ | |||
71 | EVP_PKEY_ASN1_METHOD* | 71 | EVP_PKEY_ASN1_METHOD* |
72 | EVP_PKEY_asn1_new(int id, int flags, const char *pem_str, const char *info) | 72 | EVP_PKEY_asn1_new(int id, int flags, const char *pem_str, const char *info) |
73 | { | 73 | { |
74 | EVP_PKEY_ASN1_METHOD *ameth; | 74 | EVPerror(ERR_R_DISABLED); |
75 | |||
76 | if ((ameth = calloc(1, sizeof(EVP_PKEY_ASN1_METHOD))) == NULL) | ||
77 | return NULL; | ||
78 | |||
79 | ameth->pkey_id = id; | ||
80 | ameth->pkey_base_id = id; | ||
81 | ameth->pkey_flags = flags | ASN1_PKEY_DYNAMIC; | ||
82 | |||
83 | if (info != NULL) { | ||
84 | if ((ameth->info = strdup(info)) == NULL) | ||
85 | goto err; | ||
86 | } | ||
87 | |||
88 | if (pem_str != NULL) { | ||
89 | if ((ameth->pem_str = strdup(pem_str)) == NULL) | ||
90 | goto err; | ||
91 | } | ||
92 | |||
93 | return ameth; | ||
94 | |||
95 | err: | ||
96 | EVP_PKEY_asn1_free(ameth); | ||
97 | return NULL; | 75 | return NULL; |
98 | } | 76 | } |
99 | 77 | ||
100 | void | 78 | void |
101 | EVP_PKEY_asn1_copy(EVP_PKEY_ASN1_METHOD *dst, const EVP_PKEY_ASN1_METHOD *src) | 79 | EVP_PKEY_asn1_copy(EVP_PKEY_ASN1_METHOD *dst, const EVP_PKEY_ASN1_METHOD *src) |
102 | { | 80 | { |
103 | EVP_PKEY_ASN1_METHOD preserve; | 81 | EVPerror(ERR_R_DISABLED); |
104 | |||
105 | preserve.pkey_id = dst->pkey_id; | ||
106 | preserve.pkey_base_id = dst->pkey_base_id; | ||
107 | preserve.pkey_flags = dst->pkey_flags; | ||
108 | preserve.pem_str = dst->pem_str; | ||
109 | preserve.info = dst->info; | ||
110 | |||
111 | *dst = *src; | ||
112 | |||
113 | dst->pkey_id = preserve.pkey_id; | ||
114 | dst->pkey_base_id = preserve.pkey_base_id; | ||
115 | dst->pkey_flags = preserve.pkey_flags; | ||
116 | dst->pem_str = preserve.pem_str; | ||
117 | dst->info = preserve.info; | ||
118 | } | 82 | } |
119 | 83 | ||
120 | void | 84 | void |
121 | EVP_PKEY_asn1_free(EVP_PKEY_ASN1_METHOD *ameth) | 85 | EVP_PKEY_asn1_free(EVP_PKEY_ASN1_METHOD *ameth) |
122 | { | 86 | { |
123 | if (ameth && (ameth->pkey_flags & ASN1_PKEY_DYNAMIC)) { | 87 | EVPerror(ERR_R_DISABLED); |
124 | free(ameth->pem_str); | ||
125 | free(ameth->info); | ||
126 | free(ameth); | ||
127 | } | ||
128 | } | 88 | } |
129 | 89 | ||
130 | void | 90 | void |
@@ -137,12 +97,7 @@ EVP_PKEY_asn1_set_public(EVP_PKEY_ASN1_METHOD *ameth, | |||
137 | int (*pkey_size)(const EVP_PKEY *pk), | 97 | int (*pkey_size)(const EVP_PKEY *pk), |
138 | int (*pkey_bits)(const EVP_PKEY *pk)) | 98 | int (*pkey_bits)(const EVP_PKEY *pk)) |
139 | { | 99 | { |
140 | ameth->pub_decode = pub_decode; | 100 | EVPerror(ERR_R_DISABLED); |
141 | ameth->pub_encode = pub_encode; | ||
142 | ameth->pub_cmp = pub_cmp; | ||
143 | ameth->pub_print = pub_print; | ||
144 | ameth->pkey_size = pkey_size; | ||
145 | ameth->pkey_bits = pkey_bits; | ||
146 | } | 101 | } |
147 | 102 | ||
148 | void | 103 | void |
@@ -152,9 +107,7 @@ EVP_PKEY_asn1_set_private(EVP_PKEY_ASN1_METHOD *ameth, | |||
152 | int (*priv_print)(BIO *out, const EVP_PKEY *pkey, int indent, | 107 | int (*priv_print)(BIO *out, const EVP_PKEY *pkey, int indent, |
153 | ASN1_PCTX *pctx)) | 108 | ASN1_PCTX *pctx)) |
154 | { | 109 | { |
155 | ameth->priv_decode = priv_decode; | 110 | EVPerror(ERR_R_DISABLED); |
156 | ameth->priv_encode = priv_encode; | ||
157 | ameth->priv_print = priv_print; | ||
158 | } | 111 | } |
159 | 112 | ||
160 | void | 113 | void |
@@ -167,54 +120,49 @@ EVP_PKEY_asn1_set_param(EVP_PKEY_ASN1_METHOD *ameth, | |||
167 | int (*param_print)(BIO *out, const EVP_PKEY *pkey, int indent, | 120 | int (*param_print)(BIO *out, const EVP_PKEY *pkey, int indent, |
168 | ASN1_PCTX *pctx)) | 121 | ASN1_PCTX *pctx)) |
169 | { | 122 | { |
170 | ameth->param_decode = param_decode; | 123 | EVPerror(ERR_R_DISABLED); |
171 | ameth->param_encode = param_encode; | ||
172 | ameth->param_missing = param_missing; | ||
173 | ameth->param_copy = param_copy; | ||
174 | ameth->param_cmp = param_cmp; | ||
175 | ameth->param_print = param_print; | ||
176 | } | 124 | } |
177 | 125 | ||
178 | void | 126 | void |
179 | EVP_PKEY_asn1_set_free(EVP_PKEY_ASN1_METHOD *ameth, | 127 | EVP_PKEY_asn1_set_free(EVP_PKEY_ASN1_METHOD *ameth, |
180 | void (*pkey_free)(EVP_PKEY *pkey)) | 128 | void (*pkey_free)(EVP_PKEY *pkey)) |
181 | { | 129 | { |
182 | ameth->pkey_free = pkey_free; | 130 | EVPerror(ERR_R_DISABLED); |
183 | } | 131 | } |
184 | 132 | ||
185 | void | 133 | void |
186 | EVP_PKEY_asn1_set_ctrl(EVP_PKEY_ASN1_METHOD *ameth, | 134 | EVP_PKEY_asn1_set_ctrl(EVP_PKEY_ASN1_METHOD *ameth, |
187 | int (*pkey_ctrl)(EVP_PKEY *pkey, int op, long arg1, void *arg2)) | 135 | int (*pkey_ctrl)(EVP_PKEY *pkey, int op, long arg1, void *arg2)) |
188 | { | 136 | { |
189 | ameth->pkey_ctrl = pkey_ctrl; | 137 | EVPerror(ERR_R_DISABLED); |
190 | } | 138 | } |
191 | 139 | ||
192 | void | 140 | void |
193 | EVP_PKEY_asn1_set_security_bits(EVP_PKEY_ASN1_METHOD *ameth, | 141 | EVP_PKEY_asn1_set_security_bits(EVP_PKEY_ASN1_METHOD *ameth, |
194 | int (*pkey_security_bits)(const EVP_PKEY *pkey)) | 142 | int (*pkey_security_bits)(const EVP_PKEY *pkey)) |
195 | { | 143 | { |
196 | ameth->pkey_security_bits = pkey_security_bits; | 144 | EVPerror(ERR_R_DISABLED); |
197 | } | 145 | } |
198 | 146 | ||
199 | void | 147 | void |
200 | EVP_PKEY_asn1_set_check(EVP_PKEY_ASN1_METHOD *ameth, | 148 | EVP_PKEY_asn1_set_check(EVP_PKEY_ASN1_METHOD *ameth, |
201 | int (*pkey_check)(const EVP_PKEY *pk)) | 149 | int (*pkey_check)(const EVP_PKEY *pk)) |
202 | { | 150 | { |
203 | ameth->pkey_check = pkey_check; | 151 | EVPerror(ERR_R_DISABLED); |
204 | } | 152 | } |
205 | 153 | ||
206 | void | 154 | void |
207 | EVP_PKEY_asn1_set_public_check(EVP_PKEY_ASN1_METHOD *ameth, | 155 | EVP_PKEY_asn1_set_public_check(EVP_PKEY_ASN1_METHOD *ameth, |
208 | int (*pkey_public_check)(const EVP_PKEY *pk)) | 156 | int (*pkey_public_check)(const EVP_PKEY *pk)) |
209 | { | 157 | { |
210 | ameth->pkey_public_check = pkey_public_check; | 158 | EVPerror(ERR_R_DISABLED); |
211 | } | 159 | } |
212 | 160 | ||
213 | void | 161 | void |
214 | EVP_PKEY_asn1_set_param_check(EVP_PKEY_ASN1_METHOD *ameth, | 162 | EVP_PKEY_asn1_set_param_check(EVP_PKEY_ASN1_METHOD *ameth, |
215 | int (*pkey_param_check)(const EVP_PKEY *pk)) | 163 | int (*pkey_param_check)(const EVP_PKEY *pk)) |
216 | { | 164 | { |
217 | ameth->pkey_param_check = pkey_param_check; | 165 | EVPerror(ERR_R_DISABLED); |
218 | } | 166 | } |
219 | 167 | ||
220 | int | 168 | int |