Skip to content

Conversation

SparkiDev
Copy link
Contributor

Description

Add support for:

  • SM2 elliptic curve and SM2 sign/verify
  • SM3 digest
  • SM4 cipher with modes ECB/CBC/CTR/GCM/CCM

Add APIs for SM3 and SM4.
Add SM2 sign and verify APIs.
Add support for SM3 in wc_Hash and wc_Hmac API.
Add support for SM3 and SM4 through EVP layer.
Add support for SM2-SM3 certificates. Support key ID and name hash being with SHA-1/256 or SM3.
Add support for TLS 1.3 cipher suites: TLS-SM4-GCM-SM3, TLS-SM4-CCM-SM3 Add support for TLS 1.2 SM cipher suite: ECDHE-ECDSA-SM4-CBC-SM3 Add support for SM3 in wc_PRF_TLS.
Add SM2-SM3 certificates and keys. Generated with GmSSL-3.0.0 and OpenSSL.

Testing

Tested using private implementation of SM algorithms.

Checklist

  • added tests
  • updated/added doxygen
  • updated appropriate READMEs
  • Updated manual and documentation

@SparkiDev SparkiDev self-assigned this Jun 23, 2023
@SparkiDev SparkiDev force-pushed the sm branch 4 times, most recently from 8e577b0 to 2eb4e6c Compare June 23, 2023 03:44
Copy link
Contributor

@dgarske dgarske left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, great work on this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alignment in comment off.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@SparkiDev SparkiDev force-pushed the sm branch 5 times, most recently from 7ba0b72 to 3626221 Compare June 26, 2023 05:04
@SparkiDev SparkiDev assigned dgarske and unassigned SparkiDev Jun 26, 2023
src/internal.c Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make[3]: warning: -j3 forced in submake: resetting jobserver mode.
make[3]: warning: -j3 forced in submake: resetting jobserver mode.
make[4]: warning: -j3 forced in submake: resetting jobserver mode.
In file included from ./wolfssl/internal.h:27,
                 from src/internal.c:102:
src/internal.c: In function ‘FreeCiphers’:
src/internal.c:2755:23: error: ‘Ciphers’ has no member named ‘additional’
 2755 |     XFREE(ssl->decrypt.additional, ssl->heap, DYNAMIC_TYPE_SM4_BUFFER);
      |                       ^
./wolfssl/wolfcrypt/types.h:560:63: note: in definition of macro ‘XFREE’
  560 |                     #define XFREE(p, h, t)       {void* xp = (p); if (xp) wolfSSL_Free(xp);}
      |                                                               ^
src/internal.c:2756:23: error: ‘Ciphers’ has no member named ‘additional’
 2756 |     XFREE(ssl->encrypt.additional, ssl->heap, DYNAMIC_TYPE_SM4_BUFFER);
      |                       ^
./wolfssl/wolfcrypt/types.h:560:63: note: in definition of macro ‘XFREE’
  560 |                     #define XFREE(p, h, t)       {void* xp = (p); if (xp) wolfSSL_Free(xp);}
      |                                                               ^
