Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update EBSNET port #6410

Merged
merged 1 commit into from
Jun 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/configs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Example wolfSSL configuration file templates for use when autoconf is not availa
* `user_settings_fipsv5.h`: The FIPS v5 (ready) 140-3 build options. Equivalent to `./configure --enable-fips=v5-dev`.
* `user_settings_stm32.h`: Example configuration file generated from the wolfSSL STM32 Cube pack.
* `user_settings_wolftpm.h`: Minimum options for building wolfTPM. See comment at top for ./configure used to generate.
*.`user_settings_EBSnet.h`: Example configuration file for use with EBSnet ports.

## Usage

Expand Down
1 change: 1 addition & 0 deletions examples/configs/include.am
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ EXTRA_DIST += examples/configs/user_settings_fipsv2.h
EXTRA_DIST += examples/configs/user_settings_fipsv5.h
EXTRA_DIST += examples/configs/user_settings_stm32.h
EXTRA_DIST += examples/configs/user_settings_wolftpm.h
EXTRA_DIST += examples/configs/user_settings_EBSnet.h
56 changes: 56 additions & 0 deletions examples/configs/user_settings_EBSnet.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/* user_settings_EBSnet.h
*
* Copyright (C) 2006-2023 wolfSSL Inc.
*
* This file is part of wolfSSL.
*
* wolfSSL is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* wolfSSL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
*/

/* Example wolfSSL user settings for use with EBSnet ports.
* This file is included with wolfssl/wolfcrypt/settings.h when WOLFSSL_USER_SETTINGS is defined.
*/

#ifndef WOLFSSL_USER_SETTINGS_H
#define WOLFSSL_USER_SETTINGS_H

#ifdef __cplusplus
extern "C" {
#endif

#define OPENSSL_EXTRA_X509_SMALL

#define USE_FAST_MATH
#define TFM_TIMING_RESISTANT
#define WC_RSA_BLINDING
#define ECC_TIMING_RESISTANT

#define HAVE_ECC
#define HAVE_CURVE25519
#define HAVE_AESGCM
#define WOLFSSL_SHA384
dgarske marked this conversation as resolved.
Show resolved Hide resolved

#define NO_DSA
#define NO_RC4
#define NO_MD4
#define NO_MD5
#define NO_DES3

#ifdef __cplusplus
}
#endif

#endif /* WOLFSSL_USER_SETTINGS_H */

15 changes: 15 additions & 0 deletions wolfcrypt/src/random.c
Original file line number Diff line number Diff line change
Expand Up @@ -2627,6 +2627,8 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
#elif defined(HAVE_RTP_SYS) || defined(EBSNET)

#include "rtprand.h" /* rtp_rand () */

#if (defined(HAVE_RTP_SYS) || (defined(RTPLATFORM) && (RTPLATFORM != 0)))
#include "rtptime.h" /* rtp_get_system_msec() */

int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
Expand All @@ -2640,6 +2642,19 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)

return 0;
}
#else
int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
{
word32 i;
KS_SEED(ks_get_ticks());

for (i = 0; i < sz; i++ ) {
output[i] = KS_RANDOM() % 256;
}

return 0;
}
#endif /* defined(HAVE_RTP_SYS) || (defined(RTPLATFORM) && (RTPLATFORM != 0)) */

#elif (defined(WOLFSSL_ATMEL) || defined(WOLFSSL_ATECC_RNG)) && \
!defined(WOLFSSL_PIC32MZ_RNG)
Expand Down
62 changes: 61 additions & 1 deletion wolfcrypt/src/wc_port.c
Original file line number Diff line number Diff line change
Expand Up @@ -2031,7 +2031,7 @@ int wolfSSL_CryptHwMutexUnLock(void)
}

#elif defined(EBSNET)

#if (defined(RTPLATFORM) && (RTPLATFORM != 0))
int wc_InitMutex(wolfSSL_Mutex* m)
{
if (rtp_sig_mutex_alloc(m, "wolfSSL Mutex") == -1)
Expand Down Expand Up @@ -2072,6 +2072,66 @@ int wolfSSL_CryptHwMutexUnLock(void)

return(retval);
}
#else
static int rtip_semaphore_build(wolfSSL_Mutex *m)
{
KS_SEMAPHORE_BUILD(m)
return(RTP_TRUE);
}

