Skip to content

Commit

Permalink
Add TripleDesCipherBenchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
scott-xu committed Dec 1, 2024
1 parent aebbc3c commit 86d5fed
Showing 1 changed file with 51 additions and 0 deletions.
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

View workflow job for this annotation

GitHub Actions / Windows

The type or namespace name 'CbcCipherMode' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 30 in test/Renci.SshNet.Benchmarks/Security/Cryptography/Ciphers/TripleDesCipherBenchmarks.cs

View workflow job for this annotation

GitHub Actions / Windows

There is no argument given that corresponds to the required parameter 'pkcs7Padding' of 'TripleDesCipher.TripleDesCipher(byte[], byte[], BlockCipherMode, bool)'

Check failure on line 30 in test/Renci.SshNet.Benchmarks/Security/Cryptography/Ciphers/TripleDesCipherBenchmarks.cs

View workflow job for this annotation

GitHub Actions / Windows

The type or namespace name 'CbcCipherMode' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 30 in test/Renci.SshNet.Benchmarks/Security/Cryptography/Ciphers/TripleDesCipherBenchmarks.cs

View workflow job for this annotation

GitHub Actions / Windows

There is no argument given that corresponds to the required parameter 'pkcs7Padding' of 'TripleDesCipher.TripleDesCipher(byte[], byte[], BlockCipherMode, bool)'
}

[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

View workflow job for this annotation

GitHub Actions / Windows

The type or namespace name 'CbcCipherMode' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 36 in test/Renci.SshNet.Benchmarks/Security/Cryptography/Ciphers/TripleDesCipherBenchmarks.cs

View workflow job for this annotation

GitHub Actions / Windows

There is no argument given that corresponds to the required parameter 'pkcs7Padding' of 'TripleDesCipher.TripleDesCipher(byte[], byte[], BlockCipherMode, bool)'

Check failure on line 36 in test/Renci.SshNet.Benchmarks/Security/Cryptography/Ciphers/TripleDesCipherBenchmarks.cs

View workflow job for this annotation

GitHub Actions / Windows

The type or namespace name 'CbcCipherMode' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 36 in test/Renci.SshNet.Benchmarks/Security/Cryptography/Ciphers/TripleDesCipherBenchmarks.cs

View workflow job for this annotation

GitHub Actions / Windows

There is no argument given that corresponds to the required parameter 'pkcs7Padding' of 'TripleDesCipher.TripleDesCipher(byte[], byte[], BlockCipherMode, bool)'
}

[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

View workflow job for this annotation

GitHub Actions / Windows

There is no argument given that corresponds to the required parameter 'pkcs7Padding' of 'TripleDesCipher.TripleDesCipher(byte[], byte[], BlockCipherMode, bool)'
}

[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

View workflow job for this annotation

GitHub Actions / Windows

There is no argument given that corresponds to the required parameter 'pkcs7Padding' of 'TripleDesCipher.TripleDesCipher(byte[], byte[], BlockCipherMode, bool)'
}
}
}

0 comments on commit 86d5fed

Please sign in to comment.