summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/pem/pem_info.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/pem/pem_info.c')
-rw-r--r--src/lib/libcrypto/pem/pem_info.c60
1 files changed, 59 insertions, 1 deletions
diff --git a/src/lib/libcrypto/pem/pem_info.c b/src/lib/libcrypto/pem/pem_info.c
index e1a264f4c5..4f2be892d1 100644
--- a/src/lib/libcrypto/pem/pem_info.c
+++ b/src/lib/libcrypto/pem/pem_info.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: pem_info.c,v 1.31 2025/07/12 19:57:13 tb Exp $ */ 1/* $OpenBSD: pem_info.c,v 1.32 2025/07/12 20:22:40 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -77,6 +77,64 @@
77#include "err_local.h" 77#include "err_local.h"
78#include "evp_local.h" 78#include "evp_local.h"
79 79
80X509_PKEY *
81X509_PKEY_new(void)
82{
83 X509_PKEY *ret = NULL;
84
85 if ((ret = malloc(sizeof(X509_PKEY))) == NULL) {
86 ASN1error(ERR_R_MALLOC_FAILURE);
87 goto err;
88 }
89 ret->version = 0;
90 if ((ret->enc_algor = X509_ALGOR_new()) == NULL) {
91 ASN1error(ERR_R_MALLOC_FAILURE);
92 goto err;
93 }
94 if ((ret->enc_pkey = ASN1_OCTET_STRING_new()) == NULL) {
95 ASN1error(ERR_R_MALLOC_FAILURE);
96 goto err;
97 }
98 ret->dec_pkey = NULL;
99 ret->key_length = 0;
100 ret->key_data = NULL;
101 ret->key_free = 0;
102 ret->cipher.cipher = NULL;
103 memset(ret->cipher.iv, 0, EVP_MAX_IV_LENGTH);
104 ret->references = 1;
105 return (ret);
106
107 err:
108 if (ret) {
109 X509_ALGOR_free(ret->enc_algor);
110 free(ret);
111 }
112 return NULL;
113}
114LCRYPTO_ALIAS(X509_PKEY_new);
115
116void
117X509_PKEY_free(X509_PKEY *x)
118{
119 int i;
120
121 if (x == NULL)
122 return;
123
124 i = CRYPTO_add(&x->references, -1, CRYPTO_LOCK_X509_PKEY);
125 if (i > 0)
126 return;
127
128 if (x->enc_algor != NULL)
129 X509_ALGOR_free(x->enc_algor);
130 ASN1_OCTET_STRING_free(x->enc_pkey);
131 EVP_PKEY_free(x->dec_pkey);
132 if ((x->key_data != NULL) && (x->key_free))
133 free(x->key_data);
134 free(x);
135}
136LCRYPTO_ALIAS(X509_PKEY_free);
137
80X509_INFO * 138X509_INFO *
81X509_INFO_new(void) 139X509_INFO_new(void)
82{ 140{