From e425f90fffd33786b6d45b46b67dc8bb61baecc7 Mon Sep 17 00:00:00 2001 From: Jack Lloyd Date: Fri, 6 Apr 2018 09:45:41 -0400 Subject: [PATCH] Make SM2 functions private Address issue #5670 Reviewed-by: Richard Levitte Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/6386) --- crypto/ec/ec_pmeth.c | 2 +- crypto/err/openssl.ec | 2 +- .../openssl => crypto/include/internal}/sm2.h | 0 .../include/internal}/sm2err.h | 0 crypto/sm2/sm2_crypt.c | 2 +- crypto/sm2/sm2_err.c | 2 +- crypto/sm2/sm2_sign.c | 2 +- crypto/sm2/sm2_za.c | 2 +- test/build.info | 20 ++++++++++--------- ...2crypttest.c => sm2_crypt_internal_test.c} | 2 +- ...{sm2sigtest.c => sm2_sign_internal_test.c} | 2 +- 11 files changed, 19 insertions(+), 17 deletions(-) rename {include/openssl => crypto/include/internal}/sm2.h (100%) rename {include/openssl => crypto/include/internal}/sm2err.h (100%) rename test/{sm2crypttest.c => sm2_crypt_internal_test.c} (99%) rename test/{sm2sigtest.c => sm2_sign_internal_test.c} (99%) diff --git a/crypto/ec/ec_pmeth.c b/crypto/ec/ec_pmeth.c index b4105c20f2..eefe2d0cd5 100644 --- a/crypto/ec/ec_pmeth.c +++ b/crypto/ec/ec_pmeth.c @@ -17,7 +17,7 @@ #include "internal/evp_int.h" #if !defined(OPENSSL_NO_SM2) -# include +# include "internal/sm2.h" #endif /* EC pkey context structure */ diff --git a/crypto/err/openssl.ec b/crypto/err/openssl.ec index f45e230749..7fc5788434 100644 --- a/crypto/err/openssl.ec +++ b/crypto/err/openssl.ec @@ -32,7 +32,7 @@ L CMS include/openssl/cms.h crypto/cms/cms_err.c L CT include/openssl/ct.h crypto/ct/ct_err.c L ASYNC include/openssl/async.h crypto/async/async_err.c L KDF include/openssl/kdf.h crypto/kdf/kdf_err.c -L SM2 include/openssl/sm2.h crypto/sm2/sm2_err.c +L SM2 crypto/include/internal/sm2.h crypto/sm2/sm2_err.c L OSSL_STORE include/openssl/store.h crypto/store/store_err.c # additional header files to be scanned for function names diff --git a/include/openssl/sm2.h b/crypto/include/internal/sm2.h similarity index 100% rename from include/openssl/sm2.h rename to crypto/include/internal/sm2.h diff --git a/include/openssl/sm2err.h b/crypto/include/internal/sm2err.h similarity index 100% rename from include/openssl/sm2err.h rename to crypto/include/internal/sm2err.h diff --git a/crypto/sm2/sm2_crypt.c b/crypto/sm2/sm2_crypt.c index a31c40fc7a..c3abd969eb 100644 --- a/crypto/sm2/sm2_crypt.c +++ b/crypto/sm2/sm2_crypt.c @@ -9,7 +9,7 @@ * https://www.openssl.org/source/license.html */ -#include +#include "internal/sm2.h" #include #include #include diff --git a/crypto/sm2/sm2_err.c b/crypto/sm2/sm2_err.c index 0c051f68b6..6f244a5eb0 100644 --- a/crypto/sm2/sm2_err.c +++ b/crypto/sm2/sm2_err.c @@ -9,7 +9,7 @@ */ #include -#include +#include "internal/sm2err.h" #ifndef OPENSSL_NO_ERR diff --git a/crypto/sm2/sm2_sign.c b/crypto/sm2/sm2_sign.c index e12eca12fb..ddfd318ed9 100644 --- a/crypto/sm2/sm2_sign.c +++ b/crypto/sm2/sm2_sign.c @@ -9,7 +9,7 @@ * https://www.openssl.org/source/license.html */ -#include +#include "internal/sm2.h" #include #include #include diff --git a/crypto/sm2/sm2_za.c b/crypto/sm2/sm2_za.c index f76fe0fcad..cf355238b2 100644 --- a/crypto/sm2/sm2_za.c +++ b/crypto/sm2/sm2_za.c @@ -9,7 +9,7 @@ * https://www.openssl.org/source/license.html */ -#include +#include "internal/sm2.h" #include #include #include diff --git a/test/build.info b/test/build.info index 000153d510..ee302e233c 100644 --- a/test/build.info +++ b/test/build.info @@ -28,7 +28,6 @@ INCLUDE_MAIN___test_libtestutil_OLB = /INCLUDE=MAIN aborttest test_test \ sanitytest exdatatest bntest \ ectest ecstresstest ecdsatest gmdifftest pbelutest ideatest \ - sm2sigtest sm2crypttest \ md2test \ hmactest \ rc2test rc4test rc5test \ @@ -89,14 +88,6 @@ INCLUDE_MAIN___test_libtestutil_OLB = /INCLUDE=MAIN INCLUDE[ecdsatest]=../include DEPEND[ecdsatest]=../libcrypto libtestutil.a - SOURCE[sm2sigtest]=sm2sigtest.c - INCLUDE[sm2sigtest]=../include - DEPEND[sm2sigtest]=../libcrypto libtestutil.a - - SOURCE[sm2crypttest]=sm2crypttest.c - INCLUDE[sm2crypttest]=../include - DEPEND[sm2crypttest]=../libcrypto libtestutil.a - SOURCE[gmdifftest]=gmdifftest.c INCLUDE[gmdifftest]=../include DEPEND[gmdifftest]=../libcrypto libtestutil.a @@ -448,6 +439,9 @@ INCLUDE_MAIN___test_libtestutil_OLB = /INCLUDE=MAIN IF[{- !$disabled{siphash} -}] PROGRAMS_NO_INST=siphash_internal_test ENDIF + IF[{- !$disabled{sm2} -}] + PROGRAMS_NO_INST=sm2_crypt_internal_test sm2_sign_internal_test + ENDIF IF[{- !$disabled{sm4} -}] PROGRAMS_NO_INST=sm4_internal_test ENDIF @@ -491,6 +485,14 @@ INCLUDE_MAIN___test_libtestutil_OLB = /INCLUDE=MAIN INCLUDE[siphash_internal_test]=.. ../include ../crypto/include DEPEND[siphash_internal_test]=../libcrypto.a libtestutil.a + SOURCE[sm2_sign_internal_test]=sm2_sign_internal_test.c + INCLUDE[sm2_sign_internal_test]=../include ../crypto/include + DEPEND[sm2_sign_internal_test]=../libcrypto.a libtestutil.a + + SOURCE[sm2_crypt_internal_test]=sm2_crypt_internal_test.c + INCLUDE[sm2_crypt_internal_test]=../include ../crypto/include + DEPEND[sm2_crypt_internal_test]=../libcrypto.a libtestutil.a + SOURCE[sm4_internal_test]=sm4_internal_test.c INCLUDE[sm4_internal_test]=.. ../include ../crypto/include DEPEND[sm4_internal_test]=../libcrypto.a libtestutil.a diff --git a/test/sm2crypttest.c b/test/sm2_crypt_internal_test.c similarity index 99% rename from test/sm2crypttest.c rename to test/sm2_crypt_internal_test.c index cd72cb0938..5325fa3fc5 100644 --- a/test/sm2crypttest.c +++ b/test/sm2_crypt_internal_test.c @@ -21,7 +21,7 @@ #ifndef OPENSSL_NO_SM2 -# include +# include "internal/sm2.h" static RAND_METHOD fake_rand; static const RAND_METHOD *saved_rand; diff --git a/test/sm2sigtest.c b/test/sm2_sign_internal_test.c similarity index 99% rename from test/sm2sigtest.c rename to test/sm2_sign_internal_test.c index 33be78315b..87f0d73382 100644 --- a/test/sm2sigtest.c +++ b/test/sm2_sign_internal_test.c @@ -22,7 +22,7 @@ #ifndef OPENSSL_NO_SM2 -# include +# include "internal/sm2.h" static RAND_METHOD fake_rand; static const RAND_METHOD *saved_rand; -- 2.25.1