| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- using BenchmarkDotNet.Attributes;
- using Renci.SshNet.Benchmarks.Security.Cryptography.Ciphers;
- using Renci.SshNet.Common;
- using Renci.SshNet.Security;
- namespace Renci.SshNet.Benchmarks.Common
- {
- [MemoryDiagnoser]
- [ShortRunJob]
- public class HostKeyEventArgsBenchmarks
- {
- private readonly KeyHostAlgorithm _keyHostAlgorithm;
- public HostKeyEventArgsBenchmarks()
- {
- _keyHostAlgorithm = GetKeyHostAlgorithm();
- }
- private static KeyHostAlgorithm GetKeyHostAlgorithm()
- {
- using (var s = typeof(RsaCipherBenchmarks).Assembly.GetManifestResourceStream("Renci.SshNet.Benchmarks.Data.Key.RSA.txt"))
- {
- var privateKey = new PrivateKeyFile(s);
- return (KeyHostAlgorithm) privateKey.HostKeyAlgorithms.First();
- }
- }
- [Benchmark()]
- public HostKeyEventArgs Constructor()
- {
- return new HostKeyEventArgs(_keyHostAlgorithm);
- }
- [Benchmark()]
- public (string, string) CalculateFingerPrintSHA256AndMD5()
- {
- var test = new HostKeyEventArgs(_keyHostAlgorithm);
- return (test.FingerPrintSHA256, test.FingerPrintMD5);
- }
- [Benchmark()]
- public string CalculateFingerPrintSHA256()
- {
- var test = new HostKeyEventArgs(_keyHostAlgorithm);
- return test.FingerPrintSHA256;
- }
- [Benchmark()]
- public byte[] CalculateFingerPrint()
- {
- var test = new HostKeyEventArgs(_keyHostAlgorithm);
- return test.FingerPrint;
- }
- [Benchmark()]
- public string CalculateFingerPrintMD5()
- {
- var test = new HostKeyEventArgs(_keyHostAlgorithm);
- return test.FingerPrintSHA256;
- }
- }
- }
|