make[2]: *** [Makefile:6808: src/libwolfssl_la-internal.lo] Error 1
make[2]: *** Waiting for unfinished jobs....```

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can/should we avoid changing these numbers?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed - restored numbering and added it to the end

@guidovranken
Copy link
Contributor

Ping me when the PR is ready please; I'll test it.

@SparkiDev SparkiDev force-pushed the sm branch 4 times, most recently from 6158f5e to f8cdd5b Compare July 3, 2023 05:48
Copy link
Contributor

@dgarske dgarske left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI reports (PRB-aes.txt_10):

wolfcrypt/src/aes.c: In function ‘GHASH_UPDATE’:
wolfcrypt/src/aes.c:5427:32: error: ‘Aes’ has no member named ‘M0’
 5427 |         GMULT(AES_TAG(aes), aes->M0);                   \
      |                                ^~
wolfcrypt/src/aes.c:6359:17: note: in expansion of macro ‘GHASH_ONE_BLOCK’
 6359 |                 GHASH_ONE_BLOCK(aes, AES_LASTGBLOCK(aes));
      |                 ^~~~~~~~~~~~~~~
wolfcrypt/src/aes.c:5427:32: error: ‘Aes’ has no member named ‘M0’
 5427 |         GMULT(AES_TAG(aes), aes->M0);                   \
      |                                ^~
wolfcrypt/src/aes.c:6373:13: note: in expansion of macro ‘GHASH_ONE_BLOCK’
 6373 |             GHASH_ONE_BLOCK(aes, a);
      |             ^~~~~~~~~~~~~~~
wolfcrypt/src/aes.c:5427:32: error: ‘Aes’ has no member named ‘M0’
 5427 |         GMULT(AES_TAG(aes), aes->M0);                   \
      |                                ^~
wolfcrypt/src/aes.c:6388:9: note: in expansion of macro ‘GHASH_ONE_BLOCK’
 6388 |         GHASH_ONE_BLOCK(aes, AES_LASTGBLOCK(aes));
      |         ^~~~~~~~~~~~~~~
wolfcrypt/src/aes.c:5427:32: error: ‘Aes’ has no member named ‘M0’
 5427 |         GMULT(AES_TAG(aes), aes->M0);                   \
      |                                ^~
wolfcrypt/src/aes.c:6408:17: note: in expansion of macro ‘GHASH_ONE_BLOCK’
 6408 |                 GHASH_ONE_BLOCK(aes, AES_LASTGBLOCK(aes));
      |                 ^~~~~~~~~~~~~~~
wolfcrypt/src/aes.c:5427:32: error: ‘Aes’ has no member named ‘M0’
 5427 |         GMULT(AES_TAG(aes), aes->M0);                   \
      |                                ^~
wolfcrypt/src/aes.c:6422:13: note: in expansion of macro ‘GHASH_ONE_BLOCK’
 6422 |             GHASH_ONE_BLOCK(aes, c);
      |             ^~~~~~~~~~~~~~~
wolfcrypt/src/aes.c: In function ‘GHASH_FINAL’:
wolfcrypt/src/aes.c:5427:32: error: ‘Aes’ has no member named ‘M0’
 5427 |         GMULT(AES_TAG(aes), aes->M0);                   \
      |                                ^~
wolfcrypt/src/aes.c:6454:9: note: in expansion of macro ‘GHASH_ONE_BLOCK’
 6454 |         GHASH_ONE_BLOCK(aes, AES_LASTGBLOCK(aes));
      |         ^~~~~~~~~~~~~~~
wolfcrypt/src/aes.c:5427:32: error: ‘Aes’ has no member named ‘M0’
 5427 |         GMULT(AES_TAG(aes), aes->M0);                   \
      |                                ^~
wolfcrypt/src/aes.c:6310:9: note: in expansion of macro ‘GHASH_ONE_BLOCK’
 6310 |         GHASH_ONE_BLOCK(aes, scratch);            \
      |         ^~~~~~~~~~~~~~~
wolfcrypt/src/aes.c:6457:5: note: in expansion of macro ‘GHASH_LEN_BLOCK’
 6457 |     GHASH_LEN_BLOCK(aes);
      |     ^~~~~~~~~~~~~~~
make[2]: *** [Makefile:6122: wolfcrypt/src/src_libwolfssl_la-aes.lo] Error 1

@dgarske dgarske removed their assignment Jul 3, 2023
@SparkiDev SparkiDev force-pushed the sm branch 2 times, most recently from 4f5488f to 248fd64 Compare July 3, 2023 23:40
@SparkiDev SparkiDev assigned dgarske and unassigned SparkiDev and dgarske Jul 4, 2023
Add support for:
 - SM2 elliptic curve and SM2 sign/verify
 - SM3 digest
 - SM4 cipher with modes ECB/CBC/CTR/GCM/CCM

Add APIs for SM3 and SM4.
Add SM2 sign and verify APIs.
Add support for SM3 in wc_Hash and wc_Hmac API.
Add support for SM3 and SM4 through EVP layer.
Add support for SM2-SM3 certificates. Support key ID and name hash being
with SHA-1/256 or SM3.
Add support for TLS 1.3 cipher suites: TLS-SM4-GCM-SM3, TLS-SM4-CCM-SM3
Add support for TLS 1.2 SM cipher suite: ECDHE-ECDSA-SM4-CBC-SM3
Add support for SM3 in wc_PRF_TLS.
Add SM2-SM3 certificates and keys. Generated with GmSSL-3.0.0 and
OpenSSL.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants