2016-05-17 18:52:22 +00:00
|
|
|
/*
|
|
|
|
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
1998-12-21 10:52:47 +00:00
|
|
|
*
|
2016-05-17 18:52:22 +00:00
|
|
|
* Licensed under the OpenSSL license (the "License"). You may not use
|
|
|
|
* 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 10:52:47 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2015-05-14 14:56:48 +00:00
|
|
|
#include "internal/cryptlib.h"
|
1999-04-23 22:13:45 +00:00
|
|
|
#include <openssl/evp.h>
|
|
|
|
#include <openssl/objects.h>
|
1999-07-21 22:10:23 +00:00
|
|
|
#include <openssl/x509.h>
|
1998-12-21 10:52:47 +00:00
|
|
|
|
1999-04-19 21:31:43 +00:00
|
|
|
X509_PKEY *X509_PKEY_new(void)
|
2015-01-22 03:40:55 +00:00
|
|
|
{
|
|
|
|
X509_PKEY *ret = NULL;
|
1998-12-21 10:52:47 +00:00
|
|
|
|
2015-08-25 17:25:58 +00:00
|
|
|
ret = OPENSSL_zalloc(sizeof(*ret));
|
2015-10-30 11:12:26 +00:00
|
|
|
if (ret == NULL)
|
2015-03-28 15:25:46 +00:00
|
|
|
goto err;
|
|
|
|
|
|
|
|
ret->enc_algor = X509_ALGOR_new();
|
|
|
|
ret->enc_pkey = ASN1_OCTET_STRING_new();
|
2015-10-30 11:12:26 +00:00
|
|
|
if (ret->enc_algor == NULL || ret->enc_pkey == NULL)
|
2015-03-28 15:25:46 +00:00
|
|
|
goto err;
|
2015-09-17 02:25:31 +00:00
|
|
|
|
2015-03-28 15:25:46 +00:00
|
|
|
return ret;
|
|
|
|
err:
|
|
|
|
X509_PKEY_free(ret);
|
|
|
|
ASN1err(ASN1_F_X509_PKEY_NEW, ERR_R_MALLOC_FAILURE);
|
|
|
|
return NULL;
|
2015-01-22 03:40:55 +00:00
|
|
|
}
|
1998-12-21 10:52:47 +00:00
|
|
|
|
1999-04-19 21:31:43 +00:00
|
|
|
void X509_PKEY_free(X509_PKEY *x)
|
2015-01-22 03:40:55 +00:00
|
|
|
{
|
|
|
|
if (x == NULL)
|
|
|
|
return;
|
1998-12-21 10:52:47 +00:00
|
|
|
|
2015-04-30 21:33:59 +00:00
|
|
|
X509_ALGOR_free(x->enc_algor);
|
2015-03-24 11:52:24 +00:00
|
|
|
ASN1_OCTET_STRING_free(x->enc_pkey);
|
2015-03-28 14:54:15 +00:00
|
|
|
EVP_PKEY_free(x->dec_pkey);
|
2015-05-01 14:02:07 +00:00
|
|
|
if (x->key_free)
|
2015-01-22 03:40:55 +00:00
|
|
|
OPENSSL_free(x->key_data);
|
|
|
|
OPENSSL_free(x);
|
|
|
|
}
|