Skip to content

Commit

Permalink
Setup the CSharp wrapper to have its own wolfSSL project and user_set…
Browse files Browse the repository at this point in the history
…tings.h. Revert IDE/WIN. Execute CI test applications.
  • Loading branch information
dgarske committed Aug 23, 2024
1 parent d996d91 commit 8e37de6
Show file tree
Hide file tree
Showing 18 changed files with 975 additions and 480 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/win-csharp-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,12 @@ jobs:
# Add additional options to the MSBuild command line here (like platform or verbosity level).
# See https://docs.microsoft.com/visualstudio/msbuild/msbuild-command-line-reference
run: msbuild /m /p:PlatformToolset=v142 /p:Platform=${{env.BUILD_PLATFORM}} /p:Configuration=${{env.BUILD_CONFIGURATION}} ${{env.SOLUTION_FILE_PATH}}

- name: Run wolfCrypt test
working-directory: ${{env.GITHUB_WORKSPACE}}
run: wolfssl\wrapper\CSharp\Debug\x64\wolfCrypt-test.exe

- name: Run wolfSSL client/server example
working-directory: ${{env.GITHUB_WORKSPACE}}
run: |
wolfssl\wrapper\CSharp\Debug\x64\wolfSSL-TLS-Server.exe && sleep 1 & wolfssl\wrapper\CSharp\Debug\x64\wolfSSL-TLS-Client.exe
10 changes: 0 additions & 10 deletions IDE/WIN/user_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,6 @@
#define WOLFSSL_SEND_HRR_COOKIE
#define WOLFSSL_DTLS_CID

/* Added for CSHarp wrapper */
#define WOLFSSL_KEY_GEN
#define WOLFSSL_ASN_TEMPLATE /* default */
#define HAVE_ED25519
#define HAVE_CURVE25519
#define WOLFSSL_SHA512

/* optional debug logging */
#define DEBUG_WOLFSSL

