Skip to content

Commit

Permalink
Merge pull request #17 from bigbrett/v1-release-updates
Browse files Browse the repository at this point in the history
Fix demos to work with new wolfHSM API
  • Loading branch information
billphipps authored Nov 5, 2024
2 parents 768d2d5 + 312b72d commit 98fa58d
Show file tree
Hide file tree
Showing 27 changed files with 587 additions and 807 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.DS_Store
Build/
demo/certs/*.pem

Binary file added demo/certs/alice-ecc256-key.der
Binary file not shown.
Binary file added demo/certs/bob-ecc256-key.der
Binary file not shown.
2 changes: 0 additions & 2 deletions demo/certs/curve25519-private-alice.raw

This file was deleted.

1 change: 0 additions & 1 deletion demo/certs/curve25519-private-bob.raw

This file was deleted.

2 changes: 0 additions & 2 deletions demo/certs/curve25519-public-alice.raw

This file was deleted.

1 change: 0 additions & 1 deletion demo/certs/curve25519-public-bob.raw

This file was deleted.

Binary file added demo/certs/curve25519_keyAlice.der
Binary file not shown.
Binary file added demo/certs/curve25519_keyBob.der
Binary file not shown.
Binary file removed demo/certs/ecc-private-alice.raw
Binary file not shown.
1 change: 0 additions & 1 deletion demo/certs/ecc-private-bob.raw

This file was deleted.

1 change: 0 additions & 1 deletion demo/certs/ecc-public-alice.raw

This file was deleted.

1 change: 0 additions & 1 deletion demo/certs/ecc-public-bob.raw

This file was deleted.

18 changes: 18 additions & 0 deletions demo/certs/genKeys.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

# ECC Keys
openssl genpkey -algorithm EC -pkeyopt ec_paramgen_curve:prime256v1 -out alice-ecc256-key.pem
openssl genpkey -algorithm EC -pkeyopt ec_paramgen_curve:prime256v1 -out bob-ecc256-key.pem
openssl ec -in alice-ecc256-key.pem -outform DER -out alice-ecc256-key.der
openssl ec -in bob-ecc256-key.pem -outform DER -out bob-ecc256-key.der

# RSA Key
openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -out rsa-2048-key.pem
openssl rsa -in rsa-2048-key.pem -outform DER -out rsa-2048-key.der

# TODO: Curve25519 Keys
# Either need to modify examples to split out public/private operations, or modify wolfHSM to be able to recove public keys on deserialization of private only.
#openssl genpkey -algorithm X25519 -out alice-curve25519-key.pem
#openssl genpkey -algorithm X25519 -out bob-curve25519-key.pem
#openssl pkey -in alice-curve25519-key.pem -outform DER -out alice-curve25519-key.der
#openssl pkey -in bob-curve25519-key.pem -outform DER -out bob-curve25519-key.der
Binary file added demo/certs/rsa-2048-key.der
Binary file not shown.
16 changes: 15 additions & 1 deletion demo/client/wh_demo_client_all.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,15 @@ int wh_DemoClient_All(whClientContext* clientContext)
if (rc != 0) {
return rc;
}
#ifndef NO_AES
rc = wh_DemoClient_KeystoreAes(clientContext);
if (rc != 0) {
return rc;
}
#endif

/* Crypto demos */
/**Crypto demos */
#ifndef NO_RSA
rc = wh_DemoClient_CryptoRsa(clientContext);
if (rc != 0) {
return rc;
Expand All @@ -52,7 +55,9 @@ int wh_DemoClient_All(whClientContext* clientContext)
if (rc != 0) {
return rc;
}
#endif /* !NO_RSA */

#ifdef HAVE_CURVE25519
rc = wh_DemoClient_CryptoCurve25519(clientContext);
if (rc != 0) {
return rc;
Expand All @@ -62,7 +67,9 @@ int wh_DemoClient_All(whClientContext* clientContext)
if (rc != 0) {
return rc;
}
#endif /* HAVE_CURVE25519 */

#ifdef HAVE_ECC
rc = wh_DemoClient_CryptoEcc(clientContext);
if (rc != 0) {
return rc;
Expand All @@ -72,7 +79,9 @@ int wh_DemoClient_All(whClientContext* clientContext)
if (rc != 0) {
return rc;
}
#endif /* HAVE_ECC */

#if !defined(NO_AES) && defined(HAVE_AES_CBC)
rc = wh_DemoClient_CryptoAesCbc(clientContext);
if (rc != 0) {
return rc;
Expand All @@ -82,7 +91,9 @@ int wh_DemoClient_All(whClientContext* clientContext)
if (rc != 0) {
return rc;
}
#endif /* !NO_AES && HAVE_AES_CBC */

#if !defined(NO_AES) && defined(HAVE_AESGCM)
rc = wh_DemoClient_CryptoAesGcm(clientContext);
if (rc != 0) {
return rc;
Expand All @@ -92,7 +103,9 @@ int wh_DemoClient_All(whClientContext* clientContext)
if (rc != 0) {
return rc;
}
#endif /* !NO_AES && HAVE_AESGCM */

#if defined(WOLFSSL_CMAC)
rc = wh_DemoClient_CryptoCmac(clientContext);
if (rc != 0) {
return rc;
Expand All @@ -107,6 +120,7 @@ int wh_DemoClient_All(whClientContext* clientContext)
if (rc != 0) {
return rc;
}
#endif /* WOLFSSL_CMAC */

return rc;
}
Loading

0 comments on commit 98fa58d

Please sign in to comment.