Skip to content

Commit 3cb0b4a

Browse files
authored
Merge pull request #6410 from embhorn/zd15856
Update EBSNET port
2 parents 6697181 + 53fe934 commit 3cb0b4a

8 files changed

Lines changed: 148 additions & 5 deletions

File tree

examples/configs/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Example wolfSSL configuration file templates for use when autoconf is not availa
1212
* `user_settings_fipsv5.h`: The FIPS v5 (ready) 140-3 build options. Equivalent to `./configure --enable-fips=v5-dev`.
1313
* `user_settings_stm32.h`: Example configuration file generated from the wolfSSL STM32 Cube pack.
1414
* `user_settings_wolftpm.h`: Minimum options for building wolfTPM. See comment at top for ./configure used to generate.
15+
*.`user_settings_EBSnet.h`: Example configuration file for use with EBSnet ports.
1516

1617
## Usage
1718

examples/configs/include.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ EXTRA_DIST += examples/configs/user_settings_fipsv2.h
1010
EXTRA_DIST += examples/configs/user_settings_fipsv5.h
1111
EXTRA_DIST += examples/configs/user_settings_stm32.h
1212
EXTRA_DIST += examples/configs/user_settings_wolftpm.h
13+
EXTRA_DIST += examples/configs/user_settings_EBSnet.h
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/* user_settings_EBSnet.h
2+
*
3+
* Copyright (C) 2006-2023 wolfSSL Inc.
4+
*
5+
* This file is part of wolfSSL.
6+
*
7+
* wolfSSL is free software; you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation; either version 2 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* wolfSSL is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with this program; if not, write to the Free Software
19+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20+
*/
21+
22+
/* Example wolfSSL user settings for use with EBSnet ports.
23+
* This file is included with wolfssl/wolfcrypt/settings.h when WOLFSSL_USER_SETTINGS is defined.
24+
*/
25+
26+
#ifndef WOLFSSL_USER_SETTINGS_H
27+
#define WOLFSSL_USER_SETTINGS_H
28+
29+
#ifdef __cplusplus
30+
extern "C" {
31+
#endif
32+
33+
#define OPENSSL_EXTRA_X509_SMALL
34+
35+
#define USE_FAST_MATH
36+
#define TFM_TIMING_RESISTANT
37+
#define WC_RSA_BLINDING
38+
#define ECC_TIMING_RESISTANT
39+
40+
#define HAVE_ECC
41+
#define HAVE_CURVE25519
42+
#define HAVE_AESGCM
43+
#define WOLFSSL_SHA384
44+
45+
#define NO_DSA
46+
#define NO_RC4
47+
#define NO_MD4
48+
#define NO_MD5
49+
#define NO_DES3
50+
51+
#ifdef __cplusplus
52+
}
53+
#endif
54+
55+
#endif /* WOLFSSL_USER_SETTINGS_H */
56+

wolfcrypt/src/random.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2627,6 +2627,8 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
26272627
#elif defined(HAVE_RTP_SYS) || defined(EBSNET)
26282628

26292629
#include "rtprand.h" /* rtp_rand () */
2630+
2631+
#if (defined(HAVE_RTP_SYS) || (defined(RTPLATFORM) && (RTPLATFORM != 0)))
26302632
#include "rtptime.h" /* rtp_get_system_msec() */
26312633

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

26412643
return 0;
26422644
}
2645+
#else
2646+
int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
2647+
{
2648+
word32 i;
2649+
KS_SEED(ks_get_ticks());
2650+
2651+
for (i = 0; i < sz; i++ ) {
2652+
output[i] = KS_RANDOM() % 256;
2653+
}
2654+
2655+
return 0;
2656+
}
2657+
#endif /* defined(HAVE_RTP_SYS) || (defined(RTPLATFORM) && (RTPLATFORM != 0)) */
26432658

26442659
#elif (defined(WOLFSSL_ATMEL) || defined(WOLFSSL_ATECC_RNG)) && \
26452660
!defined(WOLFSSL_PIC32MZ_RNG)

wolfcrypt/src/wc_port.c

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2031,7 +2031,7 @@ int wolfSSL_CryptHwMutexUnLock(void)
20312031
}
20322032

