Skip to content

Commit f114f2c

Browse files
authored
Merge pull request wolfSSL#9093 from kareem-wolfssl/zd20372
Multiple fixes to wolfSSL_CIPHER_description to match documentation.
2 parents 43f94a5 + cb623dc commit f114f2c

3 files changed

Lines changed: 44 additions & 31 deletions

File tree

src/keys.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1218,8 +1218,8 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
12181218
specs->bulk_cipher_algorithm = wolfssl_cipher_null;
12191219
specs->cipher_type = aead;
12201220
specs->mac_algorithm = sha256_mac;
1221-
specs->kea = 0;
1222-
specs->sig_algo = 0;
1221+
specs->kea = any_kea;
1222+
specs->sig_algo = any_sa_algo;
12231223
specs->hash_size = WC_SHA256_DIGEST_SIZE;
12241224
specs->pad_size = PAD_SHA;
12251225
specs->static_ecdh = 0;
@@ -1236,8 +1236,8 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
12361236
specs->bulk_cipher_algorithm = wolfssl_cipher_null;
12371237
specs->cipher_type = aead;
12381238
specs->mac_algorithm = sha384_mac;
1239-
specs->kea = 0;
1240-
specs->sig_algo = 0;
1239+
specs->kea = any_kea;
1240+
specs->sig_algo = any_sa_algo;
12411241
specs->hash_size = WC_SHA384_DIGEST_SIZE;
12421242
specs->pad_size = PAD_SHA;
12431243
specs->static_ecdh = 0;
@@ -1266,8 +1266,8 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
12661266
specs->bulk_cipher_algorithm = wolfssl_aes_gcm;
12671267
specs->cipher_type = aead;
12681268
specs->mac_algorithm = sha256_mac;
1269-
specs->kea = 0;
1270-
specs->sig_algo = 0;
1269+
specs->kea = any_kea;
1270+
specs->sig_algo = any_sa_algo;
12711271
specs->hash_size = WC_SHA256_DIGEST_SIZE;
12721272
specs->pad_size = PAD_SHA;
12731273
specs->static_ecdh = 0;
@@ -1284,8 +1284,8 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
12841284
specs->bulk_cipher_algorithm = wolfssl_aes_gcm;
12851285
specs->cipher_type = aead;
12861286
specs->mac_algorithm = sha384_mac;
1287-
specs->kea = 0;
1288-
specs->sig_algo = 0;
1287+
specs->kea = any_kea;
1288+
specs->sig_algo = any_sa_algo;
12891289
specs->hash_size = WC_SHA384_DIGEST_SIZE;
12901290
specs->pad_size = PAD_SHA;
12911291
specs->static_ecdh = 0;
@@ -1302,8 +1302,8 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
13021302
specs->bulk_cipher_algorithm = wolfssl_chacha;
13031303
specs->cipher_type = aead;
13041304
specs->mac_algorithm = sha256_mac;
1305-
specs->kea = 0;
1306-
specs->sig_algo = 0;
1305+
specs->kea = any_kea;
1306+
specs->sig_algo = any_sa_algo;
13071307
specs->hash_size = WC_SHA256_DIGEST_SIZE;
13081308
specs->pad_size = PAD_SHA;
13091309
specs->static_ecdh = 0;
@@ -1322,8 +1322,8 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
13221322
specs->bulk_cipher_algorithm = wolfssl_aes_ccm;
13231323
specs->cipher_type = aead;
13241324
specs->mac_algorithm = sha256_mac;
1325-
specs->kea = 0;
1326-
specs->sig_algo = 0;
1325+
specs->kea = any_kea;
1326+
specs->sig_algo = any_sa_algo;
13271327
specs->hash_size = WC_SHA256_DIGEST_SIZE;
13281328
specs->pad_size = PAD_SHA;
13291329
specs->static_ecdh = 0;
@@ -1340,8 +1340,8 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
13401340
specs->bulk_cipher_algorithm = wolfssl_aes_ccm;
13411341
specs->cipher_type = aead;
13421342
specs->mac_algorithm = sha256_mac;
1343-
specs->kea = 0;
1344-
specs->sig_algo = 0;
1343+
specs->kea = any_kea;
1344+
specs->sig_algo = any_sa_algo;
13451345
specs->hash_size = WC_SHA256_DIGEST_SIZE;
13461346
specs->pad_size = PAD_SHA;
13471347
specs->static_ecdh = 0;
@@ -1466,8 +1466,8 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
14661466
specs->bulk_cipher_algorithm = wolfssl_sm4_gcm;
14671467
specs->cipher_type = aead;
14681468
specs->mac_algorithm = sm3_mac;
1469-
specs->kea = 0;
1470-
specs->sig_algo = 0;
1469+
specs->kea = any_kea;
1470+
specs->sig_algo = any_sa_algo;
14711471
specs->hash_size = WC_SM3_DIGEST_SIZE;
14721472
specs->pad_size = PAD_SHA;
14731473
specs->static_ecdh = 0;
@@ -1484,8 +1484,8 @@ int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
14841484
specs->bulk_cipher_algorithm = wolfssl_sm4_ccm;
14851485
specs->cipher_type = aead;
14861486
specs->mac_algorithm = sm3_mac;
1487-
specs->kea = 0;
1488-
specs->sig_algo = 0;
1487+
specs->kea = any_kea;
1488+
specs->sig_algo = any_sa_algo;
14891489
specs->hash_size = WC_SM3_DIGEST_SIZE;
14901490
specs->pad_size = PAD_SHA;
14911491
specs->static_ecdh = 0;

