Skip to content

Commit 698ec3a

Browse files
authored
#158 remove threadpool methods (#159)
* cleaning up threadpool methods * removing threadpool tests and methods * version bump * readme update * updates with latest dlls
1 parent 40bdecb commit 698ec3a

61 files changed

Lines changed: 11 additions & 2968 deletions

File tree

Some content is hidden

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

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ The official Nuget page can be found [here](https://www.nuget.org/packages/cas-d
1111
**Note: All work is experimental and we understand some benchmarks might not be the most optimal.**
1212

1313
## Consuming Library Documentation
14-
This C# nuget package is dependent on our Rust layer that contains methods to run industry-standard cryptographic operations sequentially and the thread pool [cas-lib](https://github.com/Cryptographic-API-Services/cas-lib).
14+
This C# nuget package is dependent on our Rust layer that contains methods to run industry-standard cryptographic[cas-lib](https://github.com/Cryptographic-API-Services/cas-lib).
1515

1616
We utilize some smart people's existing work and we believe their documentation should be reviewed when possible.
1717
- [Spin Research](https://github.com/SpinResearch)

cas-dotnet-sdk-tests/AESWrapperTests.cs

Lines changed: 0 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,6 @@ public void Aes128BytesEncrypt()
2828
Assert.NotEqual(dataToEncrypt, encrypted);
2929
}
3030

31-
[Fact]
32-
public void Aes128BytesEncryptThreadpool()
33-
{
34-
byte[] nonceKey = this._aESWrapper.GenerateAESNonceThreadpool();
35-
byte[] key = this._aESWrapper.Aes128Key();
36-
byte[] dataToEncrypt = Encoding.UTF8.GetBytes("ThisisthedatathatneedstobeEncrypted#@$*(&");
37-
byte[] encrypted = this._aESWrapper.Aes128EncryptThreadpool(nonceKey, key, dataToEncrypt);
38-
Assert.NotEqual(dataToEncrypt, encrypted);
39-
}
4031

4132
[Fact]
4233
public void AesNonce()
@@ -45,27 +36,13 @@ public void AesNonce()
4536
Assert.True(nonceKey.Length == 12);
4637
}
4738

48-
[Fact]
49-
public void AesNonceThreadpool()
50-
{
51-
byte[] nonceKey = this._aESWrapper.GenerateAESNonceThreadpool();
52-
Assert.True(nonceKey.Length == 12);
53-
}
54-
5539
[Fact]
5640
public void Aes128Key()
5741
{
5842
byte[] key = this._aESWrapper.Aes128Key();
5943
Assert.NotEmpty(key);
6044
}
6145

62-
[Fact]
63-
public void Aes128KeyThreadpool()
64-
{
65-
byte[] key = this._aESWrapper.Aes128KeyThreadpool();
66-
Assert.NotEmpty(key);
67-
}
68-
6946
[Fact]
7047
public void Aes128BytesDecrypt()
7148
{
@@ -78,17 +55,6 @@ public void Aes128BytesDecrypt()
7855
Assert.Equal(dataToEncrypt, decrypted);
7956
}
8057

81-
[Fact]
82-
public void Aes128BytesDecryptThreadpool()
83-
{
84-
85-
byte[] nonceKey = this._aESWrapper.GenerateAESNonceThreadpool();
86-
byte[] key = this._aESWrapper.Aes128Key();
87-
byte[] dataToEncrypt = Encoding.ASCII.GetBytes("Thisisthedatathatne1233123123123123123edstobeEncrypted#@$*(&");
88-
byte[] encrypted = this._aESWrapper.Aes128EncryptThreadpool(nonceKey, key, dataToEncrypt);
89-
byte[] decrypted = this._aESWrapper.Aes128DecryptThreadpool(nonceKey, key, encrypted);
90-
Assert.Equal(dataToEncrypt, decrypted);
91-
}
9258

9359
[Fact]
9460
public void Aes256Key()
@@ -97,13 +63,6 @@ public void Aes256Key()
9763
Assert.NotEmpty(key);
9864
}
9965

100-
[Fact]
101-
public void Aes256KeyThreadpool()
102-
{
103-
byte[] key = this._aESWrapper.Aes256KeyThreadpool();
104-
Assert.NotEmpty(key);
105-
}
106-
10766
[Fact]
10867
public void Aes256X25519DiffieHellmanKeyAndNonce()
10968
{
@@ -118,20 +77,6 @@ public void Aes256X25519DiffieHellmanKeyAndNonce()
11877
Assert.Equal(aliceAesKeyAndNonce.AesKey, bobAesKeyAndNonce.AesKey);
11978
}
12079

