From 32ee452496f8cf4558d645f9db908b09df919f04 Mon Sep 17 00:00:00 2001 From: Pauli Date: Fri, 21 Jun 2019 09:27:48 +1000 Subject: [PATCH] Remove OPENSSL_memcmp. After avoiding OPENSSL_memcmp for EC curve comparison, there are no remaining uses in the source code. The function is only defined in an internal header and thus should be safe to remove for 3.0.0. Reviewed-by: Tomas Mraz Reviewed-by: Dmitry Belyavskiy (Merged from https://github.com/openssl/openssl/pull/9207) --- Configurations/unix-Makefile.tmpl | 1 - crypto/ec/ec_curve.c | 9 ++++----- crypto/o_str.c | 12 ------------ crypto/x509/v3_tlsf.c | 1 - include/internal/o_str.h | 17 ----------------- util/libcrypto.num | 2 +- util/missingcrypto.txt | 1 - 7 files changed, 5 insertions(+), 38 deletions(-) delete mode 100644 include/internal/o_str.h diff --git a/Configurations/unix-Makefile.tmpl b/Configurations/unix-Makefile.tmpl index ce93a4ed1c..52eeaa9a76 100644 --- a/Configurations/unix-Makefile.tmpl +++ b/Configurations/unix-Makefile.tmpl @@ -804,7 +804,6 @@ errors: our @cryptoheaders = qw( include/internal/dso.h include/internal/o_dir.h - include/internal/o_str.h include/internal/err.h include/internal/sslconf.h ); our @cryptoskipheaders = ( @sslheaders, diff --git a/crypto/ec/ec_curve.c b/crypto/ec/ec_curve.c index 6c7c9ddbc7..1ea85946d6 100644 --- a/crypto/ec/ec_curve.c +++ b/crypto/ec/ec_curve.c @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2002-2019 The OpenSSL Project Authors. All Rights Reserved. * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved * * Licensed under the Apache License 2.0 (the "License"). You may not use @@ -14,7 +14,6 @@ #include #include #include "internal/nelem.h" -#include "internal/o_str.h" typedef struct { int field_type, /* either NID_X9_62_prime_field or @@ -3302,10 +3301,10 @@ int ec_curve_nid_from_params(const EC_GROUP *group) /* Check the optional seed (ignore if its not set) */ && (data->seed_len == 0 || seed_len == 0 || ((size_t)data->seed_len == seed_len - && OPENSSL_memcmp(params_seed, seed, seed_len) == 0)) + && memcmp(params_seed, seed, seed_len) == 0)) /* Check that the groups params match the built-in curve params */ - && OPENSSL_memcmp(param_bytes, params, param_len * NUM_BN_FIELDS) - == 0) { + && memcmp(param_bytes, params, param_len * NUM_BN_FIELDS) + == 0) { ret = curve.nid; goto end; } diff --git a/crypto/o_str.c b/crypto/o_str.c index 0403982004..467ceb2054 100644 --- a/crypto/o_str.c +++ b/crypto/o_str.c @@ -11,18 +11,6 @@ #include #include #include "internal/cryptlib.h" -#include "internal/o_str.h" - -int OPENSSL_memcmp(const void *v1, const void *v2, size_t n) -{ - const unsigned char *c1 = v1, *c2 = v2; - int ret = 0; - - while (n && (ret = *c1 - *c2) == 0) - n--, c1++, c2++; - - return ret; -} char *CRYPTO_strdup(const char *str, const char* file, int line) { diff --git a/crypto/x509/v3_tlsf.c b/crypto/x509/v3_tlsf.c index d3ab3f81ad..28e83bb2ae 100644 --- a/crypto/x509/v3_tlsf.c +++ b/crypto/x509/v3_tlsf.c @@ -10,7 +10,6 @@ #include "e_os.h" #include "internal/cryptlib.h" #include -#include "internal/o_str.h" #include #include #include diff --git a/include/internal/o_str.h b/include/internal/o_str.h deleted file mode 100644 index dc236caa51..0000000000 --- a/include/internal/o_str.h +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright 2003-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the Apache License 2.0 (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 - */ - -#ifndef HEADER_O_STR_H -# define HEADER_O_STR_H - -# include /* to get size_t */ - -int OPENSSL_memcmp(const void *p1, const void *p2, size_t n); - -#endif diff --git a/util/libcrypto.num b/util/libcrypto.num index 0b181070eb..af6e2b96b4 100644 --- a/util/libcrypto.num +++ b/util/libcrypto.num @@ -462,7 +462,7 @@ X509v3_asid_add_id_or_range 462 3_0_0 EXIST::FUNCTION:RFC3779 X509_NAME_ENTRY_create_by_NID 463 3_0_0 EXIST::FUNCTION: EC_KEY_METHOD_get_init 464 3_0_0 EXIST::FUNCTION:EC ASN1_INTEGER_to_BN 465 3_0_0 EXIST::FUNCTION: -OPENSSL_memcmp 466 3_0_0 EXIST::FUNCTION: +OPENSSL_memcmp 466 3_0_0 NOEXIST::FUNCTION: BUF_MEM_new 467 3_0_0 EXIST::FUNCTION: DSO_set_filename 468 3_0_0 EXIST::FUNCTION: DH_new 469 3_0_0 EXIST::FUNCTION:DH diff --git a/util/missingcrypto.txt b/util/missingcrypto.txt index e68ddc883e..30b1e2dda2 100644 --- a/util/missingcrypto.txt +++ b/util/missingcrypto.txt @@ -729,7 +729,6 @@ OPENSSL_gmtime_diff OPENSSL_init OPENSSL_isservice OPENSSL_issetugid -OPENSSL_memcmp OPENSSL_sk_deep_copy OPENSSL_sk_delete OPENSSL_sk_delete_ptr -- 2.25.1