Skip to content

Commit 142843b

Browse files
authored
Slh dsa (#166)
* adding base classes and stuff * slh_dsa * update config
1 parent 14959be commit 142843b

42 files changed

Lines changed: 169 additions & 52 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cas-dotnet-sdk-tests/AESWrapperTests.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using CasDotnetSdk.KeyExchange;
22
using CasDotnetSdk.KeyExchange.Types;
33
using CasDotnetSdk.Symmetric;
4-
using CasDotnetSdk.Symmetric.Types;
54
using System.Text;
65
using Xunit;
76

@@ -118,7 +117,7 @@ public void Aes256X25519DiffieHellmanEncrypt()
118117
X25519SecretPublicKey bobSecretAndPublicKey = this._x25519Wrapper.GenerateSecretAndPublicKey();
119118
X25519SharedSecret aliceSharedSecet = this._x25519Wrapper.GenerateSharedSecret(aliceSecretAndPublicKey.SecretKey, bobSecretAndPublicKey.PublicKey);
120119
X25519SharedSecret bobSharedSecet = this._x25519Wrapper.GenerateSharedSecret(bobSecretAndPublicKey.SecretKey, aliceSecretAndPublicKey.PublicKey);
121-
byte[] aliceAesKey = this._aESWrapper.Aes256KeyNonceX25519DiffieHellman(aliceSharedSecet.SharedSecret);
120+
byte[] aliceAesKey = this._aESWrapper.Aes256KeyNonceX25519DiffieHellman(aliceSharedSecet.SharedSecret);
122121
byte[] bobAesKey = this._aESWrapper.Aes256KeyNonceX25519DiffieHellman(bobSharedSecet.SharedSecret);
123122

124123

cas-dotnet-sdk-tests/AsconWrapperTests.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using CasDotnetSdk.Signatures.Types;
2-
using CasDotnetSdk.Sponges;
1+
using CasDotnetSdk.Sponges;
32
using System.Text;
43
using Xunit;
54

cas-dotnet-sdk-tests/HpkeWrapperTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public void GenerateKeyPair()
2626
Assert.NotEmpty(result.InfoStr);
2727
}
2828

