Skip to content

Commit 43389b2

Browse files
authored
Merge pull request #8621 from dgarske/dotnet35
Fixes for building with .NET 3.5
2 parents 6d3673a + 42644a5 commit 43389b2

9 files changed

Lines changed: 832 additions & 69 deletions

File tree

.wolfssl_known_macro_extras

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,7 @@ USE_STSAFE_VERBOSE
518518
USE_TLSV13
519519
USE_WOLF_STRNSTR
520520
USS_API
521+
WindowsCE
521522
WC_AESXTS_STREAM_NO_REQUEST_ACCOUNTING
522523
WC_AES_BS_WORD_SIZE
523524
WC_AES_GCM_DEC_AUTH_EARLY

configure.ac

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4321,7 +4321,8 @@ fi
43214321

43224322
if test "$ENABLED_ECC" != "no"
43234323
then
4324-
AM_CFLAGS="$AM_CFLAGS -DHAVE_ECC -DTFM_ECC256"
4324+
AM_CFLAGS="$AM_CFLAGS -DHAVE_ECC"
4325+
43254326
if test "$ENABLED_ECC_SHAMIR" = "yes" && test "$ENABLED_LOWRESOURCE" = "no"
43264327
then
43274328
AM_CFLAGS="$AM_CFLAGS -DECC_SHAMIR"
@@ -4332,9 +4333,14 @@ then
43324333
AM_CFLAGS="$AM_CFLAGS -DWC_ECC_NONBLOCK"
43334334
fi
43344335

4335-
if test "$ENABLED_LOWRESOURCE" = "yes" && test "$ENABLED_FASTMATH" = "yes"
4336+
if test "$ENABLED_FASTMATH" = "yes"
43364337
then
4337-
AM_CFLAGS="$AM_CFLAGS -DALT_ECC_SIZE"
4338+
if test "$ENABLED_LOWRESOURCE" = "yes"
4339+
then
4340+
AM_CFLAGS="$AM_CFLAGS -DALT_ECC_SIZE"
4341+
else
4342+
AM_CFLAGS="$AM_CFLAGS -DTFM_ECC256"
4343+
fi
43384344
fi
43394345

43404346
ENABLED_CERTS=yes

wolfssl/wolfcrypt/curve25519.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ curve25519_key* wc_curve25519_new(void* heap, int devId, int *result_code);
166166
WOLFSSL_API
167167
int wc_curve25519_delete(curve25519_key* key, curve25519_key** key_p);
168168
#endif
169-
WOLFSSL_API
170169

171170
/* raw key helpers */
172171
WOLFSSL_API

wolfssl/wolfcrypt/ed25519.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,6 @@ ed25519_key* wc_ed25519_new(void* heap, int devId, int *result_code);
187187
WOLFSSL_API
188188
int wc_ed25519_delete(ed25519_key* key, ed25519_key** key_p);
189189
#endif
190-
WOLFSSL_API
191190

192191
#ifdef HAVE_ED25519_KEY_IMPORT
193192
WOLFSSL_API

wolfssl/wolfcrypt/logging.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ WOLFSSL_API void wolfSSL_SetLoggingPrefix(const char* prefix);
174174
#define WOLFSSL_STUB(m) \
175175
WOLFSSL_MSG(WOLFSSL_LOG_CAT(wolfSSL Stub, m, not implemented))
176176
WOLFSSL_API int WOLFSSL_IS_DEBUG_ON(void);
177-
#if defined(XVSNPRINTF)
177+
#if defined(XVSNPRINTF) && !defined(NO_WOLFSSL_MSG_EX)
178178
WOLFSSL_API void WOLFSSL_MSG_EX(const char* fmt, ...);
179179
#define HAVE_WOLFSSL_MSG_EX
180180
#else

wrapper/CSharp/wolfCrypt-Test/wolfCrypt-Test.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ private static void curve25519_test()
548548
IntPtr keyB = IntPtr.Zero;
549549
IntPtr publicKeyA = IntPtr.Zero;
550550
IntPtr publicKeyB = IntPtr.Zero;
551-
byte[] derKey;
551+
byte[] rawPub, rawPrivate, derKey;
552552

