]>
git.ipfire.org Git - thirdparty/openssl.git/blob - crypto/asn1/d2i_param.c
2 * Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
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
11 #include "internal/cryptlib.h"
12 #include <openssl/evp.h>
13 #include <openssl/asn1.h>
14 #include "internal/asn1.h"
15 #include "crypto/asn1.h"
16 #include "crypto/evp.h"
18 EVP_PKEY
*d2i_KeyParams(int type
, EVP_PKEY
**a
, const unsigned char **pp
,
23 if ((a
== NULL
) || (*a
== NULL
)) {
24 if ((ret
= EVP_PKEY_new()) == NULL
)
29 if (type
!= EVP_PKEY_id(ret
) && !EVP_PKEY_set_type(ret
, type
))
32 if (ret
->ameth
== NULL
|| ret
->ameth
->param_decode
== NULL
) {
33 ASN1err(ASN1_F_D2I_KEYPARAMS
, ASN1_R_UNSUPPORTED_TYPE
);
37 if (!ret
->ameth
->param_decode(ret
, pp
, length
))
44 if (a
== NULL
|| *a
!= ret
)
49 EVP_PKEY
*d2i_KeyParams_bio(int type
, EVP_PKEY
**a
, BIO
*in
)
52 const unsigned char *p
;
56 len
= asn1_d2i_read_bio(in
, &b
);
60 p
= (unsigned char *)b
->data
;
61 ret
= d2i_KeyParams(type
, a
, &p
, len
);