< Summary

Class:Microsoft.Azure.KeyVault.Cryptography.Algorithms.AesKw128
Assembly:Microsoft.Azure.KeyVault.Cryptography
File(s):C:\Git\azure-sdk-for-net\sdk\keyvault\Microsoft.Azure.KeyVault.Cryptography\src\Algorithms\AesKw128.cs
Covered lines:8
Uncovered lines:4
Coverable lines:12
Total lines:46
Line coverage:66.6% (8 of 12)
Covered branches:4
Total branches:8
Branch coverage:50% (4 of 8)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor()-100%100%
CreateDecryptor(...)-60%50%
CreateEncryptor(...)-60%50%

File(s)

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

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License. See License.txt in the project root for
 3// license information.
 4
 5using System;
 6using System.Security.Cryptography;
 7
 8namespace Microsoft.Azure.KeyVault.Cryptography.Algorithms
 9{
 10    /// <summary>
 11    /// JWE A128KW: https://tools.ietf.org/html/rfc7518#section-4.4
 12    /// </summary>
 13    public class AesKw128 : AesKw
 14    {
 15        public const string AlgorithmName = "A128KW";
 16
 17        const int KeySizeInBytes = 128 >> 3;
 18
 19        public AesKw128()
 620            : base( AlgorithmName )
 21        {
 622        }
 23
 24        public override ICryptoTransform CreateDecryptor( byte[] key, byte[] iv )
 25        {
 826            if ( key == null )
 027                throw new ArgumentNullException( "key" );
 28
 829            if ( key.Length < KeySizeInBytes )
 030                throw new ArgumentOutOfRangeException( "key", "key must be at least 128 bits" );
 31
 832            return base.CreateDecryptor( key.Take( KeySizeInBytes ), iv );
 33        }
 34
 35        public override ICryptoTransform CreateEncryptor( byte[] key, byte[] iv )
 36        {
 837            if ( key == null )
 038                throw new ArgumentNullException( "key" );
 39
 840            if ( key.Length < KeySizeInBytes )
 041                throw new ArgumentOutOfRangeException( "key", "key must be at least 128 bits long" );
 42
 843            return base.CreateEncryptor( key.Take( KeySizeInBytes ), iv );
 44        }
 45    }
 46}