/* Configurations */
#if defined(HAVE_FIPS)
/* FIPS */
Expand Down
20 changes: 11 additions & 9 deletions wolfcrypt/src/asn.c
Original file line number Diff line number Diff line change
Expand Up @@ -22552,7 +22552,7 @@ static int DecodeCertReq(DecodedCert* cert, int* criticalExt)
{
DECL_ASNGETDATA(dataASN, certReqASN_Length);
int ret = 0;
byte version;
byte version = 0;
word32 idx;

CALLOC_ASNGETDATA(dataASN, certReqASN_Length, ret, cert->heap);
Expand Down Expand Up @@ -27698,7 +27698,7 @@ static int SetCertificatePolicies(byte *output,
byte oid[MAX_OID_SZ];
word32 oidSz;
word32 sz = 0;
int piSz;
int piSz = 0;

if ((input == NULL) || (nb_certpol > MAX_CERTPOL_NB)) {
ret = BAD_FUNC_ARG;
Expand Down Expand Up @@ -30231,8 +30231,8 @@ int AddSignature(byte* buf, int bodySz, const byte* sig, int sigSz,
return (int)(idx + seqSz);
#else
DECL_ASNSETDATA(dataASN, sigASN_Length);
word32 seqSz;
int sz;
word32 seqSz = 0;
int sz = 0;
int ret = 0;

CALLOC_ASNSETDATA(dataASN, sigASN_Length, ret, NULL);
Expand Down Expand Up @@ -34813,6 +34813,7 @@ int wc_BuildEccKeyDer(ecc_key* key, byte* output, word32 *inLen,

/* Write a Private ecc key, including public to DER format,
* length on success else < 0 */
/* Note: use wc_EccKeyDerSize to get length only */
WOLFSSL_ABI
int wc_EccKeyToDer(ecc_key* key, byte* output, word32 inLen)
{
Expand All @@ -34824,10 +34825,7 @@ int wc_EccKeyToDer(ecc_key* key, byte* output, word32 inLen)
int wc_EccKeyDerSize(ecc_key* key, int pub)
{
word32 sz = 0;
int ret;

ret = wc_BuildEccKeyDer(key, NULL, &sz, pub, 1);

int ret = wc_BuildEccKeyDer(key, NULL, &sz, pub, 1);
if (ret != WC_NO_ERR_TRACE(LENGTH_ONLY_E)) {
return ret;
}
Expand All @@ -34838,7 +34836,11 @@ int wc_EccKeyDerSize(ecc_key* key, int pub)
* length on success else < 0 */
int wc_EccPrivateKeyToDer(ecc_key* key, byte* output, word32 inLen)
{
return wc_BuildEccKeyDer(key, output, &inLen, 0, 1);
int ret = wc_BuildEccKeyDer(key, output, &inLen, 0, 1);
if (ret == WC_NO_ERR_TRACE(LENGTH_ONLY_E)) {
return (int)inLen;
}
return ret;
}

#ifdef HAVE_PKCS8
Expand Down
2 changes: 2 additions & 0 deletions wrapper/CSharp/include.am
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ EXTRA_DIST+= wrapper/CSharp/wolfSSL-Example-IOCallbacks/Properties/AssemblyInfo.
EXTRA_DIST+= wrapper/CSharp/wolfSSL-Example-IOCallbacks/wolfSSL-Example-IOCallbacks.cs
EXTRA_DIST+= wrapper/CSharp/wolfSSL-Example-IOCallbacks/wolfSSL-Example-IOCallbacks.csproj
EXTRA_DIST+= wrapper/CSharp/wolfSSL_CSharp.sln
EXTRA_DIST+= wrapper/CSharp/user_settings.h
EXTRA_DIST+= wrapper/CSharp/wolfssl.vcxproj
EXTRA_DIST+= wrapper/CSharp/wolfSSL_CSharp/Properties/AssemblyInfo.cs
EXTRA_DIST+= wrapper/CSharp/wolfSSL_CSharp/Properties/Resources.Designer.cs
EXTRA_DIST+= wrapper/CSharp/wolfSSL_CSharp/Properties/Resources.resx
Expand Down
132 changes: 132 additions & 0 deletions wrapper/CSharp/user_settings.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
/* user_settings.h
*
* Copyright (C) 2006-2024 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
*/

/* These are the build settings used by the Visual Studio CSharp wrapper */

#ifndef _WIN_CSHARP_USER_SETTINGS_H_
#define _WIN_CSHARP_USER_SETTINGS_H_

/* Features */
#define NO_OLD_TLS
#define WOLFSSL_TLS13
#define WOLFSSL_DTLS
#define WOLFSSL_DTLS13
#define WOLFSSL_SEND_HRR_COOKIE
#define WOLFSSL_DTLS_CID
#define HAVE_EXTENDED_MASTER
#define HAVE_SECURE_RENEGOTIATION
#define HAVE_SUPPORTED_CURVES
#define HAVE_TLS_EXTENSIONS
#define WOLFSSL_CERT_EXT
#define WOLFSSL_CERT_REQ
#define WOLFSSL_CERT_GEN
#define HAVE_ENCRYPT_THEN_MAC
#define HAVE_ECC_ENCRYPT
#define WOLFSSL_PUBLIC_MP
#define NO_MULTIBYTE_PRINT
#define WOLFSSL_KEY_GEN /* RSA key gen */
#define WOLFSSL_ASN_TEMPLATE /* default */
#if 0
#define OPENSSL_EXTRA
#endif

#define HAVE_CRL
#if 0
/* start thread that can monitor CRL directory */
#define HAVE_CRL_MONITOR
#endif

/* Algorithms */
#define HAVE_ED25519
#define HAVE_CURVE25519

#define HAVE_AESGCM
#define WOLFSSL_AESGCM_STREAM
#define WOLFSSL_SHA384
#define WOLFSSL_SHA512

#define HAVE_HKDF

#undef NO_DH
#define HAVE_FFDHE_4096

#undef NO_RSA
#define WC_RSA_PSS
#define WOLFSSL_PSS_LONG_SALT
#define WC_RSA_BLINDING

#define HAVE_ECC
#define ECC_SHAMIR
#define ECC_TIMING_RESISTANT
#define HAVE_COMP_KEY

/* Disable features */
#define NO_PSK

/* Disable Algorithms */
#define NO_DES3
#define NO_DSA
#define NO_RC4
#define NO_MD4
#define NO_MD5
#define NO_SHA

/* Math */

/* Single Precision Support for RSA/DH 1024/2048/3072 and
* ECC P-256/P-384 */
#define WOLFSSL_HAVE_SP_ECC
#define WOLFSSL_HAVE_SP_DH
#define WOLFSSL_HAVE_SP_RSA

/* Optional Performance Speedups */
#if 0
#ifdef _WIN64
/* Assembly speedups for SP math */
#define WOLFSSL_SP_X86_64_ASM

/* Support for RDSEED instruction */
#define HAVE_INTEL_RDSEED

/* AESNI on x64 */
#define WOLFSSL_AESNI

/* Intel ASM */
#define USE_INTEL_SPEEDUP
#define WOLFSSL_X86_64_BUILD

/* Old versions of MASM compiler do not recognize newer
* instructions. */
#if 0
#define NO_AVX2_SUPPORT
#define NO_MOVBE_SUPPORT
#endif
#endif
#endif

/* Debug logging */
#if 1
#define DEBUG_WOLFSSL
#else
/* #define NO_ERROR_STRINGS */
#endif

#endif /* !_WIN_CSHARP_USER_SETTINGS_H_ */
Loading

0 comments on commit 8e37de6

Please sign in to comment.