Merge pull request #355 from h2o/kazuho/cipher-names
add `const char *ptls_cipher_suite_t::name` that contains the name of the cipher
diff --git a/include/picotls.h b/include/picotls.h
index b7f13d2..1724461 100644
--- a/include/picotls.h
+++ b/include/picotls.h
@@ -105,8 +105,11 @@
/* cipher-suites */
#define PTLS_CIPHER_SUITE_AES_128_GCM_SHA256 0x1301
+#define PTLS_CIPHER_SUITE_NAME_AES_128_GCM_SHA256 "TLS_AES_128_GCM_SHA256"
#define PTLS_CIPHER_SUITE_AES_256_GCM_SHA384 0x1302
+#define PTLS_CIPHER_SUITE_NAME_AES_256_GCM_SHA384 "TLS_AES_256_GCM_SHA384"
#define PTLS_CIPHER_SUITE_CHACHA20_POLY1305_SHA256 0x1303
+#define PTLS_CIPHER_SUITE_NAME_CHACHA20_POLY1305_SHA256 "TLS_CHACHA20_POLY1305_SHA256"
/* negotiated_groups */
#define PTLS_GROUP_SECP256R1 23
@@ -445,9 +448,22 @@
} ptls_hash_algorithm_t;
typedef const struct st_ptls_cipher_suite_t {
+ /**
+ * ID as defined by the TLS Cipher Suites registry
+ */
uint16_t id;
+ /**
+ * underlying AEAD algorithm
+ */
ptls_aead_algorithm_t *aead;
+ /**
+ * underlying hash algorithm
+ */
ptls_hash_algorithm_t *hash;
+ /**
+ * value of the "Description" field of the TLS Cipher Suites registry
+ */
+ const char *name;
} ptls_cipher_suite_t;
struct st_ptls_traffic_protection_t;
diff --git a/lib/cifra/aes128.c b/lib/cifra/aes128.c
index 26bd9e4..9fac845 100644
--- a/lib/cifra/aes128.c
+++ b/lib/cifra/aes128.c
@@ -57,5 +57,7 @@
PTLS_AESGCM_TAG_SIZE,
sizeof(struct aesgcm_context_t),
aead_aes128gcm_setup_crypto};
-ptls_cipher_suite_t ptls_minicrypto_aes128gcmsha256 = {PTLS_CIPHER_SUITE_AES_128_GCM_SHA256, &ptls_minicrypto_aes128gcm,
- &ptls_minicrypto_sha256};
+ptls_cipher_suite_t ptls_minicrypto_aes128gcmsha256 = {.id = PTLS_CIPHER_SUITE_AES_128_GCM_SHA256,
+ .name = PTLS_CIPHER_SUITE_NAME_AES_128_GCM_SHA256,
+ .aead = &ptls_minicrypto_aes128gcm,
+ .hash = &ptls_minicrypto_sha256};
diff --git a/lib/cifra/aes256.c b/lib/cifra/aes256.c
index d0568d5..1d604fc 100644
--- a/lib/cifra/aes256.c
+++ b/lib/cifra/aes256.c
@@ -57,5 +57,7 @@
PTLS_AESGCM_TAG_SIZE,
sizeof(struct aesgcm_context_t),
aead_aes256gcm_setup_crypto};
-ptls_cipher_suite_t ptls_minicrypto_aes256gcmsha384 = {PTLS_CIPHER_SUITE_AES_256_GCM_SHA384, &ptls_minicrypto_aes256gcm,
- &ptls_minicrypto_sha384};
+ptls_cipher_suite_t ptls_minicrypto_aes256gcmsha384 = {.id = PTLS_CIPHER_SUITE_AES_256_GCM_SHA384,
+ .name = PTLS_CIPHER_SUITE_NAME_AES_256_GCM_SHA384,
+ .aead = &ptls_minicrypto_aes256gcm,
+ .hash = &ptls_minicrypto_sha384};
diff --git a/lib/cifra/chacha20.c b/lib/cifra/chacha20.c
index fe19c32..8db3a18 100644
--- a/lib/cifra/chacha20.c
+++ b/lib/cifra/chacha20.c
@@ -225,5 +225,7 @@
PTLS_CHACHA20POLY1305_TAG_SIZE,
sizeof(struct chacha20poly1305_context_t),
aead_chacha20poly1305_setup_crypto};
-ptls_cipher_suite_t ptls_minicrypto_chacha20poly1305sha256 = {PTLS_CIPHER_SUITE_CHACHA20_POLY1305_SHA256,
- &ptls_minicrypto_chacha20poly1305, &ptls_minicrypto_sha256};
+ptls_cipher_suite_t ptls_minicrypto_chacha20poly1305sha256 = {.id = PTLS_CIPHER_SUITE_CHACHA20_POLY1305_SHA256,
+ .name = PTLS_CIPHER_SUITE_NAME_CHACHA20_POLY1305_SHA256,
+ .aead = &ptls_minicrypto_chacha20poly1305,
+ .hash = &ptls_minicrypto_sha256};
diff --git a/lib/openssl.c b/lib/openssl.c
index c9806ad..87c43b3 100644
--- a/lib/openssl.c
+++ b/lib/openssl.c
@@ -1604,10 +1604,14 @@
PTLS_ZERO_DIGEST_SHA256};
ptls_hash_algorithm_t ptls_openssl_sha384 = {PTLS_SHA384_BLOCK_SIZE, PTLS_SHA384_DIGEST_SIZE, sha384_create,
PTLS_ZERO_DIGEST_SHA384};
-ptls_cipher_suite_t ptls_openssl_aes128gcmsha256 = {PTLS_CIPHER_SUITE_AES_128_GCM_SHA256, &ptls_openssl_aes128gcm,
- &ptls_openssl_sha256};
-ptls_cipher_suite_t ptls_openssl_aes256gcmsha384 = {PTLS_CIPHER_SUITE_AES_256_GCM_SHA384, &ptls_openssl_aes256gcm,
- &ptls_openssl_sha384};
+ptls_cipher_suite_t ptls_openssl_aes128gcmsha256 = {.id = PTLS_CIPHER_SUITE_AES_128_GCM_SHA256,
+ .name = PTLS_CIPHER_SUITE_NAME_AES_128_GCM_SHA256,
+ .aead = &ptls_openssl_aes128gcm,
+ .hash = &ptls_openssl_sha256};
+ptls_cipher_suite_t ptls_openssl_aes256gcmsha384 = {.id = PTLS_CIPHER_SUITE_AES_256_GCM_SHA384,
+ .name = PTLS_CIPHER_SUITE_NAME_AES_256_GCM_SHA384,
+ .aead = &ptls_openssl_aes256gcm,
+ .hash = &ptls_openssl_sha384};
#if PTLS_OPENSSL_HAVE_CHACHA20_POLY1305
ptls_cipher_algorithm_t ptls_openssl_chacha20 = {
"CHACHA20", PTLS_CHACHA20_KEY_SIZE, 1 /* block size */, PTLS_CHACHA20_IV_SIZE, sizeof(struct cipher_context_t),
@@ -1622,8 +1626,10 @@
PTLS_CHACHA20POLY1305_TAG_SIZE,
sizeof(struct aead_crypto_context_t),
aead_chacha20poly1305_setup_crypto};
-ptls_cipher_suite_t ptls_openssl_chacha20poly1305sha256 = {PTLS_CIPHER_SUITE_CHACHA20_POLY1305_SHA256,
- &ptls_openssl_chacha20poly1305, &ptls_openssl_sha256};
+ptls_cipher_suite_t ptls_openssl_chacha20poly1305sha256 = {.id = PTLS_CIPHER_SUITE_CHACHA20_POLY1305_SHA256,
+ .name = PTLS_CIPHER_SUITE_NAME_CHACHA20_POLY1305_SHA256,
+ .aead = &ptls_openssl_chacha20poly1305,
+ .hash = &ptls_openssl_sha256};
#endif
ptls_cipher_suite_t *ptls_openssl_cipher_suites[] = {&ptls_openssl_aes256gcmsha384, &ptls_openssl_aes128gcmsha256,
#if PTLS_OPENSSL_HAVE_CHACHA20_POLY1305