diff options
| author | tb <> | 2025-07-12 20:22:40 +0000 |
|---|---|---|
| committer | tb <> | 2025-07-12 20:22:40 +0000 |
| commit | 69147ea8445a511462c02e8ac88d4f75fec3fa1b (patch) | |
| tree | 41b8a6669f29d8b3252ba346c343e4e0147b85f6 /src/lib/libcrypto/pem | |
| parent | d8116bd100cd9a4c1e502db89ddc6042bdb71643 (diff) | |
| download | openbsd-69147ea8445a511462c02e8ac88d4f75fec3fa1b.tar.gz openbsd-69147ea8445a511462c02e8ac88d4f75fec3fa1b.tar.bz2 openbsd-69147ea8445a511462c02e8ac88d4f75fec3fa1b.zip | |
Merge the two functions from x_pkey.c into pem_info.c
It looks like those can be unexported.
Diffstat (limited to 'src/lib/libcrypto/pem')
| -rw-r--r-- | src/lib/libcrypto/pem/pem_info.c | 60 |
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 | ||
| 80 | X509_PKEY * | ||
| 81 | X509_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 | } | ||
| 114 | LCRYPTO_ALIAS(X509_PKEY_new); | ||
| 115 | |||
| 116 | void | ||
| 117 | X509_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 | } | ||
| 136 | LCRYPTO_ALIAS(X509_PKEY_free); | ||
| 137 | |||
| 80 | X509_INFO * | 138 | X509_INFO * |
| 81 | X509_INFO_new(void) | 139 | X509_INFO_new(void) |
| 82 | { | 140 | { |