121-
[Fact]
122-
public void Aes256X25519DiffieHellmanKeyAndNonceThreadpool()
123-
{
124-
X25519SecretPublicKey aliceSecretAndPublicKey = this._x25519Wrapper.GenerateSecretAndPublicKey(); // TODO: switch to threadpool implementation
125-
X25519SecretPublicKey bobSecretAndPublicKey = this._x25519Wrapper.GenerateSecretAndPublicKey(); // TODO: switch to threadpool implementation
126-
X25519SharedSecret aliceSharedSecet = this._x25519Wrapper.GenerateSharedSecret(aliceSecretAndPublicKey.SecretKey, bobSecretAndPublicKey.PublicKey);
127-
X25519SharedSecret bobSharedSecet = this._x25519Wrapper.GenerateSharedSecret(bobSecretAndPublicKey.SecretKey, aliceSecretAndPublicKey.PublicKey);
128-
Aes256KeyAndNonceX25519DiffieHellman aliceAesKeyAndNonce = this._aESWrapper.Aes256KeyNonceX25519DiffieHellmanThreadpool(aliceSharedSecet.SharedSecret);
129-
Aes256KeyAndNonceX25519DiffieHellman bobAesKeyAndNonce = this._aESWrapper.Aes256KeyNonceX25519DiffieHellmanThreadpool(bobSharedSecet.SharedSecret);
130-
131-
Assert.True(aliceAesKeyAndNonce.AesNonce.SequenceEqual(bobAesKeyAndNonce.AesNonce));
132-
Assert.Equal(aliceAesKeyAndNonce.AesKey, bobAesKeyAndNonce.AesKey);
133-
}
134-
13580
[Fact]
13681
public void Aes128X25519DiffieHellmanKeyAndNonce()
13782
{
@@ -146,20 +91,6 @@ public void Aes128X25519DiffieHellmanKeyAndNonce()
14691
Assert.Equal(aliceAesKeyAndNonce.AesKey, bobAesKeyAndNonce.AesKey);
14792
}
14893

149-
[Fact]
150-
public void Aes128X25519DiffieHellmanKeyAndNonceThreadpool()
151-
{
152-
X25519SecretPublicKey aliceSecretAndPublicKey = this._x25519Wrapper.GenerateSecretAndPublicKey(); // TODO: switch to threadpool implementation
153-
X25519SecretPublicKey bobSecretAndPublicKey = this._x25519Wrapper.GenerateSecretAndPublicKey(); // TODO: switch to threadpool implementation
154-
X25519SharedSecret aliceSharedSecet = this._x25519Wrapper.GenerateSharedSecret(aliceSecretAndPublicKey.SecretKey, bobSecretAndPublicKey.PublicKey);
155-
X25519SharedSecret bobSharedSecet = this._x25519Wrapper.GenerateSharedSecret(bobSecretAndPublicKey.SecretKey, aliceSecretAndPublicKey.PublicKey);
156-
Aes256KeyAndNonceX25519DiffieHellman aliceAesKeyAndNonce = this._aESWrapper.Aes128KeyNonceX25519DiffieHellmanThreadpool(aliceSharedSecet.SharedSecret);
157-
Aes256KeyAndNonceX25519DiffieHellman bobAesKeyAndNonce = this._aESWrapper.Aes128KeyNonceX25519DiffieHellmanThreadpool(bobSharedSecet.SharedSecret);
158-
159-
Assert.True(aliceAesKeyAndNonce.AesNonce.SequenceEqual(bobAesKeyAndNonce.AesNonce));
160-
Assert.Equal(aliceAesKeyAndNonce.AesKey, bobAesKeyAndNonce.AesKey);
161-
}
162-
16394
[Fact]
16495
public void Aes256BytesEncrypt()
16596
{
@@ -170,16 +101,6 @@ public void Aes256BytesEncrypt()
170101
Assert.NotEqual(dataToEncrypt, encrypted);
171102
}
172103

173-
[Fact]
174-
public void Aes256BytesEncryptThreadpool()
175-
{
176-
byte[] nonceKey = this._aESWrapper.GenerateAESNonceThreadpool();
177-
byte[] key = this._aESWrapper.Aes256KeyThreadpool();
178-
byte[] dataToEncrypt = Encoding.UTF8.GetBytes("ThisisthedatathatneedstobeEncrypted#@$*(&");
179-
byte[] encrypted = this._aESWrapper.Aes256EncryptThreadpool(nonceKey, key, dataToEncrypt);
180-
Assert.NotEqual(dataToEncrypt, encrypted);
181-
}
182-
183104
[Fact]
184105
public void Aes256BytesDecrypt()
185106
{
@@ -192,18 +113,6 @@ public void Aes256BytesDecrypt()
192113
Assert.NotEqual(dataToEncrypt, encrypted);
193114
}
194115