29-
[Fact]
29+
[Fact]
3030
public void Encrypt()
3131
{
3232
HpkeKeyPairResult keyPair = this._wrapper.GenerateKeyPair();
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using CasDotnetSdk.PQC;
2+
using Xunit;
3+
4+
namespace CasDotnetSdkTests
5+
{
6+
public class SLHDSAWrapperTests
7+
{
8+
private readonly SLHDSAWrapper _wrapper;
9+
10+
public SLHDSAWrapperTests()
11+
{
12+
this._wrapper = new SLHDSAWrapper();
13+
}
14+
15+
[Fact]
16+
public void GenerateKeyPair()
17+
{
18+
var keyPair = this._wrapper.GenerateSigningAndVerificationKey();
19+
Assert.NotNull(keyPair);
20+
Assert.NotNull(keyPair.SigningKey);
21+
Assert.NotNull(keyPair.VerificationKey);
22+
Assert.True(keyPair.SigningKey.Length > 0);
23+
Assert.True(keyPair.VerificationKey.Length > 0);
24+
}
25+
26+
[Fact]
27+
public void SignAndVerify()
28+
{
29+
var keyPair = this._wrapper.GenerateSigningAndVerificationKey();
30+
byte[] message = System.Text.Encoding.UTF8.GetBytes("This is a test message.");
31+
byte[] signature = this._wrapper.Sign(keyPair.SigningKey, message);
32+
Assert.NotNull(signature);
33+
Assert.True(signature.Length > 0);
34+
bool isValid = this._wrapper.Verify(keyPair.VerificationKey, signature, message);
35+
Assert.True(isValid);
36+
// Test with a modified message
37+
byte[] modifiedMessage = System.Text.Encoding.UTF8.GetBytes("This is a modified test message.");
38+
bool isModifiedValid = this._wrapper.Verify(keyPair.VerificationKey, signature, modifiedMessage);
39+
Assert.False(isModifiedValid);
40+
}
41+
}
42+
}

cas-dotnet-sdk/Asymmetric/Linux/RSALinuxWrapper.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using CasDotnetSdk.Asymmetric.Types;
2-
using System;
32
using System.Runtime.InteropServices;
43

54
namespace CasDotnetSdk.Asymmetric.Linux

cas-dotnet-sdk/Asymmetric/Windows/RSAWindowsWrapper.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using CasDotnetSdk.Asymmetric.Types;
2-
using System;
32
using System.Runtime.InteropServices;
43

54
namespace CasDotnetSdk.Asymmetric.Windows

cas-dotnet-sdk/CASConfiguration.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using CasDotnetSdk.Storage;
55
using CASHelpers;
66
using System;
7-
using System.Diagnostics;
87
using System.Net.Http;
98
using System.Net.Http.Json;
109
using System.Threading.Tasks;
@@ -16,7 +15,7 @@ public static class CASConfiguration
1615
static CASConfiguration()
1716
{
1817
IsDevelopment = false;
19-
Url = "https://encryptionapiservices.com";
18+
Url = "https://cryptographicapiservices.com/";
2019
TokenCache = new TokenCache();
2120
BenchmarkSenderQueue = new BenchmarkSenderRetryQueue();
2221
Networking = new Networking();

cas-dotnet-sdk/Configuration/DiffieHellmanExchange.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using CasDotnetSdk.KeyExchange;
22
using CasDotnetSdk.KeyExchange.Types;
33
using CasDotnetSdk.Symmetric;
4-
using CasDotnetSdk.Symmetric.Types;
54
using CASHelpers;
65
using CASHelpers.Types.HttpResponses.UserAuthentication;
76
using System.Net.Http;

cas-dotnet-sdk/DigitalSignature/Linux/DigitalSignatureLinuxWrapper.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using CasDotnetSdk.DigitalSignature.Types;
2-
using System;
32
using System.Runtime.InteropServices;
43

54
namespace CasDotnetSdk.DigitalSignature.Linux

cas-dotnet-sdk/DigitalSignature/SHA512DigitalSignatureWrapper.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using CasDotnetSdk.DigitalSignature.Types;
33
using CasDotnetSdk.DigitalSignature.Windows;
44
using CasDotnetSdk.Helpers;
5-
using CasDotnetSdk.Http;
65
using CASHelpers;
76
using CASHelpers.Types.HttpResponses.BenchmarkAPI;
87
using System;
@@ -36,8 +35,8 @@ public SHAED25519DalekDigitialSignatureResult CreateED25519(byte[] dataToSign)
3635
}
3736

3837
DateTime start = DateTime.UtcNow;
39-
SHAED25519DalekStructDigitalSignatureResult signatureResult = (this._platform == OSPlatform.Linux) ?
40-
DigitalSignatureLinuxWrapper.sha512_ed25519_digital_signature(dataToSign, dataToSign.Length) :
38+
SHAED25519DalekStructDigitalSignatureResult signatureResult = (this._platform == OSPlatform.Linux) ?
39+
DigitalSignatureLinuxWrapper.sha512_ed25519_digital_signature(dataToSign, dataToSign.Length) :
4140
DigitalSignatureWindowsWrapper.sha512_ed25519_digital_signature(dataToSign, dataToSign.Length);
4241
byte[] publicKey = new byte[signatureResult.public_key_length];
4342
Marshal.Copy(signatureResult.public_key, publicKey, 0, signatureResult.public_key_length);
@@ -73,8 +72,8 @@ public SHARSADigitalSignatureResult CreateRsa(int rsaKeySize, byte[] dataToSign)
7372
}
7473

7574
DateTime start = DateTime.UtcNow;
76-
SHARSAStructDigitialSignatureResult result = (this._platform == OSPlatform.Linux) ?
77-
DigitalSignatureLinuxWrapper.sha_512_rsa_digital_signature(rsaKeySize, dataToSign, dataToSign.Length) :
75+
SHARSAStructDigitialSignatureResult result = (this._platform == OSPlatform.Linux) ?
76+
DigitalSignatureLinuxWrapper.sha_512_rsa_digital_signature(rsaKeySize, dataToSign, dataToSign.Length) :
7877
DigitalSignatureWindowsWrapper.sha_512_rsa_digital_signature(rsaKeySize, dataToSign, dataToSign.Length);
7978
string publicKey = Marshal.PtrToStringAnsi(result.public_key);
8079
string privateKey = Marshal.PtrToStringAnsi(result.private_key);
@@ -119,8 +118,8 @@ public bool VerifyED25519(byte[] publicKey, byte[] dataToVerify, byte[] signatur
119118
}
120119

121120
DateTime start = DateTime.UtcNow;
122-
bool result = (this._platform == OSPlatform.Linux) ?
123-
DigitalSignatureLinuxWrapper.sha512_ed25519_digital_signature_verify(publicKey, publicKey.Length, dataToVerify, dataToVerify.Length, signature, signature.Length) :
121+
bool result = (this._platform == OSPlatform.Linux) ?
122+
DigitalSignatureLinuxWrapper.sha512_ed25519_digital_signature_verify(publicKey, publicKey.Length, dataToVerify, dataToVerify.Length, signature, signature.Length) :
124123
DigitalSignatureWindowsWrapper.sha512_ed25519_digital_signature_verify(publicKey, publicKey.Length, dataToVerify, dataToVerify.Length, signature, signature.Length);
125124
DateTime end = DateTime.UtcNow;
126125
this._sender.SendNewBenchmarkMethod(MethodBase.GetCurrentMethod().Name, start, end, BenchmarkMethodType.DigitalSignature, nameof(SHA512DigitalSignatureWrapper));

0 commit comments

Comments
 (0)