553553
Console.WriteLine("\nStarting Curve25519 shared secret test...");
554554

@@ -569,6 +569,14 @@ private static void curve25519_test()
569569
}
570570
Console.WriteLine("Curve25519 Key generation test passed.");
571571

572+
573+
/* Export Public Key A private and public to raw format */
574+
wolfcrypt.Curve25519ExportKeyRaw(keyA, out rawPrivate, out rawPub);
575+
/* Export Public Key B public to raw format */
576+
rawPub = wolfcrypt.Curve25519ExportPublicKey(keyB);
577+
/* rawPub / rawPrivate - not used */
578+
579+
572580
/* Export Public Key B to DER format */
573581
Console.WriteLine("Exporting Public Key B to DER format...");
574582
ret = wolfcrypt.Curve25519ExportPublicKeyToDer(keyB, out derKey, true);

wrapper/CSharp/wolfSSL_CSharp/X509.cs

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,25 @@
1-
using System;
1+
/* X509.cs
2+
*
3+
* Copyright (C) 2006-2025 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+
using System;
223
using System.Runtime.InteropServices;
324
using System.Text;
425
using System.Threading;
@@ -9,6 +30,23 @@ public class X509
930
{
1031
private const string wolfssl_dll = "wolfssl.dll";
1132

33+
#if WindowsCE
34+
[DllImport(wolfssl_dll)]
35+
private extern static int wolfSSL_X509_get_pubkey_buffer(IntPtr x509, IntPtr buf, IntPtr bufSz);
36+
[DllImport(wolfssl_dll)]
37+
private extern static IntPtr wolfSSL_X509_get_der(IntPtr x509, IntPtr bufSz);
38+
[DllImport(wolfssl_dll)]
39+
private extern static void wolfSSL_X509_free(IntPtr x509);
40+
[DllImport(wolfssl_dll)]
41+
private extern static int wc_DerToPem(IntPtr der, int derSz, IntPtr pem, int pemSz, int type);
42+
43+
[DllImport(wolfssl_dll)]
44+
private extern static IntPtr wolfSSL_X509_get_name_oneline(IntPtr x509Name, IntPtr buf, int bufSz);
45+
[DllImport(wolfssl_dll)]
46+
private extern static IntPtr wolfSSL_X509_get_subject_name(IntPtr x509);
47+
[DllImport(wolfssl_dll)]
48+
private extern static IntPtr wolfSSL_X509_get_issuer_name(IntPtr x509);
49+
#else
1250
[DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
1351
private extern static int wolfSSL_X509_get_pubkey_buffer(IntPtr x509, IntPtr buf, IntPtr bufSz);
1452
[DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
@@ -25,6 +63,7 @@ public class X509
2563
private extern static IntPtr wolfSSL_X509_get_subject_name(IntPtr x509);
2664
[DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
2765
private extern static IntPtr wolfSSL_X509_get_issuer_name(IntPtr x509);
66+
#endif
2867

2968
private IntPtr x509;
3069
private int type;
@@ -51,11 +90,12 @@ public X509(IntPtr x509, bool isDynamic)
5190
this.x509 = x509;
5291
ret = wolfSSL_X509_get_name_oneline(
5392
wolfSSL_X509_get_issuer_name(this.x509), IntPtr.Zero, 0);
54-
this.Issuer = Marshal.PtrToStringAnsi(ret);
93+
this.Issuer = wolfssl.PtrToStringAnsi(ret);
5594

5695
ret = wolfSSL_X509_get_name_oneline(
5796
wolfSSL_X509_get_subject_name(this.x509), IntPtr.Zero, 0);
58-
this.Subject = Marshal.PtrToStringAnsi(ret);
97+
this.Subject = wolfssl.PtrToStringAnsi(ret);
98+
5999
this.isDynamic = isDynamic;
60100
}
61101

0 commit comments

Comments
 (0)