-
-
Notifications
You must be signed in to change notification settings - Fork 939
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using BenchmarkDotNet.Attributes; | ||
|
||
using Renci.SshNet.Security.Cryptography.Ciphers; | ||
using Renci.SshNet.Security.Cryptography.Ciphers.Modes; | ||
|
||
namespace Renci.SshNet.Benchmarks.Security.Cryptography.Ciphers | ||
{ | ||
[MemoryDiagnoser] | ||
public class TripleDesCipherBenchmarks | ||
{ | ||
private readonly byte[] _key; | ||
private readonly byte[] _iv; | ||
private readonly byte[] _data; | ||
|
||
public TripleDesCipherBenchmarks() | ||
{ | ||
_key = new byte[24]; | ||
_iv = new byte[8]; | ||
_data = new byte[32 * 1024]; | ||
|
||
Random random = new(Seed: 12345); | ||
random.NextBytes(_key); | ||
random.NextBytes(_iv); | ||
random.NextBytes(_data); | ||
} | ||
|
||
[Benchmark] | ||
public byte[] Encrypt_CBC() | ||
{ | ||
return new TripleDesCipher(_key, new CbcCipherMode(_iv), null).Encrypt(_data); | ||
Check failure on line 30 in test/Renci.SshNet.Benchmarks/Security/Cryptography/Ciphers/TripleDesCipherBenchmarks.cs GitHub Actions / Windows
Check failure on line 30 in test/Renci.SshNet.Benchmarks/Security/Cryptography/Ciphers/TripleDesCipherBenchmarks.cs GitHub Actions / Windows
Check failure on line 30 in test/Renci.SshNet.Benchmarks/Security/Cryptography/Ciphers/TripleDesCipherBenchmarks.cs GitHub Actions / Windows
Check failure on line 30 in test/Renci.SshNet.Benchmarks/Security/Cryptography/Ciphers/TripleDesCipherBenchmarks.cs GitHub Actions / Windows
|
||
} | ||
|
||
[Benchmark] | ||
public byte[] Decrypt_CBC() | ||
{ | ||
return new TripleDesCipher(_key, new CbcCipherMode(_iv), null).Decrypt(_data); | ||
Check failure on line 36 in test/Renci.SshNet.Benchmarks/Security/Cryptography/Ciphers/TripleDesCipherBenchmarks.cs GitHub Actions / Windows
Check failure on line 36 in test/Renci.SshNet.Benchmarks/Security/Cryptography/Ciphers/TripleDesCipherBenchmarks.cs GitHub Actions / Windows
Check failure on line 36 in test/Renci.SshNet.Benchmarks/Security/Cryptography/Ciphers/TripleDesCipherBenchmarks.cs GitHub Actions / Windows
Check failure on line 36 in test/Renci.SshNet.Benchmarks/Security/Cryptography/Ciphers/TripleDesCipherBenchmarks.cs GitHub Actions / Windows
|
||
} | ||
|
||
[Benchmark] | ||
public byte[] Encrypt_CFB() | ||
{ | ||
return new TripleDesCipher(_key, new CfbCipherMode(_iv), null).Encrypt(_data); | ||
Check failure on line 42 in test/Renci.SshNet.Benchmarks/Security/Cryptography/Ciphers/TripleDesCipherBenchmarks.cs GitHub Actions / Windows
|
||
} | ||
|
||
[Benchmark] | ||
public byte[] Decrypt_CFB() | ||
{ | ||
return new TripleDesCipher(_key, new CfbCipherMode(_iv), null).Decrypt(_data); | ||
Check failure on line 48 in test/Renci.SshNet.Benchmarks/Security/Cryptography/Ciphers/TripleDesCipherBenchmarks.cs GitHub Actions / Windows
|
||
} | ||
} | ||
} |