Skip to content

Commit 1ddc552

Browse files
committed
TLS, SM2: fix ecc key type
Set the curve explicitly if it is SM2. Set the key type to signature algorithm to handle SM2.
1 parent 840d1e9 commit 1ddc552

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/internal.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28007,6 +28007,12 @@ int DecodePrivateKey(WOLFSSL *ssl, word32* length)
2800728007
(ecc_key*)ssl->hsKey,
2800828008
ssl->buffers.key->length);
2800928009
}
28010+
#endif
28011+
#ifdef WOLFSSL_SM2
28012+
if ((ret == 0) && (ssl->buffers.keyType == sm2_sa_algo)) {
28013+
ret = wc_ecc_set_curve((ecc_key*)ssl->hsKey,
28014+
WOLFSSL_SM2_KEY_BITS / 8, ECC_SM2P256V1);
28015+
}
2801028016
#endif
2801128017
if (ret == 0) {
2801228018
WOLFSSL_MSG("Using ECC private key");
@@ -34542,7 +34548,7 @@ static int DoSessionTicket(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
3454234548
{
3454334549
word32 keySz;
3454434550

34545-
ssl->buffers.keyType = ecc_dsa_sa_algo;
34551+
ssl->buffers.keyType = ssl->options.sigAlgo;
3454634552
ret = DecodePrivateKey(ssl, &keySz);
3454734553
if (ret != 0) {
3454834554
goto exit_sske;

0 commit comments

Comments
 (0)