Create defines for TLS Group Ids
authorMatt Caswell <matt@openssl.org>
Tue, 16 Jun 2020 14:30:46 +0000 (15:30 +0100)
committerMatt Caswell <matt@openssl.org>
Fri, 19 Jun 2020 09:19:32 +0000 (10:19 +0100)
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/11914)

include/internal/tlsgroups.h [new file with mode: 0644]
providers/common/capabilities.c
ssl/t1_lib.c

diff --git a/include/internal/tlsgroups.h b/include/internal/tlsgroups.h
new file mode 100644 (file)
index 0000000..bb9832e
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2017 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License").  You may not use
+ * this file except in compliance with the License.  You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+#ifndef OSSL_INTERNAL_TLSGROUPS_H
+# define OSSL_INTERNAL_TLSGROUPS_H
+
+# define OSSL_TLS_GROUP_ID_sect163k1        0x0001
+# define OSSL_TLS_GROUP_ID_sect163r1        0x0002
+# define OSSL_TLS_GROUP_ID_sect163r2        0x0003
+# define OSSL_TLS_GROUP_ID_sect193r1        0x0004
+# define OSSL_TLS_GROUP_ID_sect193r2        0x0005
+# define OSSL_TLS_GROUP_ID_sect233k1        0x0006
+# define OSSL_TLS_GROUP_ID_sect233r1        0x0007
+# define OSSL_TLS_GROUP_ID_sect239k1        0x0008
+# define OSSL_TLS_GROUP_ID_sect283k1        0x0009
+# define OSSL_TLS_GROUP_ID_sect283r1        0x000A
+# define OSSL_TLS_GROUP_ID_sect409k1        0x000B
+# define OSSL_TLS_GROUP_ID_sect409r1        0x000C
+# define OSSL_TLS_GROUP_ID_sect571k1        0x000D
+# define OSSL_TLS_GROUP_ID_sect571r1        0x000E
+# define OSSL_TLS_GROUP_ID_secp160k1        0x000F
+# define OSSL_TLS_GROUP_ID_secp160r1        0x0010
+# define OSSL_TLS_GROUP_ID_secp160r2        0x0011
+# define OSSL_TLS_GROUP_ID_secp192k1        0x0012
+# define OSSL_TLS_GROUP_ID_secp192r1        0x0013
+# define OSSL_TLS_GROUP_ID_secp224k1        0x0014
+# define OSSL_TLS_GROUP_ID_secp224r1        0x0015
+# define OSSL_TLS_GROUP_ID_secp256k1        0x0016
+# define OSSL_TLS_GROUP_ID_secp256r1        0x0017
+# define OSSL_TLS_GROUP_ID_secp384r1        0x0018
+# define OSSL_TLS_GROUP_ID_secp521r1        0x0019
+# define OSSL_TLS_GROUP_ID_brainpoolP256r1  0x001A
+# define OSSL_TLS_GROUP_ID_brainpoolP384r1  0x001B
+# define OSSL_TLS_GROUP_ID_brainpoolP512r1  0x001C
+# define OSSL_TLS_GROUP_ID_x25519           0x001D
+# define OSSL_TLS_GROUP_ID_x448             0x001E
+# define OSSL_TLS_GROUP_ID_ffdhe2048        0x0100
+# define OSSL_TLS_GROUP_ID_ffdhe3072        0x0101
+# define OSSL_TLS_GROUP_ID_ffdhe4096        0x0102
+# define OSSL_TLS_GROUP_ID_ffdhe6144        0x0103
+# define OSSL_TLS_GROUP_ID_ffdhe8192        0x0104
+
+#endif
index 2d301d12fcecf446f6f0ba8d7a58bec45b92f328..84d2006ceeeeeddd3ca565a95f7643bd1ee8e5ac 100644 (file)
@@ -15,6 +15,7 @@
 #include <openssl/ssl.h>
 #include <openssl/params.h>
 #include "internal/nelem.h"
