< Summary

Class:Microsoft.Azure.KeyVault.Cryptography.Algorithms.EcdsaSignatureTransform
Assembly:Microsoft.Azure.KeyVault.Cryptography
File(s):C:\Git\azure-sdk-for-net\sdk\keyvault\Microsoft.Azure.KeyVault.Cryptography\src\Algorithms\Ecdsa.cs
Covered lines:5
Uncovered lines:0
Coverable lines:5
Total lines:59
Line coverage:100% (5 of 5)
Covered branches:0
Total branches:0

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-100%100%
Sign(...)-100%100%
Verify(...)-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\keyvault\Microsoft.Azure.KeyVault.Cryptography\src\Algorithms\Ecdsa.cs

#LineLine coverage
 1//
 2// Copyright (c) Microsoft Corporation. All rights reserved.
 3// Licensed under the MIT License. See License.txt in the project root for
 4// license information.
 5//
 6
 7using System;
 8using System.Security.Cryptography;
 9
 10namespace Microsoft.Azure.KeyVault.Cryptography.Algorithms
 11{
 12    /// <summary>
 13    /// Abstract Elliptic Curve Digital Signature Algorithm (ECDSA).
 14    /// </summary>
 15    public abstract class Ecdsa : AsymmetricSignatureAlgorithm
 16    {
 17        protected Ecdsa( string name ) : base( name )
 18        {
 19        }
 20
 21        protected static ISignatureTransform CreateSignatureTransform( AsymmetricAlgorithm key, string algorithmName )
 22        {
 23            if ( key == null )
 24                throw new ArgumentNullException( nameof( key ) );
 25
 26            var ecdsa = key as ECDsa;
 27            if ( ecdsa == null )
 28                throw new ArgumentException( "Invalid key type." );
 29
 30#if FullNetFx
 31            if ( ecdsa.SignatureAlgorithm != algorithmName )
 32                throw new ArgumentException( $"Invalid key algorithm. Expected {algorithmName}, found {ecdsa.SignatureAl
 33#endif
 34
 35            return new EcdsaSignatureTransform( ecdsa );
 36        }
 37    }
 38
 39    internal sealed class EcdsaSignatureTransform : ISignatureTransform
 40    {
 41        private readonly ECDsa _key;
 42
 6443        public EcdsaSignatureTransform(ECDsa key)
 44        {
 6445            _key = key;
 6446        }
 47
 48        public byte[] Sign(byte[] digest)
 49        {
 1650            return _key.SignHash(digest);
 51        }
 52
 53        public bool Verify(byte[] digest, byte[] signature)
 54        {
 4855            return _key.VerifyHash(digest, signature);
 56        }
 57    }
 58
 59}

Methods/Properties

.ctor(...)
Sign(...)
Verify(...)