195-
[Fact]
196-
public void Aes256BytesDecryptThreadpool()
197-
{
198-
byte[] nonceKey = this._aESWrapper.GenerateAESNonceThreadpool();
199-
byte[] key = this._aESWrapper.Aes256KeyThreadpool();
200-
byte[] dataToEncrypt = Encoding.UTF8.GetBytes("ThisisthedatathatneedstobeEncrypted#@$*(&");
201-
byte[] encrypted = this._aESWrapper.Aes256EncryptThreadpool(nonceKey, key, dataToEncrypt);
202-
byte[] decrypted = this._aESWrapper.Aes256DecryptThreadpool(nonceKey, key, encrypted);
203-
Assert.Equal(dataToEncrypt, decrypted);
204-
Assert.NotEqual(dataToEncrypt, encrypted);
205-
}
206-
207116
[Fact]
208117
public void Aes256X25519DiffieHellmanEncrypt()
209118
{

cas-dotnet-sdk-tests/Argon2WrapperTests.cs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,6 @@ public void HashPassword()
2424
Assert.NotEqual(password, hash);
2525
}
2626

27-
[Fact]
28-
public void HashPasswordThreadPool()
29-
{
30-
string password = "DoNotUSETHISPASS@!";
31-
string hash = this._argon2Wrapper.HashPasswordThreadPool(password);
32-
Assert.NotEqual(password, hash);
33-
}
34-
3527
[Fact]
3628
public void Verify()
3729
{
@@ -41,14 +33,6 @@ public void Verify()
4133
Assert.True(isValid);
4234
}
4335

44-
[Fact]
45-
public void VerifyThreadpool()
46-
{
47-
string password = "TestPasswordToVerify";
48-
string hash = this._argon2Wrapper.HashPasswordThreadPool(password);
49-
bool isValid = this._argon2Wrapper.VerifyThreadPool(hash, password);
50-
Assert.True(isValid);
51-
}
5236

5337
[Fact]
5438
public void FactoryTest()

cas-dotnet-sdk-tests/AsconWrapperTests.cs

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,13 @@ public void Ascon128Key()
2121
Assert.NotEmpty(key);
2222
}
2323

24-
[Fact]
25-
public void Ascon128KeyThreadpool()
26-
{
27-
byte[] key = this._asconWrapper.Ascon128KeyThreadpool();
28-
Assert.NotEmpty(key);
29-
}
30-
3124
[Fact]
3225
public void Ascon128Nonce()
3326
{
3427
byte[] nonce = this._asconWrapper.Ascon128Nonce();
3528
Assert.NotEmpty(nonce);
3629
}
3730

38-
[Fact]
39-
public void Ascon128NonceThreadpool()
40-
{
41-
byte[] nonce = this._asconWrapper.Ascon128NonceThreadpool();
42-
Assert.NotEmpty(nonce);
43-
}
44-
4531
[Fact]
4632
public void Ascon128Encrypt()
4733
{
@@ -53,16 +39,6 @@ public void Ascon128Encrypt()
5339
}
5440

5541

56-
[Fact]
57-
public void Ascon128EncryptThreadpool()
58-
{
59-
byte[] key = this._asconWrapper.Ascon128KeyThreadpool();
60-
byte[] nonce = this._asconWrapper.Ascon128NonceThreadpool();
61-
byte[] dataToEncrypt = Encoding.UTF8.GetBytes("ChattingOnTwitchAsIWorkOnThis");
62-
byte[] encrypted = this._asconWrapper.Ascon128EncryptThreadpool(nonce, key, dataToEncrypt);
63-
Assert.True(!dataToEncrypt.SequenceEqual(encrypted));
64-
}
65-
6642
[Fact]
6743
public void Ascon128Decrypt()
6844
{
@@ -73,16 +49,5 @@ public void Ascon128Decrypt()
7349
byte[] decrypted = this._asconWrapper.Ascon128Decrypt(nonce, key, encrypted);
7450
Assert.True(decrypted.SequenceEqual(dataToEncrypt));
7551
}
76-
77-
[Fact]
78-
public void Ascon128DecryptThreadpool()
79-
{
80-
byte[] key = this._asconWrapper.Ascon128KeyThreadpool();
81-
byte[] nonce = this._asconWrapper.Ascon128NonceThreadpool();
82-
byte[] dataToEncrypt = Encoding.UTF8.GetBytes("ChattingOnTwitchAsIWorkOnThis");
83-
byte[] encrypted = this._asconWrapper.Ascon128EncryptThreadpool(nonce, key, dataToEncrypt);
84-
byte[] decrypted = this._asconWrapper.Ascon128DecryptThreadpool(nonce, key, encrypted);
85-
Assert.True(decrypted.SequenceEqual(dataToEncrypt));
86-
}
8752
}
8853
}