int wc_InitMutex(wolfSSL_Mutex* m)
{
if (rtip_semaphore_build(m) == RTP_FALSE)
return BAD_MUTEX_E;
else
return 0;
}

int wc_FreeMutex(wolfSSL_Mutex* m)
{
KS_SEMAPHORE_FREE(*m);
return 0;
}

int wc_LockMutex(wolfSSL_Mutex* m)
{
if (KS_SEMAPHORE_GET(*m))
return 0;
else
return BAD_MUTEX_E;
}

int wc_UnLockMutex(wolfSSL_Mutex* m)
{
KS_SEMAPHORE_GIVE(*m);
return 0;
}
#endif
int ebsnet_fseek(int a, long b, int c)
Copy link
Contributor

Choose a reason for hiding this comment

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

Bring function ident back to align with strcasecmp?

{
int retval;

retval = (int)vf_lseek(a, b, c);
if (retval > 0)
retval = 0;
else
retval = -1;

return(retval);
}

int strcasecmp(const char *s1, const char *s2)
{
while (rtp_tolower(*s1) == rtp_tolower(*s2)) {
if (*s1 == '\0' || *s2 == '\0')
break;
s1++;
s2++;
}

return rtp_tolower(*(unsigned char *) s1) -
rtp_tolower(*(unsigned char *) s2);
}

#elif defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX)

Expand Down
2 changes: 1 addition & 1 deletion wolfssl/test.h
Original file line number Diff line number Diff line change
Expand Up @@ -2313,7 +2313,7 @@ static WC_INLINE void tcp_accept(SOCKET_T* sockfd, SOCKET_T* clientfd,

static WC_INLINE void tcp_set_nonblocking(SOCKET_T* sockfd)
{
#ifdef USE_WINDOWS_API
#if defined(USE_WINDOWS_API) || defined(EBSNET)
unsigned long blocking = 1;
int ret = ioctlsocket(*sockfd, FIONBIO, &blocking);
if (ret == SOCKET_ERROR)
Expand Down
8 changes: 6 additions & 2 deletions wolfssl/wolfcrypt/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,7 @@ extern void uITRON4_free(void *p) ;
#define SINGLE_THREADED
#endif

#if (RTPLATFORM)
#if (defined(RTPLATFORM) && (RTPLATFORM != 0))
#if (!RTP_LITTLE_ENDIAN)
#define BIG_ENDIAN_ORDER
#endif
Expand All @@ -937,9 +937,13 @@ extern void uITRON4_free(void *p) ;
#endif
#endif

#if (WINMSP3)
#define strtok_r strtok_s
#endif

#define XMALLOC(s, h, type) ((void *)rtp_malloc((s), SSL_PRO_MALLOC))
#define XFREE(p, h, type) (rtp_free(p))
#define XREALLOC(p, n, h, t) (rtp_realloc((p), (n)))
#define XREALLOC(p, n, h, t) (rtp_realloc((p), (n), (t)))

#if (WINMSP3)
#define XSTRNCASECMP(s1,s2,n) _strnicmp((s1),(s2),(n))
Expand Down
8 changes: 7 additions & 1 deletion wolfssl/wolfcrypt/wc_port.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,11 @@
#elif defined(MICRIUM)
typedef OS_MUTEX wolfSSL_Mutex;
#elif defined(EBSNET)
typedef RTP_MUTEX wolfSSL_Mutex;
#if (defined(RTPLATFORM) && (RTPLATFORM != 0))
typedef RTP_MUTEX wolfSSL_Mutex;
#else
typedef KS_RTIPSEM wolfSSL_Mutex;
#endif
#elif defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX)
typedef MUTEX_STRUCT wolfSSL_Mutex;
#elif defined(FREESCALE_FREE_RTOS)
Expand Down Expand Up @@ -474,6 +478,8 @@ WOLFSSL_ABI WOLFSSL_API int wolfCrypt_Cleanup(void);
#define XSEEK_END VSEEK_END
#define XBADFILE -1
#define XFGETS(b,s,f) -2 /* Not ported yet */
#define XSNPRINTF rtp_snprintf
#define XFPRINTF fprintf

#elif defined(LSR_FS)
#include <fs.h>
Expand Down