Skip to content

Commit

Permalink
Merge branch 'ED25519_SHA2_fix' of https://github.com/gojimmypi/wolfssl
Browse files Browse the repository at this point in the history
… into ED25519_SHA2_fix
  • Loading branch information
gojimmypi committed Oct 11, 2024
2 parents 7017398 + 3d10e7f commit 965e476
Show file tree
Hide file tree
Showing 30 changed files with 284 additions and 56 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/keep-alive.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Keep Alive

on:
schedule:
# Runs every hour
- cron: "0 * * * *"

jobs:
keep-alive:
# Don't run this on downstream forks:
if: github.repository_owner == 'gojimmypi'
runs-on: self-hosted # Ensure this runs on your self-hosted runner

steps:
- name: Run keep-alive task
run: |
echo "Running periodic keep-alive task."
11 changes: 11 additions & 0 deletions .github/workflows/self-hosted-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,14 @@ jobs:
- name: Run tests
run: |
whoami
- name: Send repository dispatch to wolfssl-actions
run: |
curl -X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.WOLFSSL_ACTION_TOKENF1 }}" \
https://api.github.com/repos/gojimmypi/wolfssl-actions/dispatches \
-H "X-GitHub-Api-Version: 2022-11-28" \
-d '{"event_type":"espressif_test","client_payload":{"unit":false,"integration":true}}'
1 change: 1 addition & 0 deletions .github/workflows/win-csharp-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
jobs:
build:

if: github.repository_owner == 'wolfssl'
runs-on: windows-latest

# This should be a safe limit for the tests to run.
Expand Down
1 change: 1 addition & 0 deletions IDE/Espressif/ESP-IDF/examples/wolfssl_test/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# wolfSSL Crypt Test Example


