2016-05-18 02:52:22 +08:00
|
|
|
/*
|
2020-11-26 22:18:57 +08:00
|
|
|
* Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
|
1998-12-21 18:52:47 +08:00
|
|
|
*
|
2018-12-06 20:17:34 +08:00
|
|
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
2016-05-18 02:52:22 +08:00
|
|
|
* this file except in compliance with the License. You can obtain a copy
|
|
|
|
* in the file LICENSE in the source distribution or at
|
|
|
|
* https://www.openssl.org/source/license.html
|
1998-12-21 18:52:47 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2015-05-14 22:56:48 +08:00
|
|
|
#include "internal/cryptlib.h"
|
1999-04-24 06:13:45 +08:00
|
|
|
#include <openssl/evp.h>
|
|
|
|
#include <openssl/objects.h>
|
1999-07-22 06:10:23 +08:00
|
|
|
#include <openssl/x509.h>
|
1998-12-21 18:52:47 +08:00
|
|
|
|
1999-04-20 05:31:43 +08:00
|
|
|
X509_PKEY *X509_PKEY_new(void)
|
1998-12-21 18:52:47 +08:00
|
|
|
{
|
|
|
|
X509_PKEY *ret = NULL;
|
|
|
|
|
2015-08-26 01:25:58 +08:00
|
|
|
ret = OPENSSL_zalloc(sizeof(*ret));
|
2015-10-30 19:12:26 +08:00
|
|
|
if (ret == NULL)
|
2022-09-29 19:57:34 +08:00
|
|
|
return NULL;
|
2015-03-28 23:25:46 +08:00
|
|
|
|
|
|
|
ret->enc_algor = X509_ALGOR_new();
|
|
|
|
ret->enc_pkey = ASN1_OCTET_STRING_new();
|
2022-09-29 19:57:34 +08:00
|
|
|
if (ret->enc_algor == NULL || ret->enc_pkey == NULL) {
|
|
|
|
X509_PKEY_free(ret);
|
|
|
|
ERR_raise(ERR_LIB_ASN1, ERR_R_ASN1_LIB);
|
|
|
|
return NULL;
|
|
|
|
}
|
2015-09-17 10:25:31 +08:00
|
|
|
|
2015-03-28 23:25:46 +08:00
|
|
|
return ret;
|
1998-12-21 18:52:47 +08:00
|
|
|
}
|
|
|
|
|
1999-04-20 05:31:43 +08:00
|
|
|
void X509_PKEY_free(X509_PKEY *x)
|
1998-12-21 18:52:47 +08:00
|
|
|
{
|
|
|
|
if (x == NULL)
|
|
|
|
return;
|
|
|
|
|
2015-05-01 05:33:59 +08:00
|
|
|
X509_ALGOR_free(x->enc_algor);
|
2015-03-24 19:52:24 +08:00
|
|
|
ASN1_OCTET_STRING_free(x->enc_pkey);
|
2015-03-28 22:54:15 +08:00
|
|
|
EVP_PKEY_free(x->dec_pkey);
|
2015-05-01 22:02:07 +08:00
|
|
|
if (x->key_free)
|
2000-06-02 06:19:21 +08:00
|
|
|
OPENSSL_free(x->key_data);
|
|
|
|
OPENSSL_free(x);
|
1998-12-21 18:52:47 +08:00
|
|
|
}
|