Compare commits
10 Commits
1dd9185aca
...
db6a8b0410
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
db6a8b0410 | ||
|
|
44db5ca7be | ||
|
|
b91aad889a | ||
|
|
fda38d4252 | ||
|
|
6c7dc4542b | ||
|
|
fab566823e | ||
|
|
23ac74f06b | ||
|
|
0938a362ac | ||
|
|
b47289b457 | ||
|
|
35aad6ef58 |
@ -1,82 +0,0 @@
|
||||
From 1374254c2904ab5b18ba4a890856824a102d4705 Mon Sep 17 00:00:00 2001
|
||||
From: Jussi Kivilinna <jussi.kivilinna@iki.fi>
|
||||
Date: Sat, 27 Apr 2019 19:33:28 +0300
|
||||
Subject: [PATCH 193/222] Prefetch GCM look-up tables
|
||||
|
||||
* cipher/cipher-gcm.c (prefetch_table, do_prefetch_tables)
|
||||
(prefetch_tables): New.
|
||||
(ghash_internal): Call prefetch_tables.
|
||||
--
|
||||
|
||||
Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
|
||||
---
|
||||
cipher/cipher-gcm.c | 33 +++++++++++++++++++++++++++++++++
|
||||
1 file changed, 33 insertions(+)
|
||||
|
||||
diff --git a/cipher/cipher-gcm.c b/cipher/cipher-gcm.c
|
||||
index c19f09f2..11f119aa 100644
|
||||
--- a/cipher/cipher-gcm.c
|
||||
+++ b/cipher/cipher-gcm.c
|
||||
@@ -118,6 +118,34 @@ static const u16 gcmR[256] = {
|
||||
0xbbf0, 0xba32, 0xb874, 0xb9b6, 0xbcf8, 0xbd3a, 0xbf7c, 0xbebe,
|
||||
};
|
||||
|
||||
+static inline
|
||||
+void prefetch_table(const void *tab, size_t len)
|
||||
+{
|
||||
+ const volatile byte *vtab = tab;
|
||||
+ size_t i;
|
||||
+
|
||||
+ for (i = 0; i < len; i += 8 * 32)
|
||||
+ {
|
||||
+ (void)vtab[i + 0 * 32];
|
||||
+ (void)vtab[i + 1 * 32];
|
||||
+ (void)vtab[i + 2 * 32];
|
||||
+ (void)vtab[i + 3 * 32];
|
||||
+ (void)vtab[i + 4 * 32];
|
||||
+ (void)vtab[i + 5 * 32];
|
||||
+ (void)vtab[i + 6 * 32];
|
||||
+ (void)vtab[i + 7 * 32];
|
||||
+ }
|
||||
+
|
||||
+ (void)vtab[len - 1];
|
||||
+}
|
||||
+
|
||||
+static inline void
|
||||
+do_prefetch_tables (const void *gcmM, size_t gcmM_size)
|
||||
+{
|
||||
+ prefetch_table(gcmM, gcmM_size);
|
||||
+ prefetch_table(gcmR, sizeof(gcmR));
|
||||
+}
|
||||
+
|
||||
#ifdef GCM_TABLES_USE_U64
|
||||
static void
|
||||
bshift (u64 * b0, u64 * b1)
|
||||
@@ -365,6 +393,8 @@ do_ghash (unsigned char *result, const unsigned char *buf, const u32 *gcmM)
|
||||
#define fillM(c) \
|
||||
do_fillM (c->u_mode.gcm.u_ghash_key.key, c->u_mode.gcm.gcm_table)
|
||||
#define GHASH(c, result, buf) do_ghash (result, buf, c->u_mode.gcm.gcm_table)
|
||||
+#define prefetch_tables(c) \
|
||||
+ do_prefetch_tables(c->u_mode.gcm.gcm_table, sizeof(c->u_mode.gcm.gcm_table))
|
||||
|
||||
#else
|
||||
|
||||
@@ -430,6 +460,7 @@ do_ghash (unsigned char *hsub, unsigned char *result, const unsigned char *buf)
|
||||
|
||||
#define fillM(c) do { } while (0)
|
||||
#define GHASH(c, result, buf) do_ghash (c->u_mode.gcm.u_ghash_key.key, result, buf)
|
||||
+#define prefetch_tables(c) do {} while (0)
|
||||
|
||||
#endif /* !GCM_USE_TABLES */
|
||||
|
||||
@@ -441,6 +472,8 @@ ghash_internal (gcry_cipher_hd_t c, byte *result, const byte *buf,
|
||||
const unsigned int blocksize = GCRY_GCM_BLOCK_LEN;
|
||||
unsigned int burn = 0;
|
||||
|
||||
+ prefetch_tables (c);
|
||||
+
|
||||
while (nblocks)
|
||||
{
|
||||
burn = GHASH (c, result, buf);
|
||||
--
|
||||
2.12.3
|
||||
@ -1,168 +0,0 @@
|
||||
From a4c561aab1014c3630bc88faf6f5246fee16b020 Mon Sep 17 00:00:00 2001
|
||||
From: Jussi Kivilinna <jussi.kivilinna@iki.fi>
|
||||
Date: Fri, 31 May 2019 17:27:25 +0300
|
||||
Subject: [PATCH] GCM: move look-up table to .data section and unshare between
|
||||
processes
|
||||
|
||||
* cipher/cipher-gcm.c (ATTR_ALIGNED_64): New.
|
||||
(gcmR): Move to 'gcm_table' structure.
|
||||
(gcm_table): New structure for look-up table with counters before and
|
||||
after.
|
||||
(gcmR): New macro.
|
||||
(prefetch_table): Handle input with length not multiple of 256.
|
||||
(do_prefetch_tables): Modify pre- and post-table counters to unshare
|
||||
look-up table pages between processes.
|
||||
--
|
||||
|
||||
GnuPG-bug-id: 4541
|
||||
Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
|
||||
---
|
||||
cipher/cipher-gcm.c | 106 +++++++++++++++++++++++++++++---------------
|
||||
1 file changed, 70 insertions(+), 36 deletions(-)
|
||||
|
||||
diff --git a/cipher/cipher-gcm.c b/cipher/cipher-gcm.c
|
||||
index 11f119aa..194e2ec9 100644
|
||||
--- a/cipher/cipher-gcm.c
|
||||
+++ b/cipher/cipher-gcm.c
|
||||
@@ -30,6 +30,14 @@
|
||||
#include "./cipher-internal.h"
|
||||
|
||||
|
||||
+/* Helper macro to force alignment to 16 or 64 bytes. */
|
||||
+#ifdef HAVE_GCC_ATTRIBUTE_ALIGNED
|
||||
+# define ATTR_ALIGNED_64 __attribute__ ((aligned (64)))
|
||||
+#else
|
||||
+# define ATTR_ALIGNED_64
|
||||
+#endif
|
||||
+
|
||||
+
|
||||
#ifdef GCM_USE_INTEL_PCLMUL
|
||||
extern void _gcry_ghash_setup_intel_pclmul (gcry_cipher_hd_t c);
|
||||
|
||||
@@ -83,40 +91,54 @@ ghash_armv7_neon (gcry_cipher_hd_t c, byte *result, const byte *buf,
|
||||
|
||||
|
||||
#ifdef GCM_USE_TABLES
|
||||
-static const u16 gcmR[256] = {
|
||||
- 0x0000, 0x01c2, 0x0384, 0x0246, 0x0708, 0x06ca, 0x048c, 0x054e,
|
||||
- 0x0e10, 0x0fd2, 0x0d94, 0x0c56, 0x0918, 0x08da, 0x0a9c, 0x0b5e,
|
||||
- 0x1c20, 0x1de2, 0x1fa4, 0x1e66, 0x1b28, 0x1aea, 0x18ac, 0x196e,
|
||||
- 0x1230, 0x13f2, 0x11b4, 0x1076, 0x1538, 0x14fa, 0x16bc, 0x177e,
|
||||
- 0x3840, 0x3982, 0x3bc4, 0x3a06, 0x3f48, 0x3e8a, 0x3ccc, 0x3d0e,
|
||||
- 0x3650, 0x3792, 0x35d4, 0x3416, 0x3158, 0x309a, 0x32dc, 0x331e,
|
||||
- 0x2460, 0x25a2, 0x27e4, 0x2626, 0x2368, 0x22aa, 0x20ec, 0x212e,
|
||||
- 0x2a70, 0x2bb2, 0x29f4, 0x2836, 0x2d78, 0x2cba, 0x2efc, 0x2f3e,
|
||||
- 0x7080, 0x7142, 0x7304, 0x72c6, 0x7788, 0x764a, 0x740c, 0x75ce,
|
||||
- 0x7e90, 0x7f52, 0x7d14, 0x7cd6, 0x7998, 0x785a, 0x7a1c, 0x7bde,
|
||||
- 0x6ca0, 0x6d62, 0x6f24, 0x6ee6, 0x6ba8, 0x6a6a, 0x682c, 0x69ee,
|
||||
- 0x62b0, 0x6372, 0x6134, 0x60f6, 0x65b8, 0x647a, 0x663c, 0x67fe,
|
||||
- 0x48c0, 0x4902, 0x4b44, 0x4a86, 0x4fc8, 0x4e0a, 0x4c4c, 0x4d8e,
|
||||
- 0x46d0, 0x4712, 0x4554, 0x4496, 0x41d8, 0x401a, 0x425c, 0x439e,
|
||||
- 0x54e0, 0x5522, 0x5764, 0x56a6, 0x53e8, 0x522a, 0x506c, 0x51ae,
|
||||
- 0x5af0, 0x5b32, 0x5974, 0x58b6, 0x5df8, 0x5c3a, 0x5e7c, 0x5fbe,
|
||||
- 0xe100, 0xe0c2, 0xe284, 0xe346, 0xe608, 0xe7ca, 0xe58c, 0xe44e,
|
||||
- 0xef10, 0xeed2, 0xec94, 0xed56, 0xe818, 0xe9da, 0xeb9c, 0xea5e,
|
||||
- 0xfd20, 0xfce2, 0xfea4, 0xff66, 0xfa28, 0xfbea, 0xf9ac, 0xf86e,
|
||||
- 0xf330, 0xf2f2, 0xf0b4, 0xf176, 0xf438, 0xf5fa, 0xf7bc, 0xf67e,
|
||||
- 0xd940, 0xd882, 0xdac4, 0xdb06, 0xde48, 0xdf8a, 0xddcc, 0xdc0e,
|
||||
- 0xd750, 0xd692, 0xd4d4, 0xd516, 0xd058, 0xd19a, 0xd3dc, 0xd21e,
|
||||
- 0xc560, 0xc4a2, 0xc6e4, 0xc726, 0xc268, 0xc3aa, 0xc1ec, 0xc02e,
|
||||
- 0xcb70, 0xcab2, 0xc8f4, 0xc936, 0xcc78, 0xcdba, 0xcffc, 0xce3e,
|
||||
- 0x9180, 0x9042, 0x9204, 0x93c6, 0x9688, 0x974a, 0x950c, 0x94ce,
|
||||
- 0x9f90, 0x9e52, 0x9c14, 0x9dd6, 0x9898, 0x995a, 0x9b1c, 0x9ade,
|
||||
- 0x8da0, 0x8c62, 0x8e24, 0x8fe6, 0x8aa8, 0x8b6a, 0x892c, 0x88ee,
|
||||
- 0x83b0, 0x8272, 0x8034, 0x81f6, 0x84b8, 0x857a, 0x873c, 0x86fe,
|
||||
- 0xa9c0, 0xa802, 0xaa44, 0xab86, 0xaec8, 0xaf0a, 0xad4c, 0xac8e,
|
||||
- 0xa7d0, 0xa612, 0xa454, 0xa596, 0xa0d8, 0xa11a, 0xa35c, 0xa29e,
|
||||
- 0xb5e0, 0xb422, 0xb664, 0xb7a6, 0xb2e8, 0xb32a, 0xb16c, 0xb0ae,
|
||||
- 0xbbf0, 0xba32, 0xb874, 0xb9b6, 0xbcf8, 0xbd3a, 0xbf7c, 0xbebe,
|
||||
-};
|
||||
+static struct
|
||||
+{
|
||||
+ volatile u32 counter_head;
|
||||
+ u32 cacheline_align[64 / 4 - 1];
|
||||
+ u16 R[256];
|
||||
+ volatile u32 counter_tail;
|
||||
+} gcm_table ATTR_ALIGNED_64 =
|
||||
+ {
|
||||
+ 0,
|
||||
+ { 0, },
|
||||
+ {
|
||||
+ 0x0000, 0x01c2, 0x0384, 0x0246, 0x0708, 0x06ca, 0x048c, 0x054e,
|
||||
+ 0x0e10, 0x0fd2, 0x0d94, 0x0c56, 0x0918, 0x08da, 0x0a9c, 0x0b5e,
|
||||
+ 0x1c20, 0x1de2, 0x1fa4, 0x1e66, 0x1b28, 0x1aea, 0x18ac, 0x196e,
|
||||
+ 0x1230, 0x13f2, 0x11b4, 0x1076, 0x1538, 0x14fa, 0x16bc, 0x177e,
|
||||
+ 0x3840, 0x3982, 0x3bc4, 0x3a06, 0x3f48, 0x3e8a, 0x3ccc, 0x3d0e,
|
||||
+ 0x3650, 0x3792, 0x35d4, 0x3416, 0x3158, 0x309a, 0x32dc, 0x331e,
|
||||
+ 0x2460, 0x25a2, 0x27e4, 0x2626, 0x2368, 0x22aa, 0x20ec, 0x212e,
|
||||
+ 0x2a70, 0x2bb2, 0x29f4, 0x2836, 0x2d78, 0x2cba, 0x2efc, 0x2f3e,
|
||||
+ 0x7080, 0x7142, 0x7304, 0x72c6, 0x7788, 0x764a, 0x740c, 0x75ce,
|
||||
+ 0x7e90, 0x7f52, 0x7d14, 0x7cd6, 0x7998, 0x785a, 0x7a1c, 0x7bde,
|
||||
+ 0x6ca0, 0x6d62, 0x6f24, 0x6ee6, 0x6ba8, 0x6a6a, 0x682c, 0x69ee,
|
||||
+ 0x62b0, 0x6372, 0x6134, 0x60f6, 0x65b8, 0x647a, 0x663c, 0x67fe,
|
||||
+ 0x48c0, 0x4902, 0x4b44, 0x4a86, 0x4fc8, 0x4e0a, 0x4c4c, 0x4d8e,
|
||||
+ 0x46d0, 0x4712, 0x4554, 0x4496, 0x41d8, 0x401a, 0x425c, 0x439e,
|
||||
+ 0x54e0, 0x5522, 0x5764, 0x56a6, 0x53e8, 0x522a, 0x506c, 0x51ae,
|
||||
+ 0x5af0, 0x5b32, 0x5974, 0x58b6, 0x5df8, 0x5c3a, 0x5e7c, 0x5fbe,
|
||||
+ 0xe100, 0xe0c2, 0xe284, 0xe346, 0xe608, 0xe7ca, 0xe58c, 0xe44e,
|
||||
+ 0xef10, 0xeed2, 0xec94, 0xed56, 0xe818, 0xe9da, 0xeb9c, 0xea5e,
|
||||
+ 0xfd20, 0xfce2, 0xfea4, 0xff66, 0xfa28, 0xfbea, 0xf9ac, 0xf86e,
|
||||
+ 0xf330, 0xf2f2, 0xf0b4, 0xf176, 0xf438, 0xf5fa, 0xf7bc, 0xf67e,
|
||||
+ 0xd940, 0xd882, 0xdac4, 0xdb06, 0xde48, 0xdf8a, 0xddcc, 0xdc0e,
|
||||
+ 0xd750, 0xd692, 0xd4d4, 0xd516, 0xd058, 0xd19a, 0xd3dc, 0xd21e,
|
||||
+ 0xc560, 0xc4a2, 0xc6e4, 0xc726, 0xc268, 0xc3aa, 0xc1ec, 0xc02e,
|
||||
+ 0xcb70, 0xcab2, 0xc8f4, 0xc936, 0xcc78, 0xcdba, 0xcffc, 0xce3e,
|
||||
+ 0x9180, 0x9042, 0x9204, 0x93c6, 0x9688, 0x974a, 0x950c, 0x94ce,
|
||||
+ 0x9f90, 0x9e52, 0x9c14, 0x9dd6, 0x9898, 0x995a, 0x9b1c, 0x9ade,
|
||||
+ 0x8da0, 0x8c62, 0x8e24, 0x8fe6, 0x8aa8, 0x8b6a, 0x892c, 0x88ee,
|
||||
+ 0x83b0, 0x8272, 0x8034, 0x81f6, 0x84b8, 0x857a, 0x873c, 0x86fe,
|
||||
+ 0xa9c0, 0xa802, 0xaa44, 0xab86, 0xaec8, 0xaf0a, 0xad4c, 0xac8e,
|
||||
+ 0xa7d0, 0xa612, 0xa454, 0xa596, 0xa0d8, 0xa11a, 0xa35c, 0xa29e,
|
||||
+ 0xb5e0, 0xb422, 0xb664, 0xb7a6, 0xb2e8, 0xb32a, 0xb16c, 0xb0ae,
|
||||
+ 0xbbf0, 0xba32, 0xb874, 0xb9b6, 0xbcf8, 0xbd3a, 0xbf7c, 0xbebe,
|
||||
+ },
|
||||
+ 0
|
||||
+ };
|
||||
+
|
||||
+#define gcmR gcm_table.R
|
||||
|
||||
static inline
|
||||
void prefetch_table(const void *tab, size_t len)
|
||||
@@ -124,7 +146,7 @@ void prefetch_table(const void *tab, size_t len)
|
||||
const volatile byte *vtab = tab;
|
||||
size_t i;
|
||||
|
||||
- for (i = 0; i < len; i += 8 * 32)
|
||||
+ for (i = 0; len - i >= 8 * 32; i += 8 * 32)
|
||||
{
|
||||
(void)vtab[i + 0 * 32];
|
||||
(void)vtab[i + 1 * 32];
|
||||
@@ -135,6 +157,10 @@ void prefetch_table(const void *tab, size_t len)
|
||||
(void)vtab[i + 6 * 32];
|
||||
(void)vtab[i + 7 * 32];
|
||||
}
|
||||
+ for (; i < len; i += 32)
|
||||
+ {
|
||||
+ (void)vtab[i];
|
||||
+ }
|
||||
|
||||
(void)vtab[len - 1];
|
||||
}
|
||||
@@ -142,8 +168,16 @@ void prefetch_table(const void *tab, size_t len)
|
||||
static inline void
|
||||
do_prefetch_tables (const void *gcmM, size_t gcmM_size)
|
||||
{
|
||||
+ /* Modify counters to trigger copy-on-write and unsharing if physical pages
|
||||
+ * of look-up table are shared between processes. Modifying counters also
|
||||
+ * causes checksums for pages to change and hint same-page merging algorithm
|
||||
+ * that these pages are frequently changing. */
|
||||
+ gcm_table.counter_head++;
|
||||
+ gcm_table.counter_tail++;
|
||||
+
|
||||
+ /* Prefetch look-up tables to cache. */
|
||||
prefetch_table(gcmM, gcmM_size);
|
||||
- prefetch_table(gcmR, sizeof(gcmR));
|
||||
+ prefetch_table(&gcm_table, sizeof(gcm_table));
|
||||
}
|
||||
|
||||
#ifdef GCM_TABLES_USE_U64
|
||||
@ -1,323 +0,0 @@
|
||||
From daedbbb5541cd8ecda1459d3b843ea4d92788762 Mon Sep 17 00:00:00 2001
|
||||
From: Jussi Kivilinna <jussi.kivilinna@iki.fi>
|
||||
Date: Fri, 31 May 2019 17:18:09 +0300
|
||||
Subject: [PATCH] AES: move look-up tables to .data section and unshare between
|
||||
processes
|
||||
|
||||
* cipher/rijndael-internal.h (ATTR_ALIGNED_64): New.
|
||||
* cipher/rijndael-tables.h (encT): Move to 'enc_tables' structure.
|
||||
(enc_tables): New structure for encryption table with counters before
|
||||
and after.
|
||||
(encT): New macro.
|
||||
(dec_tables): Add counters before and after encryption table; Move
|
||||
from .rodata to .data section.
|
||||
(do_encrypt): Change 'encT' to 'enc_tables.T'.
|
||||
(do_decrypt): Change '&dec_tables' to 'dec_tables.T'.
|
||||
* cipher/cipher-gcm.c (prefetch_table): Make inline; Handle input
|
||||
with length not multiple of 256.
|
||||
(prefetch_enc, prefetch_dec): Modify pre- and post-table counters
|
||||
to unshare look-up table pages between processes.
|
||||
--
|
||||
|
||||
GnuPG-bug-id: 4541
|
||||
Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
|
||||
---
|
||||
cipher/rijndael-internal.h | 4 +-
|
||||
cipher/rijndael-tables.h | 155 +++++++++++++++++++++----------------
|
||||
cipher/rijndael.c | 35 +++++++--
|
||||
3 files changed, 118 insertions(+), 76 deletions(-)
|
||||
|
||||
diff --git a/cipher/rijndael-internal.h b/cipher/rijndael-internal.h
|
||||
index 160fb8c..a62d4b7 100644
|
||||
--- a/cipher/rijndael-internal.h
|
||||
+++ b/cipher/rijndael-internal.h
|
||||
@@ -29,11 +29,13 @@
|
||||
#define BLOCKSIZE (128/8)
|
||||
|
||||
|
||||
-/* Helper macro to force alignment to 16 bytes. */
|
||||
+/* Helper macro to force alignment to 16 or 64 bytes. */
|
||||
#ifdef HAVE_GCC_ATTRIBUTE_ALIGNED
|
||||
# define ATTR_ALIGNED_16 __attribute__ ((aligned (16)))
|
||||
+# define ATTR_ALIGNED_64 __attribute__ ((aligned (64)))
|
||||
#else
|
||||
# define ATTR_ALIGNED_16
|
||||
+# define ATTR_ALIGNED_64
|
||||
#endif
|
||||
|
||||
|
||||
diff --git a/cipher/rijndael-tables.h b/cipher/rijndael-tables.h
|
||||
index 8359470..b54d959 100644
|
||||
--- a/cipher/rijndael-tables.h
|
||||
+++ b/cipher/rijndael-tables.h
|
||||
@@ -21,80 +21,98 @@
|
||||
/* To keep the actual implementation at a readable size we use this
|
||||
include file to define the tables. */
|
||||
|
||||
-static const u32 encT[256] =
|
||||
+static struct
|
||||
+{
|
||||
+ volatile u32 counter_head;
|
||||
+ u32 cacheline_align[64 / 4 - 1];
|
||||
+ u32 T[256];
|
||||
+ volatile u32 counter_tail;
|
||||
+} enc_tables ATTR_ALIGNED_64 =
|
||||
{
|
||||
- 0xa56363c6, 0x847c7cf8, 0x997777ee, 0x8d7b7bf6,
|
||||
- 0x0df2f2ff, 0xbd6b6bd6, 0xb16f6fde, 0x54c5c591,
|
||||
- 0x50303060, 0x03010102, 0xa96767ce, 0x7d2b2b56,
|
||||
- 0x19fefee7, 0x62d7d7b5, 0xe6abab4d, 0x9a7676ec,
|
||||
- 0x45caca8f, 0x9d82821f, 0x40c9c989, 0x877d7dfa,
|
||||
- 0x15fafaef, 0xeb5959b2, 0xc947478e, 0x0bf0f0fb,
|
||||
- 0xecadad41, 0x67d4d4b3, 0xfda2a25f, 0xeaafaf45,
|
||||
- 0xbf9c9c23, 0xf7a4a453, 0x967272e4, 0x5bc0c09b,
|
||||
- 0xc2b7b775, 0x1cfdfde1, 0xae93933d, 0x6a26264c,
|
||||
- 0x5a36366c, 0x413f3f7e, 0x02f7f7f5, 0x4fcccc83,
|
||||
- 0x5c343468, 0xf4a5a551, 0x34e5e5d1, 0x08f1f1f9,
|
||||
- 0x937171e2, 0x73d8d8ab, 0x53313162, 0x3f15152a,
|
||||
- 0x0c040408, 0x52c7c795, 0x65232346, 0x5ec3c39d,
|
||||
- 0x28181830, 0xa1969637, 0x0f05050a, 0xb59a9a2f,
|
||||
- 0x0907070e, 0x36121224, 0x9b80801b, 0x3de2e2df,
|
||||
- 0x26ebebcd, 0x6927274e, 0xcdb2b27f, 0x9f7575ea,
|
||||
- 0x1b090912, 0x9e83831d, 0x742c2c58, 0x2e1a1a34,
|
||||
- 0x2d1b1b36, 0xb26e6edc, 0xee5a5ab4, 0xfba0a05b,
|
||||
- 0xf65252a4, 0x4d3b3b76, 0x61d6d6b7, 0xceb3b37d,
|
||||
- 0x7b292952, 0x3ee3e3dd, 0x712f2f5e, 0x97848413,
|
||||
- 0xf55353a6, 0x68d1d1b9, 0x00000000, 0x2cededc1,
|
||||
- 0x60202040, 0x1ffcfce3, 0xc8b1b179, 0xed5b5bb6,
|
||||
- 0xbe6a6ad4, 0x46cbcb8d, 0xd9bebe67, 0x4b393972,
|
||||
- 0xde4a4a94, 0xd44c4c98, 0xe85858b0, 0x4acfcf85,
|
||||
- 0x6bd0d0bb, 0x2aefefc5, 0xe5aaaa4f, 0x16fbfbed,
|
||||
- 0xc5434386, 0xd74d4d9a, 0x55333366, 0x94858511,
|
||||
- 0xcf45458a, 0x10f9f9e9, 0x06020204, 0x817f7ffe,
|
||||
- 0xf05050a0, 0x443c3c78, 0xba9f9f25, 0xe3a8a84b,
|
||||
- 0xf35151a2, 0xfea3a35d, 0xc0404080, 0x8a8f8f05,
|
||||
- 0xad92923f, 0xbc9d9d21, 0x48383870, 0x04f5f5f1,
|
||||
- 0xdfbcbc63, 0xc1b6b677, 0x75dadaaf, 0x63212142,
|
||||
- 0x30101020, 0x1affffe5, 0x0ef3f3fd, 0x6dd2d2bf,
|
||||
- 0x4ccdcd81, 0x140c0c18, 0x35131326, 0x2fececc3,
|
||||
- 0xe15f5fbe, 0xa2979735, 0xcc444488, 0x3917172e,
|
||||
- 0x57c4c493, 0xf2a7a755, 0x827e7efc, 0x473d3d7a,
|
||||
- 0xac6464c8, 0xe75d5dba, 0x2b191932, 0x957373e6,
|
||||
- 0xa06060c0, 0x98818119, 0xd14f4f9e, 0x7fdcdca3,
|
||||
- 0x66222244, 0x7e2a2a54, 0xab90903b, 0x8388880b,
|
||||
- 0xca46468c, 0x29eeeec7, 0xd3b8b86b, 0x3c141428,
|
||||
- 0x79dedea7, 0xe25e5ebc, 0x1d0b0b16, 0x76dbdbad,
|
||||
- 0x3be0e0db, 0x56323264, 0x4e3a3a74, 0x1e0a0a14,
|
||||
- 0xdb494992, 0x0a06060c, 0x6c242448, 0xe45c5cb8,
|
||||
- 0x5dc2c29f, 0x6ed3d3bd, 0xefacac43, 0xa66262c4,
|
||||
- 0xa8919139, 0xa4959531, 0x37e4e4d3, 0x8b7979f2,
|
||||
- 0x32e7e7d5, 0x43c8c88b, 0x5937376e, 0xb76d6dda,
|
||||
- 0x8c8d8d01, 0x64d5d5b1, 0xd24e4e9c, 0xe0a9a949,
|
||||
- 0xb46c6cd8, 0xfa5656ac, 0x07f4f4f3, 0x25eaeacf,
|
||||
- 0xaf6565ca, 0x8e7a7af4, 0xe9aeae47, 0x18080810,
|
||||
- 0xd5baba6f, 0x887878f0, 0x6f25254a, 0x722e2e5c,
|
||||
- 0x241c1c38, 0xf1a6a657, 0xc7b4b473, 0x51c6c697,
|
||||
- 0x23e8e8cb, 0x7cdddda1, 0x9c7474e8, 0x211f1f3e,
|
||||
- 0xdd4b4b96, 0xdcbdbd61, 0x868b8b0d, 0x858a8a0f,
|
||||
- 0x907070e0, 0x423e3e7c, 0xc4b5b571, 0xaa6666cc,
|
||||
- 0xd8484890, 0x05030306, 0x01f6f6f7, 0x120e0e1c,
|
||||
- 0xa36161c2, 0x5f35356a, 0xf95757ae, 0xd0b9b969,
|
||||
- 0x91868617, 0x58c1c199, 0x271d1d3a, 0xb99e9e27,
|
||||
- 0x38e1e1d9, 0x13f8f8eb, 0xb398982b, 0x33111122,
|
||||
- 0xbb6969d2, 0x70d9d9a9, 0x898e8e07, 0xa7949433,
|
||||
- 0xb69b9b2d, 0x221e1e3c, 0x92878715, 0x20e9e9c9,
|
||||
- 0x49cece87, 0xff5555aa, 0x78282850, 0x7adfdfa5,
|
||||
- 0x8f8c8c03, 0xf8a1a159, 0x80898909, 0x170d0d1a,
|
||||
- 0xdabfbf65, 0x31e6e6d7, 0xc6424284, 0xb86868d0,
|
||||
- 0xc3414182, 0xb0999929, 0x772d2d5a, 0x110f0f1e,
|
||||
- 0xcbb0b07b, 0xfc5454a8, 0xd6bbbb6d, 0x3a16162c
|
||||
+ 0,
|
||||
+ { 0, },
|
||||
+ {
|
||||
+ 0xa56363c6, 0x847c7cf8, 0x997777ee, 0x8d7b7bf6,
|
||||
+ 0x0df2f2ff, 0xbd6b6bd6, 0xb16f6fde, 0x54c5c591,
|
||||
+ 0x50303060, 0x03010102, 0xa96767ce, 0x7d2b2b56,
|
||||
+ 0x19fefee7, 0x62d7d7b5, 0xe6abab4d, 0x9a7676ec,
|
||||
+ 0x45caca8f, 0x9d82821f, 0x40c9c989, 0x877d7dfa,
|
||||
+ 0x15fafaef, 0xeb5959b2, 0xc947478e, 0x0bf0f0fb,
|
||||
+ 0xecadad41, 0x67d4d4b3, 0xfda2a25f, 0xeaafaf45,
|
||||
+ 0xbf9c9c23, 0xf7a4a453, 0x967272e4, 0x5bc0c09b,
|
||||
+ 0xc2b7b775, 0x1cfdfde1, 0xae93933d, 0x6a26264c,
|
||||
+ 0x5a36366c, 0x413f3f7e, 0x02f7f7f5, 0x4fcccc83,
|
||||
+ 0x5c343468, 0xf4a5a551, 0x34e5e5d1, 0x08f1f1f9,
|
||||
+ 0x937171e2, 0x73d8d8ab, 0x53313162, 0x3f15152a,
|
||||
+ 0x0c040408, 0x52c7c795, 0x65232346, 0x5ec3c39d,
|
||||
+ 0x28181830, 0xa1969637, 0x0f05050a, 0xb59a9a2f,
|
||||
+ 0x0907070e, 0x36121224, 0x9b80801b, 0x3de2e2df,
|
||||
+ 0x26ebebcd, 0x6927274e, 0xcdb2b27f, 0x9f7575ea,
|
||||
+ 0x1b090912, 0x9e83831d, 0x742c2c58, 0x2e1a1a34,
|
||||
+ 0x2d1b1b36, 0xb26e6edc, 0xee5a5ab4, 0xfba0a05b,
|
||||
+ 0xf65252a4, 0x4d3b3b76, 0x61d6d6b7, 0xceb3b37d,
|
||||
+ 0x7b292952, 0x3ee3e3dd, 0x712f2f5e, 0x97848413,
|
||||
+ 0xf55353a6, 0x68d1d1b9, 0x00000000, 0x2cededc1,
|
||||
+ 0x60202040, 0x1ffcfce3, 0xc8b1b179, 0xed5b5bb6,
|
||||
+ 0xbe6a6ad4, 0x46cbcb8d, 0xd9bebe67, 0x4b393972,
|
||||
+ 0xde4a4a94, 0xd44c4c98, 0xe85858b0, 0x4acfcf85,
|
||||
+ 0x6bd0d0bb, 0x2aefefc5, 0xe5aaaa4f, 0x16fbfbed,
|
||||
+ 0xc5434386, 0xd74d4d9a, 0x55333366, 0x94858511,
|
||||
+ 0xcf45458a, 0x10f9f9e9, 0x06020204, 0x817f7ffe,
|
||||
+ 0xf05050a0, 0x443c3c78, 0xba9f9f25, 0xe3a8a84b,
|
||||
+ 0xf35151a2, 0xfea3a35d, 0xc0404080, 0x8a8f8f05,
|
||||
+ 0xad92923f, 0xbc9d9d21, 0x48383870, 0x04f5f5f1,
|
||||
+ 0xdfbcbc63, 0xc1b6b677, 0x75dadaaf, 0x63212142,
|
||||
+ 0x30101020, 0x1affffe5, 0x0ef3f3fd, 0x6dd2d2bf,
|
||||
+ 0x4ccdcd81, 0x140c0c18, 0x35131326, 0x2fececc3,
|
||||
+ 0xe15f5fbe, 0xa2979735, 0xcc444488, 0x3917172e,
|
||||
+ 0x57c4c493, 0xf2a7a755, 0x827e7efc, 0x473d3d7a,
|
||||
+ 0xac6464c8, 0xe75d5dba, 0x2b191932, 0x957373e6,
|
||||
+ 0xa06060c0, 0x98818119, 0xd14f4f9e, 0x7fdcdca3,
|
||||
+ 0x66222244, 0x7e2a2a54, 0xab90903b, 0x8388880b,
|
||||
+ 0xca46468c, 0x29eeeec7, 0xd3b8b86b, 0x3c141428,
|
||||
+ 0x79dedea7, 0xe25e5ebc, 0x1d0b0b16, 0x76dbdbad,
|
||||
+ 0x3be0e0db, 0x56323264, 0x4e3a3a74, 0x1e0a0a14,
|
||||
+ 0xdb494992, 0x0a06060c, 0x6c242448, 0xe45c5cb8,
|
||||
+ 0x5dc2c29f, 0x6ed3d3bd, 0xefacac43, 0xa66262c4,
|
||||
+ 0xa8919139, 0xa4959531, 0x37e4e4d3, 0x8b7979f2,
|
||||
+ 0x32e7e7d5, 0x43c8c88b, 0x5937376e, 0xb76d6dda,
|
||||
+ 0x8c8d8d01, 0x64d5d5b1, 0xd24e4e9c, 0xe0a9a949,
|
||||
+ 0xb46c6cd8, 0xfa5656ac, 0x07f4f4f3, 0x25eaeacf,
|
||||
+ 0xaf6565ca, 0x8e7a7af4, 0xe9aeae47, 0x18080810,
|
||||
+ 0xd5baba6f, 0x887878f0, 0x6f25254a, 0x722e2e5c,
|
||||
+ 0x241c1c38, 0xf1a6a657, 0xc7b4b473, 0x51c6c697,
|
||||
+ 0x23e8e8cb, 0x7cdddda1, 0x9c7474e8, 0x211f1f3e,
|
||||
+ 0xdd4b4b96, 0xdcbdbd61, 0x868b8b0d, 0x858a8a0f,
|
||||
+ 0x907070e0, 0x423e3e7c, 0xc4b5b571, 0xaa6666cc,
|
||||
+ 0xd8484890, 0x05030306, 0x01f6f6f7, 0x120e0e1c,
|
||||
+ 0xa36161c2, 0x5f35356a, 0xf95757ae, 0xd0b9b969,
|
||||
+ 0x91868617, 0x58c1c199, 0x271d1d3a, 0xb99e9e27,
|
||||
+ 0x38e1e1d9, 0x13f8f8eb, 0xb398982b, 0x33111122,
|
||||
+ 0xbb6969d2, 0x70d9d9a9, 0x898e8e07, 0xa7949433,
|
||||
+ 0xb69b9b2d, 0x221e1e3c, 0x92878715, 0x20e9e9c9,
|
||||
+ 0x49cece87, 0xff5555aa, 0x78282850, 0x7adfdfa5,
|
||||
+ 0x8f8c8c03, 0xf8a1a159, 0x80898909, 0x170d0d1a,
|
||||
+ 0xdabfbf65, 0x31e6e6d7, 0xc6424284, 0xb86868d0,
|
||||
+ 0xc3414182, 0xb0999929, 0x772d2d5a, 0x110f0f1e,
|
||||
+ 0xcbb0b07b, 0xfc5454a8, 0xd6bbbb6d, 0x3a16162c
|
||||
+ },
|
||||
+ 0
|
||||
};
|
||||
|
||||
-static const struct
|
||||
+#define encT enc_tables.T
|
||||
+
|
||||
+static struct
|
||||
{
|
||||
+ volatile u32 counter_head;
|
||||
+ u32 cacheline_align[64 / 4 - 1];
|
||||
u32 T[256];
|
||||
byte inv_sbox[256];
|
||||
-} dec_tables =
|
||||
+ volatile u32 counter_tail;
|
||||
+} dec_tables ATTR_ALIGNED_64 =
|
||||
{
|
||||
+ 0,
|
||||
+ { 0, },
|
||||
{
|
||||
0x50a7f451, 0x5365417e, 0xc3a4171a, 0x965e273a,
|
||||
0xcb6bab3b, 0xf1459d1f, 0xab58faac, 0x9303e34b,
|
||||
@@ -194,7 +212,8 @@ static const struct
|
||||
0xc8,0xeb,0xbb,0x3c,0x83,0x53,0x99,0x61,
|
||||
0x17,0x2b,0x04,0x7e,0xba,0x77,0xd6,0x26,
|
||||
0xe1,0x69,0x14,0x63,0x55,0x21,0x0c,0x7d
|
||||
- }
|
||||
+ },
|
||||
+ 0
|
||||
};
|
||||
|
||||
#define decT dec_tables.T
|
||||
diff --git a/cipher/rijndael.c b/cipher/rijndael.c
|
||||
index 8637195..d0edab2 100644
|
||||
--- a/cipher/rijndael.c
|
||||
+++ b/cipher/rijndael.c
|
||||
@@ -227,11 +227,11 @@ static const char *selftest(void);
|
||||
|
||||
|
||||
/* Prefetching for encryption/decryption tables. */
|
||||
-static void prefetch_table(const volatile byte *tab, size_t len)
|
||||
+static inline void prefetch_table(const volatile byte *tab, size_t len)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
- for (i = 0; i < len; i += 8 * 32)
|
||||
+ for (i = 0; len - i >= 8 * 32; i += 8 * 32)
|
||||
{
|
||||
(void)tab[i + 0 * 32];
|
||||
(void)tab[i + 1 * 32];
|
||||
@@ -242,17 +242,37 @@ static void prefetch_table(const volatile byte *tab, size_t len)
|
||||
(void)tab[i + 6 * 32];
|
||||
(void)tab[i + 7 * 32];
|
||||
}
|
||||
+ for (; i < len; i += 32)
|
||||
+ {
|
||||
+ (void)tab[i];
|
||||
+ }
|
||||
|
||||
(void)tab[len - 1];
|
||||
}
|
||||
|
||||
static void prefetch_enc(void)
|
||||
{
|
||||
- prefetch_table((const void *)encT, sizeof(encT));
|
||||
+ /* Modify counters to trigger copy-on-write and unsharing if physical pages
|
||||
+ * of look-up table are shared between processes. Modifying counters also
|
||||
+ * causes checksums for pages to change and hint same-page merging algorithm
|
||||
+ * that these pages are frequently changing. */
|
||||
+ enc_tables.counter_head++;
|
||||
+ enc_tables.counter_tail++;
|
||||
+
|
||||
+ /* Prefetch look-up tables to cache. */
|
||||
+ prefetch_table((const void *)&enc_tables, sizeof(enc_tables));
|
||||
}
|
||||
|
||||
static void prefetch_dec(void)
|
||||
{
|
||||
+ /* Modify counters to trigger copy-on-write and unsharing if physical pages
|
||||
+ * of look-up table are shared between processes. Modifying counters also
|
||||
+ * causes checksums for pages to change and hint same-page merging algorithm
|
||||
+ * that these pages are frequently changing. */
|
||||
+ dec_tables.counter_head++;
|
||||
+ dec_tables.counter_tail++;
|
||||
+
|
||||
+ /* Prefetch look-up tables to cache. */
|
||||
prefetch_table((const void *)&dec_tables, sizeof(dec_tables));
|
||||
}
|
||||
|
||||
@@ -737,7 +757,7 @@ do_encrypt (const RIJNDAEL_context *ctx,
|
||||
#ifdef USE_AMD64_ASM
|
||||
# ifdef HAVE_COMPATIBLE_GCC_AMD64_PLATFORM_AS
|
||||
return _gcry_aes_amd64_encrypt_block(ctx->keyschenc, bx, ax, ctx->rounds,
|
||||
- encT);
|
||||
+ enc_tables.T);
|
||||
# else
|
||||
/* Call SystemV ABI function without storing non-volatile XMM registers,
|
||||
* as target function does not use vector instruction sets. */
|
||||
@@ -757,7 +777,8 @@ do_encrypt (const RIJNDAEL_context *ctx,
|
||||
return ret;
|
||||
# endif /* HAVE_COMPATIBLE_GCC_AMD64_PLATFORM_AS */
|
||||
#elif defined(USE_ARM_ASM)
|
||||
- return _gcry_aes_arm_encrypt_block(ctx->keyschenc, bx, ax, ctx->rounds, encT);
|
||||
+ return _gcry_aes_arm_encrypt_block(ctx->keyschenc, bx, ax, ctx->rounds,
|
||||
+ enc_tables.T);
|
||||
#else
|
||||
return do_encrypt_fn (ctx, bx, ax);
|
||||
#endif /* !USE_ARM_ASM && !USE_AMD64_ASM*/
|
||||
@@ -1120,7 +1141,7 @@ do_decrypt (const RIJNDAEL_context *ctx, unsigned char *bx,
|
||||
#ifdef USE_AMD64_ASM
|
||||
# ifdef HAVE_COMPATIBLE_GCC_AMD64_PLATFORM_AS
|
||||
return _gcry_aes_amd64_decrypt_block(ctx->keyschdec, bx, ax, ctx->rounds,
|
||||
- &dec_tables);
|
||||
+ dec_tables.T);
|
||||
# else
|
||||
/* Call SystemV ABI function without storing non-volatile XMM registers,
|
||||
* as target function does not use vector instruction sets. */
|
||||
@@ -1141,7 +1162,7 @@ do_decrypt (const RIJNDAEL_context *ctx, unsigned char *bx,
|
||||
# endif /* HAVE_COMPATIBLE_GCC_AMD64_PLATFORM_AS */
|
||||
#elif defined(USE_ARM_ASM)
|
||||
return _gcry_aes_arm_decrypt_block(ctx->keyschdec, bx, ax, ctx->rounds,
|
||||
- &dec_tables);
|
||||
+ dec_tables.T);
|
||||
#else
|
||||
return do_decrypt_fn (ctx, bx, ax);
|
||||
#endif /*!USE_ARM_ASM && !USE_AMD64_ASM*/
|
||||
|
||||
@ -1,73 +0,0 @@
|
||||
From e8b7f10be275bcedb5fc05ed4837a89bfd605c61 Mon Sep 17 00:00:00 2001
|
||||
From: NIIBE Yutaka <gniibe@fsij.org>
|
||||
Date: Tue, 13 Apr 2021 10:00:00 +0900
|
||||
Subject: [PATCH] cipher: Hardening ElGamal by introducing exponent blinding
|
||||
too.
|
||||
|
||||
* cipher/elgamal.c (do_encrypt): Also do exponent blinding.
|
||||
|
||||
--
|
||||
|
||||
Base blinding had been introduced with USE_BLINDING. This patch add
|
||||
exponent blinding as well to mitigate side-channel attack on mpi_powm.
|
||||
|
||||
GnuPG-bug-id: 5328
|
||||
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
|
||||
---
|
||||
cipher/elgamal.c | 20 +++++++++++++++++---
|
||||
1 file changed, 17 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/cipher/elgamal.c b/cipher/elgamal.c
|
||||
index 4eb52d6..9835122 100644
|
||||
--- a/cipher/elgamal.c
|
||||
+++ b/cipher/elgamal.c
|
||||
@@ -522,8 +522,9 @@ do_encrypt(gcry_mpi_t a, gcry_mpi_t b, gcry_mpi_t input, ELG_public_key *pkey )
|
||||
static void
|
||||
decrypt (gcry_mpi_t output, gcry_mpi_t a, gcry_mpi_t b, ELG_secret_key *skey )
|
||||
{
|
||||
- gcry_mpi_t t1, t2, r;
|
||||
+ gcry_mpi_t t1, t2, r, r1, h;
|
||||
unsigned int nbits = mpi_get_nbits (skey->p);
|
||||
+ gcry_mpi_t x_blind;
|
||||
|
||||
mpi_normalize (a);
|
||||
mpi_normalize (b);
|
||||
@@ -534,20 +535,33 @@ decrypt (gcry_mpi_t output, gcry_mpi_t a, gcry_mpi_t b, ELG_secret_key *skey )
|
||||
|
||||
t2 = mpi_snew (nbits);
|
||||
r = mpi_new (nbits);
|
||||
+ r1 = mpi_new (nbits);
|
||||
+ h = mpi_new (nbits);
|
||||
+ x_blind = mpi_snew (nbits);
|
||||
|
||||
/* We need a random number of about the prime size. The random
|
||||
number merely needs to be unpredictable; thus we use level 0. */
|
||||
_gcry_mpi_randomize (r, nbits, GCRY_WEAK_RANDOM);
|
||||
|
||||
+ /* Also, exponent blinding: x_blind = x + (p-1)*r1 */
|
||||
+ _gcry_mpi_randomize (r1, nbits, GCRY_WEAK_RANDOM);
|
||||
+ mpi_set_highbit (r1, nbits - 1);
|
||||
+ mpi_sub_ui (h, skey->p, 1);
|
||||
+ mpi_mul (x_blind, h, r1);
|
||||
+ mpi_add (x_blind, skey->x, x_blind);
|
||||
+
|
||||
/* t1 = r^x mod p */
|
||||
- mpi_powm (t1, r, skey->x, skey->p);
|
||||
+ mpi_powm (t1, r, x_blind, skey->p);
|
||||
/* t2 = (a * r)^-x mod p */
|
||||
mpi_mulm (t2, a, r, skey->p);
|
||||
- mpi_powm (t2, t2, skey->x, skey->p);
|
||||
+ mpi_powm (t2, t2, x_blind, skey->p);
|
||||
mpi_invm (t2, t2, skey->p);
|
||||
/* t1 = (t1 * t2) mod p*/
|
||||
mpi_mulm (t1, t1, t2, skey->p);
|
||||
|
||||
+ mpi_free (x_blind);
|
||||
+ mpi_free (h);
|
||||
+ mpi_free (r1);
|
||||
mpi_free (r);
|
||||
mpi_free (t2);
|
||||
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
@ -1,105 +0,0 @@
|
||||
From 3462280f2e23e16adf3ed5176e0f2413d8861320 Mon Sep 17 00:00:00 2001
|
||||
From: NIIBE Yutaka <gniibe@fsij.org>
|
||||
Date: Fri, 21 May 2021 11:15:07 +0900
|
||||
Subject: [PATCH] cipher: Fix ElGamal encryption for other implementations.
|
||||
|
||||
* cipher/elgamal.c (gen_k): Remove support of smaller K.
|
||||
(do_encrypt): Never use smaller K.
|
||||
(sign): Folllow the change of gen_k.
|
||||
|
||||
--
|
||||
|
||||
Cherry-pick master commit of:
|
||||
632d80ef30e13de6926d503aa697f92b5dbfbc5e
|
||||
|
||||
This change basically reverts encryption changes in two commits:
|
||||
|
||||
74386120dad6b3da62db37f7044267c8ef34689b
|
||||
78531373a342aeb847950f404343a05e36022065
|
||||
|
||||
Use of smaller K for ephemeral key in ElGamal encryption is only good,
|
||||
when we can guarantee that recipient's key is generated by our
|
||||
implementation (or compatible).
|
||||
|
||||
For detail, please see:
|
||||
|
||||
Luca De Feo, Bertram Poettering, Alessandro Sorniotti,
|
||||
"On the (in)security of ElGamal in OpenPGP";
|
||||
in the proceedings of CCS'2021.
|
||||
|
||||
CVE-id: CVE-2021-33560(This patch actually modifies CVE-2021-40528,see:https://dev.gnupg.org/T5328#149606)
|
||||
GnuPG-bug-id: 5328
|
||||
Suggested-by: Luca De Feo, Bertram Poettering, Alessandro Sorniotti
|
||||
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
|
||||
---
|
||||
cipher/elgamal.c | 24 ++++++------------------
|
||||
1 file changed, 6 insertions(+), 18 deletions(-)
|
||||
|
||||
diff --git a/cipher/elgamal.c b/cipher/elgamal.c
|
||||
index 9835122..eead450 100644
|
||||
--- a/cipher/elgamal.c
|
||||
+++ b/cipher/elgamal.c
|
||||
@@ -66,7 +66,7 @@ static const char *elg_names[] =
|
||||
|
||||
|
||||
static int test_keys (ELG_secret_key *sk, unsigned int nbits, int nodie);
|
||||
-static gcry_mpi_t gen_k (gcry_mpi_t p, int small_k);
|
||||
+static gcry_mpi_t gen_k (gcry_mpi_t p);
|
||||
static gcry_err_code_t generate (ELG_secret_key *sk, unsigned nbits,
|
||||
gcry_mpi_t **factors);
|
||||
static int check_secret_key (ELG_secret_key *sk);
|
||||
@@ -189,11 +189,10 @@ test_keys ( ELG_secret_key *sk, unsigned int nbits, int nodie )
|
||||
|
||||
/****************
|
||||
* Generate a random secret exponent k from prime p, so that k is
|
||||
- * relatively prime to p-1. With SMALL_K set, k will be selected for
|
||||
- * better encryption performance - this must never be used signing!
|
||||
+ * relatively prime to p-1.
|
||||
*/
|
||||
static gcry_mpi_t
|
||||
-gen_k( gcry_mpi_t p, int small_k )
|
||||
+gen_k( gcry_mpi_t p )
|
||||
{
|
||||
gcry_mpi_t k = mpi_alloc_secure( 0 );
|
||||
gcry_mpi_t temp = mpi_alloc( mpi_get_nlimbs(p) );
|
||||
@@ -202,18 +201,7 @@ gen_k( gcry_mpi_t p, int small_k )
|
||||
unsigned int nbits, nbytes;
|
||||
char *rndbuf = NULL;
|
||||
|
||||
- if (small_k)
|
||||
- {
|
||||
- /* Using a k much lesser than p is sufficient for encryption and
|
||||
- * it greatly improves the encryption performance. We use
|
||||
- * Wiener's table and add a large safety margin. */
|
||||
- nbits = wiener_map( orig_nbits ) * 3 / 2;
|
||||
- if( nbits >= orig_nbits )
|
||||
- BUG();
|
||||
- }
|
||||
- else
|
||||
- nbits = orig_nbits;
|
||||
-
|
||||
+ nbits = orig_nbits;
|
||||
|
||||
nbytes = (nbits+7)/8;
|
||||
if( DBG_CIPHER )
|
||||
@@ -492,7 +480,7 @@ do_encrypt(gcry_mpi_t a, gcry_mpi_t b, gcry_mpi_t input, ELG_public_key *pkey )
|
||||
* error code.
|
||||
*/
|
||||
|
||||
- k = gen_k( pkey->p, 1 );
|
||||
+ k = gen_k( pkey->p );
|
||||
mpi_powm (a, pkey->g, k, pkey->p);
|
||||
|
||||
/* b = (y^k * input) mod p
|
||||
@@ -608,7 +596,7 @@ sign(gcry_mpi_t a, gcry_mpi_t b, gcry_mpi_t input, ELG_secret_key *skey )
|
||||
*
|
||||
*/
|
||||
mpi_sub_ui(p_1, p_1, 1);
|
||||
- k = gen_k( skey->p, 0 /* no small K ! */ );
|
||||
+ k = gen_k( skey->p );
|
||||
mpi_powm( a, skey->g, k, skey->p );
|
||||
mpi_mul(t, skey->x, a );
|
||||
mpi_subm(t, input, t, p_1 );
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
25
Use-the-compiler-switch-O0-for-compiling-jitterentro.patch
Normal file
25
Use-the-compiler-switch-O0-for-compiling-jitterentro.patch
Normal file
@ -0,0 +1,25 @@
|
||||
From 642d43d4545b48322dc10a5b9f08bc5d09a8591f Mon Sep 17 00:00:00 2001
|
||||
From: zhengxiaoxiao <zhengxiaoxiao2@huawei.com>
|
||||
Date: Tue, 1 Aug 2023 12:05:44 +0800
|
||||
Subject: [PATCH] Use the compiler switch -O0 for compiling jitterentropy.c.
|
||||
|
||||
---
|
||||
random/jitterentropy-base.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/random/jitterentropy-base.c b/random/jitterentropy-base.c
|
||||
index cf7630d..08a2cd3 100644
|
||||
--- a/random/jitterentropy-base.c
|
||||
+++ b/random/jitterentropy-base.c
|
||||
@@ -55,7 +55,7 @@
|
||||
***************************************************************************/
|
||||
|
||||
#ifdef __OPTIMIZE__
|
||||
- #error "The CPU Jitter random number generator must not be compiled with optimizations. See documentation. Use the compiler switch -O0 for compiling jitterentropy.c."
|
||||
+ #pragma GCC optimize ("O0")
|
||||
#endif
|
||||
|
||||
/*
|
||||
--
|
||||
2.33.0
|
||||
|
||||
BIN
libgcrypt-1.10.2.tar.bz2
Normal file
BIN
libgcrypt-1.10.2.tar.bz2
Normal file
Binary file not shown.
@ -1,104 +0,0 @@
|
||||
diff -up libgcrypt-1.6.1/mpi/mpicoder.c.gccopt libgcrypt-1.6.1/mpi/mpicoder.c
|
||||
--- libgcrypt-1.6.1/mpi/mpicoder.c.gccopt 2014-02-28 15:37:53.983139821 +0100
|
||||
+++ libgcrypt-1.6.1/mpi/mpicoder.c 2014-02-28 15:47:35.312576387 +0100
|
||||
@@ -627,16 +627,16 @@ _gcry_mpi_print (enum gcry_mpi_format fo
|
||||
extra = 1;
|
||||
}
|
||||
|
||||
- if (buffer && n > len)
|
||||
- {
|
||||
- /* The provided buffer is too short. */
|
||||
- xfree (tmp);
|
||||
- return GPG_ERR_TOO_SHORT;
|
||||
- }
|
||||
if (buffer)
|
||||
{
|
||||
unsigned char *s = buffer;
|
||||
|
||||
+ if (n > len)
|
||||
+ {
|
||||
+ /* The provided buffer is too short. */
|
||||
+ xfree (tmp);
|
||||
+ return GPG_ERR_TOO_SHORT;
|
||||
+ }
|
||||
if (extra == 1)
|
||||
*s++ = 0;
|
||||
else if (extra)
|
||||
@@ -654,13 +654,12 @@ _gcry_mpi_print (enum gcry_mpi_format fo
|
||||
/* Note: We ignore the sign for this format. */
|
||||
/* FIXME: for performance reasons we should put this into
|
||||
mpi_aprint because we can then use the buffer directly. */
|
||||
-
|
||||
- if (buffer && n > len)
|
||||
- return GPG_ERR_TOO_SHORT;
|
||||
if (buffer)
|
||||
{
|
||||
unsigned char *tmp;
|
||||
|
||||
+ if (n > len)
|
||||
+ return GPG_ERR_TOO_SHORT;
|
||||
tmp = _gcry_mpi_get_buffer (a, 0, &n, NULL);
|
||||
if (!tmp)
|
||||
return gpg_err_code_from_syserror ();
|
||||
@@ -678,14 +677,14 @@ _gcry_mpi_print (enum gcry_mpi_format fo
|
||||
if (negative)
|
||||
return GPG_ERR_INV_ARG;
|
||||
|
||||
- if (buffer && n+2 > len)
|
||||
- return GPG_ERR_TOO_SHORT;
|
||||
-
|
||||
if (buffer)
|
||||
{
|
||||
unsigned char *tmp;
|
||||
unsigned char *s = buffer;
|
||||
|
||||
+ if (n+2 > len)
|
||||
+ return GPG_ERR_TOO_SHORT;
|
||||
+
|
||||
s[0] = nbits >> 8;
|
||||
s[1] = nbits;
|
||||
|
||||
@@ -724,16 +723,16 @@ _gcry_mpi_print (enum gcry_mpi_format fo
|
||||
extra=1;
|
||||
}
|
||||
|
||||
- if (buffer && n+4 > len)
|
||||
- {
|
||||
- xfree(tmp);
|
||||
- return GPG_ERR_TOO_SHORT;
|
||||
- }
|
||||
-
|
||||
if (buffer)
|
||||
{
|
||||
unsigned char *s = buffer;
|
||||
|
||||
+ if (n+4 > len)
|
||||
+ {
|
||||
+ xfree(tmp);
|
||||
+ return GPG_ERR_TOO_SHORT;
|
||||
+ }
|
||||
+
|
||||
*s++ = n >> 24;
|
||||
*s++ = n >> 16;
|
||||
*s++ = n >> 8;
|
||||
@@ -761,15 +760,15 @@ _gcry_mpi_print (enum gcry_mpi_format fo
|
||||
if (!n || (*tmp & 0x80))
|
||||
extra = 2;
|
||||
|
||||
- if (buffer && 2*n + extra + negative + 1 > len)
|
||||
- {
|
||||
- xfree(tmp);
|
||||
- return GPG_ERR_TOO_SHORT;
|
||||
- }
|
||||
if (buffer)
|
||||
{
|
||||
unsigned char *s = buffer;
|
||||
|
||||
+ if (2*n + extra + negative + 1 > len)
|
||||
+ {
|
||||
+ xfree(tmp);
|
||||
+ return GPG_ERR_TOO_SHORT;
|
||||
+ }
|
||||
if (negative)
|
||||
*s++ = '-';
|
||||
if (extra)
|
||||
@ -1,122 +0,0 @@
|
||||
diff -up libgcrypt-1.7.3/tests/benchmark.c.eccfix libgcrypt-1.7.3/tests/benchmark.c
|
||||
--- libgcrypt-1.7.3/tests/benchmark.c.eccfix 2016-07-14 11:19:17.000000000 +0200
|
||||
+++ libgcrypt-1.7.3/tests/benchmark.c 2016-11-22 16:21:00.109004197 +0100
|
||||
@@ -1412,7 +1412,7 @@ ecc_bench (int iterations, int print_hea
|
||||
{
|
||||
#if USE_ECC
|
||||
gpg_error_t err;
|
||||
- const char *p_sizes[] = { "192", "224", "256", "384", "521", "Ed25519",
|
||||
+ const char *p_sizes[] = { "224", "256", "384", "521", "Ed25519",
|
||||
"gost256", "gost512" };
|
||||
int testno;
|
||||
|
||||
diff -up libgcrypt-1.7.3/tests/dsa-rfc6979.c.eccfix libgcrypt-1.7.3/tests/dsa-rfc6979.c
|
||||
--- libgcrypt-1.7.3/tests/dsa-rfc6979.c.eccfix 2016-02-18 09:38:03.000000000 +0100
|
||||
+++ libgcrypt-1.7.3/tests/dsa-rfc6979.c 2016-11-22 16:22:11.804674008 +0100
|
||||
@@ -210,16 +210,6 @@ check_dsa_rfc6979 (void)
|
||||
" ))"
|
||||
},
|
||||
{
|
||||
- "ECDSA, 192 bits (prime field)",
|
||||
- "(private-key"
|
||||
- " (ecdsa"
|
||||
- " (curve \"NIST P-192\")"
|
||||
- " (q #04AC2C77F529F91689FEA0EA5EFEC7F210D8EEA0B9E047ED56"
|
||||
- " 3BC723E57670BD4887EBC732C523063D0A7C957BC97C1C43#)"
|
||||
- " (d #6FAB034934E4C0FC9AE67F5B5659A9D7D1FEFD187EE09FD4#)"
|
||||
- " ))"
|
||||
- },
|
||||
- {
|
||||
"ECDSA, 224 bits (prime field)",
|
||||
"(private-key"
|
||||
" (ecdsa"
|
||||
@@ -443,89 +433,6 @@ check_dsa_rfc6979 (void)
|
||||
"C9F0BDABCC0D880BB137A994CC7F3980CE91CC10FAF529FC46565B15CEA854E1"
|
||||
},
|
||||
{
|
||||
- "ECDSA, 192 bits (prime field)",
|
||||
- "With SHA-1, message = \"sample\"",
|
||||
- "sha1", "sample",
|
||||
- "37D7CA00D2C7B0E5E412AC03BD44BA837FDD5B28CD3B0021",
|
||||
- "98C6BD12B23EAF5E2A2045132086BE3EB8EBD62ABF6698FF",
|
||||
- "57A22B07DEA9530F8DE9471B1DC6624472E8E2844BC25B64"
|
||||
- },
|
||||
- {
|
||||
- "ECDSA, 192 bits (prime field)",
|
||||
- "With SHA-224, message = \"sample\"",
|
||||
- "sha224", "sample",
|
||||
- "4381526B3FC1E7128F202E194505592F01D5FF4C5AF015D8",
|
||||
- "A1F00DAD97AEEC91C95585F36200C65F3C01812AA60378F5",
|
||||
- "E07EC1304C7C6C9DEBBE980B9692668F81D4DE7922A0F97A"
|
||||
- },
|
||||
- {
|
||||
- "ECDSA, 192 bits (prime field)",
|
||||
- "With SHA-256, message = \"sample\"",
|
||||
- "sha256", "sample",
|
||||
- "32B1B6D7D42A05CB449065727A84804FB1A3E34D8F261496",
|
||||
- "4B0B8CE98A92866A2820E20AA6B75B56382E0F9BFD5ECB55",
|
||||
- "CCDB006926EA9565CBADC840829D8C384E06DE1F1E381B85"
|
||||
- },
|
||||
- {
|
||||
- "ECDSA, 192 bits (prime field)",
|
||||
- "With SHA-384, message = \"sample\"",
|
||||
- "sha384", "sample",
|
||||
- "4730005C4FCB01834C063A7B6760096DBE284B8252EF4311",
|
||||
- "DA63BF0B9ABCF948FBB1E9167F136145F7A20426DCC287D5",
|
||||
- "C3AA2C960972BD7A2003A57E1C4C77F0578F8AE95E31EC5E"
|
||||
- },
|
||||
- {
|
||||
- "ECDSA, 192 bits (prime field)",
|
||||
- "With SHA-512, message = \"sample\"",
|
||||
- "sha512", "sample",
|
||||
- "A2AC7AB055E4F20692D49209544C203A7D1F2C0BFBC75DB1",
|
||||
- "4D60C5AB1996BD848343B31C00850205E2EA6922DAC2E4B8",
|
||||
- "3F6E837448F027A1BF4B34E796E32A811CBB4050908D8F67"
|
||||
- },
|
||||
- {
|
||||
- "ECDSA, 192 bits (prime field)",
|
||||
- "With SHA-1, message = \"test\"",
|
||||
- "sha1", "test",
|
||||
- "D9CF9C3D3297D3260773A1DA7418DB5537AB8DD93DE7FA25",
|
||||
- "0F2141A0EBBC44D2E1AF90A50EBCFCE5E197B3B7D4DE036D",
|
||||
- "EB18BC9E1F3D7387500CB99CF5F7C157070A8961E38700B7"
|
||||
- },
|
||||
- {
|
||||
- "ECDSA, 192 bits (prime field)",
|
||||
- "With SHA-224, message = \"test\"",
|
||||
- "sha224", "test",
|
||||
- "F5DC805F76EF851800700CCE82E7B98D8911B7D510059FBE",
|
||||
- "6945A1C1D1B2206B8145548F633BB61CEF04891BAF26ED34",
|
||||
- "B7FB7FDFC339C0B9BD61A9F5A8EAF9BE58FC5CBA2CB15293"
|
||||
- },
|
||||
- {
|
||||
- "ECDSA, 192 bits (prime field)",
|
||||
- "With SHA-256, message = \"test\"",
|
||||
- "sha256", "test",
|
||||
- "5C4CE89CF56D9E7C77C8585339B006B97B5F0680B4306C6C",
|
||||
- "3A718BD8B4926C3B52EE6BBE67EF79B18CB6EB62B1AD97AE",
|
||||
- "5662E6848A4A19B1F1AE2F72ACD4B8BBE50F1EAC65D9124F"
|
||||
- },
|
||||
- {
|
||||
- "ECDSA, 192 bits (prime field)",
|
||||
- "With SHA-384, message = \"test\"",
|
||||
- "sha384", "test",
|
||||
- "5AFEFB5D3393261B828DB6C91FBC68C230727B030C975693",
|
||||
- "B234B60B4DB75A733E19280A7A6034BD6B1EE88AF5332367",
|
||||
- "7994090B2D59BB782BE57E74A44C9A1C700413F8ABEFE77A"
|
||||
- },
|
||||
- {
|
||||
- "ECDSA, 192 bits (prime field)",
|
||||
- "With SHA-512, message = \"test\"",
|
||||
- "sha512", "test",
|
||||
- "0758753A5254759C7CFBAD2E2D9B0792EEE44136C9480527",
|
||||
- "FE4F4AE86A58B6507946715934FE2D8FF9D95B6B098FE739",
|
||||
- "74CF5605C98FBA0E1EF34D4B5A1577A7DCF59457CAE52290"
|
||||
- },
|
||||
-
|
||||
-
|
||||
-
|
||||
- {
|
||||
"ECDSA, 224 bits (prime field)",
|
||||
"With SHA-1, message = \"sample\"",
|
||||
"sha1", "sample",
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,35 +0,0 @@
|
||||
diff -up libgcrypt-1.7.3/src/visibility.c.fips-reqs libgcrypt-1.7.3/src/visibility.c
|
||||
--- libgcrypt-1.7.3/src/visibility.c.fips-reqs 2016-03-23 12:59:34.000000000 +0100
|
||||
+++ libgcrypt-1.7.3/src/visibility.c 2016-11-22 16:29:36.992042480 +0100
|
||||
@@ -1288,6 +1288,8 @@ gcry_kdf_derive (const void *passphrase,
|
||||
unsigned long iterations,
|
||||
size_t keysize, void *keybuffer)
|
||||
{
|
||||
+ if (!fips_is_operational ())
|
||||
+ return gpg_error (fips_not_operational ());
|
||||
return gpg_error (_gcry_kdf_derive (passphrase, passphraselen, algo, hashalgo,
|
||||
salt, saltlen, iterations,
|
||||
keysize, keybuffer));
|
||||
@@ -1343,6 +1345,13 @@ void
|
||||
gcry_mpi_randomize (gcry_mpi_t w,
|
||||
unsigned int nbits, enum gcry_random_level level)
|
||||
{
|
||||
+ if (!fips_is_operational ())
|
||||
+ {
|
||||
+ (void)fips_not_operational ();
|
||||
+ fips_signal_fatal_error ("called in non-operational state");
|
||||
+ fips_noreturn ();
|
||||
+ }
|
||||
+
|
||||
_gcry_mpi_randomize (w, nbits, level);
|
||||
}
|
||||
|
||||
@@ -1368,6 +1377,8 @@ gcry_prime_generate (gcry_mpi_t *prime,
|
||||
gcry_random_level_t random_level,
|
||||
unsigned int flags)
|
||||
{
|
||||
+ if (!fips_is_operational ())
|
||||
+ return gpg_error (fips_not_operational ());
|
||||
return gpg_error (_gcry_prime_generate (prime, prime_bits, factor_bits,
|
||||
factors, cb_func, cb_arg,
|
||||
random_level, flags));
|
||||
@ -1,322 +0,0 @@
|
||||
diff -up libgcrypt-1.8.3/cipher/cipher-cmac.c.cmac-selftest libgcrypt-1.8.3/cipher/cipher-cmac.c
|
||||
--- libgcrypt-1.8.3/cipher/cipher-cmac.c.cmac-selftest 2017-11-23 19:16:58.000000000 +0100
|
||||
+++ libgcrypt-1.8.3/cipher/cipher-cmac.c 2019-05-31 17:33:35.594407152 +0200
|
||||
@@ -251,3 +251,246 @@ _gcry_cipher_cmac_set_subkeys (gcry_ciph
|
||||
|
||||
return GPG_ERR_NO_ERROR;
|
||||
}
|
||||
+
|
||||
+/* CMAC selftests.
|
||||
+ * Copyright (C) 2008 Free Software Foundation, Inc.
|
||||
+ * Copyright (C) 2019 Red Hat, Inc.
|
||||
+ */
|
||||
+
|
||||
+
|
||||
+
|
||||
+/* Check one MAC with MAC ALGO using the regular MAC
|
||||
+ * API. (DATA,DATALEN) is the data to be MACed, (KEY,KEYLEN) the key
|
||||
+ * and (EXPECT,EXPECTLEN) the expected result. If TRUNC is set, the
|
||||
+ * EXPECTLEN may be less than the digest length. Returns NULL on
|
||||
+ * success or a string describing the failure. */
|
||||
+static const char *
|
||||
+check_one (int algo,
|
||||
+ const void *data, size_t datalen,
|
||||
+ const void *key, size_t keylen,
|
||||
+ const void *expect, size_t expectlen)
|
||||
+{
|
||||
+ gcry_mac_hd_t hd;
|
||||
+ unsigned char mac[512]; /* hardcoded to avoid allocation */
|
||||
+ size_t macoutlen = expectlen;
|
||||
+
|
||||
+/* printf ("MAC algo %d\n", algo); */
|
||||
+ if (_gcry_mac_get_algo_maclen (algo) != expectlen ||
|
||||
+ expectlen > sizeof (mac))
|
||||
+ return "invalid tests data";
|
||||
+ if (_gcry_mac_open (&hd, algo, 0, NULL))
|
||||
+ return "gcry_mac_open failed";
|
||||
+ if (_gcry_mac_setkey (hd, key, keylen))
|
||||
+ {
|
||||
+ _gcry_mac_close (hd);
|
||||
+ return "gcry_md_setkey failed";
|
||||
+ }
|
||||
+ if (_gcry_mac_write (hd, data, datalen))
|
||||
+ {
|
||||
+ _gcry_mac_close (hd);
|
||||
+ return "gcry_mac_write failed";
|
||||
+ }
|
||||
+ if (_gcry_mac_read (hd, mac, &macoutlen))
|
||||
+ {
|
||||
+ _gcry_mac_close (hd);
|
||||
+ return "gcry_mac_read failed";
|
||||
+ }
|
||||
+ _gcry_mac_close (hd);
|
||||
+ if (macoutlen != expectlen || memcmp (mac, expect, expectlen))
|
||||
+ {
|
||||
+/* int i; */
|
||||
+
|
||||
+/* fputs (" {", stdout); */
|
||||
+/* for (i=0; i < expectlen-1; i++) */
|
||||
+/* { */
|
||||
+/* if (i && !(i % 8)) */
|
||||
+/* fputs ("\n ", stdout); */
|
||||
+/* printf (" 0x%02x,", mac[i]); */
|
||||
+/* } */
|
||||
+/* printf (" 0x%02x } },\n", mac[i]); */
|
||||
+
|
||||
+ return "does not match";
|
||||
+ }
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+static gpg_err_code_t
|
||||
+selftests_cmac_tdes (int extended, selftest_report_func_t report)
|
||||
+{
|
||||
+ const char *what;
|
||||
+ const char *errtxt;
|
||||
+
|
||||
+ what = "Basic TDES";
|
||||
+ errtxt = check_one (GCRY_MAC_CMAC_3DES,
|
||||
+ "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96\xe9\x3d\x7e\x11\x73\x93\x17\x2a"
|
||||
+ "\xae\x2d\x8a\x57", 20,
|
||||
+ "\x8a\xa8\x3b\xf8\xcb\xda\x10\x62\x0b\xc1\xbf\x19\xfb\xb6\xcd\x58"
|
||||
+ "\xbc\x31\x3d\x4a\x37\x1c\xa8\xb5", 24,
|
||||
+ "\x74\x3d\xdb\xe0\xce\x2d\xc2\xed", 8);
|
||||
+ if (errtxt)
|
||||
+ goto failed;
|
||||
+
|
||||
+ if (extended)
|
||||
+ {
|
||||
+ what = "Extended TDES #1";
|
||||
+ errtxt = check_one (GCRY_MAC_CMAC_3DES,
|
||||
+ "", 0,
|
||||
+ "\x8a\xa8\x3b\xf8\xcb\xda\x10\x62\x0b\xc1\xbf\x19\xfb\xb6\xcd\x58"
|
||||
+ "\xbc\x31\x3d\x4a\x37\x1c\xa8\xb5", 24,
|
||||
+ "\xb7\xa6\x88\xe1\x22\xff\xaf\x95", 8);
|
||||
+ if (errtxt)
|
||||
+ goto failed;
|
||||
+
|
||||
+ what = "Extended TDES #2";
|
||||
+ errtxt = check_one (GCRY_MAC_CMAC_3DES,
|
||||
+ "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96", 8,
|
||||
+ "\x8a\xa8\x3b\xf8\xcb\xda\x10\x62\x0b\xc1\xbf\x19\xfb\xb6\xcd\x58"
|
||||
+ "\xbc\x31\x3d\x4a\x37\x1c\xa8\xb5", 24,
|
||||
+ "\x8e\x8f\x29\x31\x36\x28\x37\x97", 8);
|
||||
+ if (errtxt)
|
||||
+ goto failed;
|
||||
+
|
||||
+ what = "Extended TDES #3";
|
||||
+ errtxt = check_one (GCRY_MAC_CMAC_3DES,
|
||||
+ "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96\xe9\x3d\x7e\x11\x73\x93\x17\x2a"
|
||||
+ "\xae\x2d\x8a\x57\x1e\x03\xac\x9c\x9e\xb7\x6f\xac\x45\xaf\x8e\x51", 32,
|
||||
+ "\x8a\xa8\x3b\xf8\xcb\xda\x10\x62\x0b\xc1\xbf\x19\xfb\xb6\xcd\x58"
|
||||
+ "\xbc\x31\x3d\x4a\x37\x1c\xa8\xb5", 24,
|
||||
+ "\x33\xe6\xb1\x09\x24\x00\xea\xe5", 8);
|
||||
+ if (errtxt)
|
||||
+ goto failed;
|
||||
+ }
|
||||
+
|
||||
+ return 0; /* Succeeded. */
|
||||
+
|
||||
+ failed:
|
||||
+ if (report)
|
||||
+ report ("cmac", GCRY_MAC_CMAC_3DES, what, errtxt);
|
||||
+ return GPG_ERR_SELFTEST_FAILED;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+
|
||||
+static gpg_err_code_t
|
||||
+selftests_cmac_aes (int extended, selftest_report_func_t report)
|
||||
+{
|
||||
+ const char *what;
|
||||
+ const char *errtxt;
|
||||
+
|
||||
+ what = "Basic AES128";
|
||||
+ errtxt = check_one (GCRY_MAC_CMAC_AES,
|
||||
+ "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96\xe9\x3d\x7e\x11\x73\x93\x17\x2a"
|
||||
+ "\xae\x2d\x8a\x57\x1e\x03\xac\x9c\x9e\xb7\x6f\xac\x45\xaf\x8e\x51"
|
||||
+ "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11", 40,
|
||||
+ "\x2b\x7e\x15\x16\x28\xae\xd2\xa6\xab\xf7\x15\x88\x09\xcf\x4f\x3c", 16,
|
||||
+ "\xdf\xa6\x67\x47\xde\x9a\xe6\x30\x30\xca\x32\x61\x14\x97\xc8\x27", 16);
|
||||
+ if (errtxt)
|
||||
+ goto failed;
|
||||
+
|
||||
+ what = "Basic AES192";
|
||||
+ errtxt = check_one (GCRY_MAC_CMAC_AES,
|
||||
+ "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96\xe9\x3d\x7e\x11\x73\x93\x17\x2a"
|
||||
+ "\xae\x2d\x8a\x57\x1e\x03\xac\x9c\x9e\xb7\x6f\xac\x45\xaf\x8e\x51"
|
||||
+ "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11", 40,
|
||||
+ "\x8e\x73\xb0\xf7\xda\x0e\x64\x52\xc8\x10\xf3\x2b\x80\x90\x79\xe5"
|
||||
+ "\x62\xf8\xea\xd2\x52\x2c\x6b\x7b", 24,
|
||||
+ "\x8a\x1d\xe5\xbe\x2e\xb3\x1a\xad\x08\x9a\x82\xe6\xee\x90\x8b\x0e", 16);
|
||||
+ if (errtxt)
|
||||
+ goto failed;
|
||||
+
|
||||
+ what = "Basic AES256";
|
||||
+ errtxt = check_one (GCRY_MAC_CMAC_AES,
|
||||
+ "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96\xe9\x3d\x7e\x11\x73\x93\x17\x2a"
|
||||
+ "\xae\x2d\x8a\x57\x1e\x03\xac\x9c\x9e\xb7\x6f\xac\x45\xaf\x8e\x51"
|
||||
+ "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11", 40,
|
||||
+ "\x60\x3d\xeb\x10\x15\xca\x71\xbe\x2b\x73\xae\xf0\x85\x7d\x77\x81"
|
||||
+ "\x1f\x35\x2c\x07\x3b\x61\x08\xd7\x2d\x98\x10\xa3\x09\x14\xdf\xf4", 32,
|
||||
+ "\xaa\xf3\xd8\xf1\xde\x56\x40\xc2\x32\xf5\xb1\x69\xb9\xc9\x11\xe6", 16);
|
||||
+ if (errtxt)
|
||||
+ goto failed;
|
||||
+ if (extended)
|
||||
+ {
|
||||
+ what = "Extended AES #1";
|
||||
+ errtxt = check_one (GCRY_MAC_CMAC_AES,
|
||||
+ "", 0,
|
||||
+ "\x2b\x7e\x15\x16\x28\xae\xd2\xa6\xab\xf7\x15\x88\x09\xcf\x4f\x3c", 16,
|
||||
+ "\xbb\x1d\x69\x29\xe9\x59\x37\x28\x7f\xa3\x7d\x12\x9b\x75\x67\x46", 16);
|
||||
+ if (errtxt)
|
||||
+ goto failed;
|
||||
+
|
||||
+ what = "Extended AES #2";
|
||||
+ errtxt = check_one (GCRY_MAC_CMAC_AES,
|
||||
+ "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96\xe9\x3d\x7e\x11\x73\x93\x17\x2a", 16,
|
||||
+ "\x8e\x73\xb0\xf7\xda\x0e\x64\x52\xc8\x10\xf3\x2b\x80\x90\x79\xe5"
|
||||
+ "\x62\xf8\xea\xd2\x52\x2c\x6b\x7b", 24,
|
||||
+ "\x9e\x99\xa7\xbf\x31\xe7\x10\x90\x06\x62\xf6\x5e\x61\x7c\x51\x84", 16);
|
||||
+ if (errtxt)
|
||||
+ goto failed;
|
||||
+
|
||||
+ what = "Extended AES #3";
|
||||
+ errtxt = check_one (GCRY_MAC_CMAC_AES,
|
||||
+ "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96\xe9\x3d\x7e\x11\x73\x93\x17\x2a"
|
||||
+ "\xae\x2d\x8a\x57\x1e\x03\xac\x9c\x9e\xb7\x6f\xac\x45\xaf\x8e\x51"
|
||||
+ "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11\xe5\xfb\xc1\x19\x1a\x0a\x52\xef"
|
||||
+ "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17\xad\x2b\x41\x7b\xe6\x6c\x37\x10", 64,
|
||||
+ "\x60\x3d\xeb\x10\x15\xca\x71\xbe\x2b\x73\xae\xf0\x85\x7d\x77\x81"
|
||||
+ "\x1f\x35\x2c\x07\x3b\x61\x08\xd7\x2d\x98\x10\xa3\x09\x14\xdf\xf4", 32,
|
||||
+ "\xe1\x99\x21\x90\x54\x9f\x6e\xd5\x69\x6a\x2c\x05\x6c\x31\x54\x10", 16 );
|
||||
+ if (errtxt)
|
||||
+ goto failed;
|
||||
+ }
|
||||
+
|
||||
+ return 0; /* Succeeded. */
|
||||
+
|
||||
+ failed:
|
||||
+ if (report)
|
||||
+ report ("cmac", GCRY_MAC_CMAC_AES, what, errtxt);
|
||||
+ return GPG_ERR_SELFTEST_FAILED;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+/* Run a full self-test for ALGO and return 0 on success. */
|
||||
+static gpg_err_code_t
|
||||
+run_cmac_selftests (int algo, int extended, selftest_report_func_t report)
|
||||
+{
|
||||
+ gpg_err_code_t ec;
|
||||
+
|
||||
+ switch (algo)
|
||||
+ {
|
||||
+ case GCRY_MAC_CMAC_3DES:
|
||||
+ ec = selftests_cmac_tdes (extended, report);
|
||||
+ break;
|
||||
+ case GCRY_MAC_CMAC_AES:
|
||||
+ ec = selftests_cmac_aes (extended, report);
|
||||
+ break;
|
||||
+
|
||||
+ default:
|
||||
+ ec = GPG_ERR_MAC_ALGO;
|
||||
+ break;
|
||||
+ }
|
||||
+ return ec;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+
|
||||
+
|
||||
+/* Run the selftests for CMAC with CMAC algorithm ALGO with optional
|
||||
+ reporting function REPORT. */
|
||||
+gpg_error_t
|
||||
+_gcry_cmac_selftest (int algo, int extended, selftest_report_func_t report)
|
||||
+{
|
||||
+ gcry_err_code_t ec = 0;
|
||||
+
|
||||
+ if (!_gcry_mac_algo_info( algo, GCRYCTL_TEST_ALGO, NULL, NULL ))
|
||||
+ {
|
||||
+ ec = run_cmac_selftests (algo, extended, report);
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ ec = GPG_ERR_MAC_ALGO;
|
||||
+ if (report)
|
||||
+ report ("mac", algo, "module", "algorithm not available");
|
||||
+ }
|
||||
+ return gpg_error (ec);
|
||||
+}
|
||||
diff -up libgcrypt-1.8.3/src/cipher-proto.h.cmac-selftest libgcrypt-1.8.3/src/cipher-proto.h
|
||||
--- libgcrypt-1.8.3/src/cipher-proto.h.cmac-selftest 2017-11-23 19:16:58.000000000 +0100
|
||||
+++ libgcrypt-1.8.3/src/cipher-proto.h 2019-05-31 17:29:34.574588234 +0200
|
||||
@@ -256,6 +256,8 @@ gcry_error_t _gcry_pk_selftest (int algo
|
||||
selftest_report_func_t report);
|
||||
gcry_error_t _gcry_hmac_selftest (int algo, int extended,
|
||||
selftest_report_func_t report);
|
||||
+gcry_error_t _gcry_cmac_selftest (int algo, int extended,
|
||||
+ selftest_report_func_t report);
|
||||
|
||||
gcry_error_t _gcry_random_selftest (selftest_report_func_t report);
|
||||
|
||||
diff -up libgcrypt-1.8.3/src/fips.c.cmac-selftest libgcrypt-1.8.3/src/fips.c
|
||||
--- libgcrypt-1.8.3/src/fips.c.cmac-selftest 2018-11-01 15:40:36.051865535 +0100
|
||||
+++ libgcrypt-1.8.3/src/fips.c 2019-05-31 17:31:20.157756640 +0200
|
||||
@@ -521,29 +521,32 @@ run_digest_selftests (int extended)
|
||||
|
||||
/* Run self-tests for all HMAC algorithms. Return 0 on success. */
|
||||
static int
|
||||
-run_hmac_selftests (int extended)
|
||||
+run_mac_selftests (int extended)
|
||||
{
|
||||
- static int algos[] =
|
||||
+ static int algos[][2] =
|
||||
{
|
||||
- GCRY_MD_SHA1,
|
||||
- GCRY_MD_SHA224,
|
||||
- GCRY_MD_SHA256,
|
||||
- GCRY_MD_SHA384,
|
||||
- GCRY_MD_SHA512,
|
||||
- GCRY_MD_SHA3_224,
|
||||
- GCRY_MD_SHA3_256,
|
||||
- GCRY_MD_SHA3_384,
|
||||
- GCRY_MD_SHA3_512,
|
||||
- 0
|
||||
+ { GCRY_MD_SHA1, 0 },
|
||||
+ { GCRY_MD_SHA224, 0 },
|
||||
+ { GCRY_MD_SHA256, 0 },
|
||||
+ { GCRY_MD_SHA384, 0 },
|
||||
+ { GCRY_MD_SHA512, 0 },
|
||||
+ { GCRY_MD_SHA3_224, 0 },
|
||||
+ { GCRY_MD_SHA3_256, 0 },
|
||||
+ { GCRY_MD_SHA3_384, 0 },
|
||||
+ { GCRY_MD_SHA3_512, 0 },
|
||||
+ { GCRY_MAC_CMAC_3DES, 1 },
|
||||
+ { GCRY_MAC_CMAC_AES, 1 },
|
||||
+ { 0, 0 }
|
||||
};
|
||||
int idx;
|
||||
gpg_error_t err;
|
||||
int anyerr = 0;
|
||||
|
||||
- for (idx=0; algos[idx]; idx++)
|
||||
+ for (idx=0; algos[idx][0]; idx++)
|
||||
{
|
||||
- err = _gcry_hmac_selftest (algos[idx], extended, reporter);
|
||||
- reporter ("hmac", algos[idx], NULL,
|
||||
+ err = algos[idx][1] ? _gcry_cmac_selftest (algos[idx][0], extended, reporter) :
|
||||
+ _gcry_hmac_selftest (algos[idx][0], extended, reporter);
|
||||
+ reporter (algos[idx][1] ? "cmac" : "hmac", algos[idx][0], NULL,
|
||||
err? gpg_strerror (err):NULL);
|
||||
if (err)
|
||||
anyerr = 1;
|
||||
@@ -747,7 +750,7 @@ _gcry_fips_run_selftests (int extended)
|
||||
if (run_digest_selftests (extended))
|
||||
goto leave;
|
||||
|
||||
- if (run_hmac_selftests (extended))
|
||||
+ if (run_mac_selftests (extended))
|
||||
goto leave;
|
||||
|
||||
/* Run random tests before the pubkey tests because the latter
|
||||
@ -1,60 +0,0 @@
|
||||
diff -up libgcrypt-1.8.3/src/global.c.fips-ctor libgcrypt-1.8.3/src/global.c
|
||||
--- libgcrypt-1.8.3/src/global.c.fips-ctor 2017-11-23 19:25:58.000000000 +0100
|
||||
+++ libgcrypt-1.8.3/src/global.c 2020-04-17 16:29:59.258218015 +0200
|
||||
@@ -141,6 +141,34 @@ global_init (void)
|
||||
}
|
||||
|
||||
|
||||
+#ifndef FIPS_MODULE_PATH
|
||||
+#define FIPS_MODULE_PATH "/etc/system-fips"
|
||||
+#endif
|
||||
+
|
||||
+void __attribute__ ((constructor)) _gcry_global_constructor (void)
|
||||
+{
|
||||
+ int rv;
|
||||
+
|
||||
+ rv = access (FIPS_MODULE_PATH, F_OK);
|
||||
+ if (rv < 0 && errno != ENOENT)
|
||||
+ rv = 0;
|
||||
+
|
||||
+ if (!rv)
|
||||
+ {
|
||||
+ int no_secmem_save;
|
||||
+
|
||||
+ /* it should be always 0 at this point but let's keep on the safe side */
|
||||
+ no_secmem_save = no_secure_memory;
|
||||
+ no_secure_memory = 1;
|
||||
+ /* force selftests */
|
||||
+ global_init();
|
||||
+ _gcry_fips_run_selftests (0);
|
||||
+ if (!fips_mode())
|
||||
+ _gcry_random_close_fds ();
|
||||
+ no_secure_memory = no_secmem_save;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
/* This function is called by the macro fips_is_operational and makes
|
||||
sure that the minimal initialization has been done. This is far
|
||||
from a perfect solution and hides problems with an improper
|
||||
@@ -671,8 +699,7 @@ _gcry_vcontrol (enum gcry_ctl_cmds cmd,
|
||||
|
||||
case GCRYCTL_FIPS_MODE_P:
|
||||
if (fips_mode ()
|
||||
- && !_gcry_is_fips_mode_inactive ()
|
||||
- && !no_secure_memory)
|
||||
+ && !_gcry_is_fips_mode_inactive ())
|
||||
rc = GPG_ERR_GENERAL; /* Used as TRUE value */
|
||||
break;
|
||||
|
||||
@@ -749,9 +776,9 @@ _gcry_vcontrol (enum gcry_ctl_cmds cmd,
|
||||
break;
|
||||
|
||||
case GCRYCTL_SET_ENFORCED_FIPS_FLAG:
|
||||
- if (!any_init_done)
|
||||
+ if (fips_mode ())
|
||||
{
|
||||
- /* Not yet initialized at all. Set the enforced fips mode flag */
|
||||
+ /* We are in FIPS mode, we can set the enforced fips mode flag. */
|
||||
_gcry_set_preferred_rng_type (0);
|
||||
_gcry_set_enforced_fips_mode ();
|
||||
}
|
||||
@ -1,113 +0,0 @@
|
||||
diff -up libgcrypt-1.8.3/random/random-drbg.c.fips-enttest libgcrypt-1.8.3/random/random-drbg.c
|
||||
--- libgcrypt-1.8.3/random/random-drbg.c.fips-enttest 2017-11-23 19:16:58.000000000 +0100
|
||||
+++ libgcrypt-1.8.3/random/random-drbg.c 2019-06-24 10:04:23.219547141 +0200
|
||||
@@ -317,6 +317,7 @@ struct drbg_state_s
|
||||
unsigned char *ctr_null; /* CTR mode zero buffer */
|
||||
int seeded:1; /* DRBG fully seeded? */
|
||||
int pr:1; /* Prediction resistance enabled? */
|
||||
+ int ent_primed:1; /* Previous entropy data primed? */
|
||||
/* Taken from libgcrypt ANSI X9.31 DRNG: We need to keep track of the
|
||||
* process which did the initialization so that we can detect a fork.
|
||||
* The volatile modifier is required so that the compiler does not
|
||||
@@ -324,6 +325,7 @@ struct drbg_state_s
|
||||
pid_t seed_init_pid;
|
||||
const struct drbg_state_ops_s *d_ops;
|
||||
const struct drbg_core_s *core;
|
||||
+ unsigned char ent_hash[64]; /* Hash of previous entropy data */
|
||||
struct drbg_test_data_s *test_data;
|
||||
};
|
||||
|
||||
@@ -610,11 +612,13 @@ drbg_get_entropy (drbg_state_t drbg, uns
|
||||
size_t len)
|
||||
{
|
||||
int rc = 0;
|
||||
+ unsigned char newhash[64];
|
||||
|
||||
/* Perform testing as defined in 11.3.2 */
|
||||
if (drbg->test_data && drbg->test_data->fail_seed_source)
|
||||
return -1;
|
||||
|
||||
+redo:
|
||||
read_cb_buffer = buffer;
|
||||
read_cb_size = len;
|
||||
read_cb_len = 0;
|
||||
@@ -634,6 +638,27 @@ drbg_get_entropy (drbg_state_t drbg, uns
|
||||
#else
|
||||
rc = -1;
|
||||
#endif
|
||||
+
|
||||
+ /* to avoid storing the actual entropy obtained for indefinite
|
||||
+ time, we just store the SHA-512 hash of the entropy gathered
|
||||
+ */
|
||||
+ _gcry_md_hash_buffer (GCRY_MD_SHA512, newhash, buffer, len);
|
||||
+
|
||||
+ if (!drbg->ent_primed)
|
||||
+ {
|
||||
+ memcpy (drbg->ent_hash, newhash, sizeof (drbg->ent_hash));
|
||||
+ drbg->ent_primed = 1;
|
||||
+ goto redo;
|
||||
+ }
|
||||
+
|
||||
+ if (memcmp (newhash, drbg->ent_hash, sizeof (drbg->ent_hash)) == 0)
|
||||
+ {
|
||||
+ fips_signal_error ("Entropy source failed the continuous test");
|
||||
+ return -1; /* continuous entropy test failed */
|
||||
+ }
|
||||
+
|
||||
+ memcpy (drbg->ent_hash, newhash, sizeof (drbg->ent_hash));
|
||||
+
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -1341,26 +1366,38 @@ drbg_seed (drbg_state_t drbg, drbg_strin
|
||||
}
|
||||
else
|
||||
{
|
||||
+ int nonce = 0;
|
||||
/* Gather entropy equal to the security strength of the DRBG.
|
||||
* With a derivation function, a nonce is required in addition
|
||||
* to the entropy. A nonce must be at least 1/2 of the security
|
||||
* strength of the DRBG in size. Thus, entropy * nonce is 3/2
|
||||
* of the strength. The consideration of a nonce is only
|
||||
- * applicable during initial seeding. */
|
||||
+ * applicable during initial seeding.
|
||||
+ * To avoid pulling different length of data from entropy
|
||||
+ * source, we use 2 * strength for initial seeding. */
|
||||
entropylen = drbg_sec_strength (drbg->core->flags);
|
||||
if (!entropylen)
|
||||
return GPG_ERR_GENERAL;
|
||||
if (0 == reseed)
|
||||
- /* make sure we round up strength/2 in
|
||||
- * case it is not divisible by 2 */
|
||||
- entropylen = ((entropylen + 1) / 2) * 3;
|
||||
+ {
|
||||
+ nonce = 1;
|
||||
+ }
|
||||
dbg (("DRBG: (re)seeding with %lu bytes of entropy\n", entropylen));
|
||||
- entropy = xcalloc_secure (1, entropylen);
|
||||
+ entropy = xcalloc_secure (nonce + 1, entropylen);
|
||||
if (!entropy)
|
||||
return GPG_ERR_ENOMEM;
|
||||
ret = drbg_get_entropy (drbg, entropy, entropylen);
|
||||
if (ret)
|
||||
goto out;
|
||||
+ if (nonce)
|
||||
+ {
|
||||
+ ret = drbg_get_entropy (drbg, entropy + entropylen, entropylen);
|
||||
+ if (ret)
|
||||
+ goto out;
|
||||
+ /* make sure we round up strength/2 in
|
||||
+ * case it is not divisible by 2 */
|
||||
+ entropylen = 2 * entropylen;
|
||||
+ }
|
||||
drbg_string_fill (&data1, entropy, entropylen);
|
||||
}
|
||||
|
||||
@@ -1597,6 +1634,7 @@ drbg_instantiate (drbg_state_t drbg,
|
||||
drbg->core = &drbg_cores[coreref];
|
||||
drbg->pr = pr;
|
||||
drbg->seeded = 0;
|
||||
+ drbg->ent_primed = 0;
|
||||
if (drbg->core->flags & DRBG_HMAC)
|
||||
drbg->d_ops = &drbg_hmac_ops;
|
||||
else if (drbg->core->flags & DRBG_HASH_MASK)
|
||||
@ -1,18 +0,0 @@
|
||||
diff -up libgcrypt-1.8.3/cipher/md.c.fips-enforce libgcrypt-1.8.3/cipher/md.c
|
||||
--- libgcrypt-1.8.3/cipher/md.c.fips-enforce 2017-11-23 19:16:58.000000000 +0100
|
||||
+++ libgcrypt-1.8.3/cipher/md.c 2020-04-17 15:07:31.364945130 +0200
|
||||
@@ -409,13 +409,10 @@ md_enable (gcry_md_hd_t hd, int algorith
|
||||
}
|
||||
|
||||
|
||||
- if (!err && algorithm == GCRY_MD_MD5 && fips_mode ())
|
||||
+ if (!err && !spec->flags.fips && fips_mode ())
|
||||
{
|
||||
- _gcry_inactivate_fips_mode ("MD5 used");
|
||||
if (_gcry_enforced_fips_mode () )
|
||||
{
|
||||
- /* We should never get to here because we do not register
|
||||
- MD5 in enforced fips mode. But better throw an error. */
|
||||
err = GPG_ERR_DIGEST_ALGO;
|
||||
}
|
||||
}
|
||||
@ -1,65 +0,0 @@
|
||||
diff -up libgcrypt-1.8.4/cipher/dsa.c.fips-keygen libgcrypt-1.8.4/cipher/dsa.c
|
||||
--- libgcrypt-1.8.4/cipher/dsa.c.fips-keygen 2017-11-23 19:16:58.000000000 +0100
|
||||
+++ libgcrypt-1.8.4/cipher/dsa.c 2019-02-12 14:29:25.629513989 +0100
|
||||
@@ -457,11 +457,22 @@ generate_fips186 (DSA_secret_key *sk, un
|
||||
&prime_q, &prime_p,
|
||||
r_counter,
|
||||
r_seed, r_seedlen);
|
||||
- else
|
||||
- ec = _gcry_generate_fips186_3_prime (nbits, qbits, NULL, 0,
|
||||
+ else if (!domain->p || !domain->q)
|
||||
+ ec = _gcry_generate_fips186_3_prime (nbits, qbits,
|
||||
+ initial_seed.seed,
|
||||
+ initial_seed.seedlen,
|
||||
&prime_q, &prime_p,
|
||||
r_counter,
|
||||
r_seed, r_seedlen, NULL);
|
||||
+ else
|
||||
+ {
|
||||
+ /* Domain parameters p and q are given; use them. */
|
||||
+ prime_p = mpi_copy (domain->p);
|
||||
+ prime_q = mpi_copy (domain->q);
|
||||
+ gcry_assert (mpi_get_nbits (prime_p) == nbits);
|
||||
+ gcry_assert (mpi_get_nbits (prime_q) == qbits);
|
||||
+ ec = 0;
|
||||
+ }
|
||||
sexp_release (initial_seed.sexp);
|
||||
if (ec)
|
||||
goto leave;
|
||||
@@ -855,13 +866,12 @@ dsa_generate (const gcry_sexp_t genparms
|
||||
sexp_release (l1);
|
||||
sexp_release (domainsexp);
|
||||
|
||||
- /* Check that all domain parameters are available. */
|
||||
- if (!domain.p || !domain.q || !domain.g)
|
||||
+ /* Check that p and q domain parameters are available. */
|
||||
+ if (!domain.p || !domain.q || (!domain.g && !(flags & PUBKEY_FLAG_USE_FIPS186)))
|
||||
{
|
||||
_gcry_mpi_release (domain.p);
|
||||
_gcry_mpi_release (domain.q);
|
||||
_gcry_mpi_release (domain.g);
|
||||
- sexp_release (deriveparms);
|
||||
return GPG_ERR_MISSING_VALUE;
|
||||
}
|
||||
|
||||
diff -up libgcrypt-1.8.4/cipher/rsa.c.fips-keygen libgcrypt-1.8.4/cipher/rsa.c
|
||||
--- libgcrypt-1.8.4/cipher/rsa.c.fips-keygen 2017-11-23 19:16:58.000000000 +0100
|
||||
+++ libgcrypt-1.8.4/cipher/rsa.c 2019-02-12 14:29:25.630513971 +0100
|
||||
@@ -389,7 +389,7 @@ generate_fips (RSA_secret_key *sk, unsig
|
||||
|
||||
if (nbits < 1024 || (nbits & 0x1FF))
|
||||
return GPG_ERR_INV_VALUE;
|
||||
- if (_gcry_enforced_fips_mode() && nbits != 2048 && nbits != 3072)
|
||||
+ if (fips_mode() && nbits < 2048)
|
||||
return GPG_ERR_INV_VALUE;
|
||||
|
||||
/* The random quality depends on the transient_key flag. */
|
||||
@@ -696,7 +696,7 @@ generate_x931 (RSA_secret_key *sk, unsig
|
||||
|
||||
*swapped = 0;
|
||||
|
||||
- if (e_value == 1) /* Alias for a secure value. */
|
||||
+ if (e_value == 1 || e_value == 0) /* Alias for a secure value. */
|
||||
e_value = 65537;
|
||||
|
||||
/* Point 1 of section 4.1: k = 1024 + 256s with S >= 0 */
|
||||
@ -1,184 +0,0 @@
|
||||
diff -up libgcrypt-1.8.4/tests/basic.c.tests-fipsmode libgcrypt-1.8.4/tests/basic.c
|
||||
--- libgcrypt-1.8.4/tests/basic.c.tests-fipsmode 2018-04-17 17:29:40.000000000 +0200
|
||||
+++ libgcrypt-1.8.4/tests/basic.c 2019-02-12 13:30:48.935791024 +0100
|
||||
@@ -6964,7 +6964,7 @@ check_ciphers (void)
|
||||
check_one_cipher (algos[i], GCRY_CIPHER_MODE_CTR, 0);
|
||||
if (gcry_cipher_get_algo_blklen (algos[i]) == GCRY_CCM_BLOCK_LEN)
|
||||
check_one_cipher (algos[i], GCRY_CIPHER_MODE_CCM, 0);
|
||||
- if (gcry_cipher_get_algo_blklen (algos[i]) == GCRY_GCM_BLOCK_LEN)
|
||||
+ if (!in_fips_mode && gcry_cipher_get_algo_blklen (algos[i]) == GCRY_GCM_BLOCK_LEN)
|
||||
check_one_cipher (algos[i], GCRY_CIPHER_MODE_GCM, 0);
|
||||
if (gcry_cipher_get_algo_blklen (algos[i]) == GCRY_OCB_BLOCK_LEN)
|
||||
check_one_cipher (algos[i], GCRY_CIPHER_MODE_OCB, 0);
|
||||
@@ -7010,11 +7010,17 @@ check_cipher_modes(void)
|
||||
check_cfb_cipher ();
|
||||
check_ofb_cipher ();
|
||||
check_ccm_cipher ();
|
||||
- check_gcm_cipher ();
|
||||
- check_poly1305_cipher ();
|
||||
- check_ocb_cipher ();
|
||||
+ if (!in_fips_mode)
|
||||
+ {
|
||||
+ check_gcm_cipher ();
|
||||
+ check_poly1305_cipher ();
|
||||
+ check_ocb_cipher ();
|
||||
+ }
|
||||
check_xts_cipher ();
|
||||
- check_gost28147_cipher ();
|
||||
+ if (!in_fips_mode)
|
||||
+ {
|
||||
+ check_gost28147_cipher ();
|
||||
+ }
|
||||
check_stream_cipher ();
|
||||
check_stream_cipher_large_block ();
|
||||
|
||||
@@ -10001,7 +10007,7 @@ check_mac (void)
|
||||
show_mac_not_available (algos[i].algo);
|
||||
continue;
|
||||
}
|
||||
- if (gcry_mac_test_algo (algos[i].algo) && in_fips_mode)
|
||||
+ if ((algos[i].algo == GCRY_MAC_GMAC_AES || gcry_mac_test_algo (algos[i].algo)) && in_fips_mode)
|
||||
{
|
||||
if (verbose)
|
||||
fprintf (stderr, " algorithm %d not available in fips mode\n",
|
||||
@@ -11095,8 +11101,6 @@ main (int argc, char **argv)
|
||||
/* If we are in fips mode do some more tests. */
|
||||
gcry_md_hd_t md;
|
||||
|
||||
- /* First trigger a self-test. */
|
||||
- xgcry_control (GCRYCTL_FORCE_FIPS_MODE, 0);
|
||||
if (!gcry_control (GCRYCTL_OPERATIONAL_P, 0))
|
||||
fail ("not in operational state after self-test\n");
|
||||
|
||||
@@ -11121,15 +11125,6 @@ main (int argc, char **argv)
|
||||
gcry_md_close (md);
|
||||
if (gcry_control (GCRYCTL_OPERATIONAL_P, 0))
|
||||
fail ("expected error state but still in operational state\n");
|
||||
- else
|
||||
- {
|
||||
- /* Now run a self-test and to get back into
|
||||
- operational state. */
|
||||
- xgcry_control (GCRYCTL_FORCE_FIPS_MODE, 0);
|
||||
- if (!gcry_control (GCRYCTL_OPERATIONAL_P, 0))
|
||||
- fail ("did not reach operational after error "
|
||||
- "and self-test\n");
|
||||
- }
|
||||
}
|
||||
}
|
||||
|
||||
diff -up libgcrypt-1.8.4/tests/benchmark.c.tests-fipsmode libgcrypt-1.8.4/tests/benchmark.c
|
||||
--- libgcrypt-1.8.4/tests/benchmark.c.tests-fipsmode 2019-02-12 11:31:44.859603883 +0100
|
||||
+++ libgcrypt-1.8.4/tests/benchmark.c 2019-02-12 14:10:40.271999352 +0100
|
||||
@@ -872,8 +872,10 @@ cipher_bench ( const char *algoname )
|
||||
|| (blklen == 1 && modes[modeidx].mode != GCRY_CIPHER_MODE_STREAM))
|
||||
continue;
|
||||
|
||||
- if (modes[modeidx].req_blocksize > 0
|
||||
- && blklen != modes[modeidx].req_blocksize)
|
||||
+ if ((modes[modeidx].req_blocksize > 0
|
||||
+ && blklen != modes[modeidx].req_blocksize)
|
||||
+ || (in_fips_mode
|
||||
+ && modes[modeidx].mode == GCRY_CIPHER_MODE_GCM))
|
||||
{
|
||||
printf (" %7s %7s", "-", "-" );
|
||||
continue;
|
||||
diff -up libgcrypt-1.8.4/tests/bench-slope.c.tests-fipsmode libgcrypt-1.8.4/tests/bench-slope.c
|
||||
--- libgcrypt-1.8.4/tests/bench-slope.c.tests-fipsmode 2017-11-23 19:16:58.000000000 +0100
|
||||
+++ libgcrypt-1.8.4/tests/bench-slope.c 2019-02-12 14:14:33.618763325 +0100
|
||||
@@ -1338,7 +1338,7 @@ cipher_bench_one (int algo, struct bench
|
||||
return;
|
||||
|
||||
/* GCM has restrictions for block-size */
|
||||
- if (mode.mode == GCRY_CIPHER_MODE_GCM && blklen != GCRY_GCM_BLOCK_LEN)
|
||||
+ if (mode.mode == GCRY_CIPHER_MODE_GCM && (gcry_fips_mode_active () || blklen != GCRY_GCM_BLOCK_LEN))
|
||||
return;
|
||||
|
||||
/* XTS has restrictions for block-size */
|
||||
diff -up libgcrypt-1.8.4/tests/pubkey.c.tests-fipsmode libgcrypt-1.8.4/tests/pubkey.c
|
||||
--- libgcrypt-1.8.4/tests/pubkey.c.tests-fipsmode 2017-11-23 19:16:58.000000000 +0100
|
||||
+++ libgcrypt-1.8.4/tests/pubkey.c 2019-02-12 13:52:25.658746415 +0100
|
||||
@@ -504,15 +504,30 @@ get_dsa_key_with_domain_new (gcry_sexp_t
|
||||
rc = gcry_sexp_new
|
||||
(&key_spec,
|
||||
"(genkey (dsa (transient-key)(domain"
|
||||
- "(p #d3aed1876054db831d0c1348fbb1ada72507e5fbf9a62cbd47a63aeb7859d6921"
|
||||
- "4adeb9146a6ec3f43520f0fd8e3125dd8bbc5d87405d1ac5f82073cd762a3f8d7"
|
||||
- "74322657c9da88a7d2f0e1a9ceb84a39cb40876179e6a76e400498de4bb9379b0"
|
||||
- "5f5feb7b91eb8fea97ee17a955a0a8a37587a272c4719d6feb6b54ba4ab69#)"
|
||||
- "(q #9c916d121de9a03f71fb21bc2e1c0d116f065a4f#)"
|
||||
- "(g #8157c5f68ca40b3ded11c353327ab9b8af3e186dd2e8dade98761a0996dda99ab"
|
||||
- "0250d3409063ad99efae48b10c6ab2bba3ea9a67b12b911a372a2bba260176fad"
|
||||
- "b4b93247d9712aad13aa70216c55da9858f7a298deb670a403eb1e7c91b847f1e"
|
||||
- "ccfbd14bd806fd42cf45dbb69cd6d6b43add2a78f7d16928eaa04458dea44#)"
|
||||
+ " (p #a85378d8fd3f8d72ec7418080da21317e43ec4b62ba8c862"
|
||||
+ " 3b7e4d04441dd1a0658662596493ca8e9e8fbb7e34aaddb6"
|
||||
+ " 2e5d67b6d09a6e61b769e7c352aa2b10e20ca0636963b552"
|
||||
+ " 3e86470decbbeda027e797e7b67635d4d49c30700e74af8a"
|
||||
+ " 0ff156a801af57a26e7078f1d82f74908ecb6d07e70b3503"
|
||||
+ " eed94fa32cf17a7fc3d6cf40dc7b00830e6a2566dc073e34"
|
||||
+ " 3312517c6aa5152b4bfecd2e551fee346318a153423c996b"
|
||||
+ " 0d5dcb9102aedd38798616f1f1e0d6c403525b1f9b3d4dc7"
|
||||
+ " 66de2dfc4a56d7b8ba5963d60f3e16318870ad436952e557"
|
||||
+ " 65374eab85e8ec17d6b9a4547b9b5f2752f3105be809b23a"
|
||||
+ " 2c8d7469db02e24d592394a7dba069e9#)"
|
||||
+ " (q #d277044e50f5a4e3f510a50a0b84fdffbca047ed27602056"
|
||||
+ " 7441a0a5#)"
|
||||
+ " (g #13d754e21fd241655da891c522a65a72a89bdc64ec9b54a8"
|
||||
+ " 21ed4a898b490e0c4fcb72192a4a20f541f3f2925399f0ba"
|
||||
+ " ecf929aafbf79dfe4332393b32cd2e2fcf272f32a627434a"
|
||||
+ " 0df242b75b414df372121e53a553f222f836b000f016485b"
|
||||
+ " 6bd0898451801dcd8de64cd5365696ffc532d528c506620a"
|
||||
+ " 942a0305046d8f1876341f1e570bc3974ba6b9a438e97023"
|
||||
+ " 02a2e6e67bfd06d32bc679962271d7b40cd72f386e64e0d7"
|
||||
+ " ef86ca8ca5d14228dc2a4f16e3189886b5990674f4200f3a"
|
||||
+ " 4cf65a3f0ddba1fa672dff2f5e143d10e4e97ae84f6da095"
|
||||
+ " 35d5b9df259181a79b63b069e949972b02ba36b3586aab7e"
|
||||
+ " 45f322f82e4e85ca3ab85591b3c2a966#)"
|
||||
")))", 0, 1);
|
||||
if (rc)
|
||||
die ("error creating S-expression: %s\n", gcry_strerror (rc));
|
||||
@@ -595,7 +610,7 @@ get_dsa_key_fips186_with_seed_new (gcry_
|
||||
" (use-fips186)"
|
||||
" (transient-key)"
|
||||
" (derive-parms"
|
||||
- " (seed #0cb1990c1fd3626055d7a0096f8fa99807399871#))))",
|
||||
+ " (seed #8b4c4d671fff82e8ed932260206d0571e3a1c2cee8cd94cb73fe58f9b67488fa#))))",
|
||||
0, 1);
|
||||
if (rc)
|
||||
die ("error creating S-expression: %s\n", gcry_strerror (rc));
|
||||
diff -up libgcrypt-1.8.4/tests/t-cv25519.c.tests-fipsmode libgcrypt-1.8.4/tests/t-cv25519.c
|
||||
--- libgcrypt-1.8.4/tests/t-cv25519.c.tests-fipsmode 2017-11-23 19:16:58.000000000 +0100
|
||||
+++ libgcrypt-1.8.4/tests/t-cv25519.c 2019-02-12 14:02:35.935705390 +0100
|
||||
@@ -560,6 +560,9 @@ main (int argc, char **argv)
|
||||
xgcry_control (GCRYCTL_SET_DEBUG_FLAGS, 1u , 0);
|
||||
xgcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0);
|
||||
xgcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
|
||||
+ /* Curve25519 isn't supported in fips mode */
|
||||
+ if (gcry_fips_mode_active())
|
||||
+ return 77;
|
||||
|
||||
start_timer ();
|
||||
check_cv25519 ();
|
||||
diff -up libgcrypt-1.8.4/tests/t-secmem.c.tests-fipsmode libgcrypt-1.8.4/tests/t-secmem.c
|
||||
--- libgcrypt-1.8.4/tests/t-secmem.c.tests-fipsmode 2017-11-23 19:19:54.000000000 +0100
|
||||
+++ libgcrypt-1.8.4/tests/t-secmem.c 2019-02-12 11:51:02.462190538 +0100
|
||||
@@ -174,7 +174,8 @@ main (int argc, char **argv)
|
||||
xgcry_control (GCRYCTL_SET_DEBUG_FLAGS, 1u , 0);
|
||||
xgcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0);
|
||||
xgcry_control (GCRYCTL_INIT_SECMEM, pool_size, 0);
|
||||
- gcry_set_outofcore_handler (outofcore_handler, NULL);
|
||||
+ if (!gcry_fips_mode_active ())
|
||||
+ gcry_set_outofcore_handler (outofcore_handler, NULL);
|
||||
xgcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
|
||||
|
||||
/* Libgcrypt prints a warning when the first overflow is allocated;
|
||||
@@ -184,7 +185,8 @@ main (int argc, char **argv)
|
||||
|
||||
|
||||
test_secmem ();
|
||||
- test_secmem_overflow ();
|
||||
+ if (!gcry_fips_mode_active ())
|
||||
+ test_secmem_overflow ();
|
||||
/* FIXME: We need to improve the tests, for example by registering
|
||||
* our own log handler and comparing the output of
|
||||
* PRIV_CTL_DUMP_SECMEM_STATS to expected pattern. */
|
||||
@ -1,77 +0,0 @@
|
||||
diff -up libgcrypt-1.8.4/random/rndlinux.c.use-poll libgcrypt-1.8.4/random/rndlinux.c
|
||||
--- libgcrypt-1.8.4/random/rndlinux.c.use-poll 2018-10-26 13:50:20.000000000 +0200
|
||||
+++ libgcrypt-1.8.4/random/rndlinux.c 2018-11-20 15:51:56.760669058 +0100
|
||||
@@ -32,6 +32,7 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
+#include <poll.h>
|
||||
#if defined(__linux__) && defined(HAVE_SYSCALL)
|
||||
# include <sys/syscall.h>
|
||||
#endif
|
||||
@@ -241,9 +242,8 @@ _gcry_rndlinux_gather_random (void (*add
|
||||
return with something we will actually use 100ms. */
|
||||
while (length)
|
||||
{
|
||||
- fd_set rfds;
|
||||
- struct timeval tv;
|
||||
int rc;
|
||||
+ struct pollfd pfd;
|
||||
|
||||
/* If we have a modern Linux kernel, we first try to use the new
|
||||
* getrandom syscall. That call guarantees that the kernel's
|
||||
@@ -300,36 +300,25 @@ _gcry_rndlinux_gather_random (void (*add
|
||||
any_need_entropy = 1;
|
||||
}
|
||||
|
||||
- /* If the system has no limit on the number of file descriptors
|
||||
- and we encounter an fd which is larger than the fd_set size,
|
||||
- we don't use the select at all. The select code is only used
|
||||
- to emit progress messages. A better solution would be to
|
||||
- fall back to poll() if available. */
|
||||
-#ifdef FD_SETSIZE
|
||||
- if (fd < FD_SETSIZE)
|
||||
-#endif
|
||||
+ pfd.fd = fd;
|
||||
+ pfd.events = POLLIN;
|
||||
+
|
||||
+ _gcry_pre_syscall ();
|
||||
+ rc = poll(&pfd, 1, delay);
|
||||
+ _gcry_post_syscall ();
|
||||
+ if (!rc)
|
||||
{
|
||||
- FD_ZERO(&rfds);
|
||||
- FD_SET(fd, &rfds);
|
||||
- tv.tv_sec = delay;
|
||||
- tv.tv_usec = delay? 0 : 100000;
|
||||
- _gcry_pre_syscall ();
|
||||
- rc = select (fd+1, &rfds, NULL, NULL, &tv);
|
||||
- _gcry_post_syscall ();
|
||||
- if (!rc)
|
||||
- {
|
||||
- any_need_entropy = 1;
|
||||
- delay = 3; /* Use 3 seconds henceforth. */
|
||||
- continue;
|
||||
- }
|
||||
- else if( rc == -1 )
|
||||
- {
|
||||
- log_error ("select() error: %s\n", strerror(errno));
|
||||
- if (!delay)
|
||||
- delay = 1; /* Use 1 second if we encounter an error before
|
||||
- we have ever blocked. */
|
||||
- continue;
|
||||
- }
|
||||
+ any_need_entropy = 1;
|
||||
+ delay = 3000; /* Use 3 seconds henceforth. */
|
||||
+ continue;
|
||||
+ }
|
||||
+ else if( rc == -1 )
|
||||
+ {
|
||||
+ log_error ("poll() error: %s\n", strerror(errno));
|
||||
+ if (!delay)
|
||||
+ delay = 1000; /* Use 1 second if we encounter an error before
|
||||
+ we have ever blocked. */
|
||||
+ continue;
|
||||
}
|
||||
|
||||
do
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,139 +0,0 @@
|
||||
diff -up libgcrypt-1.8.5/src/fips.c.fips-module libgcrypt-1.8.5/src/fips.c
|
||||
--- libgcrypt-1.8.5/src/fips.c.fips-module 2020-04-20 19:07:45.924919645 +0200
|
||||
+++ libgcrypt-1.8.5/src/fips.c 2020-04-20 19:10:33.690722470 +0200
|
||||
@@ -35,10 +35,6 @@
|
||||
#include "hmac256.h"
|
||||
|
||||
|
||||
-/* The name of the file used to force libgcrypt into fips mode. */
|
||||
-#define FIPS_FORCE_FILE "/etc/gcrypt/fips_enabled"
|
||||
-
|
||||
-
|
||||
/* The states of the finite state machine used in fips mode. */
|
||||
enum module_states
|
||||
{
|
||||
@@ -122,54 +118,6 @@ _gcry_initialize_fips_mode (int force)
|
||||
goto leave;
|
||||
}
|
||||
|
||||
- /* For testing the system it is useful to override the system
|
||||
- provided detection of the FIPS mode and force FIPS mode using a
|
||||
- file. The filename is hardwired so that there won't be any
|
||||
- confusion on whether /etc/gcrypt/ or /usr/local/etc/gcrypt/ is
|
||||
- actually used. The file itself may be empty. */
|
||||
- if ( !access (FIPS_FORCE_FILE, F_OK) )
|
||||
- {
|
||||
- gcry_assert (!no_fips_mode_required);
|
||||
- goto leave;
|
||||
- }
|
||||
-
|
||||
- /* Checking based on /proc file properties. */
|
||||
- {
|
||||
- static const char procfname[] = "/proc/sys/crypto/fips_enabled";
|
||||
- FILE *fp;
|
||||
- int saved_errno;
|
||||
-
|
||||
- fp = fopen (procfname, "r");
|
||||
- if (fp)
|
||||
- {
|
||||
- char line[256];
|
||||
-
|
||||
- if (fgets (line, sizeof line, fp) && atoi (line))
|
||||
- {
|
||||
- /* System is in fips mode. */
|
||||
- fclose (fp);
|
||||
- gcry_assert (!no_fips_mode_required);
|
||||
- goto leave;
|
||||
- }
|
||||
- fclose (fp);
|
||||
- }
|
||||
- else if ((saved_errno = errno) != ENOENT
|
||||
- && saved_errno != EACCES
|
||||
- && !access ("/proc/version", F_OK) )
|
||||
- {
|
||||
- /* Problem reading the fips file despite that we have the proc
|
||||
- file system. We better stop right away. */
|
||||
- log_info ("FATAL: error reading `%s' in libgcrypt: %s\n",
|
||||
- procfname, strerror (saved_errno));
|
||||
-#ifdef HAVE_SYSLOG
|
||||
- syslog (LOG_USER|LOG_ERR, "Libgcrypt error: "
|
||||
- "reading `%s' failed: %s - abort",
|
||||
- procfname, strerror (saved_errno));
|
||||
-#endif /*HAVE_SYSLOG*/
|
||||
- abort ();
|
||||
- }
|
||||
- }
|
||||
-
|
||||
/* Fips not not requested, set flag. */
|
||||
no_fips_mode_required = 1;
|
||||
|
||||
diff -up libgcrypt-1.8.5/src/g10lib.h.fips-module libgcrypt-1.8.5/src/g10lib.h
|
||||
--- libgcrypt-1.8.5/src/g10lib.h.fips-module 2020-04-20 19:07:45.918919759 +0200
|
||||
+++ libgcrypt-1.8.5/src/g10lib.h 2020-04-20 19:11:05.003125740 +0200
|
||||
@@ -422,6 +422,9 @@ gpg_err_code_t _gcry_sexp_vextract_param
|
||||
|
||||
/*-- fips.c --*/
|
||||
|
||||
+/* The name of the file used to force libgcrypt into fips mode. */
|
||||
+#define FIPS_FORCE_FILE "/etc/gcrypt/fips_enabled"
|
||||
+
|
||||
void _gcry_initialize_fips_mode (int force);
|
||||
|
||||
int _gcry_fips_mode (void);
|
||||
diff -up libgcrypt-1.8.5/src/global.c.fips-module libgcrypt-1.8.5/src/global.c
|
||||
--- libgcrypt-1.8.5/src/global.c.fips-module 2020-04-20 19:07:45.919919741 +0200
|
||||
+++ libgcrypt-1.8.5/src/global.c 2020-04-20 19:07:45.950919149 +0200
|
||||
@@ -160,6 +160,53 @@ void __attribute__ ((constructor)) _gcry
|
||||
rv = access (FIPS_MODULE_PATH, F_OK);
|
||||
if (rv < 0 && errno != ENOENT)
|
||||
rv = 0;
|
||||
+
|
||||
+ /* For testing the system it is useful to override the system
|
||||
+ provided detection of the FIPS mode and force FIPS mode using a
|
||||
+ file. The filename is hardwired so that there won't be any
|
||||
+ confusion on whether /etc/gcrypt/ or /usr/local/etc/gcrypt/ is
|
||||
+ actually used. The file itself may be empty. */
|
||||
+ if ( !access (FIPS_FORCE_FILE, F_OK) )
|
||||
+ {
|
||||
+ rv = 0;
|
||||
+ force_fips_mode = 1;
|
||||
+ }
|
||||
+
|
||||
+ /* Checking based on /proc file properties. */
|
||||
+ {
|
||||
+ static const char procfname[] = "/proc/sys/crypto/fips_enabled";
|
||||
+ FILE *fp;
|
||||
+ int saved_errno;
|
||||
+
|
||||
+ fp = fopen (procfname, "r");
|
||||
+ if (fp)
|
||||
+ {
|
||||
+ char line[256];
|
||||
+
|
||||
+ if (fgets (line, sizeof line, fp) && atoi (line))
|
||||
+ {
|
||||
+ /* System is in fips mode. */
|
||||
+ rv = 0;
|
||||
+ force_fips_mode = 1;
|
||||
+ }
|
||||
+ fclose (fp);
|
||||
+ }
|
||||
+ else if ((saved_errno = errno) != ENOENT
|
||||
+ && saved_errno != EACCES
|
||||
+ && !access ("/proc/version", F_OK) )
|
||||
+ {
|
||||
+ /* Problem reading the fips file despite that we have the proc
|
||||
+ file system. We better stop right away. */
|
||||
+ log_info ("FATAL: error reading `%s' in libgcrypt: %s\n",
|
||||
+ procfname, strerror (saved_errno));
|
||||
+#ifdef HAVE_SYSLOG
|
||||
+ syslog (LOG_USER|LOG_ERR, "Libgcrypt error: "
|
||||
+ "reading `%s' failed: %s - abort",
|
||||
+ procfname, strerror (saved_errno));
|
||||
+#endif /*HAVE_SYSLOG*/
|
||||
+ abort ();
|
||||
+ }
|
||||
+ }
|
||||
|
||||
if (!rv)
|
||||
{
|
||||
@ -1,285 +0,0 @@
|
||||
diff -up libgcrypt-1.8.5/random/rand-internal.h.getrandom libgcrypt-1.8.5/random/rand-internal.h
|
||||
--- libgcrypt-1.8.5/random/rand-internal.h.getrandom 2017-11-23 19:16:58.000000000 +0100
|
||||
+++ libgcrypt-1.8.5/random/rand-internal.h 2020-04-20 14:55:34.875949624 +0200
|
||||
@@ -47,6 +47,7 @@ void _gcry_random_progress (const char *
|
||||
|
||||
/*-- random-csprng.c --*/
|
||||
void _gcry_rngcsprng_initialize (int full);
|
||||
+void _gcry_rngcsprng_deinit (void);
|
||||
void _gcry_rngcsprng_close_fds (void);
|
||||
void _gcry_rngcsprng_dump_stats (void);
|
||||
void _gcry_rngcsprng_secure_alloc (void);
|
||||
@@ -68,6 +69,7 @@ void _gcry_rngcsprng_fast_poll (void);
|
||||
|
||||
/*-- random-drbg.c --*/
|
||||
void _gcry_rngdrbg_inititialize (int full);
|
||||
+void _gcry_rngdrbg_deinit (void);
|
||||
void _gcry_rngdrbg_close_fds (void);
|
||||
void _gcry_rngdrbg_dump_stats (void);
|
||||
int _gcry_rngdrbg_is_faked (void);
|
||||
diff -up libgcrypt-1.8.5/random/random.c.getrandom libgcrypt-1.8.5/random/random.c
|
||||
--- libgcrypt-1.8.5/random/random.c.getrandom 2017-11-23 19:16:58.000000000 +0100
|
||||
+++ libgcrypt-1.8.5/random/random.c 2020-04-20 14:55:34.876949605 +0200
|
||||
@@ -110,8 +110,8 @@ _gcry_random_read_conf (void)
|
||||
unsigned int result = 0;
|
||||
|
||||
fp = fopen (fname, "r");
|
||||
- if (!fp)
|
||||
- return result;
|
||||
+ if (!fp) /* We make only_urandom the default. */
|
||||
+ return RANDOM_CONF_ONLY_URANDOM;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
@@ -228,6 +228,22 @@ _gcry_random_initialize (int full)
|
||||
}
|
||||
|
||||
|
||||
+/* Deinitialize this random subsystem. */
|
||||
+void
|
||||
+_gcry_random_deinit (void)
|
||||
+{
|
||||
+ if (fips_mode ())
|
||||
+ _gcry_rngdrbg_deinit ();
|
||||
+ else if (rng_types.standard)
|
||||
+ _gcry_rngcsprng_deinit ();
|
||||
+ else if (rng_types.fips)
|
||||
+ _gcry_rngdrbg_deinit ();
|
||||
+ else
|
||||
+ _gcry_rngcsprng_deinit ();
|
||||
+ /* not needed for system */
|
||||
+}
|
||||
+
|
||||
+
|
||||
/* If possible close file descriptors used by the RNG. */
|
||||
void
|
||||
_gcry_random_close_fds (void)
|
||||
diff -up libgcrypt-1.8.5/random/random-csprng.c.getrandom libgcrypt-1.8.5/random/random-csprng.c
|
||||
--- libgcrypt-1.8.5/random/random-csprng.c.getrandom 2017-11-23 19:16:58.000000000 +0100
|
||||
+++ libgcrypt-1.8.5/random/random-csprng.c 2020-04-20 15:04:27.182877975 +0200
|
||||
@@ -55,6 +55,10 @@
|
||||
#ifdef __MINGW32__
|
||||
#include <process.h>
|
||||
#endif
|
||||
+#if defined(__linux__) && defined(HAVE_SYSCALL)
|
||||
+# include <sys/syscall.h>
|
||||
+# include <linux/random.h>
|
||||
+#endif
|
||||
#include "g10lib.h"
|
||||
#include "random.h"
|
||||
#include "rand-internal.h"
|
||||
@@ -343,6 +347,21 @@ _gcry_rngcsprng_initialize (int full)
|
||||
}
|
||||
|
||||
|
||||
+void
|
||||
+_gcry_rngcsprng_deinit (void)
|
||||
+{
|
||||
+ lock_pool();
|
||||
+ pool_writepos = 0;
|
||||
+ pool_readpos = 0;
|
||||
+ pool_filled = 0;
|
||||
+ pool_filled_counter = 0;
|
||||
+ did_initial_extra_seeding = 0;
|
||||
+ pool_balance = 0;
|
||||
+ just_mixed = 0;
|
||||
+ unlock_pool();
|
||||
+}
|
||||
+
|
||||
+
|
||||
/* Try to close the FDs of the random gather module. This is
|
||||
currently only implemented for rndlinux. */
|
||||
void
|
||||
@@ -1116,6 +1135,22 @@ getfnc_gather_random (void))(void (*)(co
|
||||
enum random_origins, size_t, int);
|
||||
|
||||
#if USE_RNDLINUX
|
||||
+#if defined(__linux__) && defined(HAVE_SYSCALL) && defined(__NR_getrandom)
|
||||
+ long ret;
|
||||
+ char buffer[1];
|
||||
+
|
||||
+ _gcry_pre_syscall ();
|
||||
+ ret = syscall (__NR_getrandom,
|
||||
+ (void*)buffer, (size_t)1, (unsigned int)GRND_NONBLOCK);
|
||||
+ _gcry_post_syscall ();
|
||||
+ if (ret != -1 || errno != ENOSYS)
|
||||
+ {
|
||||
+ fnc = _gcry_rndlinux_gather_random;
|
||||
+ return fnc;
|
||||
+ }
|
||||
+ else
|
||||
+ /* The syscall is not supported - fallback to /dev/urandom. */
|
||||
+#endif
|
||||
if ( !access (NAME_OF_DEV_RANDOM, R_OK)
|
||||
&& !access (NAME_OF_DEV_URANDOM, R_OK))
|
||||
{
|
||||
diff -up libgcrypt-1.8.5/random/random-drbg.c.getrandom libgcrypt-1.8.5/random/random-drbg.c
|
||||
--- libgcrypt-1.8.5/random/random-drbg.c.getrandom 2017-11-23 19:16:58.000000000 +0100
|
||||
+++ libgcrypt-1.8.5/random/random-drbg.c 2020-04-20 15:02:37.782947902 +0200
|
||||
@@ -1811,6 +1811,22 @@ _gcry_rngdrbg_inititialize (int full)
|
||||
}
|
||||
|
||||
/*
|
||||
+ * Deinitialize the DRBG invoked by the libgcrypt API
|
||||
+ * It will be automatically re-initialized on next call
|
||||
+ */
|
||||
+void
|
||||
+_gcry_rngdrbg_deinit (void)
|
||||
+{
|
||||
+ drbg_lock ();
|
||||
+ if (drbg_state)
|
||||
+ {
|
||||
+ drbg_uninstantiate (drbg_state);
|
||||
+ drbg_state = NULL;
|
||||
+ }
|
||||
+ drbg_unlock ();
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
* Backend handler function for GCRYCTL_DRBG_REINIT
|
||||
*
|
||||
* Select a different DRBG type and initialize it.
|
||||
diff -up libgcrypt-1.8.5/random/random.h.getrandom libgcrypt-1.8.5/random/random.h
|
||||
--- libgcrypt-1.8.5/random/random.h.getrandom 2017-11-23 19:16:58.000000000 +0100
|
||||
+++ libgcrypt-1.8.5/random/random.h 2020-04-20 14:55:34.877949586 +0200
|
||||
@@ -29,6 +29,7 @@ void _gcry_register_random_progress (voi
|
||||
|
||||
void _gcry_set_preferred_rng_type (int type);
|
||||
void _gcry_random_initialize (int full);
|
||||
+void _gcry_random_deinit (void);
|
||||
void _gcry_random_close_fds (void);
|
||||
int _gcry_get_rng_type (int ignore_fips_mode);
|
||||
void _gcry_random_dump_stats(void);
|
||||
diff -up libgcrypt-1.8.5/random/rndlinux.c.getrandom libgcrypt-1.8.5/random/rndlinux.c
|
||||
--- libgcrypt-1.8.5/random/rndlinux.c.getrandom 2020-04-20 15:01:50.159848963 +0200
|
||||
+++ libgcrypt-1.8.5/random/rndlinux.c 2020-04-20 16:14:21.901610921 +0200
|
||||
@@ -35,6 +35,7 @@
|
||||
#include <poll.h>
|
||||
#if defined(__linux__) && defined(HAVE_SYSCALL)
|
||||
# include <sys/syscall.h>
|
||||
+# include <linux/random.h>
|
||||
#endif
|
||||
|
||||
#include "types.h"
|
||||
@@ -147,12 +148,12 @@ _gcry_rndlinux_gather_random (void (*add
|
||||
if (!add)
|
||||
{
|
||||
/* Special mode to close the descriptors. */
|
||||
- if (fd_random != -1)
|
||||
+ if (fd_random >= 0)
|
||||
{
|
||||
close (fd_random);
|
||||
fd_random = -1;
|
||||
}
|
||||
- if (fd_urandom != -1)
|
||||
+ if (fd_urandom >= 0)
|
||||
{
|
||||
close (fd_urandom);
|
||||
fd_urandom = -1;
|
||||
@@ -166,12 +167,12 @@ _gcry_rndlinux_gather_random (void (*add
|
||||
apid = getpid ();
|
||||
if (my_pid != apid)
|
||||
{
|
||||
- if (fd_random != -1)
|
||||
+ if (fd_random >= 0)
|
||||
{
|
||||
close (fd_random);
|
||||
fd_random = -1;
|
||||
}
|
||||
- if (fd_urandom != -1)
|
||||
+ if (fd_urandom >= 0)
|
||||
{
|
||||
close (fd_urandom);
|
||||
fd_urandom = -1;
|
||||
@@ -216,7 +217,23 @@ _gcry_rndlinux_gather_random (void (*add
|
||||
that we always require the device to be existent but want a more
|
||||
graceful behaviour if the rarely needed close operation has been
|
||||
used and the device needs to be re-opened later. */
|
||||
- if (level >= GCRY_VERY_STRONG_RANDOM && !only_urandom)
|
||||
+#if defined(__linux__) && defined(HAVE_SYSCALL) && defined(__NR_getrandom)
|
||||
+ if (fd_urandom != -2 && !_gcry_in_constructor ())
|
||||
+ {
|
||||
+ long ret;
|
||||
+
|
||||
+ _gcry_pre_syscall ();
|
||||
+ ret = syscall (__NR_getrandom,
|
||||
+ (void*)buffer, (size_t)1, (unsigned int)GRND_NONBLOCK);
|
||||
+ _gcry_post_syscall ();
|
||||
+ if (ret > -1 || errno == EAGAIN || errno == EINTR)
|
||||
+ {
|
||||
+ fd_urandom = -2;
|
||||
+ fd_random = -2;
|
||||
+ }
|
||||
+ }
|
||||
+#endif
|
||||
+ if (level >= GCRY_VERY_STRONG_RANDOM && !only_urandom && !_gcry_in_constructor ())
|
||||
{
|
||||
if (fd_random == -1)
|
||||
{
|
||||
@@ -255,6 +272,7 @@ _gcry_rndlinux_gather_random (void (*add
|
||||
* syscall and not a new device and thus we are not able to use
|
||||
* select(2) to have a timeout. */
|
||||
#if defined(__linux__) && defined(HAVE_SYSCALL) && defined(__NR_getrandom)
|
||||
+ if (fd == -2)
|
||||
{
|
||||
long ret;
|
||||
size_t nbytes;
|
||||
@@ -270,9 +288,7 @@ _gcry_rndlinux_gather_random (void (*add
|
||||
_gcry_post_syscall ();
|
||||
}
|
||||
while (ret == -1 && errno == EINTR);
|
||||
- if (ret == -1 && errno == ENOSYS)
|
||||
- ; /* The syscall is not supported - fallback to pulling from fd. */
|
||||
- else
|
||||
+ if (1)
|
||||
{ /* The syscall is supported. Some sanity checks. */
|
||||
if (ret == -1)
|
||||
log_fatal ("unexpected error from getrandom: %s\n",
|
||||
diff -up libgcrypt-1.8.5/src/g10lib.h.getrandom libgcrypt-1.8.5/src/g10lib.h
|
||||
--- libgcrypt-1.8.5/src/g10lib.h.getrandom 2020-04-20 15:08:16.528538580 +0200
|
||||
+++ libgcrypt-1.8.5/src/g10lib.h 2020-04-20 15:08:28.641309399 +0200
|
||||
@@ -464,6 +464,6 @@ gpg_err_code_t _gcry_fips_run_selftests
|
||||
void _gcry_fips_noreturn (void);
|
||||
#define fips_noreturn() (_gcry_fips_noreturn ())
|
||||
|
||||
-
|
||||
+int _gcry_in_constructor (void);
|
||||
|
||||
#endif /* G10LIB_H */
|
||||
diff -up libgcrypt-1.8.5/src/global.c.getrandom libgcrypt-1.8.5/src/global.c
|
||||
--- libgcrypt-1.8.5/src/global.c.getrandom 2020-04-20 15:06:21.891707597 +0200
|
||||
+++ libgcrypt-1.8.5/src/global.c 2020-04-20 15:07:29.018437509 +0200
|
||||
@@ -145,10 +145,18 @@ global_init (void)
|
||||
#define FIPS_MODULE_PATH "/etc/system-fips"
|
||||
#endif
|
||||
|
||||
+static int in_constructor = 0;
|
||||
+
|
||||
+int _gcry_in_constructor(void)
|
||||
+{
|
||||
+ return in_constructor;
|
||||
+}
|
||||
+
|
||||
void __attribute__ ((constructor)) _gcry_global_constructor (void)
|
||||
{
|
||||
int rv;
|
||||
|
||||
+ in_constructor = 1;
|
||||
rv = access (FIPS_MODULE_PATH, F_OK);
|
||||
if (rv < 0 && errno != ENOENT)
|
||||
rv = 0;
|
||||
@@ -163,10 +171,12 @@ void __attribute__ ((constructor)) _gcry
|
||||
/* force selftests */
|
||||
global_init();
|
||||
_gcry_fips_run_selftests (0);
|
||||
- if (!fips_mode())
|
||||
- _gcry_random_close_fds ();
|
||||
+ _gcry_random_close_fds ();
|
||||
+ _gcry_random_deinit ();
|
||||
no_secure_memory = no_secmem_save;
|
||||
}
|
||||
+
|
||||
+ in_constructor = 0;
|
||||
}
|
||||
|
||||
/* This function is called by the macro fips_is_operational and makes
|
||||
@ -1,348 +0,0 @@
|
||||
diff -up libgcrypt-1.8.5/cipher/camellia-aesni-avx2-amd64.S.intel-cet libgcrypt-1.8.5/cipher/camellia-aesni-avx2-amd64.S
|
||||
--- libgcrypt-1.8.5/cipher/camellia-aesni-avx2-amd64.S.intel-cet 2017-11-23 19:16:58.000000000 +0100
|
||||
+++ libgcrypt-1.8.5/cipher/camellia-aesni-avx2-amd64.S 2020-01-23 15:36:44.148972045 +0100
|
||||
@@ -18,8 +18,9 @@
|
||||
* License along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
-#ifdef __x86_64
|
||||
#include <config.h>
|
||||
+
|
||||
+#ifdef __x86_64
|
||||
#if (defined(HAVE_COMPATIBLE_GCC_AMD64_PLATFORM_AS) || \
|
||||
defined(HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS)) && \
|
||||
defined(ENABLE_AESNI_SUPPORT) && defined(ENABLE_AVX2_SUPPORT)
|
||||
diff -up libgcrypt-1.8.5/cipher/camellia-aesni-avx-amd64.S.intel-cet libgcrypt-1.8.5/cipher/camellia-aesni-avx-amd64.S
|
||||
--- libgcrypt-1.8.5/cipher/camellia-aesni-avx-amd64.S.intel-cet 2017-11-23 19:16:58.000000000 +0100
|
||||
+++ libgcrypt-1.8.5/cipher/camellia-aesni-avx-amd64.S 2020-01-23 15:36:44.145972088 +0100
|
||||
@@ -18,8 +18,9 @@
|
||||
* License along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
-#ifdef __x86_64
|
||||
#include <config.h>
|
||||
+
|
||||
+#ifdef __x86_64
|
||||
#if (defined(HAVE_COMPATIBLE_GCC_AMD64_PLATFORM_AS) || \
|
||||
defined(HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS)) && \
|
||||
defined(ENABLE_AESNI_SUPPORT) && defined(ENABLE_AVX_SUPPORT)
|
||||
diff -up libgcrypt-1.8.5/cipher/chacha20-avx2-amd64.S.intel-cet libgcrypt-1.8.5/cipher/chacha20-avx2-amd64.S
|
||||
--- libgcrypt-1.8.5/cipher/chacha20-avx2-amd64.S.intel-cet 2017-11-23 19:16:58.000000000 +0100
|
||||
+++ libgcrypt-1.8.5/cipher/chacha20-avx2-amd64.S 2020-01-23 15:36:16.780250066 +0100
|
||||
@@ -48,6 +48,9 @@
|
||||
.globl _gcry_chacha20_amd64_avx2_blocks
|
||||
ELF(.type _gcry_chacha20_amd64_avx2_blocks,@function;)
|
||||
_gcry_chacha20_amd64_avx2_blocks:
|
||||
+#ifdef _CET_ENDBR
|
||||
+ _CET_ENDBR
|
||||
+#endif
|
||||
.Lchacha_blocks_avx2_local:
|
||||
vzeroupper
|
||||
pushq %rbx
|
||||
diff -up libgcrypt-1.8.5/cipher/chacha20-sse2-amd64.S.intel-cet libgcrypt-1.8.5/cipher/chacha20-sse2-amd64.S
|
||||
--- libgcrypt-1.8.5/cipher/chacha20-sse2-amd64.S.intel-cet 2017-11-23 19:16:58.000000000 +0100
|
||||
+++ libgcrypt-1.8.5/cipher/chacha20-sse2-amd64.S 2020-01-23 15:36:16.783250095 +0100
|
||||
@@ -41,6 +41,9 @@
|
||||
.globl _gcry_chacha20_amd64_sse2_blocks
|
||||
ELF(.type _gcry_chacha20_amd64_sse2_blocks,@function;)
|
||||
_gcry_chacha20_amd64_sse2_blocks:
|
||||
+#ifdef _CET_ENDBR
|
||||
+ _CET_ENDBR
|
||||
+#endif
|
||||
.Lchacha_blocks_sse2_local:
|
||||
pushq %rbx
|
||||
pushq %rbp
|
||||
diff -up libgcrypt-1.8.5/cipher/poly1305-avx2-amd64.S.intel-cet libgcrypt-1.8.5/cipher/poly1305-avx2-amd64.S
|
||||
--- libgcrypt-1.8.5/cipher/poly1305-avx2-amd64.S.intel-cet 2017-11-23 19:16:58.000000000 +0100
|
||||
+++ libgcrypt-1.8.5/cipher/poly1305-avx2-amd64.S 2020-01-23 15:36:16.784250105 +0100
|
||||
@@ -43,6 +43,9 @@
|
||||
.globl _gcry_poly1305_amd64_avx2_init_ext
|
||||
ELF(.type _gcry_poly1305_amd64_avx2_init_ext,@function;)
|
||||
_gcry_poly1305_amd64_avx2_init_ext:
|
||||
+#ifdef _CET_ENDBR
|
||||
+ _CET_ENDBR
|
||||
+#endif
|
||||
.Lpoly1305_init_ext_avx2_local:
|
||||
xor %edx, %edx
|
||||
vzeroupper
|
||||
@@ -406,6 +409,9 @@ ELF(.size _gcry_poly1305_amd64_avx2_init
|
||||
.globl _gcry_poly1305_amd64_avx2_blocks
|
||||
ELF(.type _gcry_poly1305_amd64_avx2_blocks,@function;)
|
||||
_gcry_poly1305_amd64_avx2_blocks:
|
||||
+#ifdef _CET_ENDBR
|
||||
+ _CET_ENDBR
|
||||
+#endif
|
||||
.Lpoly1305_blocks_avx2_local:
|
||||
vzeroupper
|
||||
pushq %rbp
|
||||
@@ -732,6 +738,9 @@ ELF(.size _gcry_poly1305_amd64_avx2_bloc
|
||||
.globl _gcry_poly1305_amd64_avx2_finish_ext
|
||||
ELF(.type _gcry_poly1305_amd64_avx2_finish_ext,@function;)
|
||||
_gcry_poly1305_amd64_avx2_finish_ext:
|
||||
+#ifdef _CET_ENDBR
|
||||
+ _CET_ENDBR
|
||||
+#endif
|
||||
.Lpoly1305_finish_ext_avx2_local:
|
||||
vzeroupper
|
||||
pushq %rbp
|
||||
diff -up libgcrypt-1.8.5/cipher/poly1305-sse2-amd64.S.intel-cet libgcrypt-1.8.5/cipher/poly1305-sse2-amd64.S
|
||||
--- libgcrypt-1.8.5/cipher/poly1305-sse2-amd64.S.intel-cet 2017-11-23 19:16:58.000000000 +0100
|
||||
+++ libgcrypt-1.8.5/cipher/poly1305-sse2-amd64.S 2020-01-23 15:36:16.787250134 +0100
|
||||
@@ -42,6 +42,9 @@
|
||||
.globl _gcry_poly1305_amd64_sse2_init_ext
|
||||
ELF(.type _gcry_poly1305_amd64_sse2_init_ext,@function;)
|
||||
_gcry_poly1305_amd64_sse2_init_ext:
|
||||
+#ifdef _CET_ENDBR
|
||||
+ _CET_ENDBR
|
||||
+#endif
|
||||
.Lpoly1305_init_ext_x86_local:
|
||||
xor %edx, %edx
|
||||
pushq %r12
|
||||
@@ -288,6 +291,9 @@ ELF(.size _gcry_poly1305_amd64_sse2_init
|
||||
.globl _gcry_poly1305_amd64_sse2_finish_ext
|
||||
ELF(.type _gcry_poly1305_amd64_sse2_finish_ext,@function;)
|
||||
_gcry_poly1305_amd64_sse2_finish_ext:
|
||||
+#ifdef _CET_ENDBR
|
||||
+ _CET_ENDBR
|
||||
+#endif
|
||||
.Lpoly1305_finish_ext_x86_local:
|
||||
pushq %rbp
|
||||
movq %rsp, %rbp
|
||||
@@ -439,6 +445,9 @@ ELF(.size _gcry_poly1305_amd64_sse2_fini
|
||||
.globl _gcry_poly1305_amd64_sse2_blocks
|
||||
ELF(.type _gcry_poly1305_amd64_sse2_blocks,@function;)
|
||||
_gcry_poly1305_amd64_sse2_blocks:
|
||||
+#ifdef _CET_ENDBR
|
||||
+ _CET_ENDBR
|
||||
+#endif
|
||||
.Lpoly1305_blocks_x86_local:
|
||||
pushq %rbp
|
||||
movq %rsp, %rbp
|
||||
diff -up libgcrypt-1.8.5/cipher/serpent-avx2-amd64.S.intel-cet libgcrypt-1.8.5/cipher/serpent-avx2-amd64.S
|
||||
--- libgcrypt-1.8.5/cipher/serpent-avx2-amd64.S.intel-cet 2017-11-23 19:16:58.000000000 +0100
|
||||
+++ libgcrypt-1.8.5/cipher/serpent-avx2-amd64.S 2020-01-23 15:36:44.151972003 +0100
|
||||
@@ -18,8 +18,9 @@
|
||||
* License along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
-#ifdef __x86_64
|
||||
#include <config.h>
|
||||
+
|
||||
+#ifdef __x86_64
|
||||
#if (defined(HAVE_COMPATIBLE_GCC_AMD64_PLATFORM_AS) || \
|
||||
defined(HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS)) && defined(USE_SERPENT) && \
|
||||
defined(ENABLE_AVX2_SUPPORT)
|
||||
diff -up libgcrypt-1.8.5/configure.ac.intel-cet libgcrypt-1.8.5/configure.ac
|
||||
--- libgcrypt-1.8.5/configure.ac.intel-cet 2019-08-29 15:00:08.000000000 +0200
|
||||
+++ libgcrypt-1.8.5/configure.ac 2020-01-23 15:35:28.147774463 +0100
|
||||
@@ -95,6 +95,12 @@ AH_TOP([
|
||||
AH_BOTTOM([
|
||||
#define _GCRYPT_IN_LIBGCRYPT 1
|
||||
|
||||
+/* Add .note.gnu.property section for Intel CET in assembler sources
|
||||
+ when CET is enabled. */
|
||||
+#if defined(__ASSEMBLER__) && defined(__CET__)
|
||||
+# include <cet.h>
|
||||
+#endif
|
||||
+
|
||||
/* If the configure check for endianness has been disabled, get it from
|
||||
OS macros. This is intended for making fat binary builds on OS X. */
|
||||
#ifdef DISABLED_ENDIAN_CHECK
|
||||
diff -up libgcrypt-1.8.5/mpi/config.links.intel-cet libgcrypt-1.8.5/mpi/config.links
|
||||
--- libgcrypt-1.8.5/mpi/config.links.intel-cet 2017-11-23 19:16:58.000000000 +0100
|
||||
+++ libgcrypt-1.8.5/mpi/config.links 2020-01-23 15:35:46.398952954 +0100
|
||||
@@ -382,6 +382,16 @@ if test x"$mpi_cpu_arch" = x ; then
|
||||
mpi_cpu_arch="unknown"
|
||||
fi
|
||||
|
||||
+# Add .note.gnu.property section for Intel CET in assembler sources
|
||||
+# when CET is enabled. */
|
||||
+if test x"$mpi_cpu_arch" = xx86 ; then
|
||||
+ cat <<EOF >> ./mpi/asm-syntax.h
|
||||
+
|
||||
+#if defined(__ASSEMBLER__) && defined(__CET__)
|
||||
+# include <cet.h>
|
||||
+#endif
|
||||
+EOF
|
||||
+fi
|
||||
|
||||
# Make sysdep.h
|
||||
echo '/* created by config.links - do not edit */' >./mpi/sysdep.h
|
||||
diff -up libgcrypt-1.8.5/mpi/i386/mpih-add1.S.intel-cet libgcrypt-1.8.5/mpi/i386/mpih-add1.S
|
||||
--- libgcrypt-1.8.5/mpi/i386/mpih-add1.S.intel-cet 2017-11-23 19:16:58.000000000 +0100
|
||||
+++ libgcrypt-1.8.5/mpi/i386/mpih-add1.S 2020-01-23 15:37:40.470175379 +0100
|
||||
@@ -52,6 +52,10 @@ C_SYMBOL_NAME(_gcry_mpih_add_n:)
|
||||
movl 20(%esp),%edx /* s2_ptr */
|
||||
movl 24(%esp),%ecx /* size */
|
||||
|
||||
+#if defined __CET__ && (__CET__ & 1) != 0
|
||||
+ pushl %ebx
|
||||
+#endif
|
||||
+
|
||||
movl %ecx,%eax
|
||||
shrl $3,%ecx /* compute count for unrolled loop */
|
||||
negl %eax
|
||||
@@ -63,6 +67,9 @@ C_SYMBOL_NAME(_gcry_mpih_add_n:)
|
||||
subl %eax,%esi /* ... by a constant when we ... */
|
||||
subl %eax,%edx /* ... enter the loop */
|
||||
shrl $2,%eax /* restore previous value */
|
||||
+#if defined __CET__ && (__CET__ & 1) != 0
|
||||
+ leal -4(,%eax,4),%ebx /* Count for 4-byte endbr32 */
|
||||
+#endif
|
||||
#ifdef PIC
|
||||
/* Calculate start address in loop for PIC. Due to limitations in some
|
||||
assemblers, Loop-L0-3 cannot be put into the leal */
|
||||
@@ -75,29 +82,53 @@ L0: leal (%eax,%eax,8),%eax
|
||||
/* Calculate start address in loop for non-PIC. */
|
||||
leal (Loop - 3)(%eax,%eax,8),%eax
|
||||
#endif
|
||||
+#if defined __CET__ && (__CET__ & 1) != 0
|
||||
+ addl %ebx,%eax /* Adjust for endbr32 */
|
||||
+#endif
|
||||
jmp *%eax /* jump into loop */
|
||||
ALIGN (3)
|
||||
Loop: movl (%esi),%eax
|
||||
adcl (%edx),%eax
|
||||
movl %eax,(%edi)
|
||||
+#ifdef _CET_ENDBR
|
||||
+ _CET_ENDBR
|
||||
+#endif
|
||||
movl 4(%esi),%eax
|
||||
adcl 4(%edx),%eax
|
||||
movl %eax,4(%edi)
|
||||
+#ifdef _CET_ENDBR
|
||||
+ _CET_ENDBR
|
||||
+#endif
|
||||
movl 8(%esi),%eax
|
||||
adcl 8(%edx),%eax
|
||||
movl %eax,8(%edi)
|
||||
+#ifdef _CET_ENDBR
|
||||
+ _CET_ENDBR
|
||||
+#endif
|
||||
movl 12(%esi),%eax
|
||||
adcl 12(%edx),%eax
|
||||
movl %eax,12(%edi)
|
||||
+#ifdef _CET_ENDBR
|
||||
+ _CET_ENDBR
|
||||
+#endif
|
||||
movl 16(%esi),%eax
|
||||
adcl 16(%edx),%eax
|
||||
movl %eax,16(%edi)
|
||||
+#ifdef _CET_ENDBR
|
||||
+ _CET_ENDBR
|
||||
+#endif
|
||||
movl 20(%esi),%eax
|
||||
adcl 20(%edx),%eax
|
||||
movl %eax,20(%edi)
|
||||
+#ifdef _CET_ENDBR
|
||||
+ _CET_ENDBR
|
||||
+#endif
|
||||
movl 24(%esi),%eax
|
||||
adcl 24(%edx),%eax
|
||||
movl %eax,24(%edi)
|
||||
+#ifdef _CET_ENDBR
|
||||
+ _CET_ENDBR
|
||||
+#endif
|
||||
movl 28(%esi),%eax
|
||||
adcl 28(%edx),%eax
|
||||
movl %eax,28(%edi)
|
||||
@@ -110,6 +141,10 @@ Loop: movl (%esi),%eax
|
||||
sbbl %eax,%eax
|
||||
negl %eax
|
||||
|
||||
+#if defined __CET__ && (__CET__ & 1) != 0
|
||||
+ popl %ebx
|
||||
+#endif
|
||||
+
|
||||
popl %esi
|
||||
popl %edi
|
||||
ret
|
||||
diff -up libgcrypt-1.8.5/mpi/i386/mpih-sub1.S.intel-cet libgcrypt-1.8.5/mpi/i386/mpih-sub1.S
|
||||
--- libgcrypt-1.8.5/mpi/i386/mpih-sub1.S.intel-cet 2017-11-23 19:16:58.000000000 +0100
|
||||
+++ libgcrypt-1.8.5/mpi/i386/mpih-sub1.S 2020-01-23 15:37:40.472175351 +0100
|
||||
@@ -53,6 +53,10 @@ C_SYMBOL_NAME(_gcry_mpih_sub_n:)
|
||||
movl 20(%esp),%edx /* s2_ptr */
|
||||
movl 24(%esp),%ecx /* size */
|
||||
|
||||
+#if defined __CET__ && (__CET__ & 1) != 0
|
||||
+ pushl %ebx
|
||||
+#endif
|
||||
+
|
||||
movl %ecx,%eax
|
||||
shrl $3,%ecx /* compute count for unrolled loop */
|
||||
negl %eax
|
||||
@@ -64,6 +68,9 @@ C_SYMBOL_NAME(_gcry_mpih_sub_n:)
|
||||
subl %eax,%esi /* ... by a constant when we ... */
|
||||
subl %eax,%edx /* ... enter the loop */
|
||||
shrl $2,%eax /* restore previous value */
|
||||
+#if defined __CET__ && (__CET__ & 1) != 0
|
||||
+ leal -4(,%eax,4),%ebx /* Count for 4-byte endbr32 */
|
||||
+#endif
|
||||
#ifdef PIC
|
||||
/* Calculate start address in loop for PIC. Due to limitations in some
|
||||
assemblers, Loop-L0-3 cannot be put into the leal */
|
||||
@@ -76,29 +83,53 @@ L0: leal (%eax,%eax,8),%eax
|
||||
/* Calculate start address in loop for non-PIC. */
|
||||
leal (Loop - 3)(%eax,%eax,8),%eax
|
||||
#endif
|
||||
+#if defined __CET__ && (__CET__ & 1) != 0
|
||||
+ addl %ebx,%eax /* Adjust for endbr32 */
|
||||
+#endif
|
||||
jmp *%eax /* jump into loop */
|
||||
ALIGN (3)
|
||||
Loop: movl (%esi),%eax
|
||||
sbbl (%edx),%eax
|
||||
movl %eax,(%edi)
|
||||
+#ifdef _CET_ENDBR
|
||||
+ _CET_ENDBR
|
||||
+#endif
|
||||
movl 4(%esi),%eax
|
||||
sbbl 4(%edx),%eax
|
||||
movl %eax,4(%edi)
|
||||
+#ifdef _CET_ENDBR
|
||||
+ _CET_ENDBR
|
||||
+#endif
|
||||
movl 8(%esi),%eax
|
||||
sbbl 8(%edx),%eax
|
||||
movl %eax,8(%edi)
|
||||
+#ifdef _CET_ENDBR
|
||||
+ _CET_ENDBR
|
||||
+#endif
|
||||
movl 12(%esi),%eax
|
||||
sbbl 12(%edx),%eax
|
||||
movl %eax,12(%edi)
|
||||
+#ifdef _CET_ENDBR
|
||||
+ _CET_ENDBR
|
||||
+#endif
|
||||
movl 16(%esi),%eax
|
||||
sbbl 16(%edx),%eax
|
||||
movl %eax,16(%edi)
|
||||
+#ifdef _CET_ENDBR
|
||||
+ _CET_ENDBR
|
||||
+#endif
|
||||
movl 20(%esi),%eax
|
||||
sbbl 20(%edx),%eax
|
||||
movl %eax,20(%edi)
|
||||
+#ifdef _CET_ENDBR
|
||||
+ _CET_ENDBR
|
||||
+#endif
|
||||
movl 24(%esi),%eax
|
||||
sbbl 24(%edx),%eax
|
||||
movl %eax,24(%edi)
|
||||
+#ifdef _CET_ENDBR
|
||||
+ _CET_ENDBR
|
||||
+#endif
|
||||
movl 28(%esi),%eax
|
||||
sbbl 28(%edx),%eax
|
||||
movl %eax,28(%edi)
|
||||
@@ -111,6 +142,10 @@ Loop: movl (%esi),%eax
|
||||
sbbl %eax,%eax
|
||||
negl %eax
|
||||
|
||||
+#if defined __CET__ && (__CET__ & 1) != 0
|
||||
+ popl %ebx
|
||||
+#endif
|
||||
+
|
||||
popl %esi
|
||||
popl %edi
|
||||
ret
|
||||
@ -1,89 +0,0 @@
|
||||
diff -up libgcrypt-1.8.5/src/fips.c.use-fipscheck libgcrypt-1.8.5/src/fips.c
|
||||
--- libgcrypt-1.8.5/src/fips.c.use-fipscheck 2017-11-23 19:16:58.000000000 +0100
|
||||
+++ libgcrypt-1.8.5/src/fips.c 2020-04-23 10:18:36.235764741 +0200
|
||||
@@ -581,23 +581,50 @@ run_random_selftests (void)
|
||||
return !!err;
|
||||
}
|
||||
|
||||
+#ifdef ENABLE_HMAC_BINARY_CHECK
|
||||
+static int
|
||||
+get_library_path(const char *libname, const char *symbolname, char *path, size_t pathlen)
|
||||
+{
|
||||
+ Dl_info info;
|
||||
+ void *dl, *sym;
|
||||
+ int rv = -1;
|
||||
+
|
||||
+ dl = dlopen(libname, RTLD_LAZY);
|
||||
+ if (dl == NULL) {
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ sym = dlsym(dl, symbolname);
|
||||
+
|
||||
+ if (sym != NULL && dladdr(sym, &info)) {
|
||||
+ strncpy(path, info.dli_fname, pathlen-1);
|
||||
+ path[pathlen-1] = '\0';
|
||||
+ rv = 0;
|
||||
+ }
|
||||
+
|
||||
+ dlclose(dl);
|
||||
+
|
||||
+ return rv;
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
/* Run an integrity check on the binary. Returns 0 on success. */
|
||||
static int
|
||||
check_binary_integrity (void)
|
||||
{
|
||||
#ifdef ENABLE_HMAC_BINARY_CHECK
|
||||
gpg_error_t err;
|
||||
- Dl_info info;
|
||||
+ char libpath[4096];
|
||||
unsigned char digest[32];
|
||||
int dlen;
|
||||
char *fname = NULL;
|
||||
- const char key[] = "What am I, a doctor or a moonshuttle conductor?";
|
||||
-
|
||||
- if (!dladdr ("gcry_check_version", &info))
|
||||
+ const char key[] = "orboDeJITITejsirpADONivirpUkvarP";
|
||||
+
|
||||
+ if (get_library_path ("libgcrypt.so.20", "gcry_check_version", libpath, sizeof(libpath)))
|
||||
err = gpg_error_from_syserror ();
|
||||
else
|
||||
{
|
||||
- dlen = _gcry_hmac256_file (digest, sizeof digest, info.dli_fname,
|
||||
+ dlen = _gcry_hmac256_file (digest, sizeof digest, libpath,
|
||||
key, strlen (key));
|
||||
if (dlen < 0)
|
||||
err = gpg_error_from_syserror ();
|
||||
@@ -605,7 +632,7 @@ check_binary_integrity (void)
|
||||
err = gpg_error (GPG_ERR_INTERNAL);
|
||||
else
|
||||
{
|
||||
- fname = xtrymalloc (strlen (info.dli_fname) + 1 + 5 + 1 );
|
||||
+ fname = xtrymalloc (strlen (libpath) + 1 + 5 + 1 );
|
||||
if (!fname)
|
||||
err = gpg_error_from_syserror ();
|
||||
else
|
||||
@@ -614,7 +641,7 @@ check_binary_integrity (void)
|
||||
char *p;
|
||||
|
||||
/* Prefix the basename with a dot. */
|
||||
- strcpy (fname, info.dli_fname);
|
||||
+ strcpy (fname, libpath);
|
||||
p = strrchr (fname, '/');
|
||||
if (p)
|
||||
p++;
|
||||
diff -up libgcrypt-1.8.5/src/Makefile.am.use-fipscheck libgcrypt-1.8.5/src/Makefile.am
|
||||
--- libgcrypt-1.8.5/src/Makefile.am.use-fipscheck 2020-04-23 10:18:36.237764702 +0200
|
||||
+++ libgcrypt-1.8.5/src/Makefile.am 2020-04-23 10:19:03.186247455 +0200
|
||||
@@ -125,7 +125,7 @@ libgcrypt_la_LIBADD = $(gcrypt_res) \
|
||||
../cipher/libcipher.la \
|
||||
../random/librandom.la \
|
||||
../mpi/libmpi.la \
|
||||
- ../compat/libcompat.la $(GPG_ERROR_LIBS)
|
||||
+ ../compat/libcompat.la $(GPG_ERROR_LIBS) -ldl
|
||||
|
||||
|
||||
dumpsexp_SOURCES = dumpsexp.c
|
||||
Binary file not shown.
@ -3,39 +3,21 @@
|
||||
%global hmackey orboDeJITITejsirpADONivirpUkvarP
|
||||
|
||||
Name: libgcrypt
|
||||
Version: 1.8.7
|
||||
Release: 4
|
||||
Version: 1.10.2
|
||||
Release: 2
|
||||
Summary: A general-purpose cryptography library
|
||||
License: LGPLv2+
|
||||
URL: https://www.gnupg.org/
|
||||
Source0: https://www.gnupg.org/ftp/gcrypt/libgcrypt/libgcrypt-%{version}.tar.bz2
|
||||
Source7: random.conf
|
||||
|
||||
Patch0: libgcrypt-1.8.5-use-fipscheck.patch
|
||||
Patch1: libgcrypt-1.8.4-fips-keygen.patch
|
||||
Patch2: libgcrypt-1.8.4-tests-fipsmode.patch
|
||||
Patch3: libgcrypt-1.7.3-fips-cavs.patch
|
||||
Patch4: libgcrypt-1.8.4-use-poll.patch
|
||||
Patch5: libgcrypt-1.6.1-mpicoder-gccopt.patch
|
||||
Patch6: libgcrypt-1.7.3-ecc-test-fix.patch
|
||||
Patch7: libgcrypt-1.8.3-fips-ctor.patch
|
||||
Patch8: libgcrypt-1.7.3-fips-reqs.patch
|
||||
Patch9: libgcrypt-1.8.5-getrandom.patch
|
||||
Patch10: libgcrypt-1.8.3-cmac-selftest.patch
|
||||
Patch11: libgcrypt-1.8.3-fips-enttest.patch
|
||||
Patch12: libgcrypt-1.8.3-md-fips-enforce.patch
|
||||
Patch13: libgcrypt-1.8.5-intel-cet.patch
|
||||
Patch14: libgcrypt-1.8.5-fips-module.patch
|
||||
Patch15: libgcrypt-1.8.5-aes-perf.patch
|
||||
Patch16: CVE-2019-12904-1.patch
|
||||
Patch17: CVE-2019-12904-2.patch
|
||||
Patch18: CVE-2019-12904-3.patch
|
||||
Patch19: CVE-2021-33560.patch
|
||||
Patch20: CVE-2021-40528.patch
|
||||
Patch0: Use-the-compiler-switch-O0-for-compiling-jitterentro.patch
|
||||
|
||||
BuildRequires: gcc texinfo autoconf automake libtool
|
||||
BuildRequires: gawk libgpg-error-devel >= 1.11 pkgconfig
|
||||
|
||||
Provides: %{name}-sm3 = %{version}-%{release}
|
||||
|
||||
%description
|
||||
Libgcrypt is a general purpose cryptographic library originally based on code from GnuPG.
|
||||
|
||||
@ -65,15 +47,19 @@ sed -i -e '/^sys_lib_dlsearch_path_spec/s,/lib /usr/lib,/usr/lib /lib64 /usr/lib
|
||||
%make_build
|
||||
|
||||
%check
|
||||
src/hmac256 %{hmackey} src/.libs/%{gcrysoname} | cut -f1 -d ' ' >src/.libs/.%{gcrysoname}.hmac
|
||||
|
||||
make check
|
||||
|
||||
%define libpath $RPM_BUILD_ROOT%{gcrylibdir}/%{gcrysoname}.?.?
|
||||
%define __spec_install_post \
|
||||
%{?__debug_package:%{__debug_install_post}} \
|
||||
%{__arch_install_post} \
|
||||
%{__os_install_post} \
|
||||
src/hmac256 %{hmackey} $RPM_BUILD_ROOT%{gcrylibdir}/%{gcrysoname} | cut -f1 -d ' ' >$RPM_BUILD_ROOT%{gcrylibdir}/.%{gcrysoname}.hmac \
|
||||
cd src \
|
||||
sed -i -e 's|FILE=.*|FILE=\\\$1|' gen-note-integrity.sh \
|
||||
READELF=readelf AWK=awk ECHO_N="-n" bash gen-note-integrity.sh %{libpath} > %{libpath}.hmac \
|
||||
objcopy --update-section .note.fdo.integrity=%{libpath}.hmac %{libpath} %{libpath}.new \
|
||||
mv -f %{libpath}.new %{libpath} \
|
||||
rm -f %{libpath}.hmac
|
||||
%{nil}
|
||||
|
||||
%install
|
||||
@ -120,7 +106,6 @@ install -m644 %{SOURCE7} $RPM_BUILD_ROOT/etc/gcrypt/random.conf
|
||||
%dir /etc/gcrypt
|
||||
%config(noreplace) /etc/gcrypt/random.conf
|
||||
%{gcrylibdir}/*.so.*
|
||||
%{gcrylibdir}/.*.so.*.hmac
|
||||
%exclude %{_infodir}/dir
|
||||
|
||||
%files devel
|
||||
@ -137,6 +122,30 @@ install -m644 %{SOURCE7} $RPM_BUILD_ROOT/etc/gcrypt/random.conf
|
||||
%{_infodir}/gcrypt.info*
|
||||
|
||||
%changelog
|
||||
* Thu Sep 12 2024 hugel <gengqihu2@h-partners.com> - 1.10.2-2
|
||||
- Type:bugfix
|
||||
- ID:NA
|
||||
- SUG:NA
|
||||
- DESC:fix the self-check error in FIPS mode
|
||||
|
||||
* Mon Jul 24 2023 zhengxiaoxiao <zhengxiaoxiao2@huawei.com> - 1.10.2-1
|
||||
- Type:requirements
|
||||
- ID:NA
|
||||
- SUG:NA
|
||||
- DESC:Update version to 1.10.1
|
||||
|
||||
* Thu Dec 30 2021 zoulin <zoulin13@huawei.com> - 1.9.4-1
|
||||
- Type:requirements
|
||||
- ID:NA
|
||||
- SUG:NA
|
||||
- DESC:Update version to 1.9.4
|
||||
|
||||
* Wed Oct 27 2021 zhujianwei001 <zhujianwei7@huawei.com> - 1.8.7-5
|
||||
- Type:requirements
|
||||
- ID:NA
|
||||
- SUG:NA
|
||||
- DESC:add support sm3
|
||||
|
||||
* Fri Sep 24 2021 zoulin <zoulin13@huawei.com> - 1.8.7-4
|
||||
- Type:cves
|
||||
- ID:NA
|
||||
@ -144,7 +153,7 @@ install -m644 %{SOURCE7} $RPM_BUILD_ROOT/etc/gcrypt/random.conf
|
||||
- DESC:Fix CVE-2021-33560 CVE-2021-40528
|
||||
|
||||
* Fri Jul 30 2021 chenyanpanHW <chenyanpan@huawei.com> - 1.8.7-3
|
||||
- DESC: delete -S git from %autosetup, and delete BuildRequires git
|
||||
- DESC: delete -S git from autosetup, and delete BuildRequires git
|
||||
|
||||
* Mon Jun 21 2021 gaihuiying1 <gaihuiying1@huawei.com> - 1.8.7-2
|
||||
- Type:cves
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user