+#include "internal/tlsgroups.h"
 #include "prov/providercommon.h"
 
 typedef struct tls_group_constants_st {
@@ -27,42 +28,45 @@ typedef struct tls_group_constants_st {
 } TLS_GROUP_CONSTANTS;
 
 static const TLS_GROUP_CONSTANTS group_list[35] = {
-    { /* sect163k1 */ 0x0001, 80, TLS1_VERSION, 0, DTLS1_VERSION, 0 },
-    { /* sect163r1 */ 0x0002, 80, TLS1_VERSION, 0, DTLS1_VERSION, 0 },
-    { /* sect163r2 */ 0x0003, 80, TLS1_VERSION, 0, DTLS1_VERSION, 0 },
-    { /* sect193r1 */ 0x0004, 80, TLS1_VERSION, 0, DTLS1_VERSION, 0 },
-    { /* sect193r2 */ 0x0005, 80, TLS1_VERSION, 0, DTLS1_VERSION, 0 },
-    { /* sect233k1 */ 0x0006, 112, TLS1_VERSION, 0, DTLS1_VERSION, 0 },
-    { /* sect233r1 */ 0x0007, 112, TLS1_VERSION, 0, DTLS1_VERSION, 0 },
-    { /* sect239k1 */ 0x0008, 112, TLS1_VERSION, 0, DTLS1_VERSION, 0 },
-    { /* sect283k1 */ 0x0009, 128, TLS1_VERSION, 0, DTLS1_VERSION, 0 },
-    { /* sect283r1 */ 0x000A, 128, TLS1_VERSION, 0, DTLS1_VERSION, 0 },
-    { /* sect409k1 */ 0x000B, 192, TLS1_VERSION, 0, DTLS1_VERSION, 0 },
-    { /* sect409r1 */ 0x000C, 192, TLS1_VERSION, 0, DTLS1_VERSION, 0 },
-    { /* sect571k1 */ 0x000D, 256, TLS1_VERSION, 0, DTLS1_VERSION, 0 },
-    { /* sect571r1 */ 0x000E, 256, TLS1_VERSION, 0, DTLS1_VERSION, 0 },
-    { /* secp160k1 */ 0x000F, 80, TLS1_VERSION, 0, DTLS1_VERSION, 0 },
-    { /* secp160r1 */ 0x0010, 80, TLS1_VERSION, 0, DTLS1_VERSION, 0 },
-    { /* secp160r2 */ 0x0011, 80, TLS1_VERSION, 0, DTLS1_VERSION, 0 },
-    { /* secp192k1 */ 0x0012, 80, TLS1_VERSION, 0, DTLS1_VERSION, 0 },
-    { /* secp192r1 */ 0x0013, 80, TLS1_VERSION, 0, DTLS1_VERSION, 0 },
-    { /* secp224k1 */ 0x0014, 112, TLS1_VERSION, 0, DTLS1_VERSION, 0 },
-    { /* secp224r1 */ 0x0015, 112, TLS1_VERSION, 0, DTLS1_VERSION, 0 },
-    { /* secp256k1 */ 0x0016, 128, TLS1_VERSION, 0, DTLS1_VERSION, 0 },
-    { /* secp256r1 */ 0x0017, 128, TLS1_VERSION, 0, DTLS1_VERSION, 0 },
-    { /* secp384r1 */ 0x0018, 192, TLS1_VERSION, 0, DTLS1_VERSION, 0 },
-    { /* secp521r1 */ 0x0019, 256, TLS1_VERSION, 0, DTLS1_VERSION, 0 },
-    { /* brainpoolP256r1 */ 0x001A, 128, TLS1_VERSION, TLS1_2_VERSION, DTLS1_VERSION, DTLS1_2_VERSION },
-    { /* brainpoolP384r1 */ 0x001B, 192, TLS1_VERSION, TLS1_2_VERSION, DTLS1_VERSION, DTLS1_2_VERSION },
-    { /* brainpoolP512r1 */ 0x001C, 256, TLS1_VERSION, TLS1_2_VERSION, DTLS1_VERSION, DTLS1_2_VERSION },
-    { /* x25519 */ 0x001D, 128, TLS1_VERSION, 0, DTLS1_VERSION, 0 },
-    { /* x448 */ 0x001E, 224, TLS1_VERSION, 0, DTLS1_VERSION, 0 },
+    { OSSL_TLS_GROUP_ID_sect163k1, 80, TLS1_VERSION, 0, DTLS1_VERSION, 0 },
+    { OSSL_TLS_GROUP_ID_sect163r1, 80, TLS1_VERSION, 0, DTLS1_VERSION, 0 },
+    { OSSL_TLS_GROUP_ID_sect163r2, 80, TLS1_VERSION, 0, DTLS1_VERSION, 0 },
+    { OSSL_TLS_GROUP_ID_sect193r1, 80, TLS1_VERSION, 0, DTLS1_VERSION, 0 },
+    { OSSL_TLS_GROUP_ID_sect193r2, 80, TLS1_VERSION, 0, DTLS1_VERSION, 0 },
+    { OSSL_TLS_GROUP_ID_sect233k1, 112, TLS1_VERSION, 0, DTLS1_VERSION, 0 },
+    { OSSL_TLS_GROUP_ID_sect233r1, 112, TLS1_VERSION, 0, DTLS1_VERSION, 0 },
+    { OSSL_TLS_GROUP_ID_sect239k1, 112, TLS1_VERSION, 0, DTLS1_VERSION, 0 },
+    { OSSL_TLS_GROUP_ID_sect283k1, 128, TLS1_VERSION, 0, DTLS1_VERSION, 0 },
+    { OSSL_TLS_GROUP_ID_sect283r1, 128, TLS1_VERSION, 0, DTLS1_VERSION, 0 },
+    { OSSL_TLS_GROUP_ID_sect409k1, 192, TLS1_VERSION, 0, DTLS1_VERSION, 0 },
+    { OSSL_TLS_GROUP_ID_sect409r1, 192, TLS1_VERSION, 0, DTLS1_VERSION, 0 },
+    { OSSL_TLS_GROUP_ID_sect571k1, 256, TLS1_VERSION, 0, DTLS1_VERSION, 0 },
+    { OSSL_TLS_GROUP_ID_sect571r1, 256, TLS1_VERSION, 0, DTLS1_VERSION, 0 },
+    { OSSL_TLS_GROUP_ID_secp160k1, 80, TLS1_VERSION, 0, DTLS1_VERSION, 0 },
+    { OSSL_TLS_GROUP_ID_secp160r1, 80, TLS1_VERSION, 0, DTLS1_VERSION, 0 },
+    { OSSL_TLS_GROUP_ID_secp160r2, 80, TLS1_VERSION, 0, DTLS1_VERSION, 0 },
+    { OSSL_TLS_GROUP_ID_secp192k1, 80, TLS1_VERSION, 0, DTLS1_VERSION, 0 },
+    { OSSL_TLS_GROUP_ID_secp192r1, 80, TLS1_VERSION, 0, DTLS1_VERSION, 0 },
+    { OSSL_TLS_GROUP_ID_secp224k1, 112, TLS1_VERSION, 0, DTLS1_VERSION, 0 },
+    { OSSL_TLS_GROUP_ID_secp224r1, 112, TLS1_VERSION, 0, DTLS1_VERSION, 0 },
+    { OSSL_TLS_GROUP_ID_secp256k1, 128, TLS1_VERSION, 0, DTLS1_VERSION, 0 },
+    { OSSL_TLS_GROUP_ID_secp256r1, 128, TLS1_VERSION, 0, DTLS1_VERSION, 0 },
+    { OSSL_TLS_GROUP_ID_secp384r1, 192, TLS1_VERSION, 0, DTLS1_VERSION, 0 },
+    { OSSL_TLS_GROUP_ID_secp521r1, 256, TLS1_VERSION, 0, DTLS1_VERSION, 0 },
+    { OSSL_TLS_GROUP_ID_brainpoolP256r1, 128, TLS1_VERSION, TLS1_2_VERSION,
+      DTLS1_VERSION, DTLS1_2_VERSION },
+    { OSSL_TLS_GROUP_ID_brainpoolP384r1, 192, TLS1_VERSION, TLS1_2_VERSION,
+      DTLS1_VERSION, DTLS1_2_VERSION },
+    { OSSL_TLS_GROUP_ID_brainpoolP512r1, 256, TLS1_VERSION, TLS1_2_VERSION,
+      DTLS1_VERSION, DTLS1_2_VERSION },
+    { OSSL_TLS_GROUP_ID_x25519, 128, TLS1_VERSION, 0, DTLS1_VERSION, 0 },
+    { OSSL_TLS_GROUP_ID_x448, 224, TLS1_VERSION, 0, DTLS1_VERSION, 0 },
     /* Security bit values as given by BN_security_bits() */
-    { /* ffdhe2048 */ 0x0100, 112, TLS1_3_VERSION, 0, -1, -1 },
-    { /* ffdhe3072 */ 0x0101, 128, TLS1_3_VERSION, 0, -1, -1 },
-    { /* ffdhe4096 */ 0x0102, 128, TLS1_3_VERSION, 0, -1, -1 },
-    { /* ffdhe6144 */ 0x0103, 128, TLS1_3_VERSION, 0, -1, -1 },
-    { /* ffdhe8192 */ 0x0104, 192, TLS1_3_VERSION, 0, -1, -1 },
+    { OSSL_TLS_GROUP_ID_ffdhe2048, 112, TLS1_3_VERSION, 0, -1, -1 },
+    { OSSL_TLS_GROUP_ID_ffdhe3072, 128, TLS1_3_VERSION, 0, -1, -1 },
+    { OSSL_TLS_GROUP_ID_ffdhe4096, 128, TLS1_3_VERSION, 0, -1, -1 },
+    { OSSL_TLS_GROUP_ID_ffdhe6144, 128, TLS1_3_VERSION, 0, -1, -1 },
+    { OSSL_TLS_GROUP_ID_ffdhe8192, 192, TLS1_3_VERSION, 0, -1, -1 },
 };
 
 #define TLS_GROUP_ENTRY(tlsname, realname, algorithm, idx) \
index d99384e2899647bcb81b3511e0eab047d437e1cb..b2752cd03d8a5de3017069a1f18face53a1246bb 100644 (file)
@@ -24,6 +24,7 @@
 #include <openssl/provider.h>
 #include "internal/nelem.h"
 #include "internal/evp.h"
+#include "internal/tlsgroups.h"
 #include "ssl_local.h"
 #include <openssl/ct.h>
 
@@ -147,36 +148,36 @@ static struct {
     int nid;
     uint16_t group_id;
 } nid_to_group[] = {
-    {NID_sect163k1, 0x0001},
-    {NID_sect163r1, 0x0002},
-    {NID_sect163r2, 0x0003},
-    {NID_sect193r1, 0x0004},
-    {NID_sect193r2, 0x0005},
-    {NID_sect233k1, 0x0006},
-    {NID_sect233r1, 0x0007},
-    {NID_sect239k1, 0x0008},
-    {NID_sect283k1, 0x0009},
-    {NID_sect283r1, 0x000A},
-    {NID_sect409k1, 0x000B},
-    {NID_sect409r1, 0x000C},
-    {NID_sect571k1, 0x000D},
-    {NID_sect571r1, 0x000E},
-    {NID_secp160k1, 0x000F},
-    {NID_secp160r1, 0x0010},
-    {NID_secp160r2, 0x0011},
-    {NID_secp192k1, 0x0012},
-    {NID_X9_62_prime192v1, 0x0013},
-    {NID_secp224k1, 0x0014},
-    {NID_secp224r1, 0x0015},
-    {NID_secp256k1, 0x0016},
-    {NID_X9_62_prime256v1, 0x0017},
-    {NID_secp384r1, 0x0018},
-    {NID_secp521r1, 0x0019},
-    {NID_brainpoolP256r1, 0x001A},
-    {NID_brainpoolP384r1, 0x001B},
-    {NID_brainpoolP512r1, 0x001C},
-    {EVP_PKEY_X25519, 0x001D},
-    {EVP_PKEY_X448, 0x001E},
+    {NID_sect163k1, OSSL_TLS_GROUP_ID_sect163k1},
+    {NID_sect163r1, OSSL_TLS_GROUP_ID_sect163r1},
+    {NID_sect163r2, OSSL_TLS_GROUP_ID_sect163r2},
+    {NID_sect193r1, OSSL_TLS_GROUP_ID_sect193r1},
+    {NID_sect193r2, OSSL_TLS_GROUP_ID_sect193r2},
+    {NID_sect233k1, OSSL_TLS_GROUP_ID_sect233k1},
+    {NID_sect233r1, OSSL_TLS_GROUP_ID_sect233r1},
+    {NID_sect239k1, OSSL_TLS_GROUP_ID_sect239k1},
+    {NID_sect283k1, OSSL_TLS_GROUP_ID_sect283k1},
+    {NID_sect283r1, OSSL_TLS_GROUP_ID_sect283r1},
+    {NID_sect409k1, OSSL_TLS_GROUP_ID_sect409k1},
+    {NID_sect409r1, OSSL_TLS_GROUP_ID_sect409r1},
+    {NID_sect571k1, OSSL_TLS_GROUP_ID_sect571k1},
+    {NID_sect571r1, OSSL_TLS_GROUP_ID_sect571r1},
+    {NID_secp160k1, OSSL_TLS_GROUP_ID_secp160k1},
+    {NID_secp160r1, OSSL_TLS_GROUP_ID_secp160r1},
+    {NID_secp160r2, OSSL_TLS_GROUP_ID_secp160r2},
+    {NID_secp192k1, OSSL_TLS_GROUP_ID_secp192k1},
+    {NID_X9_62_prime192v1, OSSL_TLS_GROUP_ID_secp192r1},
+    {NID_secp224k1, OSSL_TLS_GROUP_ID_secp224k1},
+    {NID_secp224r1, OSSL_TLS_GROUP_ID_secp224r1},
+    {NID_secp256k1, OSSL_TLS_GROUP_ID_secp256k1},
+    {NID_X9_62_prime256v1, OSSL_TLS_GROUP_ID_secp256r1},
+    {NID_secp384r1, OSSL_TLS_GROUP_ID_secp384r1},
+    {NID_secp521r1, OSSL_TLS_GROUP_ID_secp521r1},
+    {NID_brainpoolP256r1, OSSL_TLS_GROUP_ID_brainpoolP256r1},
+    {NID_brainpoolP384r1, OSSL_TLS_GROUP_ID_brainpoolP384r1},
+    {NID_brainpoolP512r1, OSSL_TLS_GROUP_ID_brainpoolP512r1},
+    {EVP_PKEY_X25519, OSSL_TLS_GROUP_ID_x25519},
+    {EVP_PKEY_X448, OSSL_TLS_GROUP_ID_x448},
     {NID_id_tc26_gost_3410_2012_256_paramSetA, 0x0022},
     {NID_id_tc26_gost_3410_2012_256_paramSetB, 0x0023},
     {NID_id_tc26_gost_3410_2012_256_paramSetC, 0x0024},
@@ -184,11 +185,11 @@ static struct {
     {NID_id_tc26_gost_3410_2012_512_paramSetA, 0x0026},
     {NID_id_tc26_gost_3410_2012_512_paramSetB, 0x0027},
     {NID_id_tc26_gost_3410_2012_512_paramSetC, 0x0028},
-    {NID_ffdhe2048, 0x0100},
-    {NID_ffdhe3072, 0x0101},
-    {NID_ffdhe4096, 0x0102},
-    {NID_ffdhe6144, 0x0103},
-    {NID_ffdhe8192, 0x0104}
+    {NID_ffdhe2048, OSSL_TLS_GROUP_ID_ffdhe2048},
+    {NID_ffdhe3072, OSSL_TLS_GROUP_ID_ffdhe3072},
+    {NID_ffdhe4096, OSSL_TLS_GROUP_ID_ffdhe4096},
+    {NID_ffdhe6144, OSSL_TLS_GROUP_ID_ffdhe6144},
+    {NID_ffdhe8192, OSSL_TLS_GROUP_ID_ffdhe8192}
 };
 #endif