Skip to content

Commit 95bef4c

Browse files
authored
Merge pull request #9 from filipw/liboqs-0.15.0
Updated to liboqs 0.15.0
2 parents fa44562 + 9503829 commit 95bef4c

14 files changed

Lines changed: 347 additions & 73 deletions

File tree

README.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,9 @@ finally
113113

114114
## Features
115115

116-
- **Key Encapsulation Mechanisms (KEMs)**: ML-KEM, Kyber, BIKE, HQC, Classic McEliece, NTRU Prime, FrodoKEM
117-
- **Digital Signatures**: ML-DSA, Dilithium, Falcon, SPHINCS+, MAYO, CROSS, UOV
116+
- **Key Encapsulation Mechanisms (KEMs)**: ML-KEM, Kyber, BIKE, HQC, NTRU, Classic McEliece, NTRU Prime, FrodoKEM
117+
- **Digital Signatures**: ML-DSA, SLH-DSA, Falcon, SPHINCS+, MAYO, CROSS, UOV, SNOVA
118+
- **New Features**: Support for context strings in signatures and derandomized (deterministic) operations in KEM.
118119
- **Type-safe API**: Strong typing with enums for algorithms and proper resource management
119120
- **Memory management**: Automatic cleanup of native resources using IDisposable pattern
120121
- **Cross-platform**: Supports Windows x64, Windows ARM64, macOS ARM64, Linux x64, and Linux ARM64
@@ -128,19 +129,21 @@ finally
128129
- **Kyber**: Kyber512, Kyber768, Kyber1024
129130
- **BIKE**: BIKE-L1, BIKE-L3, BIKE-L5
130131
- **HQC**: HQC-128, HQC-192, HQC-256
132+
- **NTRU**: NTRU-HPS-2048-509, NTRU-HPS-2048-677, NTRU-HPS-4096-821, NTRU-HPS-4096-1229, NTRU-HRSS-701, NTRU-HRSS-1373
131133
- **Classic McEliece**: All 10 variants (e.g., 348864, 460896, 6688128, 6960119, 8192128 with fast variants)
132134
- **NTRU Prime**: sntrup761
133135
- **FrodoKEM**: FrodoKEM-640-AES, FrodoKEM-640-SHAKE, FrodoKEM-976-AES, FrodoKEM-976-SHAKE, FrodoKEM-1344-AES, FrodoKEM-1344-SHAKE
134136

135137
### Digital Signatures
136138

137139
- **ML-DSA** (NIST standardized): ML-DSA-44, ML-DSA-65, ML-DSA-87
138-
- **Dilithium**: Dilithium2, Dilithium3, Dilithium5
140+
- **SLH-DSA** (NIST standardized): All 12 pure variants (SHA2 and SHAKE, 128/192/256, fast/small)
139141
- **Falcon**: Falcon-512, Falcon-1024, Falcon-Padded-512, Falcon-Padded-1024
140142
- **SPHINCS+**: All "simple" variants (SHA2 and SHAKE, 128/192/256, fast/small)
141143
- **MAYO**: MAYO-1, MAYO-2, MAYO-3, MAYO-5
142144
- **CROSS**: All 18 variants (RSDP/RSDPG, Balanced/Fast/Small)
143145
- **UOV**: All 12 variants (Ip, Is, III, V; with pkc/skc variants)
146+
- **SNOVA**: All 12 variants
144147

145148
## Algorithm Availability
146149

@@ -229,7 +232,7 @@ git submodule update
229232
This will:
230233
- Configure and build liboqs as a shared library
231234
- Copy the resulting DLL/so/dylib to the appropriate directories
232-
- Enable all common quantum-resistant algorithms (ML-KEM, ML-DSA, Kyber, Dilithium, Falcon, FrodoKEM, BIKE, HQC, SPHINCS+, etc.)
235+
- Enable all common quantum-resistant algorithms (ML-KEM, ML-DSA, SLH-DSA, Kyber, Falcon, FrodoKEM, BIKE, HQC, SPHINCS+, NTRU, SNOVA, etc.)
233236

234237
2. **Build the .NET libraries:**
235238

@@ -252,7 +255,7 @@ git submodule update
252255

