diff options
| author | tb <> | 2023-06-25 18:45:56 +0000 |
|---|---|---|
| committer | tb <> | 2023-06-25 18:45:56 +0000 |
| commit | 85f78eb5e708f88227cbc815f99624d39cdfada5 (patch) | |
| tree | 827bc6c6e367e27b583030a88f63ac80be6f976b /src | |
| parent | 828f7d36b5a0c49731c9307ec9f510358426c53c (diff) | |
| download | openbsd-85f78eb5e708f88227cbc815f99624d39cdfada5.tar.gz openbsd-85f78eb5e708f88227cbc815f99624d39cdfada5.tar.bz2 openbsd-85f78eb5e708f88227cbc815f99624d39cdfada5.zip | |
Remove {ecdh,ecdsa}_check() and {ECDH,ECDSA}_DATA
This is now unused code. Removing it will free us up to remove some
other ugliness in the ec directory.
ok jsing
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libcrypto/ecdh/ech_lib.c | 97 | ||||
| -rw-r--r-- | src/lib/libcrypto/ecdh/ech_local.h | 14 | ||||
| -rw-r--r-- | src/lib/libcrypto/ecdsa/ecs_lib.c | 96 | ||||
| -rw-r--r-- | src/lib/libcrypto/ecdsa/ecs_local.h | 20 |
4 files changed, 4 insertions, 223 deletions
diff --git a/src/lib/libcrypto/ecdh/ech_lib.c b/src/lib/libcrypto/ecdh/ech_lib.c index 6e12126034..f062ec3fdc 100644 --- a/src/lib/libcrypto/ecdh/ech_lib.c +++ b/src/lib/libcrypto/ecdh/ech_lib.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: ech_lib.c,v 1.18 2023/06/25 18:27:38 tb Exp $ */ | 1 | /* $OpenBSD: ech_lib.c,v 1.19 2023/06/25 18:45:56 tb Exp $ */ |
| 2 | /* ==================================================================== | 2 | /* ==================================================================== |
| 3 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. | 3 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. |
| 4 | * | 4 | * |
| @@ -81,10 +81,6 @@ | |||
| 81 | 81 | ||
| 82 | static const ECDH_METHOD *default_ECDH_method = NULL; | 82 | static const ECDH_METHOD *default_ECDH_method = NULL; |
| 83 | 83 | ||
| 84 | static void *ecdh_data_new(void); | ||
| 85 | static void *ecdh_data_dup(void *); | ||
| 86 | static void ecdh_data_free(void *); | ||
| 87 | |||
| 88 | void | 84 | void |
| 89 | ECDH_set_default_method(const ECDH_METHOD *meth) | 85 | ECDH_set_default_method(const ECDH_METHOD *meth) |
| 90 | { | 86 | { |
| @@ -106,97 +102,6 @@ ECDH_set_method(EC_KEY *eckey, const ECDH_METHOD *meth) | |||
| 106 | return 0; | 102 | return 0; |
| 107 | } | 103 | } |
| 108 | 104 | ||
| 109 | static ECDH_DATA * | ||
| 110 | ECDH_DATA_new_method(ENGINE *engine) | ||
| 111 | { | ||
| 112 | ECDH_DATA *ret; | ||
| 113 | |||
| 114 | ret = malloc(sizeof(ECDH_DATA)); | ||
| 115 | if (ret == NULL) { | ||
| 116 | ECDHerror(ERR_R_MALLOC_FAILURE); | ||
| 117 | return (NULL); | ||
| 118 | } | ||
| 119 | |||
| 120 | ret->init = NULL; | ||
| 121 | |||
| 122 | ret->meth = ECDH_get_default_method(); | ||
| 123 | ret->engine = engine; | ||
| 124 | #ifndef OPENSSL_NO_ENGINE | ||
| 125 | if (!ret->engine) | ||
| 126 | ret->engine = ENGINE_get_default_ECDH(); | ||
| 127 | if (ret->engine) { | ||
| 128 | ret->meth = ENGINE_get_ECDH(ret->engine); | ||
| 129 | if (ret->meth == NULL) { | ||
| 130 | ECDHerror(ERR_R_ENGINE_LIB); | ||
| 131 | ENGINE_finish(ret->engine); | ||
| 132 | free(ret); | ||
| 133 | return NULL; | ||
| 134 | } | ||
| 135 | } | ||
| 136 | #endif | ||
| 137 | |||
| 138 | ret->flags = ret->meth->flags; | ||
| 139 | CRYPTO_new_ex_data(CRYPTO_EX_INDEX_ECDH, ret, &ret->ex_data); | ||
| 140 | return (ret); | ||
| 141 | } | ||
| 142 | |||
| 143 | static void * | ||
| 144 | ecdh_data_new(void) | ||
| 145 | { | ||
| 146 | return (void *)ECDH_DATA_new_method(NULL); | ||
| 147 | } | ||
| 148 | |||
| 149 | static void * | ||
| 150 | ecdh_data_dup(void *data) | ||
| 151 | { | ||
| 152 | ECDH_DATA *r = (ECDH_DATA *)data; | ||
| 153 | |||
| 154 | /* XXX: dummy operation */ | ||
| 155 | if (r == NULL) | ||
| 156 | return NULL; | ||
| 157 | |||
| 158 | return (void *)ecdh_data_new(); | ||
| 159 | } | ||
| 160 | |||
| 161 | void | ||
| 162 | ecdh_data_free(void *data) | ||
| 163 | { | ||
| 164 | ECDH_DATA *r = (ECDH_DATA *)data; | ||
| 165 | |||
| 166 | #ifndef OPENSSL_NO_ENGINE | ||
| 167 | ENGINE_finish(r->engine); | ||
| 168 | #endif | ||
| 169 | |||
| 170 | CRYPTO_free_ex_data(CRYPTO_EX_INDEX_ECDH, r, &r->ex_data); | ||
| 171 | |||
| 172 | freezero(r, sizeof(ECDH_DATA)); | ||
| 173 | } | ||
| 174 | |||
| 175 | ECDH_DATA * | ||
| 176 | ecdh_check(EC_KEY *key) | ||
| 177 | { | ||
| 178 | ECDH_DATA *ecdh_data; | ||
| 179 | |||
| 180 | void *data = EC_KEY_get_key_method_data(key, ecdh_data_dup, | ||
| 181 | ecdh_data_free, ecdh_data_free); | ||
| 182 | if (data == NULL) { | ||
| 183 | ecdh_data = (ECDH_DATA *)ecdh_data_new(); | ||
| 184 | if (ecdh_data == NULL) | ||
| 185 | return NULL; | ||
| 186 | data = EC_KEY_insert_key_method_data(key, (void *)ecdh_data, | ||
| 187 | ecdh_data_dup, ecdh_data_free, ecdh_data_free); | ||
| 188 | if (data != NULL) { | ||
| 189 | /* Another thread raced us to install the key_method | ||
| 190 | * data and won. */ | ||
| 191 | ecdh_data_free(ecdh_data); | ||
| 192 | ecdh_data = (ECDH_DATA *)data; | ||
| 193 | } | ||
| 194 | } else | ||
| 195 | ecdh_data = (ECDH_DATA *)data; | ||
| 196 | |||
| 197 | return ecdh_data; | ||
| 198 | } | ||
| 199 | |||
| 200 | int | 105 | int |
| 201 | ECDH_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, | 106 | ECDH_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, |
| 202 | CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func) | 107 | CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func) |
diff --git a/src/lib/libcrypto/ecdh/ech_local.h b/src/lib/libcrypto/ecdh/ech_local.h index c8cb518249..fefa817b1c 100644 --- a/src/lib/libcrypto/ecdh/ech_local.h +++ b/src/lib/libcrypto/ecdh/ech_local.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: ech_local.h,v 1.3 2023/06/25 08:12:23 tb Exp $ */ | 1 | /* $OpenBSD: ech_local.h,v 1.4 2023/06/25 18:45:56 tb Exp $ */ |
| 2 | /* ==================================================================== | 2 | /* ==================================================================== |
| 3 | * Copyright (c) 2000-2005 The OpenSSL Project. All rights reserved. | 3 | * Copyright (c) 2000-2005 The OpenSSL Project. All rights reserved. |
| 4 | * | 4 | * |
| @@ -68,18 +68,6 @@ struct ecdh_method { | |||
| 68 | char *app_data; | 68 | char *app_data; |
| 69 | }; | 69 | }; |
| 70 | 70 | ||
| 71 | typedef struct ecdh_data_st { | ||
| 72 | /* EC_KEY_METH_DATA part */ | ||
| 73 | int (*init)(EC_KEY *); | ||
| 74 | /* method specific part */ | ||
| 75 | ENGINE *engine; | ||
| 76 | int flags; | ||
| 77 | const ECDH_METHOD *meth; | ||
| 78 | CRYPTO_EX_DATA ex_data; | ||
| 79 | } ECDH_DATA; | ||
| 80 | |||
| 81 | ECDH_DATA *ecdh_check(EC_KEY *); | ||
| 82 | |||
| 83 | /* | 71 | /* |
| 84 | * ECDH Key Derivation Function as defined in ANSI X9.63. | 72 | * ECDH Key Derivation Function as defined in ANSI X9.63. |
| 85 | */ | 73 | */ |
diff --git a/src/lib/libcrypto/ecdsa/ecs_lib.c b/src/lib/libcrypto/ecdsa/ecs_lib.c index 9ba5db2fca..11e707dd55 100644 --- a/src/lib/libcrypto/ecdsa/ecs_lib.c +++ b/src/lib/libcrypto/ecdsa/ecs_lib.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: ecs_lib.c,v 1.19 2023/06/25 18:27:38 tb Exp $ */ | 1 | /* $OpenBSD: ecs_lib.c,v 1.20 2023/06/25 18:45:56 tb Exp $ */ |
| 2 | /* ==================================================================== | 2 | /* ==================================================================== |
| 3 | * Copyright (c) 1998-2005 The OpenSSL Project. All rights reserved. | 3 | * Copyright (c) 1998-2005 The OpenSSL Project. All rights reserved. |
| 4 | * | 4 | * |
| @@ -68,10 +68,6 @@ | |||
| 68 | 68 | ||
| 69 | static const ECDSA_METHOD *default_ECDSA_method = NULL; | 69 | static const ECDSA_METHOD *default_ECDSA_method = NULL; |
| 70 | 70 | ||
| 71 | static void *ecdsa_data_new(void); | ||
| 72 | static void *ecdsa_data_dup(void *); | ||
| 73 | static void ecdsa_data_free(void *); | ||
| 74 | |||
| 75 | void | 71 | void |
| 76 | ECDSA_set_default_method(const ECDSA_METHOD *meth) | 72 | ECDSA_set_default_method(const ECDSA_METHOD *meth) |
| 77 | { | 73 | { |
| @@ -93,96 +89,6 @@ ECDSA_set_method(EC_KEY *eckey, const ECDSA_METHOD *meth) | |||
| 93 | return 0; | 89 | return 0; |
| 94 | } | 90 | } |
| 95 | 91 | ||
| 96 | static ECDSA_DATA * | ||
| 97 | ECDSA_DATA_new_method(ENGINE *engine) | ||
| 98 | { | ||
| 99 | ECDSA_DATA *ret; | ||
| 100 | |||
| 101 | ret = malloc(sizeof(ECDSA_DATA)); | ||
| 102 | if (ret == NULL) { | ||
| 103 | ECDSAerror(ERR_R_MALLOC_FAILURE); | ||
| 104 | return (NULL); | ||
| 105 | } | ||
| 106 | |||
| 107 | ret->init = NULL; | ||
| 108 | |||
| 109 | ret->meth = ECDSA_get_default_method(); | ||
| 110 | ret->engine = engine; | ||
| 111 | #ifndef OPENSSL_NO_ENGINE | ||
| 112 | if (!ret->engine) | ||
| 113 | ret->engine = ENGINE_get_default_ECDSA(); | ||
| 114 | if (ret->engine) { | ||
| 115 | ret->meth = ENGINE_get_ECDSA(ret->engine); | ||
| 116 | if (ret->meth == NULL) { | ||
| 117 | ECDSAerror(ERR_R_ENGINE_LIB); | ||
| 118 | ENGINE_finish(ret->engine); | ||
| 119 | free(ret); | ||
| 120 | return NULL; | ||
| 121 | } | ||
| 122 | } | ||
| 123 | #endif | ||
| 124 | |||
| 125 | ret->flags = ret->meth->flags; | ||
| 126 | CRYPTO_new_ex_data(CRYPTO_EX_INDEX_ECDSA, ret, &ret->ex_data); | ||
| 127 | return (ret); | ||
| 128 | } | ||
| 129 | |||
| 130 | static void * | ||
| 131 | ecdsa_data_new(void) | ||
| 132 | { | ||
| 133 | return (void *)ECDSA_DATA_new_method(NULL); | ||
| 134 | } | ||
| 135 | |||
| 136 | static void * | ||
| 137 | ecdsa_data_dup(void *data) | ||
| 138 | { | ||
| 139 | ECDSA_DATA *r = (ECDSA_DATA *)data; | ||
| 140 | |||
| 141 | /* XXX: dummy operation */ | ||
| 142 | if (r == NULL) | ||
| 143 | return NULL; | ||
| 144 | |||
| 145 | return ecdsa_data_new(); | ||
| 146 | } | ||
| 147 | |||
| 148 | static void | ||
| 149 | ecdsa_data_free(void *data) | ||
| 150 | { | ||
| 151 | ECDSA_DATA *r = (ECDSA_DATA *)data; | ||
| 152 | |||
| 153 | #ifndef OPENSSL_NO_ENGINE | ||
| 154 | ENGINE_finish(r->engine); | ||
| 155 | #endif | ||
| 156 | CRYPTO_free_ex_data(CRYPTO_EX_INDEX_ECDSA, r, &r->ex_data); | ||
| 157 | |||
| 158 | freezero(r, sizeof(ECDSA_DATA)); | ||
| 159 | } | ||
| 160 | |||
| 161 | ECDSA_DATA * | ||
| 162 | ecdsa_check(EC_KEY *key) | ||
| 163 | { | ||
| 164 | ECDSA_DATA *ecdsa_data; | ||
| 165 | |||
| 166 | void *data = EC_KEY_get_key_method_data(key, ecdsa_data_dup, | ||
| 167 | ecdsa_data_free, ecdsa_data_free); | ||
| 168 | if (data == NULL) { | ||
| 169 | ecdsa_data = (ECDSA_DATA *)ecdsa_data_new(); | ||
| 170 | if (ecdsa_data == NULL) | ||
| 171 | return NULL; | ||
| 172 | data = EC_KEY_insert_key_method_data(key, (void *)ecdsa_data, | ||
| 173 | ecdsa_data_dup, ecdsa_data_free, ecdsa_data_free); | ||
| 174 | if (data != NULL) { | ||
| 175 | /* Another thread raced us to install the key_method | ||
| 176 | * data and won. */ | ||
| 177 | ecdsa_data_free(ecdsa_data); | ||
| 178 | ecdsa_data = (ECDSA_DATA *)data; | ||
| 179 | } | ||
| 180 | } else | ||
| 181 | ecdsa_data = (ECDSA_DATA *)data; | ||
| 182 | |||
| 183 | return ecdsa_data; | ||
| 184 | } | ||
| 185 | |||
| 186 | int | 92 | int |
| 187 | ECDSA_size(const EC_KEY *r) | 93 | ECDSA_size(const EC_KEY *r) |
| 188 | { | 94 | { |
diff --git a/src/lib/libcrypto/ecdsa/ecs_local.h b/src/lib/libcrypto/ecdsa/ecs_local.h index 5cdf264557..20ad0c246e 100644 --- a/src/lib/libcrypto/ecdsa/ecs_local.h +++ b/src/lib/libcrypto/ecdsa/ecs_local.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: ecs_local.h,v 1.2 2022/11/26 17:23:17 tb Exp $ */ | 1 | /* $OpenBSD: ecs_local.h,v 1.3 2023/06/25 18:45:56 tb Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Written by Nils Larsch for the OpenSSL project | 3 | * Written by Nils Larsch for the OpenSSL project |
| 4 | */ | 4 | */ |
| @@ -63,29 +63,11 @@ | |||
| 63 | 63 | ||
| 64 | __BEGIN_HIDDEN_DECLS | 64 | __BEGIN_HIDDEN_DECLS |
| 65 | 65 | ||
| 66 | typedef struct ecdsa_data_st { | ||
| 67 | /* EC_KEY_METH_DATA part */ | ||
| 68 | int (*init)(EC_KEY *); | ||
| 69 | /* method (ECDSA) specific part */ | ||
| 70 | ENGINE *engine; | ||
| 71 | int flags; | ||
| 72 | const ECDSA_METHOD *meth; | ||
| 73 | CRYPTO_EX_DATA ex_data; | ||
| 74 | } ECDSA_DATA; | ||
| 75 | |||
| 76 | struct ECDSA_SIG_st { | 66 | struct ECDSA_SIG_st { |
| 77 | BIGNUM *r; | 67 | BIGNUM *r; |
| 78 | BIGNUM *s; | 68 | BIGNUM *s; |
| 79 | }; | 69 | }; |
| 80 | 70 | ||
| 81 | /** ecdsa_check | ||
| 82 | * checks whether ECKEY->meth_data is a pointer to a ECDSA_DATA structure | ||
| 83 | * and if not it removes the old meth_data and creates a ECDSA_DATA structure. | ||
| 84 | * \param eckey pointer to a EC_KEY object | ||
| 85 | * \return pointer to a ECDSA_DATA structure | ||
| 86 | */ | ||
| 87 | ECDSA_DATA *ecdsa_check(EC_KEY *eckey); | ||
| 88 | |||
| 89 | int ossl_ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, | 71 | int ossl_ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, |
| 90 | BIGNUM **rp); | 72 | BIGNUM **rp); |
| 91 | int ossl_ecdsa_sign(int type, const unsigned char *dgst, int dlen, | 73 | int ossl_ecdsa_sign(int type, const unsigned char *dgst, int dlen, |