src/ssl.c

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12371,6 +12371,7 @@ int wolfSSL_set_compression(WOLFSSL* ssl)
1237112371
*sigAlgo = SM2k;
1237212372
break;
1237312373
case invalid_sa_algo:
12374+
case any_sa_algo:
1237412375
default:
1237512376
*hashAlgo = WC_HASH_TYPE_NONE;
1237612377
*sigAlgo = 0;
@@ -16166,6 +16167,9 @@ static WC_INLINE const char* wolfssl_kea_to_string(int kea)
1616616167
keaStr = "ECDH";
1616716168
break;
1616816169
#endif
16170+
case any_kea:
16171+
keaStr = "any";
16172+
break;
1616916173
default:
1617016174
keaStr = "unknown";
1617116175
break;
@@ -16217,6 +16221,9 @@ static WC_INLINE const char* wolfssl_sigalg_to_string(int sig_algo)
1621716221
authStr = "Ed448";
1621816222
break;
1621916223
#endif
16224+
case any_sa_algo:
16225+
authStr = "any";
16226+
break;
1622016227
default:
1622116228
authStr = "unknown";
1622216229
break;
@@ -16247,28 +16254,28 @@ static WC_INLINE const char* wolfssl_cipher_to_string(int cipher, int key_size)
1624716254
#endif
1624816255
#ifndef NO_AES
1624916256
case wolfssl_aes:
16250-
if (key_size == 128)
16257+
if (key_size == AES_128_KEY_SIZE)
1625116258
encStr = "AES(128)";
16252-
else if (key_size == 256)
16259+
else if (key_size == AES_256_KEY_SIZE)
1625316260
encStr = "AES(256)";
1625416261
else
1625516262
encStr = "AES(?)";
1625616263
break;
1625716264
#ifdef HAVE_AESGCM
1625816265
case wolfssl_aes_gcm:
16259-
if (key_size == 128)
16266+
if (key_size == AES_128_KEY_SIZE)
1626016267
encStr = "AESGCM(128)";
16261-
else if (key_size == 256)
16268+
else if (key_size == AES_256_KEY_SIZE)
1626216269
encStr = "AESGCM(256)";
1626316270
else
1626416271
encStr = "AESGCM(?)";
1626516272
break;
1626616273
#endif
1626716274
#ifdef HAVE_AESCCM
1626816275
case wolfssl_aes_ccm:
16269-
if (key_size == 128)
16276+
if (key_size == AES_128_KEY_SIZE)
1627016277
encStr = "AESCCM(128)";
16271-
else if (key_size == 256)
16278+
else if (key_size == AES_256_KEY_SIZE)
1627216279
encStr = "AESCCM(256)";
1627316280
else
1627416281
encStr = "AESCCM(?)";
@@ -16282,21 +16289,21 @@ static WC_INLINE const char* wolfssl_cipher_to_string(int cipher, int key_size)
1628216289
#endif
1628316290
#ifdef HAVE_ARIA
1628416291
case wolfssl_aria_gcm:
16285-
if (key_size == 128)
16292+
if (key_size == ARIA_128_KEY_SIZE)
1628616293
encStr = "Aria(128)";
16287-
else if (key_size == 192)
16294+
else if (key_size == ARIA_192_KEY_SIZE)
1628816295
encStr = "Aria(192)";
16289-
else if (key_size == 256)
16296+
else if (key_size == ARIA_256_KEY_SIZE)
1629016297
encStr = "Aria(256)";
1629116298
else
1629216299
encStr = "Aria(?)";
1629316300
break;
1629416301
#endif
1629516302
#ifdef HAVE_CAMELLIA
1629616303
case wolfssl_camellia:
16297-
if (key_size == 128)
16304+
if (key_size == CAMELLIA_128_KEY_SIZE)
1629816305
encStr = "Camellia(128)";
16299-
else if (key_size == 256)
16306+
else if (key_size == CAMELLIA_256_KEY_SIZE)
1630016307
encStr = "Camellia(256)";
1630116308
else
1630216309
encStr = "Camellia(?)";
@@ -16383,7 +16390,10 @@ char* wolfSSL_CIPHER_description(const WOLFSSL_CIPHER* cipher, char* in,
1638316390
authStr = wolfssl_sigalg_to_string(cipher->ssl->specs.sig_algo);
1638416391
encStr = wolfssl_cipher_to_string(cipher->ssl->specs.bulk_cipher_algorithm,
1638516392
cipher->ssl->specs.key_size);
16386-
macStr = wolfssl_mac_to_string(cipher->ssl->specs.mac_algorithm);
16393+
if (cipher->ssl->specs.cipher_type == aead)
16394+
macStr = "AEAD";
16395+
else
16396+
macStr = wolfssl_mac_to_string(cipher->ssl->specs.mac_algorithm);
1638716397

1638816398
/* Build up the string by copying onto the end. */
1638916399
XSTRNCPY(in, wolfSSL_CIPHER_get_name(cipher), (size_t)len);
@@ -19263,6 +19273,7 @@ static int SaToNid(byte sa, int* nid)
1926319273
*nid = WC_NID_sm2;
1926419274
break;
1926519275
case invalid_sa_algo:
19276+
case any_sa_algo:
1926619277
default:
1926719278
ret = WOLFSSL_FAILURE;
1926819279
break;

wolfssl/internal.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4324,7 +4324,8 @@ enum KeyExchangeAlgorithm {
43244324
dhe_psk_kea,
43254325
ecdhe_psk_kea,
43264326
ecc_diffie_hellman_kea,
4327-
ecc_static_diffie_hellman_kea /* for verify suite only */
4327+
ecc_static_diffie_hellman_kea, /* for verify suite only */
4328+
any_kea
43284329
};
43294330

43304331
/* Used with InitSuitesHashSigAlgo */
@@ -4354,6 +4355,7 @@ enum SignatureAlgorithm {
43544355
dilithium_level3_sa_algo = 15,
43554356
dilithium_level5_sa_algo = 16,
43564357
sm2_sa_algo = 17,
4358+
any_sa_algo = 18,
43574359
invalid_sa_algo = 255
43584360
};
43594361

0 commit comments

Comments
 (0)