253256
### Submodule Management
254257

255-
This project uses [liboqs v0.13.0](https://github.com/Open-Quantum-Safe/liboqs/releases/tag/0.13.0) as a git submodule.
258+
This project uses [liboqs v0.15.0](https://github.com/Open-Quantum-Safe/liboqs/releases/tag/0.15.0) as a git submodule.
256259

257260
**Update to latest liboqs version:**
258261
```bash
@@ -287,6 +290,10 @@ LibOQS.NET supports the following platforms out of the box with no additional se
287290
- **Linux ARM64**
288291
- **macOS ARM64**
289292

293+
> [!NOTE]
294+
> **Platform Limitations**:
295+
> - **Windows**: `SLH-DSA` (Pure variants) are currently disabled due to a known bug in `liboqs` 0.15.0 that causes verification failures on Windows. `BIKE` is also disabled on Windows.
296+
290297
The NuGet packages include all necessary native libraries for these platforms.
291298

292299
## Troubleshooting

build-dotnet-liboqs-linux.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,12 @@ CMAKE_ARGS="$CMAKE_ARGS -DOQS_ENABLE_KEM_KYBER=ON"
4242
CMAKE_ARGS="$CMAKE_ARGS -DOQS_ENABLE_KEM_FRODOKEM=ON"
4343
CMAKE_ARGS="$CMAKE_ARGS -DOQS_ENABLE_KEM_BIKE=ON"
4444
CMAKE_ARGS="$CMAKE_ARGS -DOQS_ENABLE_KEM_HQC=ON"
45+
CMAKE_ARGS="$CMAKE_ARGS -DOQS_ENABLE_KEM_NTRU=ON"
4546
CMAKE_ARGS="$CMAKE_ARGS -DOQS_ENABLE_KEM_NTRUPRIME=ON"
4647
CMAKE_ARGS="$CMAKE_ARGS -DOQS_ENABLE_KEM_CLASSIC_MCELIECE=ON"
4748
CMAKE_ARGS="$CMAKE_ARGS -DOQS_ENABLE_SIG_ML_DSA=ON"
48-
CMAKE_ARGS="$CMAKE_ARGS -DOQS_ENABLE_SIG_DILITHIUM=ON"
49+
CMAKE_ARGS="$CMAKE_ARGS -DOQS_ENABLE_SIG_SLH_DSA=ON"
50+
CMAKE_ARGS="$CMAKE_ARGS -DOQS_ENABLE_SIG_SNOVA=ON"
4951
CMAKE_ARGS="$CMAKE_ARGS -DOQS_ENABLE_SIG_FALCON=ON"
5052
CMAKE_ARGS="$CMAKE_ARGS -DOQS_ENABLE_SIG_SPHINCS=ON"
5153
CMAKE_ARGS="$CMAKE_ARGS -DOQS_ENABLE_SIG_MAYO=ON"

build-dotnet-liboqs-macos.sh

100644100755
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,17 @@ cmake .. \
4444
-DOQS_ENABLE_KEM_FRODOKEM=ON \
4545
-DOQS_ENABLE_KEM_BIKE=ON \
4646
-DOQS_ENABLE_KEM_HQC=ON \
47+
-DOQS_ENABLE_KEM_NTRU=ON \
4748
-DOQS_ENABLE_KEM_NTRUPRIME=ON \
4849
-DOQS_ENABLE_KEM_CLASSIC_MCELIECE=ON \
4950
-DOQS_ENABLE_SIG_ML_DSA=ON \
50-
-DOQS_ENABLE_SIG_DILITHIUM=ON \
5151
-DOQS_ENABLE_SIG_FALCON=ON \
52+
-DOQS_ENABLE_SIG_SLH_DSA=ON \
5253
-DOQS_ENABLE_SIG_SPHINCS=ON \
5354
-DOQS_ENABLE_SIG_MAYO=ON \
5455
-DOQS_ENABLE_SIG_CROSS=ON \
55-
-DOQS_ENABLE_SIG_UOV=ON
56+
-DOQS_ENABLE_SIG_UOV=ON \
57+
-DOQS_ENABLE_SIG_SNOVA=ON
5658

5759
echo "Building liboqs..."
5860
cmake --build . --config "$CONFIGURATION"

build-dotnet-liboqs.ps1

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,12 @@ try {
5050
"-DOQS_ENABLE_KEM_ML_KEM=ON"
5151
"-DOQS_ENABLE_KEM_KYBER=ON"
5252
"-DOQS_ENABLE_KEM_FRODOKEM=ON"
53-
"-DOQS_ENABLE_KEM_HQC=ON"
53+
"-DOQS_ENABLE_KEM_NTRU=ON"
5454
"-DOQS_ENABLE_KEM_NTRUPRIME=ON"
5555
"-DOQS_ENABLE_KEM_CLASSIC_MCELIECE=ON"
5656
"-DOQS_ENABLE_SIG_ML_DSA=ON"
57-
"-DOQS_ENABLE_SIG_DILITHIUM=ON"
57+
"-DOQS_ENABLE_SIG_SLH_DSA=OFF"
58+
"-DOQS_ENABLE_SIG_SNOVA=ON"
5859
"-DOQS_ENABLE_SIG_FALCON=ON"
5960
"-DOQS_ENABLE_SIG_SPHINCS=ON"
6061
"-DOQS_ENABLE_SIG_MAYO=ON"

liboqs

Submodule liboqs updated 3120 files

samples/Examples/Program.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,9 @@ public static void RunAlgorithmComparison()
259259

260260
var secLevel = kemAlg switch
261261
{
262-
KemAlgorithm.MlKem512 or KemAlgorithm.Kyber512 or KemAlgorithm.BikeL1 or KemAlgorithm.Hqc128 or KemAlgorithm.ClassicMcEliece348864 => "Level 1",
263-
KemAlgorithm.MlKem768 or KemAlgorithm.Kyber768 or KemAlgorithm.BikeL3 or KemAlgorithm.Hqc192 or KemAlgorithm.NtruPrimeSntrup761 or KemAlgorithm.ClassicMcEliece460896 => "Level 3",
264-
KemAlgorithm.MlKem1024 or KemAlgorithm.Kyber1024 or KemAlgorithm.BikeL5 or KemAlgorithm.Hqc256 or KemAlgorithm.ClassicMcEliece6688128 or KemAlgorithm.ClassicMcEliece6960119 or KemAlgorithm.ClassicMcEliece8192128 => "Level 5",
262+
KemAlgorithm.MlKem512 or KemAlgorithm.Kyber512 or KemAlgorithm.BikeL1 or KemAlgorithm.Hqc128 or KemAlgorithm.ClassicMcEliece348864 or KemAlgorithm.NtruHps2048509 or KemAlgorithm.NtruHrss701 => "Level 1",
263+
KemAlgorithm.MlKem768 or KemAlgorithm.Kyber768 or KemAlgorithm.BikeL3 or KemAlgorithm.Hqc192 or KemAlgorithm.NtruPrimeSntrup761 or KemAlgorithm.ClassicMcEliece460896 or KemAlgorithm.NtruHps2048677 => "Level 3",
264+
KemAlgorithm.MlKem1024 or KemAlgorithm.Kyber1024 or KemAlgorithm.BikeL5 or KemAlgorithm.Hqc256 or KemAlgorithm.ClassicMcEliece6688128 or KemAlgorithm.ClassicMcEliece6960119 or KemAlgorithm.ClassicMcEliece8192128 or KemAlgorithm.NtruHps4096821 or KemAlgorithm.NtruHps40961229 or KemAlgorithm.NtruHrss1373 => "Level 5",
265265
_ when kemAlg.ToString().Contains("640") => "Level 1",
266266
_ when kemAlg.ToString().Contains("976") => "Level 3",
267267
_ when kemAlg.ToString().Contains("1344") => "Level 5",
@@ -297,9 +297,9 @@ _ when kemAlg.ToString().Contains("1344") => "Level 5",
297297

298298
var secLevel = sigAlg switch
299299
{
300-
SigAlgorithm.MlDsa44 or SigAlgorithm.Dilithium2 or SigAlgorithm.Falcon512 or SigAlgorithm.FalconPadded512 => "Level 1",
301-
SigAlgorithm.MlDsa65 or SigAlgorithm.Dilithium3 => "Level 3",
302-
SigAlgorithm.MlDsa87 or SigAlgorithm.Dilithium5 or SigAlgorithm.Falcon1024 or SigAlgorithm.FalconPadded1024 => "Level 5",
300+
SigAlgorithm.MlDsa44 or SigAlgorithm.Falcon512 or SigAlgorithm.FalconPadded512 or SigAlgorithm.SlhDsaSha2128sPure or SigAlgorithm.SlhDsaSha2128fPure or SigAlgorithm.SlhDsaShake128sPure or SigAlgorithm.SlhDsaShake128fPure => "Level 1",
301+
SigAlgorithm.MlDsa65 or SigAlgorithm.SlhDsaSha2192sPure or SigAlgorithm.SlhDsaSha2192fPure or SigAlgorithm.SlhDsaShake192sPure or SigAlgorithm.SlhDsaShake192fPure => "Level 3",
302+
SigAlgorithm.MlDsa87 or SigAlgorithm.Falcon1024 or SigAlgorithm.FalconPadded1024 or SigAlgorithm.SlhDsaSha2256sPure or SigAlgorithm.SlhDsaSha2256fPure or SigAlgorithm.SlhDsaShake256sPure or SigAlgorithm.SlhDsaShake256fPure => "Level 5",
303303
_ when sigAlg.ToString().Contains("128") => "Level 1",
304304
_ when sigAlg.ToString().Contains("192") => "Level 3",
305305
_ when sigAlg.ToString().Contains("256") => "Level 5",

src/LibOQS.NET.Native/Kem.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ public struct OqsKem
2121
public UIntPtr length_secret_key;
2222
public UIntPtr length_ciphertext;
2323
public UIntPtr length_shared_secret;
24+
public UIntPtr length_keypair_seed;
25+
public UIntPtr length_encaps_seed;
26+
public IntPtr keypair_derand_function;
2427
public IntPtr keypair_function;
28+
public IntPtr encaps_derand_function;
2529
public IntPtr encaps_function;
2630
public IntPtr decaps_function;
2731
}
@@ -44,12 +48,24 @@ public struct OqsKem
4448
[DllImport(Common.LibraryName, CallingConvention = CallingConvention.Cdecl)]
4549
public static extern Common.OqsStatus OQS_KEM_keypair(IntPtr kem, IntPtr public_key, IntPtr secret_key);
4650

51+
/// <summary>
52+
/// Generate a keypair with a seed (derandomized)
53+
/// </summary>
54+
[DllImport(Common.LibraryName, CallingConvention = CallingConvention.Cdecl)]
55+
public static extern Common.OqsStatus OQS_KEM_keypair_derand(IntPtr kem, IntPtr public_key, IntPtr secret_key, IntPtr seed);
56+
4757
/// <summary>
4858
/// Encapsulate
4959
/// </summary>
5060
[DllImport(Common.LibraryName, CallingConvention = CallingConvention.Cdecl)]
5161
public static extern Common.OqsStatus OQS_KEM_encaps(IntPtr kem, IntPtr ciphertext, IntPtr shared_secret, IntPtr public_key);
5262

63+
/// <summary>
64+
/// Encapsulate with a seed (derandomized)
65+
/// </summary>
66+
[DllImport(Common.LibraryName, CallingConvention = CallingConvention.Cdecl)]
67+
public static extern Common.OqsStatus OQS_KEM_encaps_derand(IntPtr kem, IntPtr ciphertext, IntPtr shared_secret, IntPtr public_key, IntPtr seed);
68+
5369
/// <summary>
5470
/// Decapsulate
5571
/// </summary>
@@ -87,6 +103,12 @@ public struct OqsKem
87103
public static readonly string OQS_KEM_alg_hqc_128 = "HQC-128";
88104
public static readonly string OQS_KEM_alg_hqc_192 = "HQC-192";
89105
public static readonly string OQS_KEM_alg_hqc_256 = "HQC-256";
106+
public static readonly string OQS_KEM_alg_ntru_hps2048509 = "NTRU-HPS-2048-509";
107+
public static readonly string OQS_KEM_alg_ntru_hps2048677 = "NTRU-HPS-2048-677";
108+
public static readonly string OQS_KEM_alg_ntru_hps4096821 = "NTRU-HPS-4096-821";
109+
public static readonly string OQS_KEM_alg_ntru_hps40961229 = "NTRU-HPS-4096-1229";
110+
public static readonly string OQS_KEM_alg_ntru_hrss701 = "NTRU-HRSS-701";
111+
public static readonly string OQS_KEM_alg_ntru_hrss1373 = "NTRU-HRSS-1373";
90112
public static readonly string OQS_KEM_alg_ntruprime_sntrup761 = "sntrup761";
91113
public static readonly string OQS_KEM_alg_classic_mceliece_348864 = "Classic-McEliece-348864";
92114
public static readonly string OQS_KEM_alg_classic_mceliece_348864f = "Classic-McEliece-348864f";

src/LibOQS.NET.Native/LibOQS.NET.Native.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<Nullable>enable</Nullable>
88
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
99
<PackageId>LibOQS.NET.Native</PackageId>
10-
<PackageVersion>0.2.0</PackageVersion>
10+
<PackageVersion>0.3.0</PackageVersion>
1111
<Authors>filipw</Authors>
1212
<Description>Native P/Invoke bindings for liboqs - a C library for quantum-resistant cryptographic algorithms</Description>
1313
<PackageProjectUrl>https://github.com/filipw/maybe-liboqs-dotnet</PackageProjectUrl>

src/LibOQS.NET.Native/Sig.cs

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,16 @@ public struct OqsSig
1717
public IntPtr alg_version;
1818
public byte claimed_nist_level;
1919
public byte euf_cma;
20+
public byte suf_cma;
21+
public byte sig_with_ctx_support;
2022
public UIntPtr length_public_key;
2123
public UIntPtr length_secret_key;
2224
public UIntPtr length_signature;
2325
public IntPtr keypair_function;
2426
public IntPtr sign_function;
27+
public IntPtr sign_with_ctx_str_function;
2528
public IntPtr verify_function;
29+
public IntPtr verify_with_ctx_str_function;
2630
}
2731

2832
/// <summary>
@@ -50,13 +54,33 @@ public struct OqsSig
5054
public static extern Common.OqsStatus OQS_SIG_sign(IntPtr sig, IntPtr signature, ref UIntPtr signature_len,
5155
IntPtr message, UIntPtr message_len, IntPtr secret_key);
5256

57+
/// <summary>
58+
/// Sign a message with a context string
59+
/// </summary>
60+
[DllImport(Common.LibraryName, CallingConvention = CallingConvention.Cdecl)]
61+
public static extern Common.OqsStatus OQS_SIG_sign_with_ctx_str(IntPtr sig, IntPtr signature, ref UIntPtr signature_len,
62+
IntPtr message, UIntPtr message_len, IntPtr ctx_str, UIntPtr ctx_str_len, IntPtr secret_key);
63+
5364
/// <summary>
5465
/// Verify a signature
5566
/// </summary>
5667
[DllImport(Common.LibraryName, CallingConvention = CallingConvention.Cdecl)]
5768
public static extern Common.OqsStatus OQS_SIG_verify(IntPtr sig, IntPtr message, UIntPtr message_len,
5869
IntPtr signature, UIntPtr signature_len, IntPtr public_key);
5970

71+
/// <summary>
72+
/// Verify a signature with a context string
73+
/// </summary>
74+
[DllImport(Common.LibraryName, CallingConvention = CallingConvention.Cdecl)]
75+
public static extern Common.OqsStatus OQS_SIG_verify_with_ctx_str(IntPtr sig, IntPtr message, UIntPtr message_len,
76+
IntPtr signature, UIntPtr signature_len, IntPtr ctx_str, UIntPtr ctx_str_len, IntPtr public_key);
77+
78+
/// <summary>
79+
/// Check if a signature algorithm supports context strings
80+
/// </summary>
81+
[DllImport(Common.LibraryName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
82+
public static extern bool OQS_SIG_supports_ctx_str([MarshalAs(UnmanagedType.LPStr)] string method_name);
83+
6084
/// <summary>
6185
/// Check if a signature algorithm is enabled
6286
/// </summary>
@@ -79,9 +103,6 @@ public static extern Common.OqsStatus OQS_SIG_verify(IntPtr sig, IntPtr message,
79103
public static readonly string OQS_SIG_alg_ml_dsa_44 = "ML-DSA-44";
80104
public static readonly string OQS_SIG_alg_ml_dsa_65 = "ML-DSA-65";
81105
public static readonly string OQS_SIG_alg_ml_dsa_87 = "ML-DSA-87";
82-
public static readonly string OQS_SIG_alg_dilithium2 = "Dilithium2";
83-
public static readonly string OQS_SIG_alg_dilithium3 = "Dilithium3";
84-
public static readonly string OQS_SIG_alg_dilithium5 = "Dilithium5";
85106
public static readonly string OQS_SIG_alg_falcon_512 = "Falcon-512";
86107
public static readonly string OQS_SIG_alg_falcon_1024 = "Falcon-1024";
87108
public static readonly string OQS_SIG_alg_falcon_padded_512 = "Falcon-padded-512";
@@ -132,4 +153,32 @@ public static extern Common.OqsStatus OQS_SIG_verify(IntPtr sig, IntPtr message,
132153
public static readonly string OQS_SIG_alg_uov_ov_Ip_pkc_skc = "OV-Ip-pkc-skc";
133154
public static readonly string OQS_SIG_alg_uov_ov_III_pkc_skc = "OV-III-pkc-skc";
134155
public static readonly string OQS_SIG_alg_uov_ov_V_pkc_skc = "OV-V-pkc-skc";
156+
157+
// SLH-DSA identifiers
158+
public static readonly string OQS_SIG_alg_slh_dsa_sha2_128s_pure = "SLH_DSA_PURE_SHA2_128S";
159+
public static readonly string OQS_SIG_alg_slh_dsa_sha2_128f_pure = "SLH_DSA_PURE_SHA2_128F";
160+
public static readonly string OQS_SIG_alg_slh_dsa_sha2_192s_pure = "SLH_DSA_PURE_SHA2_192S";
161+
public static readonly string OQS_SIG_alg_slh_dsa_sha2_192f_pure = "SLH_DSA_PURE_SHA2_192F";
162+
public static readonly string OQS_SIG_alg_slh_dsa_sha2_256s_pure = "SLH_DSA_PURE_SHA2_256S";
163+
public static readonly string OQS_SIG_alg_slh_dsa_sha2_256f_pure = "SLH_DSA_PURE_SHA2_256F";
164+
public static readonly string OQS_SIG_alg_slh_dsa_shake_128s_pure = "SLH_DSA_PURE_SHAKE_128S";
165+
public static readonly string OQS_SIG_alg_slh_dsa_shake_128f_pure = "SLH_DSA_PURE_SHAKE_128F";
166+
public static readonly string OQS_SIG_alg_slh_dsa_shake_192s_pure = "SLH_DSA_PURE_SHAKE_192S";
167+
public static readonly string OQS_SIG_alg_slh_dsa_shake_192f_pure = "SLH_DSA_PURE_SHAKE_192F";
168+
public static readonly string OQS_SIG_alg_slh_dsa_shake_256s_pure = "SLH_DSA_PURE_SHAKE_256S";
169+
public static readonly string OQS_SIG_alg_slh_dsa_shake_256f_pure = "SLH_DSA_PURE_SHAKE_256F";
170+
171+
// SNOVA identifiers
172+
public static readonly string OQS_SIG_alg_snova_24_5_4 = "SNOVA_24_5_4";
173+
public static readonly string OQS_SIG_alg_snova_24_5_4_shake = "SNOVA_24_5_4_SHAKE";
174+
public static readonly string OQS_SIG_alg_snova_24_5_4_esk = "SNOVA_24_5_4_esk";
175+
public static readonly string OQS_SIG_alg_snova_24_5_4_shake_esk = "SNOVA_24_5_4_SHAKE_esk";
176+
public static readonly string OQS_SIG_alg_snova_37_17_2 = "SNOVA_37_17_2";
177+
public static readonly string OQS_SIG_alg_snova_25_8_3 = "SNOVA_25_8_3";
178+
public static readonly string OQS_SIG_alg_snova_56_25_2 = "SNOVA_56_25_2";
179+
public static readonly string OQS_SIG_alg_snova_49_11_3 = "SNOVA_49_11_3";
180+
public static readonly string OQS_SIG_alg_snova_37_8_4 = "SNOVA_37_8_4";
181+
public static readonly string OQS_SIG_alg_snova_24_5_5 = "SNOVA_24_5_5";
182+
public static readonly string OQS_SIG_alg_snova_60_10_4 = "SNOVA_60_10_4";
183+
public static readonly string OQS_SIG_alg_snova_29_6_5 = "SNOVA_29_6_5";
135184
}

src/LibOQS.NET.Tests/KemTests.cs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ public class KemTests
1919
[InlineData(KemAlgorithm.Hqc128)]
2020
[InlineData(KemAlgorithm.Hqc192)]
2121
[InlineData(KemAlgorithm.Hqc256)]
22+
[InlineData(KemAlgorithm.NtruHps2048509)]
23+
[InlineData(KemAlgorithm.NtruHps2048677)]
24+
[InlineData(KemAlgorithm.NtruHps4096821)]
25+
[InlineData(KemAlgorithm.NtruHps40961229)]
26+
[InlineData(KemAlgorithm.NtruHrss701)]
27+
[InlineData(KemAlgorithm.NtruHrss1373)]
2228
[InlineData(KemAlgorithm.NtruPrimeSntrup761)]
2329
// [InlineData(KemAlgorithm.ClassicMcEliece348864)]
2430
// [InlineData(KemAlgorithm.ClassicMcEliece348864f)]
@@ -172,6 +178,7 @@ public void FrodoKem_ShouldSucceed(KemAlgorithm algorithm)
172178
[InlineData(KemAlgorithm.Kyber512)]
173179
[InlineData(KemAlgorithm.BikeL1)]
174180
[InlineData(KemAlgorithm.Hqc128)]
181+
[InlineData(KemAlgorithm.NtruHps2048509)]
175182
[InlineData(KemAlgorithm.NtruPrimeSntrup761)]
176183
// [InlineData(KemAlgorithm.ClassicMcEliece348864)]
177184
[InlineData(KemAlgorithm.FrodoKem640Aes)]
@@ -362,4 +369,35 @@ public void FrodoKemVariants_ShouldHaveSameSizes(KemAlgorithm aesVariant, KemAlg
362369
Assert.Equal(ssAes1, ssAes2);
363370
Assert.Equal(ssShake1, ssShake2);
364371
}
372+
[SkippableTheory]
373+
[InlineData(KemAlgorithm.MlKem512)]
374+
public void KemDerandomized_ShouldBeDeterministic(KemAlgorithm algorithm)
375+
{
376+
Skip.If(!algorithm.IsEnabled(), $"Algorithm {algorithm} is not enabled in this build.");
377+
using var kem = new KemInstance(algorithm);
378+
Skip.If(kem.KeypairSeedLength == 0, $"Algorithm {algorithm} does not support derandomized keypair.");
379+
380+
var seed = new byte[kem.KeypairSeedLength];
381+
new Random(42).NextBytes(seed);
382+
383+
// Generate keypair twice with same seed
384+
var (pk1, sk1) = kem.GenerateKeypair(seed);
385+
var (pk2, sk2) = kem.GenerateKeypair(seed);
386+
387+
Assert.Equal(pk1, pk2);
388+
Assert.Equal(sk1, sk2);
389+
390+
// Encapsulate twice with same seed
391+
if (kem.EncapsSeedLength > 0)
392+
{
393+
var encapsSeed = new byte[kem.EncapsSeedLength];
394+
new Random(123).NextBytes(encapsSeed);
395+
396+
var (ct1, ss1) = kem.Encapsulate(pk1, encapsSeed);
397+
var (ct2, ss2) = kem.Encapsulate(pk1, encapsSeed);
398+
399+
Assert.Equal(ct1, ct2);
400+
Assert.Equal(ss1, ss2);
401+
}
402+
}
365403
}

0 commit comments

Comments
 (0)