20332033
#elif defined(EBSNET)
2034-
2034+
#if (defined(RTPLATFORM) && (RTPLATFORM != 0))
20352035
int wc_InitMutex(wolfSSL_Mutex* m)
20362036
{
20372037
if (rtp_sig_mutex_alloc(m, "wolfSSL Mutex") == -1)
@@ -2072,6 +2072,66 @@ int wolfSSL_CryptHwMutexUnLock(void)
20722072

20732073
return(retval);
20742074
}
2075+
#else
2076+
static int rtip_semaphore_build(wolfSSL_Mutex *m)
2077+
{
2078+
KS_SEMAPHORE_BUILD(m)
2079+
return(RTP_TRUE);
2080+
}
2081+
2082+
int wc_InitMutex(wolfSSL_Mutex* m)
2083+
{
2084+
if (rtip_semaphore_build(m) == RTP_FALSE)
2085+
return BAD_MUTEX_E;
2086+
else
2087+
return 0;
2088+
}
2089+
2090+
int wc_FreeMutex(wolfSSL_Mutex* m)
2091+
{
2092+
KS_SEMAPHORE_FREE(*m);
2093+
return 0;
2094+
}
2095+
2096+
int wc_LockMutex(wolfSSL_Mutex* m)
2097+
{
2098+
if (KS_SEMAPHORE_GET(*m))
2099+
return 0;
2100+
else
2101+
return BAD_MUTEX_E;
2102+
}
2103+
2104+
int wc_UnLockMutex(wolfSSL_Mutex* m)
2105+
{
2106+
KS_SEMAPHORE_GIVE(*m);
2107+
return 0;
2108+
}
2109+
#endif
2110+
int ebsnet_fseek(int a, long b, int c)
2111+
{
2112+
int retval;
2113+
2114+
retval = (int)vf_lseek(a, b, c);
2115+
if (retval > 0)
2116+
retval = 0;
2117+
else
2118+
retval = -1;
2119+
2120+
return(retval);
2121+
}
2122+
2123+
int strcasecmp(const char *s1, const char *s2)
2124+
{
2125+
while (rtp_tolower(*s1) == rtp_tolower(*s2)) {
2126+
if (*s1 == '\0' || *s2 == '\0')
2127+
break;
2128+
s1++;
2129+
s2++;
2130+
}
2131+
2132+
return rtp_tolower(*(unsigned char *) s1) -
2133+
rtp_tolower(*(unsigned char *) s2);
2134+
}
20752135

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

wolfssl/test.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2313,7 +2313,7 @@ static WC_INLINE void tcp_accept(SOCKET_T* sockfd, SOCKET_T* clientfd,
23132313

23142314
static WC_INLINE void tcp_set_nonblocking(SOCKET_T* sockfd)
23152315
{
2316-
#ifdef USE_WINDOWS_API
2316+
#if defined(USE_WINDOWS_API) || defined(EBSNET)
23172317
unsigned long blocking = 1;
23182318
int ret = ioctlsocket(*sockfd, FIONBIO, &blocking);
23192319
if (ret == SOCKET_ERROR)

wolfssl/wolfcrypt/settings.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,7 @@ extern void uITRON4_free(void *p) ;
918918
#define SINGLE_THREADED
919919
#endif
920920

921-
#if (RTPLATFORM)
921+
#if (defined(RTPLATFORM) && (RTPLATFORM != 0))
922922
#if (!RTP_LITTLE_ENDIAN)
923923
#define BIG_ENDIAN_ORDER
924924
#endif
@@ -937,9 +937,13 @@ extern void uITRON4_free(void *p) ;
937937
#endif
938938
#endif
939939

940+
#if (WINMSP3)
941+
#define strtok_r strtok_s
942+
#endif
943+
940944
#define XMALLOC(s, h, type) ((void *)rtp_malloc((s), SSL_PRO_MALLOC))
941945
#define XFREE(p, h, type) (rtp_free(p))
942-
#define XREALLOC(p, n, h, t) (rtp_realloc((p), (n)))
946+
#define XREALLOC(p, n, h, t) (rtp_realloc((p), (n), (t)))
943947

944948
#if (WINMSP3)
945949
#define XSTRNCASECMP(s1,s2,n) _strnicmp((s1),(s2),(n))

wolfssl/wolfcrypt/wc_port.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,11 @@
244244
#elif defined(MICRIUM)
245245
typedef OS_MUTEX wolfSSL_Mutex;
246246
#elif defined(EBSNET)
247-
typedef RTP_MUTEX wolfSSL_Mutex;
247+
#if (defined(RTPLATFORM) && (RTPLATFORM != 0))
248+
typedef RTP_MUTEX wolfSSL_Mutex;
249+
#else
250+
typedef KS_RTIPSEM wolfSSL_Mutex;
251+
#endif
248252
#elif defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX)
249253
typedef MUTEX_STRUCT wolfSSL_Mutex;
250254
#elif defined(FREESCALE_FREE_RTOS)
@@ -474,6 +478,8 @@ WOLFSSL_ABI WOLFSSL_API int wolfCrypt_Cleanup(void);
474478
#define XSEEK_END VSEEK_END
475479
#define XBADFILE -1
476480
#define XFGETS(b,s,f) -2 /* Not ported yet */
481+
#define XSNPRINTF rtp_snprintf
482+
#define XFPRINTF fprintf
477483

478484
#elif defined(LSR_FS)
479485
#include <fs.h>

0 commit comments

Comments
 (0)