< Summary

Information
Class: Renci.SshNet.Security.Cryptography.ED25519DigitalSignature
Assembly: Renci.SshNet
File(s): \home\appveyor\projects\ssh-net\src\Renci.SshNet\Security\Cryptography\ED25519DigitalSignature.cs
Line coverage
62%
Covered lines: 18
Uncovered lines: 11
Coverable lines: 29
Total lines: 91
Line coverage: 62%
Branch coverage
50%
Covered branches: 3
Total branches: 6
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
.ctor(...)50%271.42%
Verify(...)100%1100%
Sign(...)100%1100%
Dispose()100%10%
Dispose(...)50%444.44%
Finalize()100%1100%

File(s)

\home\appveyor\projects\ssh-net\src\Renci.SshNet\Security\Cryptography\ED25519DigitalSignature.cs

#LineLine coverage
 1using System;
 2using Renci.SshNet.Common;
 3using Renci.SshNet.Security.Chaos.NaCl;
 4
 5namespace Renci.SshNet.Security.Cryptography
 6{
 7    /// <summary>
 8    /// Implements ECDSA digital signature algorithm.
 9    /// </summary>
 10    public class ED25519DigitalSignature : DigitalSignature, IDisposable
 11    {
 12        private readonly ED25519Key _key;
 13        private bool _isDisposed;
 14
 15        /// <summary>
 16        /// Initializes a new instance of the <see cref="ED25519DigitalSignature" /> class.
 17        /// </summary>
 18        /// <param name="key">The ED25519Key key.</param>
 19        /// <exception cref="ArgumentNullException"><paramref name="key"/> is <see langword="null"/>.</exception>
 1020        public ED25519DigitalSignature(ED25519Key key)
 1021        {
 1022            if (key is null)
 023            {
 024                throw new ArgumentNullException(nameof(key));
 25            }
 26
 1027            _key = key;
 1028        }
 29
 30        /// <summary>
 31        /// Verifies the signature.
 32        /// </summary>
 33        /// <param name="input">The input.</param>
 34        /// <param name="signature">The signature.</param>
 35        /// <returns>
 36        /// <see langword="true"/> if signature was successfully verified; otherwise <see langword="false"/>.
 37        /// </returns>
 38        /// <exception cref="InvalidOperationException">Invalid signature.</exception>
 39        public override bool Verify(byte[] input, byte[] signature)
 340        {
 341            return Ed25519.Verify(signature, input, _key.PublicKey);
 342        }
 43
 44        /// <summary>
 45        /// Creates the signature.
 46        /// </summary>
 47        /// <param name="input">The input.</param>
 48        /// <returns>
 49        /// Signed input data.
 50        /// </returns>
 51        /// <exception cref="SshException">Invalid ED25519Key key.</exception>
 52        public override byte[] Sign(byte[] input)
 153        {
 154            return Ed25519.Sign(input, _key.PrivateKey);
 155        }
 56
 57        /// <summary>
 58        /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
 59        /// </summary>
 60        public void Dispose()
 061        {
 062            Dispose(disposing: true);
 063            GC.SuppressFinalize(this);
 064        }
 65
 66        /// <summary>
 67        /// Releases unmanaged and - optionally - managed resources.
 68        /// </summary>
 69        /// <param name="disposing"><see langword="true"/> to release both managed and unmanaged resources; <see langwor
 70        protected virtual void Dispose(bool disposing)
 1071        {
 1072            if (_isDisposed)
 073            {
 074                return;
 75            }
 76
 1077            if (disposing)
 078            {
 079                _isDisposed = true;
 080            }
 1081        }
 82
 83        /// <summary>
 84        /// Finalizes an instance of the <see cref="ED25519DigitalSignature"/> class.
 85        /// </summary>
 86        ~ED25519DigitalSignature()
 2087        {
 1088            Dispose(disposing: false);
 2089        }
 90    }
 91}