|
|
102646 |
From d651e25be0bc0c11f4d3d7c72be8cfbbe82b3874 Mon Sep 17 00:00:00 2001
|
|
|
102646 |
From: Jakub Jelen <jjelen@redhat.com>
|
|
|
102646 |
Date: Fri, 10 Sep 2021 18:39:00 +0200
|
|
|
102646 |
Subject: [PATCH] Allow building libgcrypt without Brainpool curves
|
|
|
102646 |
|
|
|
102646 |
* README: Document possibility to build without brainpool curves
|
|
|
102646 |
* cipher/ecc-curves.c: Conditionalize brainpool curves definitions
|
|
|
102646 |
* configure.ac: Implement possibility to build without brainpool curves
|
|
|
102646 |
* tests/curves.c: Skip brainpool curves if they are not built-in
|
|
|
102646 |
* tests/keygrip.c: Skip brainpool curves if they are not built-in
|
|
|
102646 |
|
|
|
102646 |
--
|
|
|
102646 |
|
|
|
102646 |
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
|
|
|
102646 |
---
|
|
|
102646 |
README | 3 +++
|
|
|
102646 |
cipher/ecc-curves.c | 4 ++++
|
|
|
102646 |
configure.ac | 13 +++++++++++++
|
|
|
102646 |
tests/curves.c | 46 ++++++++++++++++++++++++++++++---------------
|
|
|
102646 |
tests/keygrip.c | 2 ++
|
|
|
102646 |
5 files changed, 53 insertions(+), 15 deletions(-)
|
|
|
102646 |
|
|
|
102646 |
diff --git a/README b/README
|
|
|
102646 |
index 436b6cd4..1044109c 100644
|
|
|
102646 |
--- a/README
|
|
|
102646 |
+++ b/README
|
|
|
102646 |
@@ -127,6 +127,9 @@
|
|
|
102646 |
the list used with the current build the program
|
|
|
102646 |
tests/version may be used.
|
|
|
102646 |
|
|
|
102646 |
+ --disable-brainpool
|
|
|
102646 |
+ Do not build in support for Brainpool curves.
|
|
|
102646 |
+
|
|
|
102646 |
--disable-endian-check
|
|
|
102646 |
Don't let configure test for the endianness but
|
|
|
102646 |
try to use the OS provided macros at compile
|
|
|
102646 |
diff --git a/cipher/ecc-curves.c b/cipher/ecc-curves.c
|
|
|
102646 |
index 7c86e12c..8fd95a9c 100644
|
|
|
102646 |
--- a/cipher/ecc-curves.c
|
|
|
102646 |
+++ b/cipher/ecc-curves.c
|
|
|
102646 |
@@ -77,6 +77,7 @@ static const struct
|
|
|
102646 |
{ "NIST P-521", "1.3.132.0.35" },
|
|
|
102646 |
{ "NIST P-521", "nistp521" }, /* rfc5656. */
|
|
|
102646 |
|
|
|
102646 |
+#ifdef ENABLE_BRAINPOOL
|
|
|
102646 |
{ "brainpoolP160r1", "1.3.36.3.3.2.8.1.1.1" },
|
|
|
102646 |
{ "brainpoolP192r1", "1.3.36.3.3.2.8.1.1.3" },
|
|
|
102646 |
{ "brainpoolP224r1", "1.3.36.3.3.2.8.1.1.5" },
|
|
|
102646 |
@@ -84,6 +85,7 @@ static const struct
|
|
|
102646 |
{ "brainpoolP320r1", "1.3.36.3.3.2.8.1.1.9" },
|
|
|
102646 |
{ "brainpoolP384r1", "1.3.36.3.3.2.8.1.1.11"},
|
|
|
102646 |
{ "brainpoolP512r1", "1.3.36.3.3.2.8.1.1.13"},
|
|
|
102646 |
+#endif /* ENABLE_BRAINPOOL */
|
|
|
102646 |
|
|
|
102646 |
{ "GOST2001-test", "1.2.643.2.2.35.0" },
|
|
|
102646 |
{ "GOST2001-CryptoPro-A", "1.2.643.2.2.35.1" },
|
|
|
102646 |
@@ -297,6 +299,7 @@ static const ecc_domain_parms_t domain_parms[] =
|
|
|
102646 |
1
|
|
|
102646 |
},
|
|
|
102646 |
|
|
|
102646 |
+#ifdef ENABLE_BRAINPOOL
|
|
|
102646 |
{ "brainpoolP160r1", 160, 0,
|
|
|
102646 |
MPI_EC_WEIERSTRASS, ECC_DIALECT_STANDARD,
|
|
|
102646 |
"0xe95e4a5f737059dc60dfc7ad95b3d8139515620f",
|
|
|
102646 |
@@ -391,6 +394,7 @@ static const ecc_domain_parms_t domain_parms[] =
|
|
|
102646 |
"b2dcde494a5f485e5bca4bd88a2763aed1ca2b2fa8f0540678cd1e0f3ad80892",
|
|
|
102646 |
1
|
|
|
102646 |
},
|
|
|
102646 |
+#endif /* ENABLE_BRAINPOOL */
|
|
|
102646 |
{
|
|
|
102646 |
"GOST2001-test", 256, 0,
|
|
|
102646 |
MPI_EC_WEIERSTRASS, ECC_DIALECT_STANDARD,
|
|
|
102646 |
diff --git a/configure.ac b/configure.ac
|
|
|
102646 |
index 6efbf139..f4ac1887 100644
|
|
|
102646 |
--- a/configure.ac
|
|
|
102646 |
+++ b/configure.ac
|
|
|
102646 |
@@ -614,6 +614,14 @@ AC_ARG_WITH(fips-module-version,
|
|
|
102646 |
AC_DEFINE_UNQUOTED(FIPS_MODULE_VERSION, "$fips_module_version",
|
|
|
102646 |
[Define FIPS module version for certification])
|
|
|
102646 |
|
|
|
102646 |
+# Implementation of the --disable-brainpool switch.
|
|
|
102646 |
+AC_MSG_CHECKING([whether we want to disable the use of brainpool curves])
|
|
|
102646 |
+AC_ARG_ENABLE(brainpool,
|
|
|
102646 |
+ AS_HELP_STRING([--disable-brainpool],
|
|
|
102646 |
+ [Disable the brainpool curves]),
|
|
|
102646 |
+ use_brainpool="$enableval",use_brainpool=yes)
|
|
|
102646 |
+AC_MSG_RESULT($use_brainpool)
|
|
|
102646 |
+
|
|
|
102646 |
# Implementation of the --disable-jent-support switch.
|
|
|
102646 |
AC_MSG_CHECKING([whether jitter entropy support is requested])
|
|
|
102646 |
AC_ARG_ENABLE(jent-support,
|
|
|
102646 |
@@ -2466,6 +2474,10 @@ if test x"$ppccryptosupport" = xyes ; then
|
|
|
102646 |
AC_DEFINE(ENABLE_PPC_CRYPTO_SUPPORT,1,
|
|
|
102646 |
[Enable support for POWER 8 (PowerISA 2.07) crypto extension.])
|
|
|
102646 |
fi
|
|
|
102646 |
+if test x"$use_brainpool" = xyes ; then
|
|
|
102646 |
+ AC_DEFINE(ENABLE_BRAINPOOL, 1,
|
|
|
102646 |
+ [Enable support for the brainpool curves.])
|
|
|
102646 |
+fi
|
|
|
102646 |
if test x"$jentsupport" = xyes ; then
|
|
|
102646 |
AC_DEFINE(ENABLE_JENT_SUPPORT, 1,
|
|
|
102646 |
[Enable support for the jitter entropy collector.])
|
|
|
102646 |
@@ -3296,6 +3308,7 @@ GCRY_MSG_WRAP([Enabled digest algorithms:],[$enabled_digests])
|
|
|
102646 |
GCRY_MSG_WRAP([Enabled kdf algorithms: ],[$enabled_kdfs])
|
|
|
102646 |
GCRY_MSG_WRAP([Enabled pubkey algorithms:],[$enabled_pubkey_ciphers])
|
|
|
102646 |
GCRY_MSG_SHOW([Random number generator: ],[$random])
|
|
|
102646 |
+GCRY_MSG_SHOW([Enabled Brainpool curves: ],[$use_brainpool])
|
|
|
102646 |
GCRY_MSG_SHOW([Try using jitter entropy: ],[$jentsupport])
|
|
|
102646 |
GCRY_MSG_SHOW([Using linux capabilities: ],[$use_capabilities])
|
|
|
102646 |
GCRY_MSG_SHOW([FIPS module version: ],[$fips_module_version])
|
|
|
102646 |
diff --git a/tests/curves.c b/tests/curves.c
|
|
|
102646 |
index 3c738171..8eb79565 100644
|
|
|
102646 |
--- a/tests/curves.c
|
|
|
102646 |
+++ b/tests/curves.c
|
|
|
102646 |
@@ -33,7 +33,11 @@
|
|
|
102646 |
#include "t-common.h"
|
|
|
102646 |
|
|
|
102646 |
/* Number of curves defined in ../cipher/ecc-curves.c */
|
|
|
102646 |
-#define N_CURVES 27
|
|
|
102646 |
+#ifdef ENABLE_BRAINPOOL
|
|
|
102646 |
+# define N_CURVES 27
|
|
|
102646 |
+#else
|
|
|
102646 |
+# define N_CURVES 20
|
|
|
102646 |
+#endif
|
|
|
102646 |
|
|
|
102646 |
/* A real world sample public key. */
|
|
|
102646 |
static char const sample_key_1[] =
|
|
|
102646 |
@@ -52,6 +56,7 @@ static char const sample_key_1[] =
|
|
|
102646 |
static char const sample_key_1_curve[] = "NIST P-256";
|
|
|
102646 |
static unsigned int sample_key_1_nbits = 256;
|
|
|
102646 |
|
|
|
102646 |
+#ifdef ENABLE_BRAINPOOL
|
|
|
102646 |
/* A made up sample public key. */
|
|
|
102646 |
static char const sample_key_2[] =
|
|
|
102646 |
"(public-key\n"
|
|
|
102646 |
@@ -68,6 +73,7 @@ static char const sample_key_2[] =
|
|
|
102646 |
" ))";
|
|
|
102646 |
static char const sample_key_2_curve[] = "brainpoolP160r1";
|
|
|
102646 |
static unsigned int sample_key_2_nbits = 160;
|
|
|
102646 |
+#endif /* ENABLE_BRAINPOOL */
|
|
|
102646 |
|
|
|
102646 |
static int in_fips_mode;
|
|
|
102646 |
|
|
|
102646 |
@@ -113,6 +119,7 @@ check_matching (void)
|
|
|
102646 |
|
|
|
102646 |
gcry_sexp_release (key);
|
|
|
102646 |
|
|
|
102646 |
+#ifdef ENABLE_BRAINPOOL
|
|
|
102646 |
if (!in_fips_mode)
|
|
|
102646 |
{
|
|
|
102646 |
err = gcry_sexp_new (&key, sample_key_2, 0, 1);
|
|
|
102646 |
@@ -130,6 +137,7 @@ check_matching (void)
|
|
|
102646 |
|
|
|
102646 |
gcry_sexp_release (key);
|
|
|
102646 |
}
|
|
|
102646 |
+#endif /* ENABLE_BRAINPOOL */
|
|
|
102646 |
}
|
|
|
102646 |
|
|
|
102646 |
#define TEST_ERROR_EXPECTED (1 << 0)
|
|
|
102646 |
@@ -185,20 +193,26 @@ check_get_params (void)
|
|
|
102646 |
{ GCRY_PK_ECC, "1.3.132.0.35" },
|
|
|
102646 |
{ GCRY_PK_ECC, "nistp521" },
|
|
|
102646 |
|
|
|
102646 |
- { GCRY_PK_ECC, "brainpoolP160r1", TEST_NOFIPS },
|
|
|
102646 |
- { GCRY_PK_ECC, "1.3.36.3.3.2.8.1.1.1", TEST_NOFIPS },
|
|
|
102646 |
- { GCRY_PK_ECC, "brainpoolP192r1", TEST_NOFIPS },
|
|
|
102646 |
- { GCRY_PK_ECC, "1.3.36.3.3.2.8.1.1.3", TEST_NOFIPS },
|
|
|
102646 |
- { GCRY_PK_ECC, "brainpoolP224r1", TEST_NOFIPS },
|
|
|
102646 |
- { GCRY_PK_ECC, "1.3.36.3.3.2.8.1.1.5", TEST_NOFIPS },
|
|
|
102646 |
- { GCRY_PK_ECC, "brainpoolP256r1", TEST_NOFIPS },
|
|
|
102646 |
- { GCRY_PK_ECC, "1.3.36.3.3.2.8.1.1.7", TEST_NOFIPS },
|
|
|
102646 |
- { GCRY_PK_ECC, "brainpoolP320r1", TEST_NOFIPS },
|
|
|
102646 |
- { GCRY_PK_ECC, "1.3.36.3.3.2.8.1.1.9", TEST_NOFIPS },
|
|
|
102646 |
- { GCRY_PK_ECC, "brainpoolP384r1", TEST_NOFIPS },
|
|
|
102646 |
- { GCRY_PK_ECC, "1.3.36.3.3.2.8.1.1.11", TEST_NOFIPS },
|
|
|
102646 |
- { GCRY_PK_ECC, "brainpoolP512r1", TEST_NOFIPS },
|
|
|
102646 |
- { GCRY_PK_ECC, "1.3.36.3.3.2.8.1.1.13", TEST_NOFIPS },
|
|
|
102646 |
+#ifdef ENABLE_BRAINPOOL
|
|
|
102646 |
+# define BRAINPOOL_FLAGS TEST_NOFIPS
|
|
|
102646 |
+#else
|
|
|
102646 |
+# define BRAINPOOL_FLAGS TEST_ERROR_EXPECTED
|
|
|
102646 |
+#endif /* ENABLE_BRAINPOOL */
|
|
|
102646 |
+ { GCRY_PK_ECC, "brainpoolP160r1", BRAINPOOL_FLAGS },
|
|
|
102646 |
+ { GCRY_PK_ECC, "1.3.36.3.3.2.8.1.1.1", BRAINPOOL_FLAGS },
|
|
|
102646 |
+ { GCRY_PK_ECC, "brainpoolP192r1", BRAINPOOL_FLAGS },
|
|
|
102646 |
+ { GCRY_PK_ECC, "1.3.36.3.3.2.8.1.1.3", BRAINPOOL_FLAGS },
|
|
|
102646 |
+ { GCRY_PK_ECC, "brainpoolP224r1", BRAINPOOL_FLAGS },
|
|
|
102646 |
+ { GCRY_PK_ECC, "1.3.36.3.3.2.8.1.1.5", BRAINPOOL_FLAGS },
|
|
|
102646 |
+ { GCRY_PK_ECC, "brainpoolP256r1", BRAINPOOL_FLAGS },
|
|
|
102646 |
+ { GCRY_PK_ECC, "1.3.36.3.3.2.8.1.1.7", BRAINPOOL_FLAGS },
|
|
|
102646 |
+ { GCRY_PK_ECC, "brainpoolP320r1", BRAINPOOL_FLAGS },
|
|
|
102646 |
+ { GCRY_PK_ECC, "1.3.36.3.3.2.8.1.1.9", BRAINPOOL_FLAGS },
|
|
|
102646 |
+ { GCRY_PK_ECC, "brainpoolP384r1", BRAINPOOL_FLAGS },
|
|
|
102646 |
+ { GCRY_PK_ECC, "1.3.36.3.3.2.8.1.1.11", BRAINPOOL_FLAGS },
|
|
|
102646 |
+ { GCRY_PK_ECC, "brainpoolP512r1", BRAINPOOL_FLAGS },
|
|
|
102646 |
+ { GCRY_PK_ECC, "1.3.36.3.3.2.8.1.1.13", BRAINPOOL_FLAGS },
|
|
|
102646 |
+#undef BRAINPOOL_ERROR_EXPECTED
|
|
|
102646 |
|
|
|
102646 |
{ GCRY_PK_ECC, "GOST2001-test", TEST_NOFIPS },
|
|
|
102646 |
{ GCRY_PK_ECC, "1.2.643.2.2.35.0", TEST_NOFIPS },
|
|
|
102646 |
@@ -282,6 +296,7 @@ check_get_params (void)
|
|
|
102646 |
|
|
|
102646 |
gcry_sexp_release (param);
|
|
|
102646 |
|
|
|
102646 |
+#ifdef ENABLE_BRAINPOOL
|
|
|
102646 |
if (!in_fips_mode)
|
|
|
102646 |
{
|
|
|
102646 |
param = gcry_pk_get_param (GCRY_PK_ECDSA, sample_key_2_curve);
|
|
|
102646 |
@@ -297,6 +312,7 @@ check_get_params (void)
|
|
|
102646 |
|
|
|
102646 |
gcry_sexp_release (param);
|
|
|
102646 |
}
|
|
|
102646 |
+#endif /* ENABLE_BRAINPOOL */
|
|
|
102646 |
|
|
|
102646 |
/* Some simple tests */
|
|
|
102646 |
for (idx=0; idx < DIM (tv); idx++)
|
|
|
102646 |
diff --git a/tests/keygrip.c b/tests/keygrip.c
|
|
|
102646 |
index 49bd71bc..fc4c17be 100644
|
|
|
102646 |
--- a/tests/keygrip.c
|
|
|
102646 |
+++ b/tests/keygrip.c
|
|
|
102646 |
@@ -149,6 +149,7 @@ static struct
|
|
|
102646 |
" (q #04C8A4CEC2E9A9BC8E173531A67B0840DF345C32E261ADD780E6D83D56EFADFD5DE872F8B854819B59543CE0B7F822330464FBC4E6324DADDCD9D059554F63B344#)))",
|
|
|
102646 |
"\xE6\xDF\x94\x2D\xBD\x8C\x77\x05\xA3\xDD\x41\x6E\xFC\x04\x01\xDB\x31\x0E\x99\xB6"
|
|
|
102646 |
},
|
|
|
102646 |
+#ifdef ENABLE_BRAINPOOL
|
|
|
102646 |
{
|
|
|
102646 |
GCRY_PK_ECC,
|
|
|
102646 |
"(public-key"
|
|
|
102646 |
@@ -197,6 +198,7 @@ static struct
|
|
|
102646 |
"\xD6\xE1\xBF\x43\xAC\x9B\x9A\x12\xE7\x3F",
|
|
|
102646 |
1
|
|
|
102646 |
},
|
|
|
102646 |
+#endif /*ENABLE_BRAINPOOL */
|
|
|
102646 |
{ /* Ed25519 standard */
|
|
|
102646 |
GCRY_PK_ECC,
|
|
|
102646 |
"(public-key"
|
|
|
102646 |
--
|
|
|
102646 |
2.34.1
|
|
|
102646 |
|