cas-dotnet-sdk-tests/BcryptWrapperTests.cs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,13 @@ public void HashPassword()
2121
Assert.NotEqual(hashed, this._testPassword);
2222
}
2323

24-
[Fact]
25-
public void HashPasswordThreadPool()
26-
{
27-
string hashed = this._cryptWrapper.HashPasswordThreadPool(this._testPassword);
28-
Assert.NotEqual(hashed, this._testPassword);
29-
}
30-
3124
[Fact]
3225
public async Task Verify()
3326
{
3427
string hashedPassword = this._cryptWrapper.HashPassword(this._testPassword);
3528
Assert.True(this._cryptWrapper.Verify(hashedPassword, this._testPassword));
3629
}
3730

38-
[Fact]
39-
public async Task VerifyThreadpool()
40-
{
41-
string hashedPassword = this._cryptWrapper.HashPasswordThreadPool(this._testPassword);
42-
Assert.True(this._cryptWrapper.VerifyThreadPool(hashedPassword, this._testPassword));
43-
}
44-
4531
[Fact]
4632
public void FactoryTest()
4733
{

cas-dotnet-sdk-tests/Blake2WrapperTests.cs

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,6 @@ public void Blake2512HashBytes()
2323
Assert.NotEqual(message, hash);
2424
}
2525

26-
[Fact]
27-
public void Blake2512HashBytesThreadpool()
28-
{
29-
byte[] message = Encoding.UTF8.GetBytes("MessageToHashWithBlake2");
30-
byte[] hash = this._wrapper.Hash512Threadpool(message);
31-
Assert.NotNull(hash);
32-
Assert.NotEmpty(hash);
33-
Assert.NotEqual(message, hash);
34-
}
35-
3626
[Fact]
3727
public void Blake2256HashBytes()
3828
{
@@ -43,16 +33,6 @@ public void Blake2256HashBytes()
4333
Assert.NotEqual(message, hash);
4434
}
4535

46-
[Fact]
47-
public void Blake2256HashBytesThreadpool()
48-
{
49-
byte[] message = Encoding.UTF8.GetBytes("MessageToHashWithBlake2256");
50-
byte[] hash = this._wrapper.Hash256Threadpool(message);
51-
Assert.NotNull(hash);
52-
Assert.NotEmpty(hash);
53-
Assert.NotEqual(message, hash);
54-
}
55-
5636
[Fact]
5737
public void Blake2512VerifyBytes()
5838
{
@@ -62,15 +42,6 @@ public void Blake2512VerifyBytes()
6242
Assert.True(isValid);
6343
}
6444

65-
[Fact]
66-
public void Blake2512VerifyBytesThreadpool()
67-
{
68-
byte[] toHash = Encoding.UTF8.GetBytes("BadStuffToHash");
69-
byte[] hashed = this._wrapper.Hash512Threadpool(toHash);
70-
bool isValid = this._wrapper.Verify512Threadpool(hashed, toHash);
71-
Assert.True(isValid);
72-
}
73-
7445
[Fact]
7546
public void Blake2256VerifyBytes()
7647
{
@@ -79,14 +50,5 @@ public void Blake2256VerifyBytes()
7950
bool isValid = this._wrapper.Verify256(hashed, toHash);
8051
Assert.True(isValid);
8152
}
82-
83-
[Fact]
84-
public void Blake2256VerifyBytesThreadpool()
85-
{
86-
byte[] toHash = Encoding.UTF8.GetBytes("BadStuffToHashFor256");
87-
byte[] hashed = this._wrapper.Hash256Threadpool(toHash);
88-
bool isValid = this._wrapper.Verify256Threadpool(hashed, toHash);
89-
Assert.True(isValid);
90-
}
9153
}
9254
}

0 commit comments

Comments
 (0)