This is the ESP32 Version of the [wolfSSL wolfcrypt test application](https://github.com/wolfSSL/wolfssl/tree/master/wolfcrypt/test).

For general information on [wolfSSL examples for Espressif](../README.md), see the
Expand Down
6 changes: 6 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -5217,6 +5217,12 @@ AC_ARG_ENABLE([aeskeywrap],
)

# FIPS feature and macro setup

AS_IF([test "$FIPS_VERSION" = "dev"],
[AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_FIPS_DEV"])
AS_IF([test "$FIPS_VERSION" = "ready"],
[AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_FIPS_READY"])

AS_CASE([$FIPS_VERSION],
[v6|ready|dev],[ # FIPS 140-3 SRTP-KDF
AM_CFLAGS="$AM_CFLAGS \
Expand Down
9 changes: 9 additions & 0 deletions wolfcrypt/src/aes.c
Original file line number Diff line number Diff line change
Expand Up @@ -11299,6 +11299,7 @@ int wc_AesCcmEncrypt_ex(Aes* aes, byte* out, const byte* in, word32 sz,

#endif /* HAVE_AESCCM */

#ifndef WOLFSSL_NO_MALLOC
Aes* wc_AesNew(void* heap, int devId)
{
Aes* aes = (Aes*)XMALLOC(sizeof(Aes), heap, DYNAMIC_TYPE_AES);
Expand All @@ -11313,6 +11314,7 @@ Aes* wc_AesNew(void* heap, int devId)
}
return aes;
}
#endif

/* Initialize Aes for use with async hardware */
int wc_AesInit(Aes* aes, void* heap, int devId)
Expand Down Expand Up @@ -11449,14 +11451,18 @@ int wc_AesInit_Label(Aes* aes, const char* label, void* heap, int devId)
void wc_AesFree(Aes* aes)
{
void* heap;
#ifndef WOLFSSL_NO_MALLOC
byte isAllocated;
#endif

if (aes == NULL) {
return;
}

#ifndef WOLFSSL_NO_MALLOC
heap = aes->heap;
isAllocated = aes->isAllocated;
#endif

#ifdef WC_DEBUG_CIPHER_LIFECYCLE
(void)wc_debug_CipherLifecycleFree(&aes->CipherLifecycleTag, heap, 1);
Expand Down Expand Up @@ -11525,9 +11531,12 @@ void wc_AesFree(Aes* aes)
wc_MemZero_Check(aes, sizeof(Aes));
#endif

#ifndef WOLFSSL_NO_MALLOC
if (isAllocated) {
XFREE(aes, heap, DYNAMIC_TYPE_AES);
}
#endif
(void)heap;

}

Expand Down
12 changes: 10 additions & 2 deletions wolfcrypt/src/ed25519.c
Original file line number Diff line number Diff line change
Expand Up @@ -968,6 +968,7 @@ int wc_ed25519ph_verify_msg(const byte* sig, word32 sigLen, const byte* msg,
}
#endif /* HAVE_ED25519_VERIFY */

#ifndef WOLFSSL_NO_MALLOC
ed25519_key* wc_ed25519_new(void* heap, int devId)
{
ed25519_key* key = (ed25519_key*)XMALLOC(sizeof(ed25519_key), heap,
Expand All @@ -983,6 +984,7 @@ ed25519_key* wc_ed25519_new(void* heap, int devId)
}
return key;
}
#endif

/* initialize information and memory for key */
int wc_ed25519_init_ex(ed25519_key* key, void* heap, int devId)
Expand Down Expand Up @@ -1024,13 +1026,16 @@ int wc_ed25519_init(ed25519_key* key)
void wc_ed25519_free(ed25519_key* key)
{
void* heap;
#ifndef WOLFSSL_NO_MALLOC
byte isAllocated = 0;

#endif
if (key == NULL)
return;

#ifndef WOLFSSL_NO_MALLOC
heap = key->heap;
isAllocated = key->isAllocated;
#endif

#ifdef WOLFSSL_ED25519_PERSISTENT_SHA
ed25519_hash_free(key, &key->sha);
Expand All @@ -1045,10 +1050,13 @@ void wc_ed25519_free(ed25519_key* key)
wc_MemZero_Check(key, sizeof(ed25519_key));
#endif

#ifndef WOLFSSL_NO_MALLOC
if (isAllocated) {
XFREE(key, heap, DYNAMIC_TYPE_ED25519);
(void)heap;
}
#endif
(void)heap;

}


Expand Down
14 changes: 12 additions & 2 deletions wolfcrypt/src/hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,7 @@ int wc_Hash(enum wc_HashType hash_type, const byte* data,
NULL, INVALID_DEVID);
}

#ifndef WOLFSSL_NO_MALLOC
wc_HashAlg* wc_HashNew(enum wc_HashType type, void* heap, int devId)
{
wc_HashAlg* hash = (wc_HashAlg*)XMALLOC(sizeof(wc_HashAlg), heap,
Expand All @@ -701,6 +702,7 @@ wc_HashAlg* wc_HashNew(enum wc_HashType type, void* heap, int devId)
}
return hash;
}
#endif

int wc_HashInit_ex(wc_HashAlg* hash, enum wc_HashType type, void* heap,
int devId)
Expand All @@ -710,7 +712,9 @@ int wc_HashInit_ex(wc_HashAlg* hash, enum wc_HashType type, void* heap,
if (hash == NULL)
return BAD_FUNC_ARG;

#ifndef WOLFSSL_NO_MALLOC
hash->isAllocated = 0;
#endif
hash->type = type;

switch (type) {
Expand Down Expand Up @@ -1042,19 +1046,23 @@ int wc_HashFree(wc_HashAlg* hash, enum wc_HashType type)
{
int ret = WC_NO_ERR_TRACE(HASH_TYPE_E); /* Default to hash type error */
void* heap = NULL;
#ifndef WOLFSSL_NO_MALLOC
byte isAllocated = 0;

#endif
if (hash == NULL)
return BAD_FUNC_ARG;


#ifdef DEBUG_WOLFSSL
if (hash->type != type) {
WOLFSSL_MSG("Hash free type mismatch!");
return BAD_FUNC_ARG;
}
#endif

#ifndef WOLFSSL_NO_MALLOC
isAllocated = hash->isAllocated;
#endif

switch (type) {
case WC_HASH_TYPE_MD5:
Expand Down Expand Up @@ -1170,10 +1178,12 @@ int wc_HashFree(wc_HashAlg* hash, enum wc_HashType type)
ret = BAD_FUNC_ARG;
};

#ifndef WOLFSSL_NO_MALLOC
if (isAllocated) {
XFREE(hash, heap, DYNAMIC_TYPE_HASHES);
(void)heap;
}
#endif
(void)heap;

return ret;
}
Expand Down
2 changes: 1 addition & 1 deletion wolfcrypt/src/port/arm/armv8-32-aes-asm.S
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include <wolfssl/wolfcrypt/settings.h>

#ifdef WOLFSSL_ARMASM
#if !defined(__aarch64__) && defined(__arm__) && !defined(__thumb__)
#if !defined(__aarch64__) && defined(__arm__) && (!defined(__thumb__) || defined(__THUMB_INTERWORK__))
#ifndef WOLFSSL_ARMASM_INLINE
#ifndef NO_AES
#ifdef HAVE_AES_DECRYPT
Expand Down
6 changes: 3 additions & 3 deletions wolfcrypt/src/port/arm/armv8-32-aes-asm_c.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include <wolfssl/wolfcrypt/error-crypt.h>

#ifdef WOLFSSL_ARMASM
#if !defined(__aarch64__) && defined(__arm__) && !defined(__thumb__)
#if !defined(__aarch64__) && defined(__arm__) && (!defined(__thumb__) || defined(__THUMB_INTERWORK__))
#include <stdint.h>
#ifdef HAVE_CONFIG_H
#include <config.h>
Expand All @@ -42,7 +42,7 @@
#ifdef WOLFSSL_ARMASM_INLINE

#ifdef WOLFSSL_ARMASM
#if !defined(__aarch64__) && defined(__arm__) && !defined(__thumb__)
#if !defined(__aarch64__) && defined(__arm__) && (!defined(__thumb__) || defined(__THUMB_INTERWORK__))

#ifdef __IAR_SYSTEMS_ICC__
#define __asm__ asm
Expand Down Expand Up @@ -4854,7 +4854,7 @@ void AES_GCM_encrypt(const unsigned char* in_p, unsigned char* out_p,
#endif /* !NO_AES */
#endif /* !__aarch64__ && __arm__ && !__thumb__ */
#endif /* WOLFSSL_ARMASM */
#endif /* !defined(__aarch64__) && defined(__arm__) && !defined(__thumb__) */
#endif /* !defined(__aarch64__) && defined(__arm__) && (!defined(__thumb__) || defined(__THUMB_INTERWORK__)) */
#endif /* WOLFSSL_ARMASM */

#endif /* WOLFSSL_ARMASM_INLINE */
2 changes: 1 addition & 1 deletion wolfcrypt/src/port/arm/armv8-32-chacha-asm.S
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include <wolfssl/wolfcrypt/settings.h>

#ifdef WOLFSSL_ARMASM
#if !defined(__aarch64__) && defined(__arm__) && !defined(__thumb__)
#if !defined(__aarch64__) && defined(__arm__) && (!defined(__thumb__) || defined(__THUMB_INTERWORK__))
#ifndef WOLFSSL_ARMASM_INLINE
#ifdef HAVE_CHACHA
.text
Expand Down
6 changes: 3 additions & 3 deletions wolfcrypt/src/port/arm/armv8-32-chacha-asm_c.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include <wolfssl/wolfcrypt/error-crypt.h>

#ifdef WOLFSSL_ARMASM
#if !defined(__aarch64__) && defined(__arm__) && !defined(__thumb__)
#if !defined(__aarch64__) && defined(__arm__) && (!defined(__thumb__) || defined(__THUMB_INTERWORK__))
#include <stdint.h>
#ifdef HAVE_CONFIG_H
#include <config.h>
Expand All @@ -42,7 +42,7 @@
#ifdef WOLFSSL_ARMASM_INLINE

#ifdef WOLFSSL_ARMASM
#if !defined(__aarch64__) && defined(__arm__) && !defined(__thumb__)
#if !defined(__aarch64__) && defined(__arm__) && (!defined(__thumb__) || defined(__THUMB_INTERWORK__))

#ifdef __IAR_SYSTEMS_ICC__
#define __asm__ asm
Expand Down Expand Up @@ -570,7 +570,7 @@ void wc_chacha_use_over(byte* over_p, byte* output_p, const byte* input_p,
#endif /* HAVE_CHACHA */
#endif /* !__aarch64__ && __arm__ && !__thumb__ */
#endif /* WOLFSSL_ARMASM */
#endif /* !defined(__aarch64__) && defined(__arm__) && !defined(__thumb__) */
#endif /* !defined(__aarch64__) && defined(__arm__) && (!defined(__thumb__) || defined(__THUMB_INTERWORK__)) */
#endif /* WOLFSSL_ARMASM */

#endif /* WOLFSSL_ARMASM_INLINE */
2 changes: 1 addition & 1 deletion wolfcrypt/src/port/arm/armv8-32-curve25519.S
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include <wolfssl/wolfcrypt/settings.h>

#ifdef WOLFSSL_ARMASM
#if !defined(__aarch64__) && defined(__arm__) && !defined(__thumb__)
#if !defined(__aarch64__) && defined(__arm__) && (!defined(__thumb__) || defined(__THUMB_INTERWORK__))
#ifndef WOLFSSL_ARMASM_INLINE
#if defined(HAVE_CURVE25519) || defined(HAVE_ED25519)
#if !defined(CURVE25519_SMALL) || !defined(ED25519_SMALL)
Expand Down
6 changes: 3 additions & 3 deletions wolfcrypt/src/port/arm/armv8-32-curve25519_c.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include <wolfssl/wolfcrypt/error-crypt.h>

#ifdef WOLFSSL_ARMASM
#if !defined(__aarch64__) && defined(__arm__) && !defined(__thumb__)
#if !defined(__aarch64__) && defined(__arm__) && (!defined(__thumb__) || defined(__THUMB_INTERWORK__))
#include <stdint.h>
#ifdef HAVE_CONFIG_H
#include <config.h>
Expand All @@ -42,7 +42,7 @@
#ifdef WOLFSSL_ARMASM_INLINE

#ifdef WOLFSSL_ARMASM
#if !defined(__aarch64__) && defined(__arm__) && !defined(__thumb__)
#if !defined(__aarch64__) && defined(__arm__) && (!defined(__thumb__) || defined(__THUMB_INTERWORK__))

#ifdef __IAR_SYSTEMS_ICC__
#define __asm__ asm
Expand Down Expand Up @@ -9430,7 +9430,7 @@ void sc_muladd(byte* s_p, const byte* a_p, const byte* b_p, const byte* c_p)
#endif /* HAVE_CURVE25519 || HAVE_ED25519 */
#endif /* !__aarch64__ && __arm__ && !__thumb__ */
#endif /* WOLFSSL_ARMASM */
#endif /* !defined(__aarch64__) && defined(__arm__) && !defined(__thumb__) */
#endif /* !defined(__aarch64__) && defined(__arm__) && (!defined(__thumb__) || defined(__THUMB_INTERWORK__)) */
#endif /* WOLFSSL_ARMASM */

#endif /* WOLFSSL_ARMASM_INLINE */
2 changes: 1 addition & 1 deletion wolfcrypt/src/port/arm/armv8-32-kyber-asm.S
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include <wolfssl/wolfcrypt/settings.h>

#ifdef WOLFSSL_ARMASM
#if !defined(__aarch64__) && defined(__arm__) && !defined(__thumb__)
#if !defined(__aarch64__) && defined(__arm__) && (!defined(__thumb__) || defined(__THUMB_INTERWORK__))
#ifndef WOLFSSL_ARMASM_INLINE
#ifdef WOLFSSL_WC_KYBER
.text
Expand Down
6 changes: 3 additions & 3 deletions wolfcrypt/src/port/arm/armv8-32-kyber-asm_c.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include <wolfssl/wolfcrypt/error-crypt.h>

#ifdef WOLFSSL_ARMASM
#if !defined(__aarch64__) && defined(__arm__) && !defined(__thumb__)
#if !defined(__aarch64__) && defined(__arm__) && (!defined(__thumb__) || defined(__THUMB_INTERWORK__))
#include <stdint.h>
#ifdef HAVE_CONFIG_H
#include <config.h>
Expand All @@ -42,7 +42,7 @@
#ifdef WOLFSSL_ARMASM_INLINE

#ifdef WOLFSSL_ARMASM
#if !defined(__aarch64__) && defined(__arm__) && !defined(__thumb__)
#if !defined(__aarch64__) && defined(__arm__) && (!defined(__thumb__) || defined(__THUMB_INTERWORK__))

#ifdef __IAR_SYSTEMS_ICC__
#define __asm__ asm
Expand Down Expand Up @@ -9233,7 +9233,7 @@ unsigned int kyber_arm32_rej_uniform(sword16* p_p, unsigned int len_p,
#endif /* WOLFSSL_WC_KYBER */
#endif /* !__aarch64__ && __arm__ && !__thumb__ */
#endif /* WOLFSSL_ARMASM */
#endif /* !defined(__aarch64__) && defined(__arm__) && !defined(__thumb__) */
#endif /* !defined(__aarch64__) && defined(__arm__) && (!defined(__thumb__) || defined(__THUMB_INTERWORK__)) */
#endif /* WOLFSSL_ARMASM */

#endif /* WOLFSSL_ARMASM_INLINE */
2 changes: 1 addition & 1 deletion wolfcrypt/src/port/arm/armv8-32-poly1305-asm.S
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include <wolfssl/wolfcrypt/settings.h>

#ifdef WOLFSSL_ARMASM
#if !defined(__aarch64__) && defined(__arm__) && !defined(__thumb__)
#if !defined(__aarch64__) && defined(__arm__) && (!defined(__thumb__) || defined(__THUMB_INTERWORK__))
#ifndef WOLFSSL_ARMASM_INLINE
#ifdef HAVE_POLY1305
.text
Expand Down
Loading

0 comments on commit 965e476

Please sign in to comment.