diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Core/Microsoft.Azure.KeyVault.Core.csproj b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Core/Microsoft.Azure.KeyVault.Core.csproj index 5349103f9186..ffa8527fec35 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Core/Microsoft.Azure.KeyVault.Core.csproj +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Core/Microsoft.Azure.KeyVault.Core.csproj @@ -5,8 +5,8 @@ Microsoft Azure Key Vault Core Class Library Microsoft Azure Key Vault Core Microsoft.Azure.KeyVault.Core - 2.0.4 - Microsoft Azure key vault core + 2.0.5 + Microsoft Azure Key Vault Core net452;netstandard1.4 diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Core/Properties/AssemblyInfo.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Core/Properties/AssemblyInfo.cs index 27f4baaf1a83..75ab762d857a 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Core/Properties/AssemblyInfo.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Core/Properties/AssemblyInfo.cs @@ -5,7 +5,7 @@ using System.Reflection; -[assembly: AssemblyTitle("Microsoft Azure key vault core")] +[assembly: AssemblyTitle("Microsoft Azure Key Vault Core")] [assembly: AssemblyDescription("Microsoft Azure Key Vault Core Class Library")] [assembly: AssemblyVersion("2.0.0.0")] diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Cryptography.Tests/Tests/Cryptography/Algorithms/EcKeyTests.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Cryptography.Tests/Tests/Cryptography/Algorithms/EcKeyTests.cs new file mode 100644 index 000000000000..bbd5d62bf482 --- /dev/null +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Cryptography.Tests/Tests/Cryptography/Algorithms/EcKeyTests.cs @@ -0,0 +1,137 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. + +using System; +using Microsoft.Azure.KeyVault.WebKey; +using Newtonsoft.Json; +using Xunit; + +namespace Microsoft.Azure.KeyVault.Cryptography.Tests +{ + /// + /// Verify RSAKey + /// + public class EcKeyTests : IClassFixture + { + private static readonly string P256TestKey = "{\"kty\":\"EC\",\"key_ops\":[\"sign\",\"verify\"],\"crv\":\"P-256\",\"x\":\"IzSTOwCKbS-BEdPwVT0xGnW18zzgyG7CwnMDKLULyQo\",\"y\":\"K7m-pJxgWIjHGHMF5IZpWLasH6TizES9eidg--wQkSE\",\"d\":\"9hY6iHNcR-IuyacHOelfiCvjRWyfOscFVL05zJM4Ne4\"}"; + private static readonly string P384TestKey = "{\"kty\":\"EC\",\"key_ops\":[\"sign\",\"verify\"],\"crv\":\"P-384\",\"x\":\"5XN86Y1xhKo1GuohlWzcvoJmZs36USIFopOU1wha6qbtZzM2C1OK01lh8DJYwQsi\",\"y\":\"ZsI5YcBKzo-0d5lS3106nYPshOi9LcCecNJebIina6fw7Ab7TD3f3fhNxEaAE6ja\",\"d\":\"6g0maM_o7vcYWJzPMwqE3l0v2vsyjWtOsvRyAch44aZLg9IGaVEUu6Ol718ICyWX\"}"; + private static readonly string P521TestKey = "{\"kty\":\"EC\",\"key_ops\":[\"sign\",\"verify\"],\"crv\":\"P-521\",\"x\":\"ASggRFEA2L_FxGjnU5FNplPHBi8tU0e2L89ZWro4ZpDYvBvel0gjao_S23fuNFlhufLp5kePdGbqujy45wHKMjMR\",\"y\":\"AFDVBsQZN2V1lox2kMCmqWL5Kn4f3X0mtqnBLWgPlOSl6l-tMDHj8gcLnMGJZNarCKVGVrdjhmK9BpbYy0Q8Omnm\",\"d\":\"AJC_2pp8DO_LxfFuC7yMfd7TGD51f8ydJgHy-Tf-37NBToBjGPo6njEcrppW1QSVWTMJpjfVWJb6x24YZQ73PP04\"}"; + private static readonly string Secp256k1TestKey = "{\"kty\":\"EC\",\"key_ops\":[\"sign\",\"verify\"],\"crv\":\"SECP256K1\",\"x\":\"yBMUvQwthIjbdvYUC2DDDs6I45dqG0B1GQ3-Eg5RxXM\",\"y\":\"KGf5oIzA7QNhZ8gXP8LSQfZKSMsGrmcUphyWpD2ingg\",\"d\":\"qmWUH9HNAAYzeNrVYbtoVlrnbiRIa2jDZW5YJh7OoUs\"}"; + + [Fact] + public static void HardCodedKeysMustWork() + { + if ( !IsCngSupported() ) + return; + + DoHardCodedKeyTests( P256TestKey, EcKey.P256, 256, "ES256", 32 ); + DoHardCodedKeyTests( P384TestKey, EcKey.P384, 384, "ES384", 48 ); + DoHardCodedKeyTests( P521TestKey, EcKey.P521, 521, "ES512", 64 ); + DoHardCodedKeyTests( Secp256k1TestKey, EcKey.SECP256K1, 256, "ECDSA256", 32 ); + } + + private static void DoHardCodedKeyTests( string json, string curve, int keySize, string defaultAlgo, int digestSize ) + { + var privateKey = CreateKeyFromJwk( json, curve, defaultAlgo, true ); + var publicKey = CreateKeyFromJwk( json, curve, defaultAlgo ); + + DoSignVerifyTests( digestSize, privateKey, publicKey ); + } + + private static EcKey CreateKeyFromJwk( string json, string curve, string defaultAlgo, bool isPrivateKey = false ) + { + var jwk = JsonConvert.DeserializeObject( json ); + var kid = new Guid().ToString( "N" ); + var key = new EcKey( kid, curve, jwk.X, jwk.Y, isPrivateKey ? jwk.D : null ); + Assert.Equal( kid, key.Kid ); + Assert.Equal( defaultAlgo, key.DefaultSignatureAlgorithm ); + return key; + } + + [Fact] + public static void RandomKeysMustWork() + { + if ( !IsCngSupported() ) + return; + + DoRamdomKeyTest( EcKey.P256, 256, "ES256", 32 ); + DoRamdomKeyTest( EcKey.P384, 384, "ES384", 48 ); + DoRamdomKeyTest( EcKey.P521, 521, "ES512", 64 ); + DoRamdomKeyTest( EcKey.SECP256K1, 256, "ECDSA256", 32 ); + } + + private static void DoRamdomKeyTest( string curve, int keySize, string defaultAlgo, int digestSize ) + { + var key = CreateRandomKey( curve, defaultAlgo ); + DoSignVerifyTests( digestSize, key, null ); + } + + private static EcKey CreateRandomKey( string curve, string defaultAlgo ) + { + var kid = new Guid().ToString( "N" ); + var key = new EcKey( kid, curve ); + Assert.Equal( kid, key.Kid ); + Assert.Equal( defaultAlgo, key.DefaultSignatureAlgorithm ); + return key; + } + + private static void DoSignVerifyTests( int digestSize, EcKey privateKey, EcKey publicKey ) + { + // Create pseudo-random hash. + var rnd = new Random( 0 ); + var digest = new byte[digestSize]; + rnd.NextBytes( digest ); + + bool verified; + + // Check if private key can sign digest. + var signatureResult = privateKey.SignAsync( digest, null ).Result; + var signature = signatureResult.Item1; + var algorithm = signatureResult.Item2; + Assert.Equal( algorithm, privateKey.DefaultSignatureAlgorithm ); + + // Check if private key can verify digest. + verified = privateKey.VerifyAsync( digest, signature, algorithm ).Result; + Assert.True( verified ); + + if ( publicKey != null ) + { + // Check if public key can verify digest. + verified = publicKey.VerifyAsync( digest, signature, algorithm ).Result; + Assert.True( verified ); + } + + signature[signature.Length - 1] ^= 1; + + // Check if private key can deny invalid digest. + verified = privateKey.VerifyAsync( digest, signature, algorithm ).Result; + Assert.False( verified ); + + if ( publicKey != null ) + { + // Check if public key can deny invalid digest. + verified = publicKey.VerifyAsync( digest, signature, algorithm ).Result; + Assert.False( verified ); + } + } + + /// + /// Insures Windows CNG (NCrypt) is supported on this platform. + /// + /// For instance, CNG is not supported on Linux. + private static bool IsCngSupported() + { + try + { + var key = CreateRandomKey( EcKey.P256, "ES256" ); + key.Dispose(); + return true; + } + catch ( PlatformNotSupportedException ) + { + return false; + } + } + } +} \ No newline at end of file diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Cryptography/AlgorithmResolver.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Cryptography/AlgorithmResolver.cs index aaf05d00cb62..7affcfd88ed8 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Cryptography/AlgorithmResolver.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Cryptography/AlgorithmResolver.cs @@ -33,9 +33,14 @@ static AlgorithmResolver() Default.AddAlgorithm( Rs256.AlgorithmName, new Rs256() ); -#if NET45 +#if FullNetFx Default.AddAlgorithm( RsNull.AlgorithmName, new RsNull() ); #endif + + Default.AddAlgorithm( Es256.AlgorithmName, new Es256() ); + Default.AddAlgorithm( Es384.AlgorithmName, new Es384() ); + Default.AddAlgorithm( Es512.AlgorithmName, new Es512() ); + Default.AddAlgorithm( Ecdsa256.AlgorithmName, new Ecdsa256() ); } [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] @@ -62,10 +67,10 @@ public Algorithm this[ string algorithmName ] public void AddAlgorithm( string algorithmName, Algorithm provider ) { if ( string.IsNullOrWhiteSpace( algorithmName ) ) - throw new ArgumentNullException( "algorithmName" ); + throw new ArgumentNullException( nameof( algorithmName ) ); if ( provider == null ) - throw new ArgumentNullException( "provider" ); + throw new ArgumentNullException( nameof( provider ) ); _algorithms[algorithmName] = provider; } diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Cryptography/Algorithms/Ecdsa.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Cryptography/Algorithms/Ecdsa.cs new file mode 100644 index 000000000000..946f9b91d7bd --- /dev/null +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Cryptography/Algorithms/Ecdsa.cs @@ -0,0 +1,59 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// + +using System; +using System.Security.Cryptography; + +namespace Microsoft.Azure.KeyVault.Cryptography.Algorithms +{ + /// + /// Abstract Elliptic Curve Digital Signature Algorithm (ECDSA). + /// + public abstract class Ecdsa : AsymmetricSignatureAlgorithm + { + protected Ecdsa( string name ) : base( name ) + { + } + + protected static ISignatureTransform CreateSignatureTransform( AsymmetricAlgorithm key, string algorithmName ) + { + if ( key == null ) + throw new ArgumentNullException( nameof( key ) ); + + var ecdsa = key as ECDsa; + if ( ecdsa == null ) + throw new ArgumentException( "Invalid key type." ); + +#if FullNetFx + if ( ecdsa.SignatureAlgorithm != algorithmName ) + throw new ArgumentException( $"Invalid key algorithm. Expected {algorithmName}, found {ecdsa.SignatureAlgorithm}." ); +#endif + + return new EcdsaSignatureTransform( ecdsa ); + } + } + + internal sealed class EcdsaSignatureTransform : ISignatureTransform + { + private readonly ECDsa _key; + + public EcdsaSignatureTransform(ECDsa key) + { + _key = key; + } + + public byte[] Sign(byte[] digest) + { + return _key.SignHash(digest); + } + + public bool Verify(byte[] digest, byte[] signature) + { + return _key.VerifyHash(digest, signature); + } + } + +} diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Cryptography/Algorithms/Ecdsa256.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Cryptography/Algorithms/Ecdsa256.cs new file mode 100644 index 000000000000..de26e6939993 --- /dev/null +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Cryptography/Algorithms/Ecdsa256.cs @@ -0,0 +1,27 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// + +using System.Security.Cryptography; + +namespace Microsoft.Azure.KeyVault.Cryptography.Algorithms +{ + /// + /// Represents ECDSA with a generic 256 bit curve. + /// + public class Ecdsa256 : Ecdsa + { + public const string AlgorithmName = "ECDSA256"; + + public Ecdsa256() : base( AlgorithmName ) + { + } + + public override ISignatureTransform CreateSignatureTransform( AsymmetricAlgorithm key ) + { + return CreateSignatureTransform( key, AlgorithmName ); + } + } +} diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Cryptography/Algorithms/Es256.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Cryptography/Algorithms/Es256.cs new file mode 100644 index 000000000000..28afc8d9cd94 --- /dev/null +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Cryptography/Algorithms/Es256.cs @@ -0,0 +1,27 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// + +using System.Security.Cryptography; + +namespace Microsoft.Azure.KeyVault.Cryptography.Algorithms +{ + /// + /// Represents ECDSA with curve P-256 from NIST. + /// + public class Es256 : Ecdsa + { + public const string AlgorithmName = "ES256"; + + public Es256() : base( AlgorithmName ) + { + } + + public override ISignatureTransform CreateSignatureTransform( AsymmetricAlgorithm key ) + { + return CreateSignatureTransform( key, AlgorithmName ); + } + } +} diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Cryptography/Algorithms/Es384.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Cryptography/Algorithms/Es384.cs new file mode 100644 index 000000000000..3c363a247d18 --- /dev/null +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Cryptography/Algorithms/Es384.cs @@ -0,0 +1,27 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// + +using System.Security.Cryptography; + +namespace Microsoft.Azure.KeyVault.Cryptography.Algorithms +{ + /// + /// Represents ECDSA with curve P-384 from NIST. + /// + public class Es384 : Ecdsa + { + public const string AlgorithmName = "ES384"; + + public Es384() : base( AlgorithmName ) + { + } + + public override ISignatureTransform CreateSignatureTransform( AsymmetricAlgorithm key ) + { + return CreateSignatureTransform( key, AlgorithmName ); + } + } +} \ No newline at end of file diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Cryptography/Algorithms/Es512.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Cryptography/Algorithms/Es512.cs new file mode 100644 index 000000000000..7ac1e68bbc38 --- /dev/null +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Cryptography/Algorithms/Es512.cs @@ -0,0 +1,27 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// + +using System.Security.Cryptography; + +namespace Microsoft.Azure.KeyVault.Cryptography.Algorithms +{ + /// + /// Represents ECDSA with curve P-521 from NIST. + /// + public class Es512 : Ecdsa + { + public const string AlgorithmName = "ES512"; + + public Es512() : base( AlgorithmName ) + { + } + + public override ISignatureTransform CreateSignatureTransform( AsymmetricAlgorithm key ) + { + return CreateSignatureTransform( key, AlgorithmName ); + } + } +} diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Cryptography/Algorithms/NativeMethods.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Cryptography/Algorithms/NativeMethods.cs index 5d46ffbe1935..c470f35a886c 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Cryptography/Algorithms/NativeMethods.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Cryptography/Algorithms/NativeMethods.cs @@ -2,8 +2,6 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. -#if NET45 - using System; using System.IO; using System.Runtime.InteropServices; @@ -22,6 +20,25 @@ internal static class NativeMethods internal const int BCRYPT_RSAPRIVATE_MAGIC = 0x32415352; internal const int BCRYPT_RSAFULLPRIVATE_MAGIC = 0x33415352; + internal const int BCRYPT_ECDSA_PUBLIC_P256_MAGIC = 0x31534345; + internal const int BCRYPT_ECDSA_PRIVATE_P256_MAGIC = 0x32534345; + internal const int BCRYPT_ECDSA_PUBLIC_P384_MAGIC = 0x33534345; + internal const int BCRYPT_ECDSA_PRIVATE_P384_MAGIC = 0x34534345; + internal const int BCRYPT_ECDSA_PUBLIC_P521_MAGIC = 0x35534345; + internal const int BCRYPT_ECDSA_PRIVATE_P521_MAGIC = 0x36534345; + internal const int BCRYPT_ECDSA_PUBLIC_GENERIC_MAGIC = 0x50444345; + internal const int BCRYPT_ECDSA_PRIVATE_GENERIC_MAGIC = 0x56444345; + + internal const string BCRYPT_ECCFULLPUBLIC_BLOB = "ECCFULLPUBLICBLOB"; + internal const string BCRYPT_ECCFULLPRIVATE_BLOB = "ECCFULLPRIVATEBLOB"; + internal const string BCRYPT_ECC_PARAMETERS = "ECCParameters"; + + internal const int BCRYPT_ECC_PRIME_SHORT_WEIERSTRASS_CURVE = 0x1; + internal const int BCRYPT_ECC_PRIME_TWISTED_EDWARDS_CURVE = 0x2; + internal const int BCRYPT_ECC_PRIME_MONTGOMERY_CURVE = 0x3; + + internal const int BCRYPT_NO_CURVE_GENERATION_ALG_ID = 0x0; + [StructLayout( LayoutKind.Sequential )] internal struct NCRYPT_PKCS1_PADDING_INFO { @@ -114,5 +131,3 @@ internal static byte[] NewNCryptPrivateBlob( RSAParameters rsaParams ) } } } - -#endif \ No newline at end of file diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Cryptography/Algorithms/Rs256.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Cryptography/Algorithms/Rs256.cs index 8b193279a95b..874e73e8a7f0 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Cryptography/Algorithms/Rs256.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Cryptography/Algorithms/Rs256.cs @@ -53,7 +53,7 @@ public byte[] Sign( byte[] digest ) if ( digest.Length != 32 ) throw new ArgumentOutOfRangeException( "digest", "The digest must be 32 bytes for SHA-256" ); -#if NET45 +#if FullNetFx if ( _key is RSACryptoServiceProvider ) { return ((RSACryptoServiceProvider)_key).SignHash( digest, OID_OIWSEC_SHA256 ); @@ -79,7 +79,7 @@ public bool Verify( byte[] digest, byte[] signature ) throw new ArgumentNullException( "signature" ); -#if NET45 +#if FullNetFx if ( _key is RSACryptoServiceProvider ) { return ((RSACryptoServiceProvider)_key).VerifyHash( digest, OID_OIWSEC_SHA256, signature ); diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Cryptography/Algorithms/RsNull.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Cryptography/Algorithms/RsNull.cs index 2388ad61a2b1..4caab9f9c056 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Cryptography/Algorithms/RsNull.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Cryptography/Algorithms/RsNull.cs @@ -4,7 +4,7 @@ // license information. // -#if NET45 +#if FullNetFx using System; using System.Security.Cryptography; diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Cryptography/Algorithms/Rsa15.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Cryptography/Algorithms/Rsa15.cs index 0432048d3975..e1122dfd3b85 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Cryptography/Algorithms/Rsa15.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Cryptography/Algorithms/Rsa15.cs @@ -82,7 +82,7 @@ public byte[] TransformFinalBlock( byte[] inputBuffer, int inputOffset, int inpu { byte[] block = inputBuffer.Skip( inputOffset ).Take( inputCount ).ToArray(); -#if NET45 +#if FullNetFx if ( _csp is RSACryptoServiceProvider ) { return ( ( RSACryptoServiceProvider )_csp ).Decrypt( block, false ); @@ -147,7 +147,7 @@ public byte[] TransformFinalBlock( byte[] inputBuffer, int inputOffset, int inpu { byte[] block = inputBuffer.Skip( inputOffset ).Take( inputCount ).ToArray(); -#if NET45 +#if FullNetFx if ( _csp is RSACryptoServiceProvider ) { return ( ( RSACryptoServiceProvider )_csp ).Encrypt( block, false ); diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Cryptography/Algorithms/RsaOaep.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Cryptography/Algorithms/RsaOaep.cs index 7f6aac52e382..fddea5f2f62b 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Cryptography/Algorithms/RsaOaep.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Cryptography/Algorithms/RsaOaep.cs @@ -85,7 +85,7 @@ public byte[] TransformFinalBlock( byte[] inputBuffer, int inputOffset, int inpu { byte[] block = inputBuffer.Skip( inputOffset ).Take( inputCount ).ToArray(); -#if NET45 +#if FullNetFx if ( _csp is RSACryptoServiceProvider ) { return ( ( RSACryptoServiceProvider )_csp ).Decrypt( block, true ); @@ -150,7 +150,7 @@ public byte[] TransformFinalBlock( byte[] inputBuffer, int inputOffset, int inpu { byte[] block = inputBuffer.Skip( inputOffset ).Take( inputCount ).ToArray(); -#if NET45 +#if FullNetFx if ( _csp is RSACryptoServiceProvider ) { return ( ( RSACryptoServiceProvider )_csp ).Encrypt( block, true ); diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Cryptography/EcKey.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Cryptography/EcKey.cs new file mode 100644 index 000000000000..0b9127266e3b --- /dev/null +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Cryptography/EcKey.cs @@ -0,0 +1,649 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. + +using System; +using System.IO; +using System.Security.Cryptography; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Azure.KeyVault.Core; +using Microsoft.Azure.KeyVault.Cryptography; +using Microsoft.Azure.KeyVault.Cryptography.Algorithms; + +#if NETSTANDARD +using TaskException = System.Threading.Tasks.Task; +#endif + +namespace Microsoft.Azure.KeyVault +{ + /// + /// An elliptic curve key. + /// + public class EcKey : IKey + { + public const string P256 = "P-256"; + public const string P384 = "P-384"; + public const string P521 = "P-521"; + public const string SECP256K1 = "SECP256K1"; + + private static readonly string DefaultCurve = P256; + + private ECDsa _ecdsa; + + /// + /// Key Identifier + /// + public string Kid { get; } + + /// + /// Constructor, creates a P-256 key with a GUID identifier. + /// + public EcKey() : this( Guid.NewGuid().ToString( "D" ), DefaultCurve ) + { + } + + /// + /// Constructor, creates a P-256 key. + /// + /// The key identifier to use + public EcKey( string kid ) : this( kid, DefaultCurve ) + { + } + + /// + /// Constructor. + /// + /// The key identifier to use + /// The name of elliptic curve to use + public EcKey( string kid, string curve ) + { + if ( string.IsNullOrWhiteSpace( kid ) ) + throw new ArgumentNullException( nameof( kid ) ); + + Kid = kid; + + var kcp = new CngKeyCreationParameters(); + kcp.ExportPolicy = CngExportPolicies.AllowPlaintextExport; + kcp.KeyUsage = CngKeyUsages.Signing; + + CngAlgorithm cngAlgo; + switch ( curve ) + { + case P256: + cngAlgo = CngAlgorithm.ECDsaP256; + DefaultSignatureAlgorithm = Es256.AlgorithmName; + break; + + case P384: + cngAlgo = CngAlgorithm.ECDsaP384; + DefaultSignatureAlgorithm = Es384.AlgorithmName; + break; + + case P521: + cngAlgo = CngAlgorithm.ECDsaP521; + DefaultSignatureAlgorithm = Es512.AlgorithmName; + break; + + case SECP256K1: + cngAlgo = CngAlgorithm_Generic_ECDSA; + kcp.Parameters.Add( new CngProperty( NativeMethods.BCRYPT_ECC_PARAMETERS, Secp256k1Parameters.CurveBlob, CngPropertyOptions.None ) ); + DefaultSignatureAlgorithm = Ecdsa256.AlgorithmName; + break; + + default: + throw new ArgumentException( $"Unsupported curve: \"{curve}\"." ); + } + + var key = CngKey.Create( cngAlgo, null, kcp ); + _ecdsa = new ECDsaCng( key ); + } + + /// + /// Constructor + /// + /// The key identifier to use + /// The name of elliptic curve to use; supported values are constants described in this class. + /// The value of public point field X. + /// The value of public point field Y. + /// The value of private key D. If null, only the public key operations will be allowed. + public EcKey( string kid, string curve, byte[] x, byte[] y, byte[] d = null ) + { + if ( string.IsNullOrWhiteSpace( kid ) ) + throw new ArgumentNullException( nameof( kid ) ); + + if ( string.IsNullOrWhiteSpace( curve ) ) + throw new ArgumentNullException( nameof( curve ) ); + + if ( x == null ) + throw new ArgumentNullException( nameof( x ) ); + + if ( y == null ) + throw new ArgumentNullException( nameof( y ) ); + + Kid = kid; + + CngKey key; + + switch ( curve ) + { + case P256: + key = ImportNistKey( NativeMethods.BCRYPT_ECDSA_PRIVATE_P256_MAGIC, NativeMethods.BCRYPT_ECDSA_PUBLIC_P256_MAGIC, 32, x, y, d ); + DefaultSignatureAlgorithm = Es256.AlgorithmName; + break; + + case P384: + key = ImportNistKey( NativeMethods.BCRYPT_ECDSA_PRIVATE_P384_MAGIC, NativeMethods.BCRYPT_ECDSA_PUBLIC_P384_MAGIC, 48, x, y, d ); + DefaultSignatureAlgorithm = Es384.AlgorithmName; + break; + + case P521: + key = ImportNistKey( NativeMethods.BCRYPT_ECDSA_PRIVATE_P521_MAGIC, NativeMethods.BCRYPT_ECDSA_PUBLIC_P521_MAGIC, 66, x, y, d ); + DefaultSignatureAlgorithm = Es512.AlgorithmName; + break; + + case SECP256K1: + key = ImportGenericKey( Secp256k1Parameters, x, y, d ); + DefaultSignatureAlgorithm = Ecdsa256.AlgorithmName; + break; + + default: + throw new ArgumentException( $"Invalid curve name: \"{curve}\"", nameof( curve ) ); + } + + _ecdsa = new ECDsaCng( key ); + } + + private CngKey ImportNistKey( int privateMagic, int publicMagic, int size, byte[] x, byte[] y, byte[] d ) + { + if ( d == null || IsZero( d ) ) + return ImportNistPublicKey( publicMagic, size, x, y ); + + return ImportNistPrivateKey( privateMagic, size, x, y, d ); + } + + private CngKey ImportNistPublicKey( int magic, int sizeInBytes, byte[] x, byte[] y ) + { + // Format described by BCRYPT_ECCKEY_BLOB (BCRYPT_ECCPUBLIC_BLOB). + // https://msdn.microsoft.com/en-us/library/windows/desktop/aa375520(v=vs.85).aspx + + var keyBlob = new byte[4 + 4 + sizeInBytes + sizeInBytes]; + using ( var writer = new BinaryWriter( new MemoryStream( keyBlob ) ) ) + { + writer.Write( magic ); + writer.Write( sizeInBytes ); + AlignAndWrite( writer, x, sizeInBytes, nameof( x ) ); + AlignAndWrite( writer, y, sizeInBytes, nameof( y ) ); + } + + return CngKey.Import( keyBlob, CngKeyBlobFormat.EccPublicBlob ); + } + + private CngKey ImportNistPrivateKey( int magic, int sizeInBytes, byte[] x, byte[] y, byte[] d ) + { + // Format described by BCRYPT_ECCKEY_BLOB (BCRYPT_ECCPRIVATE_BLOB). + // https://msdn.microsoft.com/en-us/library/windows/desktop/aa375520(v=vs.85).aspx + + var keyBlob = new byte[4 + 4 + sizeInBytes + sizeInBytes + sizeInBytes]; + using ( var writer = new BinaryWriter( new MemoryStream( keyBlob ) ) ) + { + writer.Write( magic ); + writer.Write( sizeInBytes ); + AlignAndWrite( writer, x, sizeInBytes, nameof( x ) ); + AlignAndWrite( writer, y, sizeInBytes, nameof( y ) ); + AlignAndWrite( writer, d, sizeInBytes, nameof( d ) ); + } + + return CngKey.Import( keyBlob, CngKeyBlobFormat.EccPrivateBlob ); + } + + private CngKey ImportGenericKey( EcKeyCurveParameters curveParameters, byte[] x, byte[] y, byte[] d ) + { + if ( d == null || IsZero( d ) ) + return ImportGenericPublicKey( curveParameters, x, y ); + + return ImportGenericPrivateKey( curveParameters, x, y, d ); + } + + private CngKey ImportGenericPublicKey( EcKeyCurveParameters curveParameters, byte[] x, byte[] y ) + { + /* struct BCRYPT_ECCFULLKEY_BLOB + { + ULONG dwMagic; // BCRYPT_ECDSA_PUBLIC_GENERIC_MAGIC or BCRYPT_ECDSA_PRIVATE_GENERIC_MAGIC + BCRYPT_ECC_PARAMETER_HEADER curveParameters; + BYTE Qx[cbFieldLength] // X-coordinate of the public point. + BYTE Qy[cbFieldLength] // Y-coordinate of the public point. + BYTE d[cbSubgroupOrder] // Private key. Zero if only public key is required. + } + */ + + var keyBlob = new byte[curveParameters.KeyBlobSize]; + using ( var writer = new BinaryWriter( new MemoryStream( keyBlob ) ) ) + { + writer.Write( NativeMethods.BCRYPT_ECDSA_PUBLIC_GENERIC_MAGIC ); + curveParameters.WriteTo( writer ); + + var size = curveParameters.KeySizeInBytes; + AlignAndWrite( writer, x, size, nameof( x ) ); + AlignAndWrite( writer, y, size, nameof( y ) ); + } + + return CngKey.Import( keyBlob, CngKeyBlobFormat_Generic_Public ); + } + + private CngKey ImportGenericPrivateKey( EcKeyCurveParameters curveParameters, byte[] x, byte[] y, byte[] d ) + { + /* struct BCRYPT_ECCFULLKEY_BLOB + { + ULONG dwMagic; // BCRYPT_ECDSA_PUBLIC_GENERIC_MAGIC or BCRYPT_ECDSA_PRIVATE_GENERIC_MAGIC + BCRYPT_ECC_PARAMETER_HEADER curveParameters; + BYTE Qx[cbFieldLength] // X-coordinate of the public point. + BYTE Qy[cbFieldLength] // Y-coordinate of the public point. + BYTE d[cbSubgroupOrder] // Private key. Zero if only public key is required. + } + */ + + var keyBlob = new byte[curveParameters.KeyBlobSize]; + using ( var writer = new BinaryWriter( new MemoryStream( keyBlob ) ) ) + { + writer.Write( NativeMethods.BCRYPT_ECDSA_PRIVATE_GENERIC_MAGIC ); + curveParameters.WriteTo( writer ); + + var size = curveParameters.KeySizeInBytes; + AlignAndWrite( writer, x, size, nameof( x ) ); + AlignAndWrite( writer, y, size, nameof( y ) ); + AlignAndWrite( writer, d, size, nameof( d ) ); + } + + return CngKey.Import( keyBlob, CngKeyBlobFormat_Generic_Private ); + } + + /// + /// Constructor. + /// + /// The key identifier to use + /// The ECDsa object for the key + /// The ECDsa object is IDisposable, this class will hold a + /// reference to the ECDsa object but will not dispose it, the caller + /// of this constructor is responsible for the lifetime of this + /// parameter. + public EcKey( string kid, ECDsa ecdsa ) + { + if ( string.IsNullOrWhiteSpace( kid ) ) + throw new ArgumentNullException( nameof( kid ) ); + + if ( ecdsa == null ) + throw new ArgumentNullException( nameof( ecdsa ) ); + + Kid = kid; + + // NOTE: ECDsa is disposable and that may lead to runtime errors later. + _ecdsa = ecdsa; + } + + // Intentionally excluded. + //~EcKey() + //{ + // Dispose( false ); + //} + + public void Dispose() + { + Dispose( true ); + GC.SuppressFinalize( this ); + } + + protected virtual void Dispose( bool disposing ) + { + // Clean up managed resources if Dispose was called + if ( disposing ) + { + if ( _ecdsa != null ) + { + _ecdsa.Dispose(); + _ecdsa = null; + } + } + } + + #region IKey implementation + + public string DefaultEncryptionAlgorithm => null; + + public string DefaultKeyWrapAlgorithm => null; + + public string DefaultSignatureAlgorithm { get; set; } + + public Task DecryptAsync( byte[] ciphertext, byte[] iv, byte[] authenticationData = null, byte[] authenticationTag = null, string algorithm = RsaOaep.AlgorithmName, CancellationToken token = default( CancellationToken ) ) + { + throw MethodNotSupported( nameof( DecryptAsync ) ); + } + + public Task> EncryptAsync( byte[] plaintext, byte[] iv = null, byte[] authenticationData = null, string algorithm = RsaOaep.AlgorithmName, CancellationToken token = default( CancellationToken ) ) + { + throw MethodNotSupported( nameof( EncryptAsync ) ); + } + + public Task> WrapKeyAsync( byte[] key, string algorithm = RsaOaep.AlgorithmName, CancellationToken token = default( CancellationToken ) ) + { + throw MethodNotSupported( nameof( WrapKeyAsync ) ); + } + + public Task UnwrapKeyAsync( byte[] encryptedKey, string algorithm = RsaOaep.AlgorithmName, CancellationToken token = default( CancellationToken ) ) + { + throw MethodNotSupported( nameof( UnwrapKeyAsync ) ); + } + + private Exception MethodNotSupported( string methodName ) + { + throw new NotSupportedException( $"Method {methodName} cannot is not supported by EcKey {Kid}." ); + } + + public Task> SignAsync( byte[] digest, string algorithm, CancellationToken token = default( CancellationToken ) ) + { + if ( _ecdsa == null ) + throw new ObjectDisposedException( $"EcKey {Kid} is disposed" ); + + if ( algorithm == null ) + algorithm = DefaultSignatureAlgorithm; + + if ( digest == null ) + throw new ArgumentNullException( nameof( digest ) ); + + var algo = AlgorithmResolver.Default[algorithm] as AsymmetricSignatureAlgorithm; + var transform = algo?.CreateSignatureTransform( _ecdsa ); + + if ( algo == null || transform == null ) + throw new NotSupportedException( $"algorithm {algorithm} is not supported by EcKey {Kid}" ); + + try + { + var result = new Tuple( transform.Sign( digest ), algorithm ); + + return Task.FromResult( result ); + } + catch ( Exception ex ) + { + return TaskException.FromException>( ex ); + } + } + + public Task VerifyAsync( byte[] digest, byte[] signature, string algorithm, CancellationToken token = default( CancellationToken ) ) + { + if ( _ecdsa == null ) + throw new ObjectDisposedException( $"EcKey {Kid} is disposed" ); + + if ( digest == null ) + throw new ArgumentNullException( nameof( digest ) ); + + if ( signature == null ) + throw new ArgumentNullException( nameof( signature ) ); + + if ( algorithm == null ) + algorithm = DefaultSignatureAlgorithm; + + var algo = AlgorithmResolver.Default[algorithm] as AsymmetricSignatureAlgorithm; + var transform = algo?.CreateSignatureTransform( _ecdsa ); + + if ( algo == null || transform == null ) + throw new NotSupportedException( $"algorithm {algorithm} is not supported by EcKey {Kid}" ); + + try + { + var result = transform.Verify( digest, signature ); + + return Task.FromResult( result ); + } + catch ( Exception ex ) + { + return TaskException.FromException( ex ); + } + } + + #endregion + + #region Utilities + + private static bool IsZero( byte[] v ) + { + if ( v == null ) + return true; + + for ( var i = 0; i < v.Length; ++i ) + if ( v[i] != 0 ) + return false; + + return true; + } + + private static void AlignAndWrite( BinaryWriter writer, byte[] bytes, int size, string paramName ) + { + if ( bytes.Length >= size ) + { + for ( var i = 0; i < bytes.Length - size; ++i ) + if ( bytes[i] != 0 ) + throw new ArgumentException( $"Value of {paramName} is bigger than allowed for this key." ); + + writer.Write( bytes, bytes.Length - size, size ); + return; + } + + for ( var i = bytes.Length; i < size; ++i ) + writer.Write( (byte) 0 ); + writer.Write( bytes ); + } + + private static readonly CngKeyBlobFormat CngKeyBlobFormat_Generic_Public = new CngKeyBlobFormat( NativeMethods.BCRYPT_ECCFULLPUBLIC_BLOB ); + private static readonly CngKeyBlobFormat CngKeyBlobFormat_Generic_Private = new CngKeyBlobFormat( NativeMethods.BCRYPT_ECCFULLPRIVATE_BLOB ); + + private static readonly CngAlgorithm CngAlgorithm_Generic_ECDSA = new CngAlgorithm( "ECDSA" ); + + private static EcKeyCurveParameters _secp256k1Parameters; + + private static EcKeyCurveParameters Secp256k1Parameters + { + get + { + if ( _secp256k1Parameters != null ) + return _secp256k1Parameters; + + return _secp256k1Parameters = new EcKeyCurveParameters + { + // Copied from http://www.secg.org/sec2-v2.pdf and verified to match https://en.bitcoin.it/wiki/Secp256k1. + CurveType = EcKeyCurveType.PrimeShortWeierstrass, + Hash = null, + Prime = Convert.FromBase64String( "/////////////////////////////////////v///C8=" ), + A = Convert.FromBase64String( "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=" ), + B = Convert.FromBase64String( "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAc=" ), + Gx = Convert.FromBase64String( "eb5mfvncu6xVoGKVzocLBwKb/NstzijZWfKBWxb4F5g=" ), + Gy = Convert.FromBase64String( "SDradyajxGVdpPv8DhEIqP0XtEimhVQZnEfQj/sQ1Lg=" ), + Order = Convert.FromBase64String( "/////////////////////rqu3OavSKA7v9JejNA2QUE=" ), + Cofactor = Convert.FromBase64String( "AQ==" ), + Seed = Convert.FromBase64String( "" ), + }; + } + } + + #endregion + } + + internal sealed class EcKeyCurveParameters + { + public EcKeyCurveType CurveType { get; set; } + public string Hash { get; set; } + public byte[] Prime { get; set; } + public byte[] A { get; set; } + public byte[] B { get; set; } + public byte[] Gx { get; set; } + public byte[] Gy { get; set; } + public byte[] Order { get; set; } + public byte[] Cofactor { get; set; } + public byte[] Seed { get; set; } + + public int KeySizeInBytes => Prime.Length; + + public int CurveBlobSize + { + get + { + var cbFieldLength = Prime.Length; + var cbSubgroupOrder = Order.Length; + var cbCofactor = Cofactor.Length; + var cbSeed = Seed.Length; + + var size = 7 * sizeof( uint ) + 5 * cbFieldLength + cbSubgroupOrder + cbCofactor + cbSeed; + + return size; + } + } + + public byte[] CurveBlob + { + get + { + var result = new byte[CurveBlobSize]; + using ( var writer = new BinaryWriter( new MemoryStream( result ) ) ) + WriteTo( writer ); + return result; + } + } + + public int KeyBlobSize + { + get + { + var cbFieldLength = Prime.Length; + var size = sizeof( uint ) + CurveBlobSize + 3 * cbFieldLength; + return size; + } + } + + public override string ToString() + { + var sb = new StringBuilder(); + sb.AppendLine( $"new {nameof( EcKeyCurveParameters )}" ); + sb.AppendLine( "{" ); + sb.AppendLine( $" {nameof( CurveType )} = {nameof( EcKeyCurveType )}.{CurveType}," ); + var hashDesc = Hash == null ? "null" : $"\"{Hash}\""; + sb.AppendLine( $" {nameof( Hash )} = {hashDesc}," ); + sb.AppendLine( $" {nameof( Prime )} = {GetBytesDesc( Prime )}," ); + sb.AppendLine( $" {nameof( A )} = {GetBytesDesc( A )}," ); + sb.AppendLine( $" {nameof( B )} = {GetBytesDesc( B )}," ); + sb.AppendLine( $" {nameof( Gx )} = {GetBytesDesc( Gx )}," ); + sb.AppendLine( $" {nameof( Gy )} = {GetBytesDesc( Gy )}," ); + sb.AppendLine( $" {nameof( Order )} = {GetBytesDesc( Order )}," ); + sb.AppendLine( $" {nameof( Cofactor )} = {GetBytesDesc( Cofactor )}," ); + sb.AppendLine( $" {nameof( Seed )} = {GetBytesDesc( Seed )}," ); + sb.AppendLine( "}" ); + return sb.ToString(); + } + + private static string GetBytesDesc( byte[] bytes ) + { + if ( bytes == null ) + return "null"; + var base64 = Convert.ToBase64String( bytes ); + return $"Convert.FromBase64String(\"{base64}\")"; + } + + public void WriteTo( BinaryWriter writer ) + { + /* + struct BCRYPT_ECC_PARAMETER_HEADER + { + ULONG dwVersion; //Version of the structure + ECC_CURVE_TYPE_ENUM dwCurveType; //Supported curve types. + ECC_CURVE_ALG_ID_ENUM dwCurveGenerationAlgId; //For X.592 verification purposes, if we include Seed we will need to include the algorithm ID. + ULONG cbFieldLength; //Byte length of the fields P, A, B, X, Y. + ULONG cbSubgroupOrder; //Byte length of the subgroup. + ULONG cbCofactor; //Byte length of cofactor of G in E. + ULONG cbSeed; //Byte length of the seed used to generate the curve. + //P[cbFieldLength] Prime specifying the base field. + //A[cbFieldLength] Coefficient A of the equation y^2 = x^3 + A*x + B mod p + //B[cbFieldLength] Coefficient B of the equation y^2 = x^3 + A*x + B mod p + //Gx[cbFieldLength] X-coordinate of the base point. + //Gy[cbFieldLength] Y-coordinate of the base point. + //n[cbSubgroupOrder] Order of the group generated by G = (x,y) + //h[cbCofactor] Cofactor of G in E. + //S[cbSeed] Seed of the curve. + } + */ + + var cbFieldLength = Prime.Length; + var cbSubgroupOrder = Order.Length; + var cbCofactor = Cofactor.Length; + var cbSeed = Seed.Length; + + writer.Write( 1 ); // version + writer.Write( ToCurveType( CurveType ) ); + writer.Write( ToCurveGenerationAlgId( Hash ) ); + writer.Write( cbFieldLength ); + writer.Write( cbSubgroupOrder ); + writer.Write( cbCofactor ); + writer.Write( cbSeed ); + + AlignAndWrite( writer, Prime, cbFieldLength, nameof( Prime ) ); + AlignAndWrite( writer, A, cbFieldLength, nameof( A ) ); + AlignAndWrite( writer, B, cbFieldLength, nameof( B ) ); + AlignAndWrite( writer, Gx, cbFieldLength, nameof( Gx ) ); + AlignAndWrite( writer, Gy, cbFieldLength, nameof( Gy ) ); + AlignAndWrite( writer, Order, cbSubgroupOrder, nameof( Order ) ); + AlignAndWrite( writer, Cofactor, cbCofactor, nameof( Cofactor ) ); + AlignAndWrite( writer, Seed, cbSeed, nameof( Seed ) ); + } + + private static int ToCurveType( EcKeyCurveType type ) + { + switch ( type ) + { + case EcKeyCurveType.PrimeMontgomery: + return NativeMethods.BCRYPT_ECC_PRIME_MONTGOMERY_CURVE; + + case EcKeyCurveType.PrimeShortWeierstrass: + return NativeMethods.BCRYPT_ECC_PRIME_SHORT_WEIERSTRASS_CURVE; + + case EcKeyCurveType.PrimeTwistedEdwards: + return NativeMethods.BCRYPT_ECC_PRIME_TWISTED_EDWARDS_CURVE; + + default: + throw new InvalidOperationException( $"Unsupported curve type: {type}" ); + } + } + + private static int ToCurveGenerationAlgId( string hash ) + { + if ( !string.IsNullOrWhiteSpace( hash ) ) + throw new InvalidOperationException( $"Unsupported curve generation hash algorithm: {hash}" ); + return NativeMethods.BCRYPT_NO_CURVE_GENERATION_ALG_ID; + } + + private static void AlignAndWrite( BinaryWriter writer, byte[] bytes, int size, string paramName ) + { + if ( bytes.Length >= size ) + { + for ( var i = 0; i < bytes.Length - size; ++i ) + if ( bytes[i] != 0 ) + throw new ArgumentException( $"Value of {paramName} is bigger than allowed for this curve." ); + + writer.Write( bytes, bytes.Length - size, size ); + return; + } + + for ( var i = bytes.Length; i < size; ++i ) + writer.Write( (byte) 0 ); + + writer.Write( bytes ); + } + } + + internal enum EcKeyCurveType + { + Characteristic2, + Implicit, + Named, + PrimeMontgomery, + PrimeShortWeierstrass, + PrimeTwistedEdwards + } +} \ No newline at end of file diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Cryptography/IncrementalHash.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Cryptography/IncrementalHash.cs index 9fdb364106e4..54e7cf89cd54 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Cryptography/IncrementalHash.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Cryptography/IncrementalHash.cs @@ -4,7 +4,7 @@ // license information. // -#if NET45 +#if FullNetFx using System; using System.Security.Cryptography; diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Cryptography/Microsoft.Azure.KeyVault.Cryptography.csproj b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Cryptography/Microsoft.Azure.KeyVault.Cryptography.csproj index 5d533da66132..b5a1f789bfee 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Cryptography/Microsoft.Azure.KeyVault.Cryptography.csproj +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Cryptography/Microsoft.Azure.KeyVault.Cryptography.csproj @@ -4,9 +4,9 @@ Microsoft.Azure.KeyVault.Cryptography Microsoft Azure Key Vault Cryptography Class Library Microsoft Azure Key Vault Cryptography - 2.0.5 + 2.0.6 Microsoft.Azure.KeyVault.Cryptography - Microsoft Azure key vault cryptography + Microsoft Azure Key Vault Cryptography net452;netstandard1.4 @@ -40,6 +40,7 @@ + diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Cryptography/Properties/AssemblyInfo.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Cryptography/Properties/AssemblyInfo.cs index aa910e92b3a5..2a3f7c3de2cb 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Cryptography/Properties/AssemblyInfo.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Cryptography/Properties/AssemblyInfo.cs @@ -5,7 +5,7 @@ using System.Reflection; -[assembly: AssemblyTitle("Microsoft Azure key vault cryptography")] +[assembly: AssemblyTitle("Microsoft Azure Key Vault cryptography")] [assembly: AssemblyDescription("Microsoft Azure Key Vault Cryptography Class Library.")] [assembly: AssemblyVersion("2.0.0.0")] diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Cryptography/TaskExtensions.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Cryptography/TaskExtensions.cs index e7553eb9c86d..cb21a358577e 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Cryptography/TaskExtensions.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Cryptography/TaskExtensions.cs @@ -4,7 +4,7 @@ // license information. // -#if NET45 +#if FullNetFx using System; using System.Threading.Tasks; diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Extensions/Microsoft.Azure.KeyVault.Extensions.csproj b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Extensions/Microsoft.Azure.KeyVault.Extensions.csproj index de3a1ef1c3b1..495b644b22e2 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Extensions/Microsoft.Azure.KeyVault.Extensions.csproj +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Extensions/Microsoft.Azure.KeyVault.Extensions.csproj @@ -5,7 +5,7 @@ Microsoft Azure Key Vault Extensions Class Library Microsoft Azure Key Vault Extensions Microsoft.Azure.KeyVault.Extensions - 2.0.5 + 2.4.0 net452;netstandard1.4 diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Tests/KeyVaultOperationsTest.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Tests/KeyVaultOperationsTest.cs index a9c01ce8e9c1..08808c1a9928 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Tests/KeyVaultOperationsTest.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Tests/KeyVaultOperationsTest.cs @@ -300,6 +300,108 @@ public void KeyVaultWrapUnwrapRsaOaep256Test() } } + [Fact] + public void KeyVaultEcKeyCreateSignVerifyP256() + { + using (MockContext context = MockContext.Start(GetType().FullName)) + { + var curve = JsonWebKeyCurveName.P256; + var digestSize = 256; + var algorithm = JsonWebKeySignatureAlgorithm.ES256; + + TestEcKeyCreateSignVerify(curve, digestSize, algorithm); + } + } + + [Fact] + public void KeyVaultEcKeyCreateSignVerifyP384() + { + using (MockContext context = MockContext.Start(GetType().FullName)) + { + var curve = JsonWebKeyCurveName.P384; + var digestSize = 384; + var algorithm = JsonWebKeySignatureAlgorithm.ES384; + + TestEcKeyCreateSignVerify(curve, digestSize, algorithm); + } + } + + [Fact] + public void KeyVaultEcKeyCreateSignVerifyP521() + { + using (MockContext context = MockContext.Start(GetType().FullName)) + { + var curve = JsonWebKeyCurveName.P521; + var digestSize = 512; + var algorithm = JsonWebKeySignatureAlgorithm.ES512; + + TestEcKeyCreateSignVerify(curve, digestSize, algorithm); + } + } + + [Fact] + public void KeyVaultEcKeyCreateSignVerifySECP256K1() + { + using (MockContext context = MockContext.Start(GetType().FullName)) + { + var curve = JsonWebKeyCurveName.SECP256K1; + var digestSize = 256; + var algorithm = JsonWebKeySignatureAlgorithm.ECDSA256; + + TestEcKeyCreateSignVerify(curve, digestSize, algorithm); + } + } + + private void TestEcKeyCreateSignVerify(string curve, int digestSize, string algorithm) + { + var client = GetKeyVaultClient(); + + var keyParameters = new NewKeyParameters(); + + keyParameters.Kty = JsonWebKeyType.EllipticCurve; + keyParameters.CurveName = curve; + keyParameters.KeyOps = new[] { JsonWebKeyOperation.Sign, JsonWebKeyOperation.Verify }; + + // Create an EC software key. + var keyBundle = client.CreateKeyAsync(_vaultAddress, _keyName, keyParameters).Result; + + TestSignVerify(client, keyBundle, digestSize, algorithm); + } + + private static void TestSignVerify(KeyVaultClient client, KeyBundle keyBundle, int digestSize, string algorithm) + { + var key = keyBundle.Key; + var kid = key.Kid; + var ecdsa = key.ToECDsa(false); + + // Sign. + var digest = RandomBytes(digestSize / 8); + Assert.True(digest.Length * 8 == digestSize); + + var signatureResult = client.SignAsync(kid, algorithm, digest).Result; + var signature = signatureResult.Result; + Assert.Equal(kid, signatureResult.Kid); + + // Verify - positive test. + var verified = client.VerifyAsync(kid, algorithm, digest, signature).Result; + Assert.True(verified); + +#if FullNetFx + verified = ecdsa.VerifyData(digest, signature); + Assert.True(verified); +#endif + + // Verify - negative test. + signature[signature.Length - 1] ^= 1; + verified = client.VerifyAsync(kid, algorithm, digest, signature).Result; + Assert.False(verified); + +#if FullNetFx + verified = ecdsa.VerifyData(digest, signature); + Assert.False(verified); +#endif + } + [Fact] public void KeyVaultCreateGetDeleteKeyTest() { @@ -341,7 +443,7 @@ public void KeyVaultCreateGetDeleteKeyTest() catch (KeyVaultErrorException ex) { if (ex.Response.StatusCode != HttpStatusCode.NotFound || ex.Body.Error.Message != ex.Message) - throw ex; + throw; } if (_softDeleteEnabled) @@ -819,9 +921,9 @@ public void KeyVaultListKeyVersionsTest() Assert.True(recoveryLevelIsConsistent, "the 'recoveryLevel' attribute did not consistently return the expected value."); } } - #endregion +#endregion - #region Deleted Key Operations +#region Deleted Key Operations [Fact] public void KeyVaultGetDeletedKeyTest() @@ -901,7 +1003,7 @@ public void KeyVaultKeyCreateDeleteRecoverPurgeTest() catch (KeyVaultErrorException ex) { if (ex.Response.StatusCode != HttpStatusCode.NotFound || ex.Body.Error.Message != ex.Message) - throw ex; + throw; } this.fixture.WaitOnDeletedKey(client, _vaultAddress, keyName); @@ -941,7 +1043,7 @@ public void KeyVaultKeyCreateDeleteRecoverPurgeTest() catch (KeyVaultErrorException ex) { if (ex.Response.StatusCode != HttpStatusCode.NotFound || ex.Body.Error.Message != ex.Message) - throw ex; + throw; } this.fixture.WaitOnDeletedKey(client, _vaultAddress, keyName); @@ -957,7 +1059,7 @@ public void KeyVaultKeyCreateDeleteRecoverPurgeTest() catch (KeyVaultErrorException ex) { if (ex.Response.StatusCode != HttpStatusCode.NotFound || ex.Body.Error.Message != ex.Message) - throw ex; + throw; } } @@ -1052,9 +1154,9 @@ public void KeyVaultListDeletedKeysTest() Assert.True(recoveryLevelIsConsistent, "the 'recoveryLevel' attribute did not consistently return the expected value."); } } - #endregion +#endregion - #region Secret Operations +#region Secret Operations [Fact] public void KeyVaultSecretCreateUpdateDeleteTest() @@ -1124,7 +1226,7 @@ public void KeyVaultSecretCreateUpdateDeleteTest() catch (KeyVaultErrorException ex) { if (ex.Response.StatusCode != HttpStatusCode.NotFound || ex.Body.Error.Message != ex.Message) - throw ex; + throw; } Assert.True(recoveryLevelAttributeIsConsistent, "The recoveryLevel attribute did not return consistently the expected value"); @@ -1372,7 +1474,7 @@ public void KeyVaultTestSecretExtendedAttributes() .GetAwaiter() .GetResult(); } - catch (KeyVaultErrorException ex) + catch (KeyVaultErrorException) { Assert.False(false, "failed to re-enable disabled secret in soft-delete-enabled vault; cleanup will fail"); } @@ -1396,9 +1498,9 @@ public void KeyVaultTestSecretExtendedAttributes() } } - #endregion +#endregion - #region Deleted Secret Operations +#region Deleted Secret Operations [Fact] public void KeyVaultGetDeletedSecretTest() @@ -1478,7 +1580,7 @@ public void KeyVaultSecretCreateDeleteRecoverPurgeTest() catch (KeyVaultErrorException ex) { if (ex.Response.StatusCode != HttpStatusCode.NotFound || ex.Body.Error.Message != ex.Message) - throw ex; + throw; } this.fixture.WaitOnDeletedSecret(client, _vaultAddress, secretName); @@ -1521,7 +1623,7 @@ public void KeyVaultSecretCreateDeleteRecoverPurgeTest() catch (KeyVaultErrorException ex) { if (ex.Response.StatusCode != HttpStatusCode.NotFound || ex.Body.Error.Message != ex.Message) - throw ex; + throw; } this.fixture.WaitOnDeletedSecret(client, _vaultAddress, secretName); @@ -1537,7 +1639,7 @@ public void KeyVaultSecretCreateDeleteRecoverPurgeTest() catch (KeyVaultErrorException ex) { if (ex.Response.StatusCode != HttpStatusCode.NotFound || ex.Body.Error.Message != ex.Message) - throw ex; + throw; } } @@ -1632,9 +1734,9 @@ public void KeyVaultListDeletedSecretsTest() } } - #endregion +#endregion - #region Certificate Operations +#region Certificate Operations [Fact] public void KeyVaultCertificateImportTest() { @@ -2592,7 +2694,7 @@ public void KeyVaultCertificateAsyncDeleteOperationTest() catch (KeyVaultErrorException ex) { if (ex.Response.StatusCode != HttpStatusCode.NotFound || ex.Body.Error.Message != ex.Message) - throw ex; + throw; } } } @@ -3004,9 +3106,9 @@ public void KeyVaultCertificateCreateManualEnrolledTest() } } - #endregion +#endregion - #region Deleted Certificate Operations +#region Deleted Certificate Operations [Fact] public void KeyVaultGetDeletedCertificateTest() @@ -3171,7 +3273,7 @@ public void KeyVaultCertificateCreateDeleteRecoverPurgeTest() catch (KeyVaultErrorException ex) { if (ex.Response.StatusCode != HttpStatusCode.NotFound || ex.Body.Error.Message != ex.Message) - throw ex; + throw; } this.fixture.WaitOnDeletedCertificate(client, _vaultAddress, name); @@ -3208,7 +3310,7 @@ public void KeyVaultCertificateCreateDeleteRecoverPurgeTest() catch (KeyVaultErrorException ex) { if (ex.Response.StatusCode != HttpStatusCode.NotFound || ex.Body.Error.Message != ex.Message) - throw ex; + throw; } this.fixture.WaitOnDeletedCertificate(client, _vaultAddress, name); @@ -3224,7 +3326,7 @@ public void KeyVaultCertificateCreateDeleteRecoverPurgeTest() catch (KeyVaultErrorException ex) { if (ex.Response.StatusCode != HttpStatusCode.NotFound || ex.Body.Error.Message != ex.Message) - throw ex; + throw; } } @@ -3348,9 +3450,9 @@ public void KeyVaultListDeletedCertificatesTest() } } - #endregion +#endregion - #region Storage Operations +#region Storage Operations [Fact] public void KeyVaultStorageCreateTest() @@ -3735,9 +3837,9 @@ public void KeyVaultStorageSasDefListTest() } } - #endregion +#endregion - #region Helper Methods +#region Helper Methods private static SecretAttributes NewSecretAttributes(bool enabled, bool active, bool expired) { @@ -4169,6 +4271,6 @@ private static bool VerifyDeletionRecoveryLevel(CertificateAttributes attributes && attributes.RecoveryLevel.ToLowerInvariant().Contains(DeletionRecoveryLevel.Purgeable.ToLowerInvariant()) && !(isSoftDeleteEnabledVault ^ attributes.RecoveryLevel.ToLowerInvariant().Contains(DeletionRecoveryLevel.Recoverable.ToLowerInvariant())); } - #endregion +#endregion } } diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Tests/SessionRecords/Microsoft.Azure.KeyVault.Tests.KeyVaultOperationsTest/KeyVaultEcKeyCreateSignVerifyP256.json b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Tests/SessionRecords/Microsoft.Azure.KeyVault.Tests.KeyVaultOperationsTest/KeyVaultEcKeyCreateSignVerifyP256.json new file mode 100644 index 000000000000..33afa5b435ec --- /dev/null +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Tests/SessionRecords/Microsoft.Azure.KeyVault.Tests.KeyVaultOperationsTest/KeyVaultEcKeyCreateSignVerifyP256.json @@ -0,0 +1,292 @@ +{ + "Entries": [ + { + "RequestUri": "//keys/EcTestKeyP256/create?api-version=2016-10-01", + "EncodedRequestUri": "Ly9rZXlzL0VjVGVzdEtleVAyNTYvY3JlYXRlP2FwaS12ZXJzaW9uPTIwMTYtMTAtMDE=", + "RequestMethod": "POST", + "RequestBody": "{\r\n \"kty\": \"EC\",\r\n \"crv\": \"P-256\",\r\n \"key_size\": null,\r\n \"key_ops\": null,\r\n \"attributes\": null,\r\n \"tags\": null\r\n}", + "RequestHeaders": { + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Content-Length": [ + "181" + ], + "x-ms-client-request-id": [ + "6bf748fc-2665-456e-bacb-368108f23734" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.25009.03", + "Microsoft.Azure.KeyVault.KeyVaultClient/2.2.1-preview" + ] + }, + "ResponseBody": "{\r\n \"key\": {\r\n \"kid\": \"https://kv-sdk-test.vault-int.azure-int.net/keys/EcTestKeyP256/fe277909d7e248f7913d6049ccf8451f\",\r\n \"kty\": \"EC\",\r\n \"key_ops\": [\r\n \"sign\",\r\n \"verify\"\r\n ],\r\n \"crv\": \"P-256\",\r\n \"x\": \"IzSTOwCKbS-BEdPwVT0xGnW18zzgyG7CwnMDKLULyQo\",\r\n \"y\": \"K7m-pJxgWIjHGHMF5IZpWLasH6TizES9eidg--wQkSE\"\r\n },\r\n \"attributes\": {\r\n \"recoveryLevel\": \"Recoverable+Purgeable\",\r\n \"enabled\": true,\r\n \"nbf\": null,\r\n \"exp\": null,\r\n \"created\": 1493942958,\r\n \"updated\": 1493942958\r\n }\r\n}", + "ResponseHeaders": { + "Content-Length": [ + "676" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ], + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Fri, 05 May 2017 00:09:18 GMT" + ], + "Pragma": [ + "no-cache" + ], + "Server": [ + "Microsoft-IIS/8.5" + ], + "x-ms-keyvault-region": [ + "eastus2" + ], + "x-ms-request-id": [ + "d9337449-73a3-4d58-bc2a-93b135104fed" + ], + "x-ms-keyvault-service-version": [ + "1.0.0.1185" + ], + "X-AspNet-Version": [ + "4.0.30319" + ], + "X-Powered-By": [ + "ASP.NET" + ], + "Strict-Transport-Security": [ + "max-age=31536000;includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ] + }, + "StatusCode": 200 + }, + { + "RequestUri": "/keys/EcTestKeyP256/fe277909d7e248f7913d6049ccf8451f/sign?api-version=2016-10-01", + "EncodedRequestUri": "L2tleXMvRWNUZXN0S2V5UDI1Ni9mZTI3NzkwOWQ3ZTI0OGY3OTEzZDYwNDljY2Y4NDUxZi9zaWduP2FwaS12ZXJzaW9uPTIwMTYtMTAtMDE=", + "RequestMethod": "POST", + "RequestBody": "{\r\n \"alg\": \"ES256\",\r\n \"value\": \"GgxGb1115NitZ2XV9RnbyCt8NDs3+IUA7F5kAFOTsw0=\"\r\n}", + "RequestHeaders": { + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Content-Length": [ + "81" + ], + "x-ms-client-request-id": [ + "744e35ba-a678-46c9-aec0-e6466bcd4f32" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.24214.01", + "Microsoft.Azure.KeyVault.KeyVaultClient/2.1.0-preview" + ] + }, + "ResponseBody": "{\r\n \"kid\": \"https://kv-sdk-test.vault-int.azure-int.net/keys/EcTestKeyP256/fe277909d7e248f7913d6049ccf8451f\",\r\n \"value\": \"++QH5ItfacooSkOktqhhUIBvBbz7H0cPoAZWdm5Y/xJqQprw4BKkwB0xPZ95Gek+bcb4qB/tZMjbDsbNocdOSg==\"\r\n}", + "ResponseHeaders": { + "Content-Length": [ + "455" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ], + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Wed, 05 Apr 2017 23:14:27 GMT" + ], + "Pragma": [ + "no-cache" + ], + "Server": [ + "Microsoft-IIS/8.5" + ], + "x-ms-keyvault-region": [ + "eastus2" + ], + "x-ms-request-id": [ + "16e60192-b5a1-4889-874f-3400f21d8012" + ], + "x-ms-keyvault-service-version": [ + "1.0.0.1152" + ], + "X-AspNet-Version": [ + "4.0.30319" + ], + "X-Powered-By": [ + "ASP.NET" + ], + "Strict-Transport-Security": [ + "max-age=31536000;includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ] + }, + "StatusCode": 200 + }, + { + "RequestUri": "/keys/EcTestKeyP256/fe277909d7e248f7913d6049ccf8451f/verify?api-version=2016-10-01", + "EncodedRequestUri": "L2tleXMvRWNUZXN0S2V5UDI1Ni9mZTI3NzkwOWQ3ZTI0OGY3OTEzZDYwNDljY2Y4NDUxZi92ZXJpZnk/YXBpLXZlcnNpb249MjAxNi0xMC0wMQ==", + "RequestMethod": "POST", + "RequestBody": "{\r\n \"alg\": \"ES256\",\r\n \"digest\": \"GgxGb1115NitZ2XV9RnbyCt8NDs3+IUA7F5kAFOTsw0=\",\r\n \"value\": \"++QH5ItfacooSkOktqhhUIBvBbz7H0cPoAZWdm5Y/xJqQprw4BKkwB0xPZ95Gek+bcb4qB/tZMjbDsbNocdOSg==\"\r\n}", + "RequestHeaders": { + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Content-Length": [ + "440" + ], + "x-ms-client-request-id": [ + "e94b742a-13ee-482b-9bf3-e07019ca0759" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.24214.01", + "Microsoft.Azure.KeyVault.KeyVaultClient/2.1.0-preview" + ] + }, + "ResponseBody": "{\r\n \"value\": true\r\n}", + "ResponseHeaders": { + "Content-Length": [ + "14" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ], + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Wed, 05 Apr 2017 23:14:27 GMT" + ], + "Pragma": [ + "no-cache" + ], + "Server": [ + "Microsoft-IIS/8.5" + ], + "x-ms-keyvault-region": [ + "eastus2" + ], + "x-ms-request-id": [ + "d0891bfa-c785-4b4a-aadb-f3847f6af1c3" + ], + "x-ms-keyvault-service-version": [ + "1.0.0.1152" + ], + "X-AspNet-Version": [ + "4.0.30319" + ], + "X-Powered-By": [ + "ASP.NET" + ], + "Strict-Transport-Security": [ + "max-age=31536000;includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ] + }, + "StatusCode": 200 + }, + { + "RequestUri": "/keys/EcTestKeyP256/fe277909d7e248f7913d6049ccf8451f/verify?api-version=2016-10-01", + "EncodedRequestUri": "L2tleXMvRWNUZXN0S2V5UDI1Ni9mZTI3NzkwOWQ3ZTI0OGY3OTEzZDYwNDljY2Y4NDUxZi92ZXJpZnk/YXBpLXZlcnNpb249MjAxNi0xMC0wMQ==", + "RequestMethod": "POST", + "RequestBody": "{\r\n \"alg\": \"ES256\",\r\n \"digest\": \"GgxGb1115NitZ2XV9RnbyCt8NDs3+IUA7F5kAFOTsw0=\",\r\n \"value\": \"++QH5ItfacooSkOktqhhUIBvBbz7H0cPoAZWdm5Y/xJqQprw4BKkwB0xPZ95Gek+bcb4qB/tZMjbDsbNocdOSw==\"\r\n}", + "RequestHeaders": { + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Content-Length": [ + "440" + ], + "x-ms-client-request-id": [ + "e94b742a-13ee-482b-9bf3-e07019ca0759" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.24214.01", + "Microsoft.Azure.KeyVault.KeyVaultClient/2.1.0-preview" + ] + }, + "ResponseBody": "{\r\n \"value\": false\r\n}", + "ResponseHeaders": { + "Content-Length": [ + "14" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ], + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Wed, 05 Apr 2017 23:14:27 GMT" + ], + "Pragma": [ + "no-cache" + ], + "Server": [ + "Microsoft-IIS/8.5" + ], + "x-ms-keyvault-region": [ + "eastus2" + ], + "x-ms-request-id": [ + "d0891bfa-c785-4b4a-aadb-f3847f6af1c3" + ], + "x-ms-keyvault-service-version": [ + "1.0.0.1152" + ], + "X-AspNet-Version": [ + "4.0.30319" + ], + "X-Powered-By": [ + "ASP.NET" + ], + "Strict-Transport-Security": [ + "max-age=31536000;includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ] + }, + "StatusCode": 200 + } + ], + "Names": {}, + "Variables": { + "VaultAddress": "https://kv-sdk-test.vault-int.azure-int.net/", + "KeyName": "EcTestKeyP256", + "KeyVersion": "fe277909d7e248f7913d6049ccf8451f", + "SoftDeleteEnabled": "True", + "RandomBytes": "GgxGb1115NitZ2XV9RnbyCt8NDs3+IUA7F5kAFOTsw0=" + } +} \ No newline at end of file diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Tests/SessionRecords/Microsoft.Azure.KeyVault.Tests.KeyVaultOperationsTest/KeyVaultEcKeyCreateSignVerifyP384.json b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Tests/SessionRecords/Microsoft.Azure.KeyVault.Tests.KeyVaultOperationsTest/KeyVaultEcKeyCreateSignVerifyP384.json new file mode 100644 index 000000000000..919d3035129e --- /dev/null +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Tests/SessionRecords/Microsoft.Azure.KeyVault.Tests.KeyVaultOperationsTest/KeyVaultEcKeyCreateSignVerifyP384.json @@ -0,0 +1,292 @@ +{ + "Entries": [ + { + "RequestUri": "//keys/EcTestKeyP384/create?api-version=2016-10-01", + "EncodedRequestUri": "Ly9rZXlzL0VjVGVzdEtleVAzODQvY3JlYXRlP2FwaS12ZXJzaW9uPTIwMTYtMTAtMDE=", + "RequestMethod": "POST", + "RequestBody": "{\r\n \"kty\": \"EC\",\r\n \"crv\": \"P-384\",\r\n \"key_size\": null,\r\n \"key_ops\": null,\r\n \"attributes\": null,\r\n \"tags\": null\r\n}", + "RequestHeaders": { + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Content-Length": [ + "181" + ], + "x-ms-client-request-id": [ + "6bf748fc-2665-456e-bacb-368108f23734" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.25009.03", + "Microsoft.Azure.KeyVault.KeyVaultClient/2.2.1-preview" + ] + }, + "ResponseBody": "{\r\n \"key\": {\r\n \"kid\": \"https://kv-sdk-test.vault-int.azure-int.net/keys/EcTestKeyP384/fe277909d7e248f7913d6049ccf8451f\",\r\n \"kty\": \"EC\",\r\n \"key_ops\": [\r\n \"sign\",\r\n \"verify\"\r\n ],\r\n \"crv\": \"P-384\",\r\n \"x\": \"5XN86Y1xhKo1GuohlWzcvoJmZs36USIFopOU1wha6qbtZzM2C1OK01lh8DJYwQsi\",\r\n \"y\": \"ZsI5YcBKzo-0d5lS3106nYPshOi9LcCecNJebIina6fw7Ab7TD3f3fhNxEaAE6ja\"\r\n },\r\n \"attributes\": {\r\n \"recoveryLevel\": \"Recoverable+Purgeable\",\r\n \"enabled\": true,\r\n \"nbf\": null,\r\n \"exp\": null,\r\n \"created\": 1493942958,\r\n \"updated\": 1493942958\r\n }\r\n}", + "ResponseHeaders": { + "Content-Length": [ + "676" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ], + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Fri, 05 May 2017 00:09:18 GMT" + ], + "Pragma": [ + "no-cache" + ], + "Server": [ + "Microsoft-IIS/8.5" + ], + "x-ms-keyvault-region": [ + "eastus2" + ], + "x-ms-request-id": [ + "d9337449-73a3-4d58-bc2a-93b135104fed" + ], + "x-ms-keyvault-service-version": [ + "1.0.0.1185" + ], + "X-AspNet-Version": [ + "4.0.30319" + ], + "X-Powered-By": [ + "ASP.NET" + ], + "Strict-Transport-Security": [ + "max-age=31536000;includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ] + }, + "StatusCode": 200 + }, + { + "RequestUri": "/keys/EcTestKeyP384/fe277909d7e248f7913d6049ccf8451f/sign?api-version=2016-10-01", + "EncodedRequestUri": "L2tleXMvRWNUZXN0S2V5UDM4NC9mZTI3NzkwOWQ3ZTI0OGY3OTEzZDYwNDljY2Y4NDUxZi9zaWduP2FwaS12ZXJzaW9uPTIwMTYtMTAtMDE=", + "RequestMethod": "POST", + "RequestBody": "{\r\n \"alg\": \"ES384\",\r\n \"value\": \"GgxGb1115NitZ2XV9RnbyCt8NDs3+IUA7F5kAFOTsw1KQCl1z3RsD/S+wk0eBOtL\"\r\n}", + "RequestHeaders": { + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Content-Length": [ + "81" + ], + "x-ms-client-request-id": [ + "744e35ba-a678-46c9-aec0-e6466bcd4f32" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.24214.01", + "Microsoft.Azure.KeyVault.KeyVaultClient/2.1.0-preview" + ] + }, + "ResponseBody": "{\r\n \"kid\": \"https://kv-sdk-test.vault-int.azure-int.net/keys/EcTestKeyP384/fe277909d7e248f7913d6049ccf8451f\",\r\n \"value\": \"/rrrI7jPDvMqFS5+/umzDaxT3oWmdypRoqLBvGPGaAqfwK6qGHGK5ZHFBwVO008hsy9KZxgDK09YavjxqOhLKxD79ozJYdB2LGSkv+I5qU7p2/P/JprtK5Qi9+qj4Cbs\"\r\n}", + "ResponseHeaders": { + "Content-Length": [ + "455" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ], + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Wed, 05 Apr 2017 23:14:27 GMT" + ], + "Pragma": [ + "no-cache" + ], + "Server": [ + "Microsoft-IIS/8.5" + ], + "x-ms-keyvault-region": [ + "eastus2" + ], + "x-ms-request-id": [ + "16e60192-b5a1-4889-874f-3400f21d8012" + ], + "x-ms-keyvault-service-version": [ + "1.0.0.1152" + ], + "X-AspNet-Version": [ + "4.0.30319" + ], + "X-Powered-By": [ + "ASP.NET" + ], + "Strict-Transport-Security": [ + "max-age=31536000;includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ] + }, + "StatusCode": 200 + }, + { + "RequestUri": "/keys/EcTestKeyP384/fe277909d7e248f7913d6049ccf8451f/verify?api-version=2016-10-01", + "EncodedRequestUri": "L2tleXMvRWNUZXN0S2V5UDM4NC9mZTI3NzkwOWQ3ZTI0OGY3OTEzZDYwNDljY2Y4NDUxZi92ZXJpZnk/YXBpLXZlcnNpb249MjAxNi0xMC0wMQ==", + "RequestMethod": "POST", + "RequestBody": "{\r\n \"alg\": \"ES384\",\r\n \"digest\": \"GgxGb1115NitZ2XV9RnbyCt8NDs3+IUA7F5kAFOTsw1KQCl1z3RsD/S+wk0eBOtL\",\r\n \"value\": \"/rrrI7jPDvMqFS5+/umzDaxT3oWmdypRoqLBvGPGaAqfwK6qGHGK5ZHFBwVO008hsy9KZxgDK09YavjxqOhLKxD79ozJYdB2LGSkv+I5qU7p2/P/JprtK5Qi9+qj4Cbs\"\r\n}", + "RequestHeaders": { + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Content-Length": [ + "440" + ], + "x-ms-client-request-id": [ + "e94b742a-13ee-482b-9bf3-e07019ca0759" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.24214.01", + "Microsoft.Azure.KeyVault.KeyVaultClient/2.1.0-preview" + ] + }, + "ResponseBody": "{\r\n \"value\": true\r\n}", + "ResponseHeaders": { + "Content-Length": [ + "14" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ], + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Wed, 05 Apr 2017 23:14:27 GMT" + ], + "Pragma": [ + "no-cache" + ], + "Server": [ + "Microsoft-IIS/8.5" + ], + "x-ms-keyvault-region": [ + "eastus2" + ], + "x-ms-request-id": [ + "d0891bfa-c785-4b4a-aadb-f3847f6af1c3" + ], + "x-ms-keyvault-service-version": [ + "1.0.0.1152" + ], + "X-AspNet-Version": [ + "4.0.30319" + ], + "X-Powered-By": [ + "ASP.NET" + ], + "Strict-Transport-Security": [ + "max-age=31536000;includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ] + }, + "StatusCode": 200 + }, + { + "RequestUri": "/keys/EcTestKeyP384/fe277909d7e248f7913d6049ccf8451f/verify?api-version=2016-10-01", + "EncodedRequestUri": "L2tleXMvRWNUZXN0S2V5UDM4NC9mZTI3NzkwOWQ3ZTI0OGY3OTEzZDYwNDljY2Y4NDUxZi92ZXJpZnk/YXBpLXZlcnNpb249MjAxNi0xMC0wMQ==", + "RequestMethod": "POST", + "RequestBody": "{\r\n \"alg\": \"ES384\",\r\n \"digest\": \"GgxGb1115NitZ2XV9RnbyCt8NDs3+IUA7F5kAFOTsw1KQCl1z3RsD/S+wk0eBOtL\",\r\n \"value\": \"/rrrI7jPDvMqFS5+/umzDaxT3oWmdypRoqLBvGPGaAqfwK6qGHGK5ZHFBwVO008hsy9KZxgDK09YavjxqOhLKxD79ozJYdB2LGSkv+I5qU7p2/P/JprtK5Qi9+qj4Cbt\"\r\n}", + "RequestHeaders": { + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Content-Length": [ + "440" + ], + "x-ms-client-request-id": [ + "e94b742a-13ee-482b-9bf3-e07019ca0759" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.24214.01", + "Microsoft.Azure.KeyVault.KeyVaultClient/2.1.0-preview" + ] + }, + "ResponseBody": "{\r\n \"value\": false\r\n}", + "ResponseHeaders": { + "Content-Length": [ + "14" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ], + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Wed, 05 Apr 2017 23:14:27 GMT" + ], + "Pragma": [ + "no-cache" + ], + "Server": [ + "Microsoft-IIS/8.5" + ], + "x-ms-keyvault-region": [ + "eastus2" + ], + "x-ms-request-id": [ + "d0891bfa-c785-4b4a-aadb-f3847f6af1c3" + ], + "x-ms-keyvault-service-version": [ + "1.0.0.1152" + ], + "X-AspNet-Version": [ + "4.0.30319" + ], + "X-Powered-By": [ + "ASP.NET" + ], + "Strict-Transport-Security": [ + "max-age=31536000;includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ] + }, + "StatusCode": 200 + } + ], + "Names": {}, + "Variables": { + "VaultAddress": "https://kv-sdk-test.vault-int.azure-int.net/", + "KeyName": "EcTestKeyP384", + "KeyVersion": "fe277909d7e248f7913d6049ccf8451f", + "SoftDeleteEnabled": "True", + "RandomBytes": "GgxGb1115NitZ2XV9RnbyCt8NDs3+IUA7F5kAFOTsw1KQCl1z3RsD/S+wk0eBOtL" + } +} \ No newline at end of file diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Tests/SessionRecords/Microsoft.Azure.KeyVault.Tests.KeyVaultOperationsTest/KeyVaultEcKeyCreateSignVerifyP521.json b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Tests/SessionRecords/Microsoft.Azure.KeyVault.Tests.KeyVaultOperationsTest/KeyVaultEcKeyCreateSignVerifyP521.json new file mode 100644 index 000000000000..121749929a7d --- /dev/null +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Tests/SessionRecords/Microsoft.Azure.KeyVault.Tests.KeyVaultOperationsTest/KeyVaultEcKeyCreateSignVerifyP521.json @@ -0,0 +1,292 @@ +{ + "Entries": [ + { + "RequestUri": "//keys/EcTestKeyP521/create?api-version=2016-10-01", + "EncodedRequestUri": "Ly9rZXlzL0VjVGVzdEtleVA1MjEvY3JlYXRlP2FwaS12ZXJzaW9uPTIwMTYtMTAtMDE=", + "RequestMethod": "POST", + "RequestBody": "{\r\n \"kty\": \"EC\",\r\n \"crv\": \"P-521\",\r\n \"key_size\": null,\r\n \"key_ops\": null,\r\n \"attributes\": null,\r\n \"tags\": null\r\n}", + "RequestHeaders": { + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Content-Length": [ + "181" + ], + "x-ms-client-request-id": [ + "6bf748fc-2665-456e-bacb-368108f23734" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.25009.03", + "Microsoft.Azure.KeyVault.KeyVaultClient/2.2.1-preview" + ] + }, + "ResponseBody": "{\r\n \"key\": {\r\n \"kid\": \"https://kv-sdk-test.vault-int.azure-int.net/keys/EcTestKeyP521/fe277909d7e248f7913d6049ccf8451f\",\r\n \"kty\": \"EC\",\r\n \"key_ops\": [\r\n \"sign\",\r\n \"verify\"\r\n ],\r\n \"crv\": \"P-521\",\r\n \"x\": \"ASggRFEA2L_FxGjnU5FNplPHBi8tU0e2L89ZWro4ZpDYvBvel0gjao_S23fuNFlhufLp5kePdGbqujy45wHKMjMR\",\r\n \"y\": \"AFDVBsQZN2V1lox2kMCmqWL5Kn4f3X0mtqnBLWgPlOSl6l-tMDHj8gcLnMGJZNarCKVGVrdjhmK9BpbYy0Q8Omnm\"\r\n },\r\n \"attributes\": {\r\n \"recoveryLevel\": \"Recoverable+Purgeable\",\r\n \"enabled\": true,\r\n \"nbf\": null,\r\n \"exp\": null,\r\n \"created\": 1493942958,\r\n \"updated\": 1493942958\r\n }\r\n}", + "ResponseHeaders": { + "Content-Length": [ + "676" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ], + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Fri, 05 May 2017 00:09:18 GMT" + ], + "Pragma": [ + "no-cache" + ], + "Server": [ + "Microsoft-IIS/8.5" + ], + "x-ms-keyvault-region": [ + "eastus2" + ], + "x-ms-request-id": [ + "d9337449-73a3-4d58-bc2a-93b135104fed" + ], + "x-ms-keyvault-service-version": [ + "1.0.0.1185" + ], + "X-AspNet-Version": [ + "4.0.30319" + ], + "X-Powered-By": [ + "ASP.NET" + ], + "Strict-Transport-Security": [ + "max-age=31536000;includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ] + }, + "StatusCode": 200 + }, + { + "RequestUri": "/keys/EcTestKeyP521/fe277909d7e248f7913d6049ccf8451f/sign?api-version=2016-10-01", + "EncodedRequestUri": "L2tleXMvRWNUZXN0S2V5UDUyMS9mZTI3NzkwOWQ3ZTI0OGY3OTEzZDYwNDljY2Y4NDUxZi9zaWduP2FwaS12ZXJzaW9uPTIwMTYtMTAtMDE=", + "RequestMethod": "POST", + "RequestBody": "{\r\n \"alg\": \"ES512\",\r\n \"value\": \"GgxGb1115NitZ2XV9RnbyCt8NDs3+IUA7F5kAFOTsw1KQCl1z3RsD/S+wk0eBOtLtZj+qEa1aiGGRoL+EOSEGg==\"\r\n}", + "RequestHeaders": { + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Content-Length": [ + "81" + ], + "x-ms-client-request-id": [ + "744e35ba-a678-46c9-aec0-e6466bcd4f32" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.24214.01", + "Microsoft.Azure.KeyVault.KeyVaultClient/2.1.0-preview" + ] + }, + "ResponseBody": "{\r\n \"kid\": \"https://kv-sdk-test.vault-int.azure-int.net/keys/EcTestKeyP521/fe277909d7e248f7913d6049ccf8451f\",\r\n \"value\": \"AM/ZcMDD0PWWYGo5FVeK6Vq6m3wBU8DnKdIatPFA1wfp+DFlrJxIfvc8pkr5K0/f24OnamEpq2xjLswocvxn1YmbAHlG7dpP9cSSAayoKQ5oUNPC6LweXjXpS3v77GaQvIEmIeWeDOEV0uxAUBt8EnuNE6/oEui2poibEvVZ2cPM7UUl\"\r\n}", + "ResponseHeaders": { + "Content-Length": [ + "455" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ], + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Wed, 05 Apr 2017 23:14:27 GMT" + ], + "Pragma": [ + "no-cache" + ], + "Server": [ + "Microsoft-IIS/8.5" + ], + "x-ms-keyvault-region": [ + "eastus2" + ], + "x-ms-request-id": [ + "16e60192-b5a1-4889-874f-3400f21d8012" + ], + "x-ms-keyvault-service-version": [ + "1.0.0.1152" + ], + "X-AspNet-Version": [ + "4.0.30319" + ], + "X-Powered-By": [ + "ASP.NET" + ], + "Strict-Transport-Security": [ + "max-age=31536000;includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ] + }, + "StatusCode": 200 + }, + { + "RequestUri": "/keys/EcTestKeyP521/fe277909d7e248f7913d6049ccf8451f/verify?api-version=2016-10-01", + "EncodedRequestUri": "L2tleXMvRWNUZXN0S2V5UDUyMS9mZTI3NzkwOWQ3ZTI0OGY3OTEzZDYwNDljY2Y4NDUxZi92ZXJpZnk/YXBpLXZlcnNpb249MjAxNi0xMC0wMQ==", + "RequestMethod": "POST", + "RequestBody": "{\r\n \"alg\": \"ES512\",\r\n \"digest\": \"GgxGb1115NitZ2XV9RnbyCt8NDs3+IUA7F5kAFOTsw1KQCl1z3RsD/S+wk0eBOtLtZj+qEa1aiGGRoL+EOSEGg==\",\r\n \"value\": \"AM/ZcMDD0PWWYGo5FVeK6Vq6m3wBU8DnKdIatPFA1wfp+DFlrJxIfvc8pkr5K0/f24OnamEpq2xjLswocvxn1YmbAHlG7dpP9cSSAayoKQ5oUNPC6LweXjXpS3v77GaQvIEmIeWeDOEV0uxAUBt8EnuNE6/oEui2poibEvVZ2cPM7UUl\"\r\n}", + "RequestHeaders": { + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Content-Length": [ + "440" + ], + "x-ms-client-request-id": [ + "e94b742a-13ee-482b-9bf3-e07019ca0759" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.24214.01", + "Microsoft.Azure.KeyVault.KeyVaultClient/2.1.0-preview" + ] + }, + "ResponseBody": "{\r\n \"value\": true\r\n}", + "ResponseHeaders": { + "Content-Length": [ + "14" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ], + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Wed, 05 Apr 2017 23:14:27 GMT" + ], + "Pragma": [ + "no-cache" + ], + "Server": [ + "Microsoft-IIS/8.5" + ], + "x-ms-keyvault-region": [ + "eastus2" + ], + "x-ms-request-id": [ + "d0891bfa-c785-4b4a-aadb-f3847f6af1c3" + ], + "x-ms-keyvault-service-version": [ + "1.0.0.1152" + ], + "X-AspNet-Version": [ + "4.0.30319" + ], + "X-Powered-By": [ + "ASP.NET" + ], + "Strict-Transport-Security": [ + "max-age=31536000;includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ] + }, + "StatusCode": 200 + }, + { + "RequestUri": "/keys/EcTestKeyP521/fe277909d7e248f7913d6049ccf8451f/verify?api-version=2016-10-01", + "EncodedRequestUri": "L2tleXMvRWNUZXN0S2V5UDUyMS9mZTI3NzkwOWQ3ZTI0OGY3OTEzZDYwNDljY2Y4NDUxZi92ZXJpZnk/YXBpLXZlcnNpb249MjAxNi0xMC0wMQ==", + "RequestMethod": "POST", + "RequestBody": "{\r\n \"alg\": \"ES512\",\r\n \"digest\": \"GgxGb1115NitZ2XV9RnbyCt8NDs3+IUA7F5kAFOTsw1KQCl1z3RsD/S+wk0eBOtLtZj+qEa1aiGGRoL+EOSEGg==\",\r\n \"value\": \"AM/ZcMDD0PWWYGo5FVeK6Vq6m3wBU8DnKdIatPFA1wfp+DFlrJxIfvc8pkr5K0/f24OnamEpq2xjLswocvxn1YmbAHlG7dpP9cSSAayoKQ5oUNPC6LweXjXpS3v77GaQvIEmIeWeDOEV0uxAUBt8EnuNE6/oEui2poibEvVZ2cPM7UUk\"\r\n}", + "RequestHeaders": { + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Content-Length": [ + "440" + ], + "x-ms-client-request-id": [ + "e94b742a-13ee-482b-9bf3-e07019ca0759" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.24214.01", + "Microsoft.Azure.KeyVault.KeyVaultClient/2.1.0-preview" + ] + }, + "ResponseBody": "{\r\n \"value\": false\r\n}", + "ResponseHeaders": { + "Content-Length": [ + "14" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ], + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Wed, 05 Apr 2017 23:14:27 GMT" + ], + "Pragma": [ + "no-cache" + ], + "Server": [ + "Microsoft-IIS/8.5" + ], + "x-ms-keyvault-region": [ + "eastus2" + ], + "x-ms-request-id": [ + "d0891bfa-c785-4b4a-aadb-f3847f6af1c3" + ], + "x-ms-keyvault-service-version": [ + "1.0.0.1152" + ], + "X-AspNet-Version": [ + "4.0.30319" + ], + "X-Powered-By": [ + "ASP.NET" + ], + "Strict-Transport-Security": [ + "max-age=31536000;includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ] + }, + "StatusCode": 200 + } + ], + "Names": {}, + "Variables": { + "VaultAddress": "https://kv-sdk-test.vault-int.azure-int.net/", + "KeyName": "EcTestKeyP521", + "KeyVersion": "fe277909d7e248f7913d6049ccf8451f", + "SoftDeleteEnabled": "True", + "RandomBytes": "GgxGb1115NitZ2XV9RnbyCt8NDs3+IUA7F5kAFOTsw1KQCl1z3RsD/S+wk0eBOtLtZj+qEa1aiGGRoL+EOSEGg==" + } +} \ No newline at end of file diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Tests/SessionRecords/Microsoft.Azure.KeyVault.Tests.KeyVaultOperationsTest/KeyVaultEcKeyCreateSignVerifySECP256K1.json b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Tests/SessionRecords/Microsoft.Azure.KeyVault.Tests.KeyVaultOperationsTest/KeyVaultEcKeyCreateSignVerifySECP256K1.json new file mode 100644 index 000000000000..384330603503 --- /dev/null +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.Tests/SessionRecords/Microsoft.Azure.KeyVault.Tests.KeyVaultOperationsTest/KeyVaultEcKeyCreateSignVerifySECP256K1.json @@ -0,0 +1,292 @@ +{ + "Entries": [ + { + "RequestUri": "//keys/EcTestKeySECP256K1/create?api-version=2016-10-01", + "EncodedRequestUri": "Ly9rZXlzL0VjVGVzdEtleVNFQ1AyNTZLMS9jcmVhdGU/YXBpLXZlcnNpb249MjAxNi0xMC0wMQ==", + "RequestMethod": "POST", + "RequestBody": "{\r\n \"kty\": \"EC\",\r\n \"crv\": \"SECP256K1\",\r\n \"key_size\": null,\r\n \"key_ops\": null,\r\n \"attributes\": null,\r\n \"tags\": null\r\n}", + "RequestHeaders": { + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Content-Length": [ + "181" + ], + "x-ms-client-request-id": [ + "6bf748fc-2665-456e-bacb-368108f23734" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.25009.03", + "Microsoft.Azure.KeyVault.KeyVaultClient/2.2.1-preview" + ] + }, + "ResponseBody": "{\r\n \"key\": {\r\n \"kid\": \"https://kv-sdk-test.vault-int.azure-int.net/keys/EcTestKeySECP256K1/fe277909d7e248f7913d6049ccf8451f\",\r\n \"kty\": \"EC\",\r\n \"key_ops\": [\r\n \"sign\",\r\n \"verify\"\r\n ],\r\n \"crv\": \"SECP256K1\",\r\n \"x\": \"yBMUvQwthIjbdvYUC2DDDs6I45dqG0B1GQ3-Eg5RxXM\",\r\n \"y\": \"KGf5oIzA7QNhZ8gXP8LSQfZKSMsGrmcUphyWpD2ingg\"\r\n },\r\n \"attributes\": {\r\n \"recoveryLevel\": \"Recoverable+Purgeable\",\r\n \"enabled\": true,\r\n \"nbf\": null,\r\n \"exp\": null,\r\n \"created\": 1493942958,\r\n \"updated\": 1493942958\r\n }\r\n}", + "ResponseHeaders": { + "Content-Length": [ + "676" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ], + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Fri, 05 May 2017 00:09:18 GMT" + ], + "Pragma": [ + "no-cache" + ], + "Server": [ + "Microsoft-IIS/8.5" + ], + "x-ms-keyvault-region": [ + "eastus2" + ], + "x-ms-request-id": [ + "d9337449-73a3-4d58-bc2a-93b135104fed" + ], + "x-ms-keyvault-service-version": [ + "1.0.0.1185" + ], + "X-AspNet-Version": [ + "4.0.30319" + ], + "X-Powered-By": [ + "ASP.NET" + ], + "Strict-Transport-Security": [ + "max-age=31536000;includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ] + }, + "StatusCode": 200 + }, + { + "RequestUri": "/keys/EcTestKeySECP256K1/fe277909d7e248f7913d6049ccf8451f/sign?api-version=2016-10-01", + "EncodedRequestUri": "L2tleXMvRWNUZXN0S2V5U0VDUDI1NksxL2ZlMjc3OTA5ZDdlMjQ4Zjc5MTNkNjA0OWNjZjg0NTFmL3NpZ24/YXBpLXZlcnNpb249MjAxNi0xMC0wMQ==", + "RequestMethod": "POST", + "RequestBody": "{\r\n \"alg\": \"ES256\",\r\n \"value\": \"GgxGb1115NitZ2XV9RnbyCt8NDs3+IUA7F5kAFOTsw0=\"\r\n}", + "RequestHeaders": { + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Content-Length": [ + "81" + ], + "x-ms-client-request-id": [ + "744e35ba-a678-46c9-aec0-e6466bcd4f32" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.24214.01", + "Microsoft.Azure.KeyVault.KeyVaultClient/2.1.0-preview" + ] + }, + "ResponseBody": "{\r\n \"kid\": \"https://kv-sdk-test.vault-int.azure-int.net/keys/EcTestKeySECP256K1/fe277909d7e248f7913d6049ccf8451f\",\r\n \"value\": \"dQViRw9RI6Y8rbhQElmdK+wXlkcWKzcIryuSluq9AbzY/d40gQEkAu1QP//UHpVW+rSWiTgySr9yUnvrsR8NwA==\"\r\n}", + "ResponseHeaders": { + "Content-Length": [ + "455" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ], + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Wed, 05 Apr 2017 23:14:27 GMT" + ], + "Pragma": [ + "no-cache" + ], + "Server": [ + "Microsoft-IIS/8.5" + ], + "x-ms-keyvault-region": [ + "eastus2" + ], + "x-ms-request-id": [ + "16e60192-b5a1-4889-874f-3400f21d8012" + ], + "x-ms-keyvault-service-version": [ + "1.0.0.1152" + ], + "X-AspNet-Version": [ + "4.0.30319" + ], + "X-Powered-By": [ + "ASP.NET" + ], + "Strict-Transport-Security": [ + "max-age=31536000;includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ] + }, + "StatusCode": 200 + }, + { + "RequestUri": "/keys/EcTestKeySECP256K1/fe277909d7e248f7913d6049ccf8451f/verify?api-version=2016-10-01", + "EncodedRequestUri": "L2tleXMvRWNUZXN0S2V5U0VDUDI1NksxL2ZlMjc3OTA5ZDdlMjQ4Zjc5MTNkNjA0OWNjZjg0NTFmL3ZlcmlmeT9hcGktdmVyc2lvbj0yMDE2LTEwLTAx", + "RequestMethod": "POST", + "RequestBody": "{\r\n \"alg\": \"ES256\",\r\n \"digest\": \"GgxGb1115NitZ2XV9RnbyCt8NDs3+IUA7F5kAFOTsw0=\",\r\n \"value\": \"dQViRw9RI6Y8rbhQElmdK+wXlkcWKzcIryuSluq9AbzY/d40gQEkAu1QP//UHpVW+rSWiTgySr9yUnvrsR8NwA==\"\r\n}", + "RequestHeaders": { + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Content-Length": [ + "440" + ], + "x-ms-client-request-id": [ + "e94b742a-13ee-482b-9bf3-e07019ca0759" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.24214.01", + "Microsoft.Azure.KeyVault.KeyVaultClient/2.1.0-preview" + ] + }, + "ResponseBody": "{\r\n \"value\": true\r\n}", + "ResponseHeaders": { + "Content-Length": [ + "14" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ], + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Wed, 05 Apr 2017 23:14:27 GMT" + ], + "Pragma": [ + "no-cache" + ], + "Server": [ + "Microsoft-IIS/8.5" + ], + "x-ms-keyvault-region": [ + "eastus2" + ], + "x-ms-request-id": [ + "d0891bfa-c785-4b4a-aadb-f3847f6af1c3" + ], + "x-ms-keyvault-service-version": [ + "1.0.0.1152" + ], + "X-AspNet-Version": [ + "4.0.30319" + ], + "X-Powered-By": [ + "ASP.NET" + ], + "Strict-Transport-Security": [ + "max-age=31536000;includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ] + }, + "StatusCode": 200 + }, + { + "RequestUri": "/keys/EcTestKeySECP256K1/fe277909d7e248f7913d6049ccf8451f/verify?api-version=2016-10-01", + "EncodedRequestUri": "L2tleXMvRWNUZXN0S2V5U0VDUDI1NksxL2ZlMjc3OTA5ZDdlMjQ4Zjc5MTNkNjA0OWNjZjg0NTFmL3ZlcmlmeT9hcGktdmVyc2lvbj0yMDE2LTEwLTAx", + "RequestMethod": "POST", + "RequestBody": "{\r\n \"alg\": \"ES256\",\r\n \"digest\": \"GgxGb1115NitZ2XV9RnbyCt8NDs3+IUA7F5kAFOTsw0=\",\r\n \"value\": \"dQViRw9RI6Y8rbhQElmdK+wXlkcWKzcIryuSluq9AbzY/d40gQEkAu1QP//UHpVW+rSWiTgySr9yUnvrsR8NwQ==\"\r\n}", + "RequestHeaders": { + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Content-Length": [ + "440" + ], + "x-ms-client-request-id": [ + "e94b742a-13ee-482b-9bf3-e07019ca0759" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.24214.01", + "Microsoft.Azure.KeyVault.KeyVaultClient/2.1.0-preview" + ] + }, + "ResponseBody": "{\r\n \"value\": false\r\n}", + "ResponseHeaders": { + "Content-Length": [ + "14" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ], + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Wed, 05 Apr 2017 23:14:27 GMT" + ], + "Pragma": [ + "no-cache" + ], + "Server": [ + "Microsoft-IIS/8.5" + ], + "x-ms-keyvault-region": [ + "eastus2" + ], + "x-ms-request-id": [ + "d0891bfa-c785-4b4a-aadb-f3847f6af1c3" + ], + "x-ms-keyvault-service-version": [ + "1.0.0.1152" + ], + "X-AspNet-Version": [ + "4.0.30319" + ], + "X-Powered-By": [ + "ASP.NET" + ], + "Strict-Transport-Security": [ + "max-age=31536000;includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ] + }, + "StatusCode": 200 + } + ], + "Names": {}, + "Variables": { + "VaultAddress": "https://kv-sdk-test.vault-int.azure-int.net/", + "KeyName": "EcTestKeySECP256K1", + "KeyVersion": "fe277909d7e248f7913d6049ccf8451f", + "SoftDeleteEnabled": "True", + "RandomBytes": "GgxGb1115NitZ2XV9RnbyCt8NDs3+IUA7F5kAFOTsw0=" + } +} \ No newline at end of file diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.WebKey.Tests/Microsoft.Azure.KeyVault.WebKey.Tests.csproj b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.WebKey.Tests/Microsoft.Azure.KeyVault.WebKey.Tests.csproj index 5a35bcecd474..1b7868ec68f3 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.WebKey.Tests/Microsoft.Azure.KeyVault.WebKey.Tests.csproj +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.WebKey.Tests/Microsoft.Azure.KeyVault.WebKey.Tests.csproj @@ -3,7 +3,7 @@ Microsoft.Azure.KeyVault.WebKey.Tests Microsoft.Azure.KeyVault.WebKey.Tests Class Library - 2.0.2 + 2.1.0 Microsoft.Azure.KeyVault.WebKey.Tests diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.WebKey.Tests/WebKeyEcValidationTest.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.WebKey.Tests/WebKeyEcValidationTest.cs new file mode 100644 index 000000000000..f736be6ba525 --- /dev/null +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.WebKey.Tests/WebKeyEcValidationTest.cs @@ -0,0 +1,274 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. + +using System; +using System.Security.Cryptography; +using System.Text; +using Newtonsoft.Json; +using Xunit; + +namespace Microsoft.Azure.KeyVault.WebKey.Tests +{ + public static class WebKeyEcValidationTest + { + private static readonly string P256TestKey = "{\"kty\":\"EC\",\"key_ops\":[\"sign\",\"verify\"],\"crv\":\"P-256\",\"x\":\"IzSTOwCKbS-BEdPwVT0xGnW18zzgyG7CwnMDKLULyQo\",\"y\":\"K7m-pJxgWIjHGHMF5IZpWLasH6TizES9eidg--wQkSE\",\"d\":\"9hY6iHNcR-IuyacHOelfiCvjRWyfOscFVL05zJM4Ne4\"}"; + private static readonly string P384TestKey = "{\"kty\":\"EC\",\"key_ops\":[\"sign\",\"verify\"],\"crv\":\"P-384\",\"x\":\"5XN86Y1xhKo1GuohlWzcvoJmZs36USIFopOU1wha6qbtZzM2C1OK01lh8DJYwQsi\",\"y\":\"ZsI5YcBKzo-0d5lS3106nYPshOi9LcCecNJebIina6fw7Ab7TD3f3fhNxEaAE6ja\",\"d\":\"6g0maM_o7vcYWJzPMwqE3l0v2vsyjWtOsvRyAch44aZLg9IGaVEUu6Ol718ICyWX\"}"; + private static readonly string P521TestKey = "{\"kty\":\"EC\",\"key_ops\":[\"sign\",\"verify\"],\"crv\":\"P-521\",\"x\":\"ASggRFEA2L_FxGjnU5FNplPHBi8tU0e2L89ZWro4ZpDYvBvel0gjao_S23fuNFlhufLp5kePdGbqujy45wHKMjMR\",\"y\":\"AFDVBsQZN2V1lox2kMCmqWL5Kn4f3X0mtqnBLWgPlOSl6l-tMDHj8gcLnMGJZNarCKVGVrdjhmK9BpbYy0Q8Omnm\",\"d\":\"AJC_2pp8DO_LxfFuC7yMfd7TGD51f8ydJgHy-Tf-37NBToBjGPo6njEcrppW1QSVWTMJpjfVWJb6x24YZQ73PP04\"}"; + private static readonly string Secp256k1TestKey = "{\"kty\":\"EC\",\"key_ops\":[\"sign\",\"verify\"],\"crv\":\"SECP256K1\",\"x\":\"yBMUvQwthIjbdvYUC2DDDs6I45dqG0B1GQ3-Eg5RxXM\",\"y\":\"KGf5oIzA7QNhZ8gXP8LSQfZKSMsGrmcUphyWpD2ingg\",\"d\":\"qmWUH9HNAAYzeNrVYbtoVlrnbiRIa2jDZW5YJh7OoUs\"}"; + + [Fact] + public static void HardCodedKeysMustWork() + { + if ( !IsCngSupported() ) + return; + + DoHardCodedKeyTests( P256TestKey, JsonWebKeyCurveName.P256, 256, 32 ); + DoHardCodedKeyTests( P384TestKey, JsonWebKeyCurveName.P384, 384, 48 ); + DoHardCodedKeyTests( P521TestKey, JsonWebKeyCurveName.P521, 521, 64 ); + DoHardCodedKeyTests( Secp256k1TestKey, JsonWebKeyCurveName.SECP256K1, 256, 32 ); + } + + private static void DoHardCodedKeyTests( string json, string curve, int keySize, int digestSize ) + { + var jwk = DoSerializationTests( json, curve, keySize ); + DoECDsaTests( jwk, digestSize ); + } + + [Fact] + public static void RandomKeysMustWork() + { + if ( !IsCngSupported() ) + return; + + DoRamdomKeyTest( JsonWebKeyCurveName.P256, 256, 32 ); + DoRamdomKeyTest( JsonWebKeyCurveName.P384, 384, 48 ); + DoRamdomKeyTest( JsonWebKeyCurveName.P521, 521, 64 ); + DoRamdomKeyTest( JsonWebKeyCurveName.SECP256K1, 256, 32 ); + } + + private static void DoRamdomKeyTest( string curve, int keySize, int digestSize ) + { + var ecdsa = CreateRandomKey( curve ); + + // The constructor must accept a random key. + var jwk = new JsonWebKey( ecdsa, true ); + VerifyAttributes( jwk, curve, keySize, true ); + + var ecdsa2 = jwk.ToECDsa( true ); + Assert.True( ecdsa2.KeySize == keySize, $"Expected key size to be {keySize}, but found {ecdsa2.KeySize}" ); + + // This call insures JsonWebKey is not using dummy or constant-result methods. + DoSignVerifyTests( digestSize, ecdsa, jwk.ToECDsa() ); + + // Do normal tests. + DoSerializationTests( JsonConvert.SerializeObject( jwk ), curve, keySize ); + DoECDsaTests( jwk, digestSize ); + } + + private static ECDsa CreateRandomKey( string curve ) + { + CngAlgorithm algo; + switch ( curve ) + { + case JsonWebKeyCurveName.P256: + algo = CngAlgorithm.ECDsaP256; + break; + + case JsonWebKeyCurveName.P384: + algo = CngAlgorithm.ECDsaP384; + break; + + case JsonWebKeyCurveName.P521: + algo = CngAlgorithm.ECDsaP521; + break; + + case JsonWebKeyCurveName.SECP256K1: + algo = new CngAlgorithm( "ECDSA" ); + break; + + default: + throw new NotImplementedException( $"Curve tests not implemented: {curve}" ); + } + + var kcp = new CngKeyCreationParameters + { + ExportPolicy = CngExportPolicies.AllowPlaintextExport, + KeyUsage = CngKeyUsages.Signing, + }; + + if ( curve == JsonWebKeyCurveName.SECP256K1 ) + kcp.Parameters.Add( new CngProperty( "ECCCurveName", Encoding.Unicode.GetBytes( "secP256k1\0" ), CngPropertyOptions.None ) ); + + return new ECDsaCng( CngKey.Create( algo, null, kcp ) ); + } + + private static JsonWebKey DoSerializationTests( string json, string curve, int keySize ) + { + var jwk = JsonConvert.DeserializeObject( json ); + VerifyAttributes( jwk, curve, keySize, true ); + + // Serialization round-trip. + var json2 = JsonConvert.SerializeObject( jwk ); + Assert.True( json2 == json, $"Expected: {json}\r\nFound: {json2}" ); + + var jwk2 = JsonConvert.DeserializeObject( json ); + + // Equals method. + Assert.True( jwk.Equals( jwk2 ) ); + + // Equals must consider curve. + jwk2.CurveName = null; + Assert.False( jwk.Equals( jwk2 ) ); + jwk2.CurveName = jwk.CurveName; + + // Equals must consider X. + jwk2.X = null; + Assert.False( jwk.Equals( jwk2 ) ); + jwk2.X = (byte[]) jwk.X.Clone(); + + // Equals must consider Y. + jwk2.Y = null; + Assert.False( jwk.Equals( jwk2 ) ); + jwk2.Y = (byte[]) jwk.Y.Clone(); + + // Equals must consider D. + jwk2.D = null; + Assert.False( jwk.Equals( jwk2 ) ); + jwk2.D = (byte[]) jwk.D.Clone(); + + return jwk; + } + + private static void DoECDsaTests( JsonWebKey jwk, int digestSize ) + { + var privateEcdsa = jwk.ToECDsa( true ); + var publicEcdsa = jwk.ToECDsa(); + + // Round-trip with private Ecdsa. + var jwk2 = new JsonWebKey( privateEcdsa ); + var publicEcdsa2 = jwk2.ToECDsa(); + + DoSignVerifyTests( digestSize, privateEcdsa, publicEcdsa2 ); + + // Round-trip with public Ecdsa. + jwk2 = new JsonWebKey( publicEcdsa ); + publicEcdsa2 = jwk2.ToECDsa(); + + DoSignVerifyTests( digestSize, privateEcdsa, publicEcdsa2 ); + } + + private static void DoSignVerifyTests( int digestSize, ECDsa privateEcdsa, ECDsa publicEcdsa ) + { + // Create pseudo-random hash. + var rnd = new Random( 0 ); + var digest = new byte[digestSize]; + rnd.NextBytes( digest ); + + bool verified; + + // Check if private key can sign digest. + var signature = privateEcdsa.SignHash( digest ); + + // Check if private key can verify digest. + verified = privateEcdsa.VerifyHash( digest, signature ); + Assert.True( verified ); + + // Check if public key can verify digest. + verified = publicEcdsa.VerifyHash( digest, signature ); + Assert.True( verified ); + + signature[signature.Length - 1] ^= 1; + + // Check if private key can deny invalid digest. + verified = privateEcdsa.VerifyHash( digest, signature ); + Assert.False( verified ); + + // Check if public key can deny invalid digest. + verified = publicEcdsa.VerifyHash( digest, signature ); + Assert.False( verified ); + } + + [Fact] + public static void PrivateKeyMustBeProtected() + { + if ( !IsCngSupported() ) + return; + + DoPrivateKeyMustBeProtectedTests( P256TestKey, 32 ); + DoPrivateKeyMustBeProtectedTests( Secp256k1TestKey, 32 ); + } + + private static void DoPrivateKeyMustBeProtectedTests( string json, int digestSize ) + { + // Create pseudo-random hash. + var rnd = new Random( 0 ); + var digest = new byte[digestSize]; + rnd.NextBytes( digest ); + + // Get the key. + var jwk = JsonConvert.DeserializeObject( json ); + var privateEcdsa = jwk.ToECDsa( true ); + + // Exporting ECDsa must not include private key. + var ecdsa = jwk.ToECDsa(); + Assert.ThrowsAny( () => ecdsa.SignHash( digest ) ); + + // Exporting ECParameters must not include private key. + var ecParams = jwk.ToEcParameters(); + Assert.Null( ecParams.D ); + + // Importing ECDsa with private key must not include private key. + var jwk2 = new JsonWebKey( privateEcdsa ); + Assert.Null( jwk2.D ); + + // Importing ECParameters without private key must work. + ecParams.D = null; + jwk2 = new JsonWebKey( ecParams ); + jwk2.ToECDsa(); + + jwk.D = null; + + // Exporting ECDsa when WebKey lacks private key, must work. + var publicEcdsa = jwk.ToECDsa(); + DoSignVerifyTests( digestSize, privateEcdsa, publicEcdsa ); + + // Exporting ECDsa demanding private key when WebKey lacks private key, must throw exception. + Assert.Throws( () => jwk.ToECDsa( true ) ); + + // Exporting ECParameters demanding private key when WebKey lacks private key, must throw exception. + Assert.Throws( () => jwk.ToEcParameters( true ) ); + } + + private static void VerifyAttributes( JsonWebKey jwk, string curve, int keySize, bool expectPrivateKey ) + { + var keySizeInBytes = ( keySize + 7 ) / 8; + Assert.Equal( JsonWebKeyType.EllipticCurve, jwk.Kty ); + Assert.Equal( curve, jwk.CurveName ); + Assert.Equal( keySizeInBytes, jwk.X.Length ); + Assert.Equal( keySizeInBytes, jwk.Y.Length ); + if ( expectPrivateKey ) + Assert.Equal( keySizeInBytes, jwk.D.Length ); + var operations = new[] {JsonWebKeyOperation.Sign, JsonWebKeyOperation.Verify}; + Assert.Equal( operations, jwk.KeyOps ); + } + + /// + /// Insures Windows CNG (NCrypt) is supported on this platform. + /// + /// For instance, CNG is not supported on Linux. + private static bool IsCngSupported() + { + try + { + var key = CreateRandomKey( JsonWebKeyCurveName.P256 ); + key.Dispose(); + return true; + } + catch ( PlatformNotSupportedException ) + { + return false; + } + } + } +} \ No newline at end of file diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.WebKey.Tests/WebKeyHsmRsaValidationTest.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.WebKey.Tests/WebKeyHsmRsaValidationTest.cs index b5a7c6d75d17..6897fd12d2c2 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.WebKey.Tests/WebKeyHsmRsaValidationTest.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.WebKey.Tests/WebKeyHsmRsaValidationTest.cs @@ -4,11 +4,6 @@ // using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Security.Cryptography; using Xunit; namespace Microsoft.Azure.KeyVault.WebKey.Tests @@ -16,7 +11,7 @@ namespace Microsoft.Azure.KeyVault.WebKey.Tests public class WebKeyHsmRsaValidationTest { string keyWithoutT = "{\"kid\":\"key_id\",\"kty\":\"RSA-HSM\",\"key_ops\":[\"encrypt\",\"decrypt\"],\"n\":\"1_6ZtP288hEkKML-L6nFyZh1PD1rmAgwbbwjEvTSDK_008BYWhjp_6ULy9BhWtRIytNkPkm9gzaBTrCpp-vyDXPGa836Htp-w8u5JmxoUZchJh576m3m-8ZYWTmZSAp5SpruyKAmLSxPJHEWPXQntnmuTMjb9HBT9Ltrwc0ZDk-jsMLYunDJrNmrRUxQgb0zQ_Tl5fJjj8j-0KVx2RXtbfWFvf5fRdBYyP3m0aUpoopQPwtXszD2LcSKMJ_TnmnvMWr8MOA5aRlBaGdBk7zBgRafvDPam3Q2AvFA9mfcAVncpfZ3JFm73VARw6MofXtRqOHtZ7y4oNbY95xXwU2r6w\",\"e\":\"AQAB\"}"; - string keyWithT = "{\"kid\":\"key_id\",\"kty\":\"RSA-HSM\",\"key_ops\":[\"encrypt\",\"decrypt\"],\"key_hsm\":\"T-TOKEN\"}"; + string keyWithT = "{\"kid\":\"key_id\",\"kty\":\"RSA-HSM\",\"key_ops\":[\"encrypt\",\"decrypt\"],\"n\":\"1_6ZtP288hEkKML-L6nFyZh1PD1rmAgwbbwjEvTSDK_008BYWhjp_6ULy9BhWtRIytNkPkm9gzaBTrCpp-vyDXPGa836Htp-w8u5JmxoUZchJh576m3m-8ZYWTmZSAp5SpruyKAmLSxPJHEWPXQntnmuTMjb9HBT9Ltrwc0ZDk-jsMLYunDJrNmrRUxQgb0zQ_Tl5fJjj8j-0KVx2RXtbfWFvf5fRdBYyP3m0aUpoopQPwtXszD2LcSKMJ_TnmnvMWr8MOA5aRlBaGdBk7zBgRafvDPam3Q2AvFA9mfcAVncpfZ3JFm73VARw6MofXtRqOHtZ7y4oNbY95xXwU2r6w\",\"e\":\"AQAB\",\"key_hsm\":\"T-TOKEN\"}"; [Fact] public void RsaHsmValidation() @@ -24,7 +19,7 @@ public void RsaHsmValidation() var keyNoT = JsonConvert.DeserializeObject(keyWithoutT); var keyT = JsonConvert.DeserializeObject(keyWithT); - Assert.True(keyNoT.IsValid()); + Assert.True(!keyNoT.IsValid()); Assert.False(keyNoT.HasPrivateKey()); Assert.True(keyT.IsValid()); diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.WebKey.Tests/WebKeyOperationsTest.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.WebKey.Tests/WebKeyOperationsTest.cs index 7f99d813f23d..df7d139b8d56 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.WebKey.Tests/WebKeyOperationsTest.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.WebKey.Tests/WebKeyOperationsTest.cs @@ -62,6 +62,8 @@ private static void CheckInstance(object key, string kty) switch (kty) { case JsonWebKeyType.Octet: + case JsonWebKeyType.EllipticCurve: + case JsonWebKeyType.EllipticCurveHsm: case JsonWebKeyType.Rsa: case JsonWebKeyType.RsaHsm: // Supported types must have ClearMemory() implemented. diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.WebKey.Tests/WebKeyRsaValidationTest.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.WebKey.Tests/WebKeyRsaValidationTest.cs index 29e8d8d9d7d8..7efc7a5550f6 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.WebKey.Tests/WebKeyRsaValidationTest.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.WebKey.Tests/WebKeyRsaValidationTest.cs @@ -27,7 +27,7 @@ private static byte[] Decrypt( RSA key, byte[] cipherText ) { byte[] plainText = null; -#if NET452 +#if FullNetFx if ( key is RSACryptoServiceProvider ) { plainText = ( ( RSACryptoServiceProvider )key ).Decrypt( cipherText, true ); @@ -52,7 +52,7 @@ private static byte[] Encrypt( RSA key ) { byte[] cipherText = null; -#if NET452 +#if FullNetFx if ( key is RSACryptoServiceProvider ) { cipherText = ( ( RSACryptoServiceProvider )key ).Encrypt( _plainText, true ); @@ -184,56 +184,6 @@ private static void PadParameter( JsonWebKey key, string paramName, int targetLe SetParameter( key, paramName, padded ); } - [Fact(Skip = "Fails on NETCore on differnt platforms. The reason is still unknown, but likely a test bug.")] - public void ExcessBitMustThrowException() - { - foreach ( var ordinary in GetOrdinaryTestKeys().Values ) - { - foreach ( var paramName in _rsaFields ) - { - var excessBitKey = JsonConvert.DeserializeObject( ordinary ); - AddExcessBitOnParameter( excessBitKey, paramName ); - if ( paramName == "E" || paramName == "N" ) - KeyMustThrowCryptoException( paramName, excessBitKey ); - else - ExcessBitMustThrowInvalidLength( paramName, excessBitKey ); - } - } - } - - private static void AddExcessBitOnParameter( JsonWebKey key, string paramName ) - { - var data = GetParameter( key, paramName ); - int excessLen; - if ( paramName == "E" || paramName == "N" ) - excessLen = 1 + data.Length; - else - excessLen = 1 + GetRequiredLen( data.Length ); - var excess = new byte[excessLen]; - Array.Copy( data, 0, excess, excessLen - data.Length, data.Length ); - excess[0] = 1; - SetParameter( key, paramName, excess ); - } - - private static void ExcessBitMustThrowInvalidLength( string paramName, JsonWebKey excessBitKey ) - { - try - { - // We sill must be able to serialize and de-serialize - var serialized = excessBitKey.ToString(); - JsonConvert.DeserializeObject( serialized ); - - KeyMustThrowInvalidLength( excessBitKey ); - - // Test only public parameters, which should work. - KeyMustWork( excessBitKey ); - } - catch ( Exception ex ) - { - throw new Exception( "Key with extra bit on \"" + paramName + "\" didn't produce expected result", ex ); - } - } - private static int GetRequiredLen( int len ) { var requiredLen = len; @@ -343,69 +293,6 @@ private static void KeysMustBeCompatible( JsonWebKey publicKey, JsonWebKey priva } } - private static void KeyMustThrowCryptoException( string paramName, JsonWebKey badKey ) - { - // We sill must be able to serialize... - var serialized = badKey.ToString(); - // ...and deserialize - var deserialized = JsonConvert.DeserializeObject( serialized ); - Assert.Equal( badKey, deserialized ); - - try - { - KeyMustThrowCryptoException( badKey ); - } - catch ( Exception ex ) - { - throw new Exception( "Key with extra bit on \"" + paramName + "\" didn't produce expected result", ex ); - } - } - - private static void KeyMustThrowCryptoException( JsonWebKey badKey ) - { - RSA rsa; - try - { - rsa = badKey.ToRSA( true ); - //throw new Exception( "ToRSA(true) didn't throw exception." ); - } - catch ( CryptographicException ) - { - return; - } - - // Perform encrypt and decrypt with the key - EncryptDecrypt( rsa ); - } - - private static void KeyMustThrowInvalidLength( JsonWebKey excessBitKey ) - { - try - { - excessBitKey.ToRSAParameters( true ); - throw new Exception( "ToRSAParameters should throw exception." ); - } - catch ( ArgumentException e ) - { - ValidateInvalidLength( e ); - } - - try - { - excessBitKey.ToRSA( true ); - throw new Exception( "ToRSA should throw exception." ); - } - catch ( ArgumentException e ) - { - ValidateInvalidLength( e ); - } - } - - private static void ValidateInvalidLength( ArgumentException e ) - { - Assert.True( e.Message.ToLowerInvariant().Contains( "invalid length" ), "Unexpected error message: " + e.Message ); - } - public static void EmitTestData( int keySize ) { EmitOrdinary( keySize ); diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.WebKey/ECParameters.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.WebKey/ECParameters.cs new file mode 100644 index 000000000000..ebd408c5e96a --- /dev/null +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.WebKey/ECParameters.cs @@ -0,0 +1,528 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. + +using System; +using System.IO; +using System.Security.Cryptography; +using System.Text; + +namespace Microsoft.Azure.KeyVault.WebKey +{ + /// + /// EC parameters class. + /// + public class ECParameters + { + /// + /// Name of this curve. + /// + public string Curve { get; set; } + + /// + /// X coordinate for the Elliptic Curve point. + /// + public byte[] X { get; set; } + + /// + /// Y coordinate for the Elliptic Curve point. + /// + public byte[] Y { get; set; } + + /// + /// ECC private key. + /// + public byte[] D { get; set; } + + internal ECDsaCng ToEcdsa( bool includePrivateParameters ) + { + switch ( Curve ) + { + case JsonWebKeyCurveName.P256: + return ToNistCurveEcdsa( includePrivateParameters ? BCRYPT_ECDSA_PRIVATE_P256_MAGIC : BCRYPT_ECDSA_PUBLIC_P256_MAGIC, 32, includePrivateParameters ); + + case JsonWebKeyCurveName.P384: + return ToNistCurveEcdsa( includePrivateParameters ? BCRYPT_ECDSA_PRIVATE_P384_MAGIC : BCRYPT_ECDSA_PUBLIC_P384_MAGIC, 48, includePrivateParameters ); + + case JsonWebKeyCurveName.P521: + return ToNistCurveEcdsa( includePrivateParameters ? BCRYPT_ECDSA_PRIVATE_P521_MAGIC : BCRYPT_ECDSA_PUBLIC_P521_MAGIC, 66, includePrivateParameters ); + + case JsonWebKeyCurveName.SECP256K1: + return ToGenericCurveEcdsa( includePrivateParameters ? BCRYPT_ECDSA_PRIVATE_GENERIC_MAGIC : BCRYPT_ECDSA_PUBLIC_GENERIC_MAGIC, Secp256k1, includePrivateParameters ); + + default: + var curveDesc = Curve == null ? "null" : $"\"{Curve}\""; + throw new InvalidOperationException( $"Invalid curve: {curveDesc}" ); + } + } + + private ECDsaCng ToNistCurveEcdsa( int dwMagic, int sizeInBytes, bool includePrivateParameters ) + { + const int sizeOfdwMagic = sizeof( uint ); + const int sizeOfdwSize = sizeof( uint ); + var sizeOfX = sizeInBytes; + var sizeOfY = sizeInBytes; + var sizeOfD = includePrivateParameters ? sizeInBytes : 0; + + var keyBlob = new byte[sizeOfdwMagic + sizeOfdwSize + sizeOfX + sizeOfY + sizeOfD]; + + using ( var writer = new BinaryWriter( new MemoryStream( keyBlob ) ) ) + { + writer.Write( dwMagic ); + writer.Write( sizeInBytes ); + AlignAndWrite( writer, X, sizeInBytes, nameof( X ) ); + AlignAndWrite( writer, Y, sizeInBytes, nameof( Y ) ); + if ( includePrivateParameters ) + AlignAndWrite( writer, D, sizeInBytes, nameof( D ) ); + } + + var key = CngKey.Import( keyBlob, includePrivateParameters ? CngKeyBlobFormat.EccPrivateBlob : CngKeyBlobFormat.EccPublicBlob ); + return new ECDsaCng( key ); + } + + private ECDsaCng ToGenericCurveEcdsa( int dwMagic, BCRYPT_ECC_PARAMETER_HEADER curveParameters, bool includePrivateParameters ) + { + var sizeInBytes = curveParameters.KeySizeInBytes; + var keyBlob = new byte[curveParameters.KeyBlobSize]; + + using ( var writer = new BinaryWriter( new MemoryStream( keyBlob ) ) ) + { + writer.Write( dwMagic ); + curveParameters.WriteTo( writer ); + + AlignAndWrite( writer, X, sizeInBytes, nameof( X ) ); + AlignAndWrite( writer, Y, sizeInBytes, nameof( Y ) ); + if ( includePrivateParameters ) + AlignAndWrite( writer, D, sizeInBytes, nameof( D ) ); + } + + var key = CngKey.Import( keyBlob, includePrivateParameters ? CngKeyBlobFormat_EccFullPrivateBlob : CngKeyBlobFormat_EccFullPublicBlob ); + return new ECDsaCng( key ); + } + + private static void AlignAndWrite( BinaryWriter writer, byte[] bytes, int size, string paramName ) + { + if ( bytes == null ) + throw new ArgumentException( $"Value of {paramName} is null." ); + + if ( bytes.Length >= size ) + { + for ( var i = 0; i < bytes.Length - size; ++i ) + if ( bytes[i] != 0 ) + throw new ArgumentException( $"Value of {paramName} is bigger than allowed for this curve." ); + + writer.Write( bytes, bytes.Length - size, size ); + return; + } + + for ( var i = bytes.Length; i < size; ++i ) + writer.Write( (byte) 0 ); + + writer.Write( bytes ); + } + + internal static ECParameters FromEcdsa( ECDsaCng ecdsa, bool includePrivateParameters ) + { + if ( ecdsa == null ) + throw new ArgumentNullException( nameof( ecdsa ) ); + + var keyBlobFormat = includePrivateParameters ? CngKeyBlobFormat.EccPrivateBlob : CngKeyBlobFormat.EccPublicBlob; + var keyBlob = ecdsa.Key.Export( keyBlobFormat ); + + // If curve is generic, we need to export again to get the full blob. + var dwMagic = BitConverter.ToInt32( keyBlob, 0 ); + switch ( dwMagic ) + { + case BCRYPT_ECDSA_PUBLIC_GENERIC_MAGIC: + keyBlob = ecdsa.Key.Export( CngKeyBlobFormat_EccFullPublicBlob ); + break; + case BCRYPT_ECDSA_PRIVATE_GENERIC_MAGIC: + keyBlob = ecdsa.Key.Export( CngKeyBlobFormat_EccFullPrivateBlob ); + break; + } + + var result = new ECParameters(); + using ( var reader = new BinaryReader( new MemoryStream( keyBlob ) ) ) + { + dwMagic = reader.ReadInt32(); + switch ( dwMagic ) + { + case BCRYPT_ECDSA_PUBLIC_P256_MAGIC: + ThrowIfPrivateParametersNeeded( includePrivateParameters, BCRYPT_ECDSA_PRIVATE_P256_MAGIC, dwMagic ); + ReadNistBlob( reader, 32, result, false ); + result.Curve = JsonWebKeyCurveName.P256; + break; + + case BCRYPT_ECDSA_PRIVATE_P256_MAGIC: + ReadNistBlob( reader, 32, result, true ); + result.Curve = JsonWebKeyCurveName.P256; + break; + + case BCRYPT_ECDSA_PUBLIC_P384_MAGIC: + ThrowIfPrivateParametersNeeded( includePrivateParameters, BCRYPT_ECDSA_PRIVATE_P384_MAGIC, dwMagic ); + ReadNistBlob( reader, 48, result, false ); + result.Curve = JsonWebKeyCurveName.P384; + break; + + case BCRYPT_ECDSA_PRIVATE_P384_MAGIC: + ReadNistBlob( reader, 48, result, true ); + result.Curve = JsonWebKeyCurveName.P384; + break; + + case BCRYPT_ECDSA_PUBLIC_P521_MAGIC: + ThrowIfPrivateParametersNeeded( includePrivateParameters, BCRYPT_ECDSA_PRIVATE_P521_MAGIC, dwMagic ); + ReadNistBlob( reader, 66, result, false ); + result.Curve = JsonWebKeyCurveName.P521; + break; + + case BCRYPT_ECDSA_PRIVATE_P521_MAGIC: + ReadNistBlob( reader, 66, result, true ); + result.Curve = JsonWebKeyCurveName.P521; + break; + + case BCRYPT_ECDSA_PUBLIC_GENERIC_MAGIC: + ThrowIfPrivateParametersNeeded( includePrivateParameters, BCRYPT_ECDSA_PRIVATE_GENERIC_MAGIC, dwMagic ); + ReadGenericBlob( reader, 32, result, false ); + break; + + case BCRYPT_ECDSA_PRIVATE_GENERIC_MAGIC: + ReadGenericBlob( reader, 32, result, true ); + break; + + default: + throw new NotSupportedException( $"Unexpected CNG key blob type. Magic number: 0x{dwMagic:X}." ); + } + } + + return result; + } + + private static void ThrowIfPrivateParametersNeeded( bool privateParametersNeeded, int expectedMagic, int actualMagic ) + { + if ( privateParametersNeeded ) + throw new InvalidOperationException( $"CNG returned key blob without private parameters. Expected magic: 0x{expectedMagic:X}, Actual magic: 0x{actualMagic:X}" ); + } + + private static void ReadNistBlob( BinaryReader reader, int expectedSize, ECParameters dest, bool includePrivateParameters ) + { + var size = reader.ReadInt32(); + dest.X = ValidateSize( reader.ReadBytes( size ), expectedSize, nameof( dest.X ) ); + dest.Y = ValidateSize( reader.ReadBytes( size ), expectedSize, nameof( dest.Y ) ); + if ( includePrivateParameters ) + dest.D = ValidateSize( reader.ReadBytes( size ), expectedSize, nameof( dest.D ) ); + } + + private static void ReadGenericBlob( BinaryReader reader, int expectedSize, ECParameters dest, bool includePrivateParameters ) + { + /* struct BCRYPT_ECCFULLKEY_BLOB + { + ULONG dwMagic; // BCRYPT_ECDSA_PUBLIC_GENERIC_MAGIC or BCRYPT_ECDSA_PRIVATE_GENERIC_MAGIC + BCRYPT_ECC_PARAMETER_HEADER curveParameters; + BYTE Qx[cbFieldLength] // X-coordinate of the public point. + BYTE Qy[cbFieldLength] // Y-coordinate of the public point. + BYTE d[cbSubgroupOrder] // Private key. Zero if only public key is required. + } + */ + + // The magic was read before. + + var curve = new BCRYPT_ECC_PARAMETER_HEADER(); + curve.ReadFrom( reader ); + + if ( !curve.Equals( Secp256k1 ) ) + throw new NotSupportedException( $"Unsupported curve: {curve}" ); + + dest.Curve = JsonWebKeyCurveName.SECP256K1; + + var cbFieldLength = curve.Prime.Length; + dest.X = ValidateSize( reader.ReadBytes( cbFieldLength ), expectedSize, nameof( dest.X ) ); + dest.Y = ValidateSize( reader.ReadBytes( cbFieldLength ), expectedSize, nameof( dest.Y ) ); + if ( includePrivateParameters ) + dest.D = ValidateSize( reader.ReadBytes( cbFieldLength ), expectedSize, nameof( dest.D ) ); + } + + private static BCRYPT_ECC_PARAMETER_HEADER _secp256k1; + + private static BCRYPT_ECC_PARAMETER_HEADER Secp256k1 + { + get + { + if ( _secp256k1 != null ) + return _secp256k1; + + return _secp256k1 = new BCRYPT_ECC_PARAMETER_HEADER + { + dwVersion = 0x1, + dwCurveType = 0x1, + dwCurveGenerationAlgId = 0x0, + Prime = new byte[] {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFC, 0x2F}, + A = new byte[] {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, + B = new byte[] {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7}, + Gx = new byte[] {0x79, 0xBE, 0x66, 0x7E, 0xF9, 0xDC, 0xBB, 0xAC, 0x55, 0xA0, 0x62, 0x95, 0xCE, 0x87, 0xB, 0x7, 0x2, 0x9B, 0xFC, 0xDB, 0x2D, 0xCE, 0x28, 0xD9, 0x59, 0xF2, 0x81, 0x5B, 0x16, 0xF8, 0x17, 0x98}, + Gy = new byte[] {0x48, 0x3A, 0xDA, 0x77, 0x26, 0xA3, 0xC4, 0x65, 0x5D, 0xA4, 0xFB, 0xFC, 0xE, 0x11, 0x8, 0xA8, 0xFD, 0x17, 0xB4, 0x48, 0xA6, 0x85, 0x54, 0x19, 0x9C, 0x47, 0xD0, 0x8F, 0xFB, 0x10, 0xD4, 0xB8}, + Order = new byte[] {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xBA, 0xAE, 0xDC, 0xE6, 0xAF, 0x48, 0xA0, 0x3B, 0xBF, 0xD2, 0x5E, 0x8C, 0xD0, 0x36, 0x41, 0x41}, + Cofactor = new byte[] {0x1}, + Seed = new byte[] { }, + }; + } + } + + private static byte[] ValidateSize( byte[] bytes, int expectedSize, string fieldName ) + { + if ( bytes.Length > expectedSize ) + for ( var i = 0; i < bytes.Length - expectedSize; ++i ) + if ( bytes[i] != 0 ) + throw new InvalidOperationException( $"Key parameter {fieldName} is larger than expected." ); + return bytes; + } + + internal const int BCRYPT_ECDSA_PUBLIC_P256_MAGIC = 0x31534345; + internal const int BCRYPT_ECDSA_PRIVATE_P256_MAGIC = 0x32534345; + internal const int BCRYPT_ECDSA_PUBLIC_P384_MAGIC = 0x33534345; + internal const int BCRYPT_ECDSA_PRIVATE_P384_MAGIC = 0x34534345; + internal const int BCRYPT_ECDSA_PUBLIC_P521_MAGIC = 0x35534345; + internal const int BCRYPT_ECDSA_PRIVATE_P521_MAGIC = 0x36534345; + internal const int BCRYPT_ECDSA_PUBLIC_GENERIC_MAGIC = 0x50444345; + internal const int BCRYPT_ECDSA_PRIVATE_GENERIC_MAGIC = 0x56444345; + + internal const string BCRYPT_ECCFULLPUBLIC_BLOB = "ECCFULLPUBLICBLOB"; + internal const string BCRYPT_ECCFULLPRIVATE_BLOB = "ECCFULLPRIVATEBLOB"; + + private static readonly CngKeyBlobFormat CngKeyBlobFormat_EccFullPublicBlob = new CngKeyBlobFormat( BCRYPT_ECCFULLPUBLIC_BLOB ); + private static readonly CngKeyBlobFormat CngKeyBlobFormat_EccFullPrivateBlob = new CngKeyBlobFormat( BCRYPT_ECCFULLPRIVATE_BLOB ); + } + + internal sealed class BCRYPT_ECC_PARAMETER_HEADER + { + internal const int BCRYPT_ECC_PRIME_SHORT_WEIERSTRASS_CURVE = 0x1; + internal const int BCRYPT_ECC_PRIME_TWISTED_EDWARDS_CURVE = 0x2; + internal const int BCRYPT_ECC_PRIME_MONTGOMERY_CURVE = 0x3; + + internal const int BCRYPT_NO_CURVE_GENERATION_ALG_ID = 0x0; + + public int dwVersion; + public int dwCurveType; + public int dwCurveGenerationAlgId; + public byte[] Prime; + public byte[] A; + public byte[] B; + public byte[] Gx; + public byte[] Gy; + public byte[] Order; + public byte[] Cofactor; + public byte[] Seed; + + public int KeySizeInBytes => Prime.Length; + + public int CurveBlobSize + { + get + { + var cbFieldLength = Prime.Length; + var cbSubgroupOrder = Order.Length; + var cbCofactor = Cofactor.Length; + var cbSeed = Seed.Length; + + var size = 7 * sizeof( uint ) + 5 * cbFieldLength + cbSubgroupOrder + cbCofactor + cbSeed; + + return size; + } + } + + public int KeyBlobSize + { + get + { + var cbFieldLength = Prime.Length; + var size = sizeof( uint ) + CurveBlobSize + 3 * cbFieldLength; + return size; + } + } + + public override string ToString() + { + var sb = new StringBuilder(); + sb.AppendLine( "{" ); + sb.AppendLine( $" {nameof( dwVersion )} = 0x{dwVersion:X}," ); + sb.AppendLine( $" {nameof( dwCurveType )} = 0x{dwCurveType:X}," ); + sb.AppendLine( $" {nameof( dwCurveGenerationAlgId )} = 0x{dwCurveGenerationAlgId:X}," ); + sb.AppendLine( $" {nameof( Prime )} = {GetBytesDesc( Prime )}," ); + sb.AppendLine( $" {nameof( A )} = {GetBytesDesc( A )}," ); + sb.AppendLine( $" {nameof( B )} = {GetBytesDesc( B )}," ); + sb.AppendLine( $" {nameof( Gx )} = {GetBytesDesc( Gx )}," ); + sb.AppendLine( $" {nameof( Gy )} = {GetBytesDesc( Gy )}," ); + sb.AppendLine( $" {nameof( Order )} = {GetBytesDesc( Order )}," ); + sb.AppendLine( $" {nameof( Cofactor )} = {GetBytesDesc( Cofactor )}," ); + sb.AppendLine( $" {nameof( Seed )} = {GetBytesDesc( Seed )}," ); + sb.AppendLine( "}" ); + return sb.ToString(); + } + + private static string GetBytesDesc( byte[] bytes ) + { + if ( bytes == null ) + return "null"; + + var sb = new StringBuilder(); + sb.Append( "new byte[] { " ); + for ( var i = 0; i < bytes.Length; ++i ) + { + if ( i > 0 ) + sb.Append( ", " ); + sb.Append( "0x" ).Append( bytes[i].ToString( "X" ) ); + } + sb.Append( " }" ); + + return sb.ToString(); + } + + public override bool Equals( object obj ) + { + if ( obj == this ) + return true; + + var other = obj as BCRYPT_ECC_PARAMETER_HEADER; + if ( other == null ) + return false; + + if ( other.dwVersion != dwVersion ) + return false; + + if ( other.dwCurveType != dwCurveType ) + return false; + + if ( other.dwCurveGenerationAlgId != dwCurveGenerationAlgId ) + return false; + + if ( !BytesEquals( other.Prime, Prime ) ) + return false; + + if ( !BytesEquals( other.A, A ) ) + return false; + + if ( !BytesEquals( other.B, B ) ) + return false; + + if ( !BytesEquals( other.Gx, Gx ) ) + return false; + + if ( !BytesEquals( other.Gy, Gy ) ) + return false; + + if ( !BytesEquals( other.Order, Order ) ) + return false; + + if ( !BytesEquals( other.Cofactor, Cofactor ) ) + return false; + if ( !BytesEquals( other.Seed, Seed ) ) + return false; + + return true; + } + + private static bool BytesEquals( byte[] a, byte[] b ) + { + if ( a == b ) + return true; + + if ( ( a == null ) != ( b == null ) ) + return false; + + if ( a.Length != b.Length ) + return false; + + for ( var i = 0; i < a.Length; ++i ) + if ( a[i] != b[i] ) + return false; + + return true; + } + + public void ReadFrom( BinaryReader reader ) + { + /* + struct BCRYPT_ECC_PARAMETER_HEADER + { + ULONG dwVersion; //Version of the structure + ECC_CURVE_TYPE_ENUM dwCurveType; //Supported curve types. + ECC_CURVE_ALG_ID_ENUM dwCurveGenerationAlgId; //For X.592 verification purposes, if we include Seed we will need to include the algorithm ID. + ULONG cbFieldLength; //Byte length of the fields P, A, B, X, Y. + ULONG cbSubgroupOrder; //Byte length of the subgroup. + ULONG cbCofactor; //Byte length of cofactor of G in E. + ULONG cbSeed; //Byte length of the seed used to generate the curve. + //P[cbFieldLength] Prime specifying the base field. + //A[cbFieldLength] Coefficient A of the equation y^2 = x^3 + A*x + B mod p + //B[cbFieldLength] Coefficient B of the equation y^2 = x^3 + A*x + B mod p + //Gx[cbFieldLength] X-coordinate of the base point. + //Gy[cbFieldLength] Y-coordinate of the base point. + //n[cbSubgroupOrder] Order of the group generated by G = (x,y) + //h[cbCofactor] Cofactor of G in E. + //S[cbSeed] Seed of the curve. + } + */ + + dwVersion = reader.ReadInt32(); + dwCurveType = reader.ReadInt32(); + dwCurveGenerationAlgId = reader.ReadInt32(); + var cbFieldLength = reader.ReadInt32(); + var cbSubgroupOrder = reader.ReadInt32(); + var cbCofactor = reader.ReadInt32(); + var cbSeed = reader.ReadInt32(); + + Prime = reader.ReadBytes( cbFieldLength ); + A = reader.ReadBytes( cbFieldLength ); + B = reader.ReadBytes( cbFieldLength ); + Gx = reader.ReadBytes( cbFieldLength ); + Gy = reader.ReadBytes( cbFieldLength ); + Order = reader.ReadBytes( cbSubgroupOrder ); + Cofactor = reader.ReadBytes( cbCofactor ); + Seed = reader.ReadBytes( cbSeed ); + } + + public void WriteTo( BinaryWriter writer ) + { + var cbFieldLength = Prime.Length; + var cbSubgroupOrder = Order.Length; + var cbCofactor = Cofactor.Length; + var cbSeed = Seed.Length; + + writer.Write( dwVersion ); + writer.Write( dwCurveType ); + writer.Write( dwCurveGenerationAlgId ); + writer.Write( cbFieldLength ); + writer.Write( cbSubgroupOrder ); + writer.Write( cbCofactor ); + writer.Write( cbSeed ); + + AlignAndWrite( writer, Prime, cbFieldLength, nameof( Prime ) ); + AlignAndWrite( writer, A, cbFieldLength, nameof( A ) ); + AlignAndWrite( writer, B, cbFieldLength, nameof( B ) ); + AlignAndWrite( writer, Gx, cbFieldLength, nameof( Gx ) ); + AlignAndWrite( writer, Gy, cbFieldLength, nameof( Gy ) ); + AlignAndWrite( writer, Order, cbSubgroupOrder, nameof( Order ) ); + AlignAndWrite( writer, Cofactor, cbCofactor, nameof( Cofactor ) ); + AlignAndWrite( writer, Seed, cbSeed, nameof( Seed ) ); + } + + private static void AlignAndWrite( BinaryWriter writer, byte[] bytes, int size, string paramName ) + { + if ( bytes == null ) + throw new ArgumentException( $"Value of {paramName} is null." ); + + if ( bytes.Length >= size ) + { + for ( var i = 0; i < bytes.Length - size; ++i ) + if ( bytes[i] != 0 ) + throw new ArgumentException( $"Value of {paramName} is bigger than allowed for this curve." ); + + writer.Write( bytes, bytes.Length - size, size ); + return; + } + + for ( var i = bytes.Length; i < size; ++i ) + writer.Write( (byte) 0 ); + + writer.Write( bytes ); + } + } +} \ No newline at end of file diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.WebKey/EccExtension.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.WebKey/EccExtension.cs new file mode 100644 index 000000000000..94c5062df62f --- /dev/null +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.WebKey/EccExtension.cs @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. + +using System; +using System.Collections.Generic; +using System.Security.Cryptography; + +namespace Microsoft.Azure.KeyVault.WebKey +{ + /// + /// Because the current version of ECC is not supporting some of the operations needed for WebKey, + /// those operations are added as ECC extension. + /// + public static class EccExtension + { + /// + /// Exports EC parameters from a CNG object. + /// + /// The CNG object initialized with desired key + /// Determines whether the private key part is to be exported. + /// + public static ECParameters ExportParameters( this ECDsa ecdsa, bool includePrivateParameters ) + { + var ecdsaCng = GetEcdsaCng( ecdsa ); + return ECParameters.FromEcdsa( ecdsaCng, includePrivateParameters ); + } + + public static string[] GetKeyOperations( this ECDsa ecdsa ) + { + var keyUsage = GetEcdsaCng( ecdsa ).Key.KeyUsage; + + if ( !_cngOperations.ContainsKey( keyUsage ) ) + throw new CryptographicException( $"Unknown key usage {keyUsage}" ); + + return (string[]) _cngOperations[keyUsage].Clone(); + } + + private static ECDsaCng GetEcdsaCng( ECDsa ecdsa ) + { + var ecdsaCng = ecdsa as ECDsaCng; + if ( ecdsaCng == null ) + throw new NotSupportedException( $"This version requires a CNG object." ); + return ecdsaCng; + } + + private static readonly Dictionary _cngOperations; + + static EccExtension() + { + _cngOperations = new Dictionary + { + {CngKeyUsages.None, new string[0]}, + {CngKeyUsages.Signing, new[] {JsonWebKeyOperation.Sign, JsonWebKeyOperation.Verify}}, + {CngKeyUsages.Decryption, new[] {JsonWebKeyOperation.Encrypt, JsonWebKeyOperation.Decrypt, JsonWebKeyOperation.Wrap, JsonWebKeyOperation.Unwrap}}, + {CngKeyUsages.AllUsages, JsonWebKeyOperation.AllOperations} + }; + } + } +} \ No newline at end of file diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.WebKey/JsonWebKey.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.WebKey/JsonWebKey.cs index bd56cf4d5278..d52f9d028eeb 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.WebKey/JsonWebKey.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.WebKey/JsonWebKey.cs @@ -4,11 +4,9 @@ // using System; -using System.Linq; -using System.Runtime.Serialization; -using Newtonsoft.Json; -using System.Security.Cryptography; using System.Collections.Generic; +using System.Security.Cryptography; +using Newtonsoft.Json; namespace Microsoft.Azure.KeyVault.WebKey { @@ -16,28 +14,38 @@ namespace Microsoft.Azure.KeyVault.WebKey /// As of http://tools.ietf.org/html/draft-ietf-jose-json-web-key-18 /// [JsonObject] - public class JsonWebKey + public sealed class JsonWebKey { // DataContract property names - internal const string Property_Kid = "kid"; - internal const string Property_Kty = "kty"; + internal const string Property_Kid = "kid"; + + internal const string Property_Kty = "kty"; internal const string Property_KeyOps = "key_ops"; // RSA Key Property Names - internal const string Property_D = "d"; + internal const string Property_D = "d"; + internal const string Property_DP = "dp"; internal const string Property_DQ = "dq"; - internal const string Property_E = "e"; + internal const string Property_E = "e"; internal const string Property_QI = "qi"; - internal const string Property_N = "n"; - internal const string Property_P = "p"; - internal const string Property_Q = "q"; + internal const string Property_N = "n"; + internal const string Property_P = "p"; + internal const string Property_Q = "q"; + + // ECC Key Property Names + internal const string Property_Crv = "crv"; + + internal const string Property_X = "x"; + + internal const string Property_Y = "y"; + // Property_D the same as RSA Key // Symmetric Key Property Names - internal const string Property_K = "k"; + internal const string Property_K = "k"; // HSM Token Property Names - internal const string Property_T = "key_hsm"; + internal const string Property_T = "key_hsm"; /// /// Key Identifier @@ -79,13 +87,6 @@ public class JsonWebKey #region RSA Private Key Parameters - /// - /// RSA private exponent - /// - [JsonProperty( DefaultValueHandling = DefaultValueHandling.Ignore, NullValueHandling = NullValueHandling.Ignore, PropertyName = Property_D, Required = Required.Default )] - [JsonConverter( typeof( Base64UrlJsonConverter ) )] - public byte[] D { get; set; } - /// /// RSA Private Key Parameter /// @@ -123,14 +124,48 @@ public class JsonWebKey #endregion + #region EC Public Key Parameters + + /// + /// The curve for Elliptic Curve Cryptography (ECC) algorithms + /// + [JsonProperty( DefaultValueHandling = DefaultValueHandling.Ignore, NullValueHandling = NullValueHandling.Ignore, PropertyName = Property_Crv, Required = Required.Default )] + public string CurveName { get; set; } + + /// + /// X coordinate for the Elliptic Curve point. + /// + [JsonProperty( DefaultValueHandling = DefaultValueHandling.Ignore, NullValueHandling = NullValueHandling.Ignore, PropertyName = Property_X, Required = Required.Default )] + [JsonConverter( typeof( Base64UrlJsonConverter ) )] + public byte[] X { get; set; } + + /// + /// Y coordinate for the Elliptic Curve point. + /// + [JsonProperty( DefaultValueHandling = DefaultValueHandling.Ignore, NullValueHandling = NullValueHandling.Ignore, PropertyName = Property_Y, Required = Required.Default )] + [JsonConverter( typeof( Base64UrlJsonConverter ) )] + public byte[] Y { get; set; } + + #endregion + + #region EC and RSA Private Key Parameters + + /// + /// RSA private exponent or ECC private key. + /// + [JsonProperty( DefaultValueHandling = DefaultValueHandling.Ignore, NullValueHandling = NullValueHandling.Ignore, PropertyName = Property_D, Required = Required.Default )] + [JsonConverter( typeof( Base64UrlJsonConverter ) )] + public byte[] D { get; set; } + + #endregion #region Symmetric Key Parameters /// /// Symmetric key /// - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore, NullValueHandling = NullValueHandling.Ignore, PropertyName = Property_K, Required = Required.Default)] - [JsonConverter(typeof( Base64UrlJsonConverter ))] + [JsonProperty( DefaultValueHandling = DefaultValueHandling.Ignore, NullValueHandling = NullValueHandling.Ignore, PropertyName = Property_K, Required = Required.Default )] + [JsonConverter( typeof( Base64UrlJsonConverter ) )] public byte[] K { get; set; } #endregion @@ -138,10 +173,49 @@ public class JsonWebKey /// /// HSM Token, used with "Bring Your Own Key" /// - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore, NullValueHandling = NullValueHandling.Ignore, PropertyName = Property_T, Required = Required.Default)] - [JsonConverter(typeof( Base64UrlJsonConverter ))] + [JsonProperty( DefaultValueHandling = DefaultValueHandling.Ignore, NullValueHandling = NullValueHandling.Ignore, PropertyName = Property_T, Required = Required.Default )] + [JsonConverter( typeof( Base64UrlJsonConverter ) )] public byte[] T { get; set; } + /// + /// Holds properties that are not part of current schema. + /// + [JsonExtensionData] + public IDictionary ExtensionData; + + /// + /// Iterates over all JSON properties of this object, calling the specified visitor. + /// + /// All JSON properties are visited. This includes normal properties, properties that are not useful for the + /// key type, and properties that are not part of current schema (extension data). + /// Users must assume the properties are visited in random order. + /// A visitor that will be called for each property. + public void VisitProperties( Action visitor ) + { + if ( visitor == null ) + throw new ArgumentNullException( nameof( visitor ) ); + + visitor( Property_Crv, CurveName ); + visitor( Property_D, D ); + visitor( Property_DP, DP ); + visitor( Property_DQ, DQ ); + visitor( Property_E, E ); + visitor( Property_K, K ); + visitor( Property_KeyOps, KeyOps ); + visitor( Property_Kid, Kid ); + visitor( Property_Kty, Kty ); + visitor( Property_N, N ); + visitor( Property_P, P ); + visitor( Property_Q, Q ); + visitor( Property_T, T ); + visitor( Property_X, X ); + visitor( Property_Y, Y ); + + if ( ExtensionData != null ) + foreach ( var entry in ExtensionData ) + visitor( entry.Key, entry.Value ); + } + /// /// Creates an instance of /// @@ -155,23 +229,49 @@ public JsonWebKey() /// Converts an AES object to a WebKey of type Octet /// /// - /// - public JsonWebKey(Aes aesProvider) + public JsonWebKey( Aes aesProvider ) { - if (aesProvider == null) - throw new ArgumentNullException("aesProvider"); + if ( aesProvider == null ) + throw new ArgumentNullException( "aesProvider" ); Kty = JsonWebKeyType.Octet; K = aesProvider.Key; } + /// + /// Initializes a new instance with the key provided by the ECDsa object. + /// + /// The ECDsa object previously initialized with the desired key. + /// Tells if the instance must inclue private parameters. + /// This requires the key in the ECDsa object to include private material and be marked as exportable. + public JsonWebKey( ECDsa ecsda, bool includePrivateParameters = false ) + : this( ecsda.ExportParameters( includePrivateParameters ) ) + { + KeyOps = ecsda.GetKeyOperations(); + } + + /// + /// Converts a ECParameters object to a WebKey of type EC. + /// + /// The EC object to convert + /// A WebKey representing the EC object + public JsonWebKey( ECParameters ecParameters ) + { + Kty = JsonWebKeyType.EllipticCurve; + + CurveName = ecParameters.Curve; + D = ecParameters.D; + X = ecParameters.X; + Y = ecParameters.Y; + } + /// /// Converts a RSA object to a WebKey of type RSA. /// /// The RSA object to convert /// True to include the RSA private key parameters /// A WebKey representing the RSA object - public JsonWebKey(RSA rsaProvider, bool includePrivateParameters = false) : this(rsaProvider.ExportParameters(includePrivateParameters)) + public JsonWebKey( RSA rsaProvider, bool includePrivateParameters = false ) : this( rsaProvider.ExportParameters( includePrivateParameters ) ) { } @@ -180,7 +280,7 @@ public JsonWebKey(RSA rsaProvider, bool includePrivateParameters = false) : this /// /// The RSA object to convert /// A WebKey representing the RSA object - public JsonWebKey(RSAParameters rsaParameters) + public JsonWebKey( RSAParameters rsaParameters ) { Kty = JsonWebKeyType.Rsa; @@ -197,18 +297,15 @@ public JsonWebKey(RSAParameters rsaParameters) public override bool Equals( object obj ) { - if ( obj == null ) - return false; - - if (obj == this) + if ( obj == this ) return true; - JsonWebKey other = obj as JsonWebKey; + var other = obj as JsonWebKey; if ( other == null ) return false; - return this.Equals( other ); + return Equals( other ); } /// @@ -218,64 +315,112 @@ public override bool Equals( object obj ) /// whether the objects are equals public bool Equals( JsonWebKey other ) { + if ( other == this ) + return true; + if ( other == null ) return false; - if (!string.Equals(Kid, other.Kid)) + if ( !string.Equals( Kid, other.Kid ) ) + return false; + + if ( !string.Equals( Kty, other.Kty ) ) return false; - if (!string.Equals(Kty, other.Kty)) + if ( !AreEqual( KeyOps, other.KeyOps ) ) return false; - if (!AreEqual(KeyOps, other.KeyOps)) + if ( !string.Equals( CurveName, other.CurveName ) ) return false; - if (!AreEqual(K, other.K)) + if ( !AreEqual( K, other.K ) ) return false; // Public parameters - if (!AreEqual(N, other.N)) + if ( !AreEqual( N, other.N ) ) return false; - if (!AreEqual(E, other.E)) + if ( !AreEqual( E, other.E ) ) + return false; + + if ( !AreEqual( X, other.X ) ) + return false; + + if ( !AreEqual( Y, other.Y ) ) return false; // Private parameters - if (!AreEqual(D, other.D)) + if ( !AreEqual( D, other.D ) ) return false; - if (!AreEqual(DP, other.DP)) + if ( !AreEqual( DP, other.DP ) ) return false; - if (!AreEqual(DQ, other.DQ)) + if ( !AreEqual( DQ, other.DQ ) ) return false; - if (!AreEqual(QI, other.QI)) + if ( !AreEqual( QI, other.QI ) ) return false; - if (!AreEqual(P, other.P)) + if ( !AreEqual( P, other.P ) ) return false; - if (!AreEqual(Q, other.Q)) + if ( !AreEqual( Q, other.Q ) ) return false; // HSM token - if (!AreEqual(T, other.T)) + if ( !AreEqual( T, other.T ) ) return false; return true; } - private bool AreEqual(IList item1, IList item2) + private static bool AreEqual( byte[] a, byte[] b ) { - return (item1 == item2) || (item1 != null && item2 != null && item1.SequenceEqual(item2)); + if ( a == b ) + return true; + + if ( a == null ) + // b can't be null because otherwise we would return true above. + return b.Length == 0; + + if ( b == null ) + // Likewise, a can't be null. + return a.Length == 0; + + if ( a.Length != b.Length ) + return false; + + for ( var i = 0; i < a.Length; ++i ) + if ( a[i] != b[i] ) + return false; + + return true; + } + + private static bool AreEqual( IList a, IList b ) + { + if ( a == b ) + return true; + + if ( ( a == null ) != ( b == null ) ) + return false; + + if ( a.Count != b.Count ) + return false; + + for ( var i = 0; i < a.Count; ++i ) + if ( a[i] != b[i] ) + return false; + + return true; } public override int GetHashCode() { var hashCode = 48313; // setting it to a random prime number - if (Kid != null) + if ( Kid != null ) { hashCode += Kid.GetHashCode(); } @@ -283,21 +428,24 @@ public override int GetHashCode() switch ( Kty ) { case JsonWebKeyType.Octet: - return hashCode += GetHashCode( K ); + return hashCode + GetHashCode( K ); + + case JsonWebKeyType.EllipticCurve: + return hashCode + GetHashCode( X ); case JsonWebKeyType.Rsa: - return hashCode += GetHashCode( N ); + return hashCode + GetHashCode( N ); + case JsonWebKeyType.EllipticCurveHsm: case JsonWebKeyType.RsaHsm: - return hashCode += GetHashCode( T ); + return hashCode + GetHashCode( T ); default: return hashCode; } } - - private int GetHashCode( byte[] obj ) + private static int GetHashCode( byte[] obj ) { if ( obj == null || obj.Length == 0 ) return 0; @@ -305,9 +453,9 @@ private int GetHashCode( byte[] obj ) var hashCode = 0; // Rotate by 3 bits and XOR the new value. - for ( var i = 0; i < obj.Length; i++ ) - hashCode = ( hashCode << 3 ) | ( hashCode >> ( 29 ) ) ^ obj[i]; - + foreach ( var v in obj ) + hashCode = ( hashCode << 3 ) | ( hashCode >> 29 ) ^ v; + return hashCode; } @@ -315,17 +463,20 @@ private int GetHashCode( byte[] obj ) /// Verifies whether this object has a private key /// /// True if the object has private key; false otherwise. - public virtual bool HasPrivateKey() + public bool HasPrivateKey() { switch ( Kty ) { case JsonWebKeyType.Octet: return K != null; + case JsonWebKeyType.EllipticCurve: + case JsonWebKeyType.EllipticCurveHsm: + return D != null; + case JsonWebKeyType.Rsa: case JsonWebKeyType.RsaHsm: - var privateParameters = new bool[] { D != null, DP != null, DQ != null, QI != null, P != null, Q != null }; - return privateParameters.All( ( value ) => value ); + return D != null && DP != null && DQ != null && QI != null && P != null && Q != null; default: return false; @@ -334,91 +485,17 @@ public virtual bool HasPrivateKey() /// /// Determines if the WebKey object is valid according to the rules for - /// each of the possible WebKeyTypes. For more information, see WebKeyTypes. + /// each of value of JsonWebKeyType. /// /// true if the WebKey is valid - public virtual bool IsValid() - { - // MUST have kty - if ( string.IsNullOrEmpty( Kty ) ) - return false; - - // Validate Key Operations - if (KeyOps != null && KeyOps.Count != 0) - { - if (!KeyOps.All((op) => { return JsonWebKeyOperation.AllOperations.Contains(op); })) - return false; - } - - // Per-kty validation - switch ( Kty ) - { - case JsonWebKeyType.EllipticCurve: - break; - - case JsonWebKeyType.Octet: - return IsValidOctet(); - - case JsonWebKeyType.Rsa: - return IsValidRsa(); - - case JsonWebKeyType.RsaHsm: - return IsValidRsaHsm(); - } - - return false; - } - - private bool IsValidOctet() - { - if ( K != null ) - return true; - - return false; - } - - private bool IsValidRsa() - { - // MUST have public key parameters - if ( N == null || E == null ) - return false; - - // MAY have private key parameters, but only ALL or NONE - var privateParameters = new bool[] { D != null, DP != null, DQ != null, QI != null, P != null, Q != null }; - - if ( privateParameters.All( ( value ) => value ) || privateParameters.All( ( value ) => !value ) ) - return true; - - return false; - } - - private bool IsValidRsaHsm() + public bool IsValid() { - // MAY have public key parameters - if ( ( N == null && E != null ) || ( N != null && E == null ) ) - return false; - - // MUST NOT have private key parameters - var privateParameters = new bool[] { D != null, DP != null, DQ != null, QI != null, P != null, Q != null }; - - if ( privateParameters.Any( ( value ) => value ) ) - return false; + var verifierOptions = + JsonWebKeyVerifier.Options.DenyIncompatibleOperations | + JsonWebKeyVerifier.Options.DenyExtraneousFields; - // MUST have ( T || ( N && E ) ) - var tokenParameters = T != null; - var publicParameters = ( N != null && E != null ); - - if ( tokenParameters && publicParameters ) - return false; - - return ( tokenParameters || publicParameters ); - } - - [OnDeserialized] - internal void OnDeserialized(StreamingContext context) - { - if (!IsValid()) - throw new JsonSerializationException("JsonWebKey is not valid"); + string unused = null; + return JsonWebKeyVerifier.VerifyByKeyType( this, verifierOptions, ref unused ); } /// @@ -427,18 +504,18 @@ internal void OnDeserialized(StreamingContext context) /// An AES object public Aes ToAes() { - if (!Kty.Equals(JsonWebKeyType.Octet)) - throw new InvalidOperationException("key is not an octet key"); + if ( !Kty.Equals( JsonWebKeyType.Octet ) ) + throw new InvalidOperationException( "key is not an octet key" ); - if (K == null) - throw new InvalidOperationException("key does not contain a value"); + if ( K == null ) + throw new InvalidOperationException( "key does not contain a value" ); - Aes aesProvider = Aes.Create(); + var result = Aes.Create(); - if (aesProvider != null) - aesProvider.Key = K; + if ( result != null ) + result.Key = K; - return aesProvider; + return result; } /// @@ -446,116 +523,155 @@ public Aes ToAes() /// public void CanonicalizeRSA() { - N = RemoveLeadingZeros(N); - E = RemoveLeadingZeros(E); - D = RemoveLeadingZeros(D); - DP = RemoveLeadingZeros(DP); - DQ = RemoveLeadingZeros(DQ); - QI = RemoveLeadingZeros(QI); - P = RemoveLeadingZeros(P); - Q = RemoveLeadingZeros(Q); + N = RemoveLeadingZeros( N ); + E = RemoveLeadingZeros( E ); + D = RemoveLeadingZeros( D ); + DP = RemoveLeadingZeros( DP ); + DQ = RemoveLeadingZeros( DQ ); + QI = RemoveLeadingZeros( QI ); + P = RemoveLeadingZeros( P ); + Q = RemoveLeadingZeros( Q ); } /// /// Converts a WebKey of type RSA or RSAHSM to a RSA object /// - /// Determines whether private key material, if available, is included + /// Tells if private material must be included. /// An initialized RSA instance - public RSA ToRSA(bool includePrivateParameters = false) + public RSA ToRSA( bool includePrivateParameters = false ) { - var rsaParameters = ToRSAParameters(includePrivateParameters); - var rsaProvider = RSA.Create(); - - rsaProvider.ImportParameters(rsaParameters); - - return rsaProvider; + var rsaParameters = ToRSAParameters( includePrivateParameters ); + var result = RSA.Create(); + result.ImportParameters( rsaParameters ); + return result; } /// /// Converts a WebKey of type RSA or RSAHSM to a RSA parameter object /// - /// Determines whether private key material, if available, is included + /// Tells if private material must be included. /// An RSA parameter - public RSAParameters ToRSAParameters(bool includePrivateParameters = false) + public RSAParameters ToRSAParameters( bool includePrivateParameters = false ) { - if (!string.Equals(JsonWebKeyType.Rsa, Kty) && !string.Equals(JsonWebKeyType.RsaHsm, Kty)) - throw new ArgumentException("JsonWebKey is not a RSA key"); + if ( Kty != JsonWebKeyType.Rsa && Kty != JsonWebKeyType.RsaHsm ) + throw new ArgumentException( "JsonWebKey is not a RSA key" ); - VerifyNonZero("N", N); - VerifyNonZero("E", E); + VerifyNonZero( nameof( N ), N ); + VerifyNonZero( nameof( E ), E ); // Length requirements defined by 2.2.2.9.1 RSA Private Key BLOB (https://msdn.microsoft.com/en-us/library/cc250013.aspx). // See KV bugs 190589 and 183469. var result = new RSAParameters(); - result.Modulus = RemoveLeadingZeros(N); - result.Exponent = ForceLength("E", E, 4); + result.Modulus = RemoveLeadingZeros( N ); + result.Exponent = ForceLength( nameof( E ), E, 4 ); - if (includePrivateParameters) + if ( includePrivateParameters ) { var bitlen = result.Modulus.Length * 8; - result.D = ForceLength("D", D, bitlen / 8); - result.DP = ForceLength("DP", DP, bitlen / 16); - result.DQ = ForceLength("DQ", DQ, bitlen / 16); - result.InverseQ = ForceLength("IQ", QI, bitlen / 16); - result.P = ForceLength("P", P, bitlen / 16); - result.Q = ForceLength("Q", Q, bitlen / 16); - }; + result.D = ForceLength( nameof( D ), D, bitlen / 8 ); + result.DP = ForceLength( nameof( DP ), DP, bitlen / 16 ); + result.DQ = ForceLength( nameof( DQ ), DQ, bitlen / 16 ); + result.InverseQ = ForceLength( nameof( QI ), QI, bitlen / 16 ); + result.P = ForceLength( nameof( P ), P, bitlen / 16 ); + result.Q = ForceLength( nameof( Q ), Q, bitlen / 16 ); + } return result; } - private static void VerifyNonZero(string name, byte[] value) + /// + /// Converts a WebKey of type EC or EC-HSM to an ECDsa object + /// + /// Tells if private material must be included. + /// An initialized ECDsa instance + public ECDsa ToECDsa( bool includePrivateParameters = false ) + { + return ToEcParameters( includePrivateParameters ).ToEcdsa( includePrivateParameters ); + } + + /// + /// Converts a WebKey of type EC or EC-HSM to an EC parameter object. + /// + /// Tells if private material must be included. + /// An EC parameter object + public ECParameters ToEcParameters( bool includePrivateParameters = false ) { - if (value != null && value.Length > 0) + if ( Kty != JsonWebKeyType.EllipticCurve && Kty != JsonWebKeyType.EllipticCurveHsm ) + throw new ArgumentException( "JsonWebKey is not an EC key" ); + + VerifyNonZero( nameof( X ), X ); + VerifyNonZero( nameof( Y ), Y ); + + var requiredSize = JsonWebKeyCurveName.GetKeyParameterSize( CurveName ); + if ( requiredSize < 0 ) { - for (var i = 0; i < value.Length; ++i) - if (value[i] != 0) - return; + var curveDesc = CurveName == null ? "null" : $"\"{CurveName}\""; + throw new ArgumentException( $"Invalid curve type: {curveDesc}" ); } - throw new ArgumentException("Value of \"" + name + "\" must be non-zero."); + var result = new ECParameters(); + result.Curve = CurveName; + result.X = ForceLength( nameof( X ), X, requiredSize ); + result.Y = ForceLength( nameof( Y ), Y, requiredSize ); + + if ( includePrivateParameters ) + { + VerifyNonZero( nameof( D ), D ); + result.D = ForceLength( nameof( D ), D, requiredSize ); + } + + return result; } - private static byte[] RemoveLeadingZeros(byte[] value) + private static void VerifyNonZero( string name, byte[] value ) + { + if ( value != null ) + foreach ( var t in value ) + if ( t != 0 ) + return; + + throw new ArgumentException( $"Value of \"{name}\" must be non-zero." ); + } + + private static byte[] RemoveLeadingZeros( byte[] value ) { // Do nothing if: // 1) value is null. // 2) value is empty. // 3) value has length of 1 (this is considered a useful zero). // 4) first byte is already non-zero (optimization). - if (value == null || value.Length <= 1 || value[0] != 0) + if ( value == null || value.Length <= 1 || value[0] != 0 ) return value; // We know that value[0] is zero, so we start from 1. - for (var i = 1; i < value.Length; ++i) + for ( var i = 1; i < value.Length; ++i ) { - if (value[i] != 0) + if ( value[i] != 0 ) { var result = new byte[value.Length - i]; - Array.Copy(value, i, result, 0, result.Length); + Array.Copy( value, i, result, 0, result.Length ); return result; } } // If all is zero, return an array with a single useful zero. - return new byte[] { 0 }; + return new byte[] {0}; } - private static byte[] ForceLength(string name, byte[] value, int requiredLength) + private static byte[] ForceLength( string name, byte[] value, int requiredLength ) { + if ( value == null || value.Length == 0 ) + throw new ArgumentException( $"Value of \"{name}\" is null or empty." ); - if (value == null || value.Length == 0) - throw new ArgumentException("Value of \"" + name + "\" is null or empty."); - - if (value.Length == requiredLength) + if ( value.Length == requiredLength ) return value; - if (value.Length < requiredLength) + if ( value.Length < requiredLength ) { var padded = new byte[requiredLength]; - Array.Copy(value, 0, padded, requiredLength - value.Length, value.Length); + Array.Copy( value, 0, padded, requiredLength - value.Length, value.Length ); return padded; } @@ -563,16 +679,15 @@ private static byte[] ForceLength(string name, byte[] value, int requiredLength) // Make sure the extra bytes are all zeros. var extraLen = value.Length - requiredLength; - for (var i = 0; i < extraLen; ++i) - if (value[i] != 0) - throw new ArgumentException("Invalid length of \"" + name + "\": expected at most " + - requiredLength + " bytes, found " + (value.Length - i) + " bytes."); + for ( var i = 0; i < extraLen; ++i ) + if ( value[i] != 0 ) + throw new ArgumentException( $"Invalid length of \"{name}\": expected at most {requiredLength} bytes, found {value.Length - i} bytes." ); var trimmed = new byte[requiredLength]; - Array.Copy(value, value.Length - requiredLength, trimmed, 0, requiredLength); + Array.Copy( value, value.Length - requiredLength, trimmed, 0, requiredLength ); return trimmed; } - + public override string ToString() { return JsonConvert.SerializeObject( this ); @@ -587,31 +702,39 @@ public void ClearMemory() // We ignore kty and clear everything. // Octet keys: - ZeroArray(K); + ZeroArray( K ); K = null; // Rsa keys: // We want to clear public key to avoid identification. - ZeroArray(N); - ZeroArray(E); + ZeroArray( N ); + ZeroArray( E ); // Private material of RSA: - ZeroArray(D); - ZeroArray(DP); - ZeroArray(DQ); - ZeroArray(QI); - ZeroArray(P); - ZeroArray(Q); + ZeroArray( D ); + ZeroArray( DP ); + ZeroArray( DQ ); + ZeroArray( QI ); + ZeroArray( P ); + ZeroArray( Q ); N = E = D = DP = DQ = QI = P = Q = null; // RsaHsm keys: - ZeroArray(T); + ZeroArray( T ); T = null; - switch (Kty) + // Elliptic curve + ZeroArray( X ); + ZeroArray( Y ); + ZeroArray( D ); // D is intentionally repeated. + X = Y = D = null; + + switch ( Kty ) { case JsonWebKeyType.Octet: + case JsonWebKeyType.EllipticCurve: + case JsonWebKeyType.EllipticCurveHsm: case JsonWebKeyType.Rsa: case JsonWebKeyType.RsaHsm: // Supported types fall here. @@ -620,16 +743,15 @@ public void ClearMemory() default: // Unsupported types fall here. // If someone forgets to implement ClearMemory() for a new kty, this exception will reveal the mistake. - // Note that although there is JsonWebKeyType.EllipticCurve, it's not supported yet. - throw new NotImplementedException("Unsupported kty: " + Kty); + throw new NotImplementedException( $"Unsupported kty: {Kty}" ); } } - private static void ZeroArray(byte[] a) + private static void ZeroArray( byte[] a ) { - if (a == null) + if ( a == null ) return; - Array.Clear(a, 0, a.Length); + Array.Clear( a, 0, a.Length ); } } -} +} \ No newline at end of file diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.WebKey/JsonWebKeyCurveName.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.WebKey/JsonWebKeyCurveName.cs new file mode 100644 index 000000000000..44c124e83b70 --- /dev/null +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.WebKey/JsonWebKeyCurveName.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. + +namespace Microsoft.Azure.KeyVault.WebKey +{ + /// + /// Elliptic Curve Cryptography (ECC) curve names. + /// + public static class JsonWebKeyCurveName + { + public const string P256 = "P-256"; + public const string P384 = "P-384"; + public const string P521 = "P-521"; + public const string SECP256K1 = "SECP256K1"; + + private static readonly string[] _allCurves = {P256, P384, P521, SECP256K1}; + + /// + /// All curves for EC. Use clone to avoid FxCop violation + /// + public static string[] AllCurves => (string[]) _allCurves.Clone(); + + /// + /// Returns the required size, in bytes, of each key parameters (X, Y and D), or -1 if the curve is unsupported. + /// + /// The curve for which key parameter size is required. + /// + public static int GetKeyParameterSize( string curve ) + { + switch ( curve ) + { + case P256: + case SECP256K1: + return 32; + + case P384: + return 48; + + case P521: + return 66; + + default: + return -1; + } + } + } +} \ No newline at end of file diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.WebKey/JsonWebKeyOperations.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.WebKey/JsonWebKeyOperations.cs index b8431f97f853..05a107ebc78a 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.WebKey/JsonWebKeyOperations.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.WebKey/JsonWebKeyOperations.cs @@ -5,7 +5,6 @@ namespace Microsoft.Azure.KeyVault.WebKey { - /// /// Supported JsonWebKey operations /// @@ -13,19 +12,24 @@ public static class JsonWebKeyOperation { public const string Encrypt = "encrypt"; public const string Decrypt = "decrypt"; - public const string Sign = "sign"; - public const string Verify = "verify"; - public const string Wrap = "wrapKey"; - public const string Unwrap = "unwrapKey"; + public const string Sign = "sign"; + public const string Verify = "verify"; + public const string Wrap = "wrapKey"; + public const string Unwrap = "unwrapKey"; /// - /// All operations names. Use clone to avoid FxCop violation + /// All operations names. /// - public static string[] AllOperations + public static string[] AllOperations => (string[]) _allOperations.Clone(); + + private static readonly string[] _allOperations = {Encrypt, Decrypt, Sign, Verify, Wrap, Unwrap}; + + public static bool IsValidOperation( string operation ) { - get { return (string[])_allOperations.Clone(); } + foreach ( var validOperation in _allOperations ) + if ( operation == validOperation ) + return true; + return false; } - - private static readonly string[] _allOperations = new string[] { Encrypt, Decrypt, Sign, Verify, Wrap, Unwrap }; } -} +} \ No newline at end of file diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.WebKey/JsonWebKeySignatureAlgorithms.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.WebKey/JsonWebKeySignatureAlgorithms.cs index c62f071ab8d7..9c075364f43a 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.WebKey/JsonWebKeySignatureAlgorithms.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.WebKey/JsonWebKeySignatureAlgorithms.cs @@ -3,6 +3,8 @@ // license information. // +using System.Linq; + namespace Microsoft.Azure.KeyVault.WebKey { /// @@ -23,14 +25,22 @@ public static class JsonWebKeySignatureAlgorithm // RSASSA-PSS using SHA-512 and MGF1 with SHA-512 public const string PS512 = "PS512"; + // ECDSA using P-256 and SHA-256 + public const string ES256 = "ES256"; + // ECDSA using P-384 and SHA-384 + public const string ES384 = "ES384"; + // ECDSA using P-521 and SHA-512 + public const string ES512 = "ES512"; + // ECDSA using generic curve and SHA-256 (suited for SECP256K1) + public const string ECDSA256 = "ECDSA256"; + + public static string[] AllRsaAlgorithms => new[] { RS256, RS384, RS512, RSNULL, PS256, PS384, PS512 }; + + public static string[] AllEcAlgorithms => new[] { ES256, ES384, ES512, ECDSA256 }; + /// /// All algorithms names. Use clone to avoid FxCop violation /// - public static string[] AllAlgorithms - { - get { return (string[])_allAlgorithms.Clone(); } - } - - private static readonly string[] _allAlgorithms = { RS256, RS384, RS512, RSNULL, PS256, PS384, PS512 }; + public static string[] AllAlgorithms => AllRsaAlgorithms.Concat(AllEcAlgorithms).ToArray(); } } diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.WebKey/JsonWebKeyType.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.WebKey/JsonWebKeyType.cs new file mode 100644 index 000000000000..b9ac2a36448c --- /dev/null +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.WebKey/JsonWebKeyType.cs @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. + +using System.Collections.Generic; + +namespace Microsoft.Azure.KeyVault.WebKey +{ + /// + /// Supported JsonWebKey key types (kty) + /// + public static class JsonWebKeyType + { + public const string EllipticCurve /******/ = "EC"; + public const string EllipticCurveHsm /***/ = "EC-HSM"; + public const string Rsa /****************/ = "RSA"; + public const string RsaHsm /*************/ = "RSA-HSM"; + public const string Octet /**************/ = "oct"; + + public static IReadOnlyList AllTypes => _allTypes; + + private static readonly string[] _allTypes = {EllipticCurve, EllipticCurveHsm, Rsa, RsaHsm, Octet}; + } +} \ No newline at end of file diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.WebKey/JsonWebKeyTypes.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.WebKey/JsonWebKeyTypes.cs deleted file mode 100644 index e24c6ae1e6c4..000000000000 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.WebKey/JsonWebKeyTypes.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// - -namespace Microsoft.Azure.KeyVault.WebKey -{ - /// - /// Supported JsonWebKey key types (kty) - /// - public static class JsonWebKeyType - { - public const string EllipticCurve = "EC"; - public const string Rsa = "RSA"; - public const string RsaHsm = "RSA-HSM"; - public const string Octet = "oct"; - - /// - /// All types names. Use clone to avoid FxCop violation - /// - public static string[] AllTypes - { - get { return (string[])_allTypes.Clone(); } - } - - private static readonly string[] _allTypes = { EllipticCurve, Rsa, RsaHsm, Octet }; - } -} diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.WebKey/JsonWebKeyVerificationException.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.WebKey/JsonWebKeyVerificationException.cs new file mode 100644 index 000000000000..6fcffd0c5657 --- /dev/null +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.WebKey/JsonWebKeyVerificationException.cs @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. + +using System; + +namespace Microsoft.Azure.KeyVault.WebKey +{ + public sealed class JsonWebKeyVerificationException : Exception + { + public JsonWebKeyVerificationException( string message ) : base( message ) + { + } + + public JsonWebKeyVerificationException( string message, Exception inner ) : base( message, inner ) + { + } + } +} \ No newline at end of file diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.WebKey/JsonWebKeyVerifier.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.WebKey/JsonWebKeyVerifier.cs new file mode 100644 index 000000000000..b40c358b4005 --- /dev/null +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.WebKey/JsonWebKeyVerifier.cs @@ -0,0 +1,1134 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Text; + +namespace Microsoft.Azure.KeyVault.WebKey +{ + /// + /// A class that verifies instances of according to key type. + /// + public abstract class JsonWebKeyVerifier + { + /// + /// Indicates which type of key this verifier applies to. + /// + /// This is typically a value of , though other values are allowed if registered + /// with the method. + public string Kty { get; } + + /// + /// Initializes a new instance setting the specified value in the property. + /// + /// Indicates which type of key this verifier applies to. + /// If the specified value is null, empty or whitespace. + /// If the specified value contains invalid characters. + protected JsonWebKeyVerifier( string kty ) + { + if ( string.IsNullOrWhiteSpace( kty ) ) + throw new ArgumentNullException( nameof( kty ) ); + + foreach ( var ch in kty ) + { + if ( ch >= '0' && ch <= '9' ) + continue; + if ( ch >= 'A' && ch <= 'Z' ) + continue; + if ( ch >= 'a' && ch <= 'z' ) + continue; + if ( ch == '-' || ch == '.' || ch == '_' ) + continue; + + throw new ArgumentException( "Value contains invalid characters.", nameof( kty ) ); + } + + Kty = kty; + } + + /// + /// Tells if the type of key verified by this object supports public key algorithms. + /// + /// Note to implementers: if this method returns true, the methods + /// , , and + /// must be overriden. + public abstract bool IsPublicKeyCrypto { get; } + + /// + /// Tells if the type of key verified by this object supports symmetric key algorithms. + /// + /// Note to implementers: if this method returns true, the methods + /// and must be overriden. + public abstract bool IsSymmetricKeyCrypto { get; } + + /// + /// Tells if the type of key verified by this object contains a secret component, such as a hardware key token. + /// + /// Note to implementers: if this method returns true, the methods + /// and must be overriden. + public abstract bool HasSecretKey { get; } + + /// + /// Determines if the specified instance contains values at properties that represent the public key. + /// + /// If all required public key properties (for the key type) are specified in the instance, the method must return + /// true and not modify the parameter. + /// If some public key property is missing, the method must return false and set + /// with a value - typically a - containing all missing properties. + /// The instance to verify. + /// A reference to a variable that tells the list of missing properties. Callers must + /// set the variable to null, and examine the value only if this method returns false. + public virtual bool IsPublicKeyComplete( JsonWebKey webKey, ref ICollection missingProps ) + { + throw ThrowDefaultForPublicKeyCrypto( nameof( IsPublicKeyComplete ) ); + } + + /// + /// Determines if the specified instance contains a possibly valid public key (see remarks). + /// + /// Because fully validating a key may require unfeasable amount of resources, this method only has to check + /// for obvious issues. As a guideline, we say that the code only verifies obvious issues if it runs in constant time. + /// It's perfectly valid for implementors to do nothing and simply return true. + /// This method assumes that was called and returned true. It + /// doesn't test again for the presence of required properties. It may throw + /// if the caller doesn't see returning true first. + /// If the valiation code finds no issue, this method must return true without modifying the value of + /// . + /// If some issue is found, this method must return false and tell more details in the + /// parameter. + /// The instance to verify. + /// A reference to a variable that will contain an error message. Callers must + /// set the variable to null, and examine the value only if this method returns false. + public virtual bool IsPublicKeyValid( JsonWebKey webKey, ref string errorMsg ) + { + throw ThrowDefaultForPublicKeyCrypto( nameof( IsPublicKeyValid ) ); + } + + /// + /// Same as , but for the private key. + /// + public virtual bool IsPrivateKeyComplete( JsonWebKey webKey, ref ICollection missingProps ) + { + throw ThrowDefaultForPublicKeyCrypto( nameof( IsPrivateKeyComplete ) ); + } + + /// + /// Same as , but for the private key. + /// + public virtual bool IsPrivateKeyValid( JsonWebKey webKey, ref string errorMsg ) + { + throw ThrowDefaultForPublicKeyCrypto( nameof( IsPrivateKeyValid ) ); + } + + /// + /// Determines if the specified instance contains values in one or more properties that + /// represent the private key. + /// + /// This method is used to protect private key material from accidental leakage. + /// If no private key property (for the key type) is specified in the instance, the method must return + /// false and not modify the parameter. + /// If one or more private key property is specified, the method must return true and optionally + /// set with a value - typically a - containing the specified properties. + /// The instance to verify. + /// A reference to a variable that tells the list of specified properties. Callers must + /// set the variable to null and examine the value only if this method returns true. + /// true if a value is found in at least one property that describe the private key; + /// false otherwise. + public virtual bool IsAnyPrivateKeyParamSpecified( JsonWebKey webKey, ref ICollection specifiedProps ) + { + throw ThrowDefaultForPublicKeyCrypto( nameof( IsAnyPrivateKeyParamSpecified ) ); + } + + private Exception ThrowDefaultForPublicKeyCrypto( string methodName ) + { + if ( IsPublicKeyCrypto ) + throw new NotImplementedException( $"Type {GetType().Name} is a bad implementation. If {nameof( IsPublicKeyCrypto )} returns true, then {methodName} must be overriden and the base must not be called." ); + + throw new InvalidOperationException( $"Type {GetType().Name} is not intended for public key cryptography." ); + } + + /// + /// Determines if the specified instance contains values at properties that represent the symmetric key. + /// + /// If all required symmetric key properties (for the key type) are specified in the instance, the method must return + /// true and not modify the parameter. + /// If some property is missing, the method must return false and set + /// to a value - typically a - containing all missing properties. + /// The instance to verify. + /// A reference to a variable that tells the list of missing properties. Callers must + /// set the variable to null, and examine the value only if this method returns false. + public virtual bool IsSymmetricKeyComplete( JsonWebKey webKey, ref ICollection missingProps ) + { + throw ThrowDefaultForSymmetricKeyCrypto( nameof( IsSymmetricKeyComplete ) ); + } + + /// + /// Determines if the specified instance contains a possibly valid symmetric key (see remarks). + /// + /// Because fully validating a key may require unfeasable amount of resources, this method only has to check + /// for obvious issues. As a guideline, we say that the code only verifies obvious issues if it runs in constant time. + /// It's perfectly valid for implementors to do nothing and simply return true. + /// This method assumes that was called and returned true. It + /// doesn't test again for the presence of required properties. It may throw + /// if the caller doesn't see returning true first. + /// If the valiation code finds no issue, this method must return true without modifying the value of + /// . + /// If some issue is found, this method must return false and tell more details in the + /// parameter. + /// The instance to verify. + /// A reference to a variable that will contain an error message. Callers must + /// set the variable to null, and examine the value only if this method returns false. + public virtual bool IsSymmetricKeyValid( JsonWebKey webKey, ref string errorMsg ) + { + throw ThrowDefaultForSymmetricKeyCrypto( nameof( IsSymmetricKeyValid ) ); + } + + private Exception ThrowDefaultForSymmetricKeyCrypto( string methodName ) + { + if ( IsSymmetricKeyCrypto ) + throw new NotImplementedException( $"Type {GetType().Name} is a bad implementation. If {nameof( IsSymmetricKeyCrypto )} returns true, then {methodName} must be overriden and the base must not be called." ); + + throw new InvalidOperationException( $"Type {GetType().Name} is not intended for symmetric key cryptography." ); + } + + /// + /// Determines if the specified instance contains values at properties that represent the secret key. + /// + /// If all required secret key properties (for the key type) are specified in the instance, the method must return + /// true and not modify the parameter. + /// If some property is missing, the method must return false and set + /// to a value - typically a - containing all missing properties. + /// The instance to verify. + /// A reference to a variable that tells the list of missing properties. Callers must + /// set the variable to null, and examine the value only if this method returns false. + public virtual bool IsSecretKeyComplete( JsonWebKey webKey, ref ICollection missingProps ) + { + throw ThrowDefaultForSecretKeyCrypto( nameof( IsSecretKeyComplete ) ); + } + + /// + /// Determines if the specified instance contains a possibly valid secret key (see remarks). + /// + /// Because fully validating a key may require unfeasable amount of resources, this method only has to check + /// for obvious issues. As a guideline, we say that the code only verifies obvious issues if it runs in constant time. + /// It's perfectly valid for implementors to do nothing and simply return true. + /// This method assumes that was called and returned true. It + /// doesn't test again for the presence of required properties. It may throw + /// if the caller doesn't see returning true first. + /// If the valiation code finds no issue, this method must return true without modifying the value of + /// . + /// If some issue is found, this method must return false and tell more details in the + /// parameter. + /// The instance to verify. + /// A reference to a variable that will contain an error message. Callers must + /// set the variable to null, and examine the value only if this method returns false. + public virtual bool IsSecretKeyValid( JsonWebKey webKey, ref string errorMsg ) + { + throw ThrowDefaultForSecretKeyCrypto( nameof( IsSecretKeyValid ) ); + } + + private Exception ThrowDefaultForSecretKeyCrypto( string methodName ) + { + if ( HasSecretKey ) + throw new NotImplementedException( $"Type {GetType().Name} is a bad implementation. If {nameof( HasSecretKey )} returns true, then {methodName} must be overriden and the base must not be called." ); + + throw new InvalidOperationException( $"Type {GetType().Name} is not intended to keys that have a secret component (for instance, HSM keys)." ); + } + + private static volatile SortedSet _validOperations; + + public static bool IsOperationValid( string opName ) + { + if ( _validOperations == null ) + { + // No lock here; we accept multiple threads initializing. + var validOperations = new SortedSet(); + + foreach ( var op in JsonWebKeyOperation.AllOperations ) + validOperations.Add( op ); + + _validOperations = validOperations; + } + + // No lock here; collection is read-only at this time. + return _validOperations.Contains( opName ); + } + + private volatile SortedSet _compatibleOperations; + + public bool IsOperationCompatible( string opName ) + { + if ( _compatibleOperations == null ) + { + // No lock here; we accept multiple threads initializing. + var compatibleOperations = new SortedSet(); + + AddCompatibleOperations( compatibleOperations ); + + _compatibleOperations = compatibleOperations; + } + + // No lock here; collection is read-only at this time. + return _compatibleOperations.Contains( opName ); + } + + /// + /// Adds to the specified collection all operations that can be performed with keys whose type is handled by + /// this object. + /// + /// For instance, if keys can only be used for digital signatures, this method should add only + /// and . + protected abstract void AddCompatibleOperations( ICollection compatibleOperations ); + + private HashSet _usedProperties; + + public bool IsPropertyUsed( string propName ) + { + if ( _usedProperties == null ) + { + // No lock here; we accept multiple threads initializing. + var usedProperties = new HashSet(); + + AddUsedProperties( usedProperties ); + + usedProperties.Add( JsonWebKey.Property_Kid ); + usedProperties.Add( JsonWebKey.Property_Kty ); + usedProperties.Add( JsonWebKey.Property_KeyOps ); + + _usedProperties = usedProperties; + } + + // No lock here; collection is read-only at this point. + return _usedProperties.Contains( propName ); + } + + /// + /// Adds to the specified collection all JsonWebKey properties that are useful to keys whose type is handled by + /// this object. + /// + /// This method must add JSON property names, such as "crv", "p", etc. It must not add + /// C# property names. + /// This method doesn't have to add "kid", "kty" and "key_ops". + /// Thes properties are assumed to be useful to all keys.. + protected abstract void AddUsedProperties( ICollection usedProperties ); + + [Flags] + public enum Options + { + /// + /// Use this value if you don't want to specify any other. + /// + None = 0, + + /// + /// Fails if any private key material is present. Use this to defend against leakage. + /// + /// This value is only used for keys that support public key cryptography. It's ignored in other key types. + DenyPrivateKey /*********/ = 1 << 0, + + /// + /// Fails if private key material is not fully present. Use this before storing or importing a JsonWebKey + /// value into a subsystem that needs to keep the private key. + /// + /// This value is only used for keys that support public key cryptography. It's ignored in other key types. + RequirePrivateKey /******/ = 1 << 1, + + /// + /// Fails if there the "key_ops" value of the verified key contains an incompatible operation. + /// + DenyIncompatibleOperations = 1 << 2, + + /// + /// Fails if the JsonWebKey object describes values at properties that are not used by the corresponding key type. + /// Use this to defend against properties incorrectly set, and also some forms of leakage. + /// + DenyExtraneousFields /***/ = 1 << 3, + + /// + /// Reserved for future use. + /// + VerifyDecrypt /**********/ = 1 << 10, + + /// + /// Reserved for future use. + /// + VerifySign /*************/ = 1 << 11, + + /// + /// Do not return false if the verification fails; throws an exception instead. + /// + ThrowException /*********/ = 1 << 20 + } + + /// + /// Verifies the specified JsonWebKey instance. + /// + /// Verification first examines the property to select a verifier instance + /// (for more information, see the method). If a verifier is found, it's used to check + /// if the key conforms to the corresponding key type. + /// The instance to verify. + /// Tells how verification is to behave. + /// A reference to a variable that will tell the error message, if verification fails. This + /// is only set if the method returns false. If the method returns true or throws + /// an exception, the will not me modified. + /// true if the JsonWebKey value is valid, false otherwise. + /// If the parameter is null. + /// If the parameter contains invalid options. + /// If the JsonWebKey object is invalid and the option + /// was specified. + /// + public bool Verify( JsonWebKey webKey, Options options, ref string error ) + { + if ( webKey == null ) + throw new ArgumentNullException( nameof( webKey ) ); + + if ( options.HasFlag( Options.DenyPrivateKey ) && options.HasFlag( Options.RequirePrivateKey ) ) + throw new ArgumentException( $"Cannot use {Options.DenyPrivateKey} and {Options.RequirePrivateKey} at same time.", nameof( options ) ); + + if ( options.HasFlag( Options.VerifyDecrypt ) || options.HasFlag( Options.VerifySign ) ) + throw new NotImplementedException(); + + if ( !VerifyNotNullOrWhiteSpace( webKey.Kty, JsonWebKey.Property_Kty, options, ref error ) ) + return false; + + if ( webKey.Kty != Kty ) + return SetError( options, ref error, $"Expected {JsonWebKey.Property_Kty} to be \"{Kty}\", but found something else." ); + + if ( IsPublicKeyCrypto ) + { + if ( !VerifyPublicKey( this, webKey, options, ref error ) ) + return false; + + if ( options.HasFlag( Options.DenyPrivateKey ) && !VerifyNoPrivateKey( this, webKey, options, ref error ) ) + return false; + + if ( options.HasFlag( Options.RequirePrivateKey ) && !VerifyPrivateKey( this, webKey, options, ref error ) ) + return false; + } + + if ( IsSymmetricKeyCrypto ) + { + if ( !VerifySymmetricKey( this, webKey, options, ref error ) ) + return false; + } + + if ( HasSecretKey && !VerifySecretKey( this, webKey, options, ref error ) ) + return false; + + if ( options.HasFlag( Options.DenyIncompatibleOperations ) && !VerifyOperationsAreCompatible( this, webKey, options, ref error ) ) + return false; + + if ( !options.HasFlag( Options.DenyIncompatibleOperations ) && !VerifyOperationsAreValid( webKey, options, ref error ) ) + return false; + + if ( options.HasFlag( Options.DenyExtraneousFields ) && !VerifyNoExtraneousFields( this, webKey, options, ref error ) ) + return false; + + return true; + } + + /// + /// Verifies the specified JsonWebKey instance according to . + /// + /// This method selects a verifier based on the value of , + /// then calls the verifier's method. + /// + /// + /// + /// + public static bool VerifyByKeyType( JsonWebKey webKey, Options options, ref string error ) + { + if ( webKey == null ) + throw new ArgumentNullException( nameof( webKey ) ); + + if ( !VerifyNotNullOrWhiteSpace( webKey.Kty, JsonWebKey.Property_Kty, options, ref error ) ) + return false; + + JsonWebKeyVerifier verifier; + + lock ( _verifiersLock ) + { + InitVerifiers(); + if ( !VerifyEnum( webKey.Kty, JsonWebKey.Property_Kty, _verifiers, out verifier, options, ref error ) ) + return false; + } + + return verifier.Verify( webKey, options, ref error ); + } + + private static readonly object _verifiersLock = new object(); + + private static volatile SortedDictionary _verifiers; + + private static void InitVerifiers() + { + if ( _verifiers != null ) + return; + + var verifiers = new SortedDictionary(); + + RegisterAt( verifiers, OctetKeyVerifier.Instance ); + RegisterAt( verifiers, EllipticCurveKeyVerifier.Instance ); + RegisterAt( verifiers, EllipticCurveHsmKeyVerifier.Instance ); + RegisterAt( verifiers, RsaKeyVerifier.Instance ); + RegisterAt( verifiers, RsaHsmKeyVerifier.Instance ); + + _verifiers = verifiers; + } + + /// + /// Registers a verifier for a value. + /// + /// Throws exception is a previous verifier for same value is already registered. + /// There is no need to register verifiers for values described on . + /// The verifier to register. + /// + public static void Register( JsonWebKeyVerifier verifier ) + { + if ( verifier == null ) + throw new ArgumentNullException( nameof( verifier ) ); + + lock ( _verifiersLock ) + { + InitVerifiers(); + RegisterAt( _verifiers, verifier ); + } + } + + private static void RegisterAt( IDictionary verifiers, JsonWebKeyVerifier verifier ) + { + Debug.Assert( verifiers != null ); + + if ( verifiers.TryGetValue( verifier.Kty, out JsonWebKeyVerifier _ ) ) + throw new InvalidOperationException( $"Value already registered for \"{verifier.Kty}\"." ); + + verifiers[verifier.Kty] = verifier; + } + + /// + /// Returns the verifier registered for the specified kty value, or null if the kty value was not registered. + /// + /// This method never returns null for values described on . + /// + public static JsonWebKeyVerifier GetVerifier( string kty ) + { + if ( string.IsNullOrWhiteSpace( kty ) ) + throw new ArgumentNullException( nameof( kty ) ); + + lock ( _verifiersLock ) + { + InitVerifiers(); + _verifiers.TryGetValue( kty, out JsonWebKeyVerifier result ); + return result; + } + } + + private static bool VerifyPublicKey( JsonWebKeyVerifier verifier, JsonWebKey webKey, Options options, ref string error ) + { + return VerifyKeyParameters( + "public", + verifier.IsPublicKeyComplete, + verifier.IsPublicKeyValid, + webKey, + options, + ref error ); + } + + private static bool VerifyNoPrivateKey( JsonWebKeyVerifier verifier, JsonWebKey webKey, Options options, ref string error ) + { + ICollection specifiedProps = null; + if ( !verifier.IsAnyPrivateKeyParamSpecified( webKey, ref specifiedProps ) ) + return true; + + if ( specifiedProps == null || specifiedProps.Count == 0 ) + return SetError( options, ref error, "Private key parameters must not be specified." ); + + return SetError( options, ref error, $"Private key parameters must not be specified: {SurroundWithQuotes( specifiedProps )}" ); + } + + private static bool VerifyPrivateKey( JsonWebKeyVerifier verifier, JsonWebKey webKey, Options options, ref string error ) + { + return VerifyKeyParameters( + "private", + verifier.IsPrivateKeyComplete, + verifier.IsPrivateKeyValid, + webKey, + options, + ref error ); + } + + private static bool VerifySymmetricKey( JsonWebKeyVerifier verifier, JsonWebKey webKey, Options options, ref string error ) + { + return VerifyKeyParameters( + "symmetric", + verifier.IsSymmetricKeyComplete, + verifier.IsSymmetricKeyValid, + webKey, + options, + ref error ); + } + + private static bool VerifySecretKey( JsonWebKeyVerifier verifier, JsonWebKey webKey, Options options, ref string error ) + { + return VerifyKeyParameters( + "secret", + verifier.IsSecretKeyComplete, + verifier.IsSecretKeyValid, + webKey, + options, + ref error ); + } + + private delegate bool IsCompleteProc( JsonWebKey webKey, ref ICollection missingProps ); + + private delegate bool IsValidProc( JsonWebKey webKey, ref string errorMsg ); + + private static bool VerifyKeyParameters( string name, IsCompleteProc isCompleteProc, IsValidProc isValidProc, JsonWebKey webKey, Options options, ref string error ) + { + ICollection missingParams = null; + if ( !isCompleteProc( webKey, ref missingParams ) ) + { + if ( missingParams == null || missingParams.Count == 0 ) + return SetError( options, ref error, $"Missing {name} key parameters." ); + + return SetError( options, ref error, $"Missing {name} key parameters: {SurroundWithQuotes( missingParams )}" ); + } + + string errorMsg = null; + if ( !isValidProc( webKey, ref errorMsg ) ) + { + if ( errorMsg != null ) + errorMsg = $"Invalid {name} key parameters: {errorMsg}"; + else + errorMsg = $"Invalid {name} key parameters."; + + return SetError( options, ref error, errorMsg ); + } + + return true; + } + + private static bool VerifyOperationsAreValid( JsonWebKey webKey, Options options, ref string error ) + { + if ( webKey.KeyOps == null ) + return true; + + StringBuilder invalid = null; + + foreach ( var keyOp in webKey.KeyOps ) + if ( !IsOperationValid( keyOp ) ) + { + if ( invalid == null ) + invalid = new StringBuilder(); + else + invalid.Append( ", " ); + + invalid.Append( '"' ).Append( keyOp ).Append( '"' ); + } + + if ( invalid != null ) + { + var validOps = SurroundWithQuotes( _validOperations ); + return SetError( options, ref error, $"Found invalid operations: {invalid}. Valid operations are: {validOps}." ); + } + + return true; + } + + private static bool VerifyOperationsAreCompatible( JsonWebKeyVerifier verifier, JsonWebKey webKey, Options options, ref string error ) + { + if ( webKey.KeyOps == null ) + return true; + + StringBuilder incompatible = null; + + foreach ( var keyOp in webKey.KeyOps ) + if ( !verifier.IsOperationCompatible( keyOp ) ) + { + if ( incompatible == null ) + incompatible = new StringBuilder(); + else + incompatible.Append( ", " ); + + incompatible.Append( '"' ).Append( keyOp ).Append( '"' ); + } + + if ( incompatible != null ) + { + var compatibleOps = SurroundWithQuotes( verifier._compatibleOperations ); + return SetError( options, ref error, $"Found invalid or incompatible operations: {incompatible}. Valid and compatible operations are: {compatibleOps}." ); + } + + return true; + } + + private static bool VerifyNoExtraneousFields( JsonWebKeyVerifier verifier, JsonWebKey webKey, Options options, ref string error ) + { + StringBuilder extraneous = null; + + void VerifyProperty( string name, object value ) + { + if ( value == null || verifier.IsPropertyUsed( name ) ) + return; + + if ( extraneous == null ) + extraneous = new StringBuilder(); + else + extraneous.Append( ", " ); + + extraneous.Append( '"' ).Append( name ).Append( '"' ); + } + + webKey.VisitProperties( VerifyProperty ); + + if ( extraneous != null ) + return SetError( options, ref error, $"Extraneous properties: {extraneous}" ); + + return true; + } + + private static bool VerifyEnum( string value, string name, IDictionary dictionary, out T item, Options options, ref string error ) + { + if ( !dictionary.TryGetValue( value, out item ) ) + return SetError( options, ref error, $"Expected {name} to be one of {SurroundWithQuotes( dictionary.Keys )}, but found something else." ); + + if ( item == null ) + throw new InvalidOperationException( $"Dictionary for {name} is returning null for \"{value}\"." ); + + return true; + } + + private static bool VerifyNotNullOrWhiteSpace( string value, string name, Options options, ref string error ) + { + if ( string.IsNullOrWhiteSpace( value ) ) + return SetError( options, ref error, $"A value for {name} is mandatory." ); + + return true; + } + + private static bool SetError( Options options, ref string error, string message ) + { + if ( options.HasFlag( Options.ThrowException ) ) + throw new JsonWebKeyVerificationException( message ); + error = message; + return false; + } + + /// + /// Helper method that surrounds string values with double-quotes. + /// + /// For instance, the strings Foo, Bar cause this method to return "Foo", "Bar". + protected static string SurroundWithQuotes( ICollection items ) + { + return "\"" + string.Join( "\", \"", items ) + "\""; + } + + /// + /// Helper method that joins the operation of creating a collection (if required) and adding an item to it. + /// + /// If the collection is null, this method creates one of type . Then it adds the specified item to the collection. + protected static void AddItem( ref ICollection items, T newItem ) + { + if ( items == null ) + items = new List(); + items.Add( newItem ); + } + + /// + /// Helper method that validates the size of a byte array. + /// + /// A valid array meets the following criteria: + /// + /// is not null; + /// the length is at least ; and + /// excess leading bytes are all zeros. + /// + /// The array to validate. + /// The array name, which may be used to build error messages. + /// The required size, in bytes. + /// A reference to a variable that will contain the error message. This is only set + /// if the method returns false. + /// true if the array has a valid size; false otherwise. + protected static bool ValidateKeyParameterSize( byte[] value, string name, int requiredSize, ref string errorMsg ) + { + if ( value == null || value.Length < requiredSize ) + { + var sizeDesc = value == null ? "null" : value.Length.ToString(); + errorMsg = $"Expected {name} to have at least {requiredSize} bytes, but found {sizeDesc}."; + return false; + } + + var excess = value.Length - requiredSize; + for ( var i = 0; i < excess; ++i ) + { + if ( value[i] != 0 ) + errorMsg = $"Expected {name} to have at most {requiredSize} bytes, but found {requiredSize + excess}."; + --excess; + } + + return true; + } + } + + internal sealed class OctetKeyVerifier : JsonWebKeyVerifier + { + public static JsonWebKeyVerifier Instance { get; } = new OctetKeyVerifier(); + + private OctetKeyVerifier() : base( JsonWebKeyType.Octet ) + { + } + + public override bool IsPublicKeyCrypto => false; + public override bool IsSymmetricKeyCrypto => true; + public override bool HasSecretKey => false; + + protected override void AddCompatibleOperations( ICollection compatibleOperations ) + { + compatibleOperations.Add( JsonWebKeyOperation.Encrypt ); + compatibleOperations.Add( JsonWebKeyOperation.Decrypt ); + compatibleOperations.Add( JsonWebKeyOperation.Wrap ); + compatibleOperations.Add( JsonWebKeyOperation.Unwrap ); + } + + protected override void AddUsedProperties( ICollection usedProperties ) + { + usedProperties.Add( JsonWebKey.Property_K ); + } + + public override bool IsSymmetricKeyComplete( JsonWebKey arg, ref ICollection missingProps ) + { + if ( arg.K == null || arg.K.Length == 0 ) + { + AddItem( ref missingProps, JsonWebKey.Property_K ); + return false; + } + + return true; + } + + public override bool IsSymmetricKeyValid( JsonWebKey arg, ref string errorMsg ) + { + return true; + } + } + + internal abstract class EllipticCurveKeyVerifierBase : JsonWebKeyVerifier + { + protected EllipticCurveKeyVerifierBase( string kty ) : base( kty ) + { + } + + public override bool IsPublicKeyCrypto => true; + public override bool IsSymmetricKeyCrypto => false; + + protected override void AddCompatibleOperations( ICollection compatibleOperations ) + { + compatibleOperations.Add( JsonWebKeyOperation.Sign ); + compatibleOperations.Add( JsonWebKeyOperation.Verify ); + } + + protected override void AddUsedProperties( ICollection usedProperties ) + { + usedProperties.Add( JsonWebKey.Property_Crv ); + usedProperties.Add( JsonWebKey.Property_X ); + usedProperties.Add( JsonWebKey.Property_Y ); + } + + public override bool IsPublicKeyComplete( JsonWebKey webKey, ref ICollection missingProps ) + { + var result = true; + + if ( string.IsNullOrWhiteSpace( webKey.CurveName ) ) + { + AddItem( ref missingProps, JsonWebKey.Property_Crv ); + result = false; + } + + if ( webKey.X == null || webKey.X.Length == 0 ) + { + AddItem( ref missingProps, JsonWebKey.Property_X ); + result = false; + } + + if ( webKey.Y == null || webKey.Y.Length == 0 ) + { + AddItem( ref missingProps, JsonWebKey.Property_Y ); + result = false; + } + + return result; + } + + public override bool IsPublicKeyValid( JsonWebKey webKey, ref string errorMsg ) + { + var requiredSize = JsonWebKeyCurveName.GetKeyParameterSize( webKey.CurveName ); + + if ( requiredSize < 0 ) + { + errorMsg = $"Unsupported curve: \"{webKey.CurveName}\". Supported curves are: {SurroundWithQuotes( JsonWebKeyCurveName.AllCurves )}."; + return false; + } + + if ( !ValidateKeyParameterSize( webKey.X, nameof( webKey.X ), requiredSize, ref errorMsg ) ) + return false; + + if ( !ValidateKeyParameterSize( webKey.Y, nameof( webKey.Y ), requiredSize, ref errorMsg ) ) + return false; + + return true; + } + } + + internal sealed class EllipticCurveKeyVerifier : EllipticCurveKeyVerifierBase + { + public static JsonWebKeyVerifier Instance { get; } = new EllipticCurveKeyVerifier(); + + private EllipticCurveKeyVerifier() : base( JsonWebKeyType.EllipticCurve ) + { + } + + public override bool HasSecretKey => false; + + protected override void AddUsedProperties( ICollection usedProperties ) + { + base.AddUsedProperties( usedProperties ); + usedProperties.Add( JsonWebKey.Property_D ); + } + + public override bool IsPrivateKeyComplete( JsonWebKey webKey, ref ICollection missingProps ) + { + if ( webKey.D == null || webKey.D.Length == 0 ) + { + AddItem( ref missingProps, JsonWebKey.Property_D ); + return false; + } + + return true; + } + + public override bool IsPrivateKeyValid( JsonWebKey webKey, ref string errorMsg ) + { + var requiredSize = JsonWebKeyCurveName.GetKeyParameterSize( webKey.CurveName ); + + if ( requiredSize < 0 ) + { + errorMsg = $"Unsupported curve: \"{webKey.CurveName}\". Supported curves are: {SurroundWithQuotes( JsonWebKeyCurveName.AllCurves )}."; + return false; + } + + if ( !ValidateKeyParameterSize( webKey.D, nameof( webKey.D ), requiredSize, ref errorMsg ) ) + return false; + + return true; + } + } + + internal sealed class EllipticCurveHsmKeyVerifier : EllipticCurveKeyVerifierBase + { + public static JsonWebKeyVerifier Instance { get; } = new EllipticCurveHsmKeyVerifier(); + + private EllipticCurveHsmKeyVerifier() : base( JsonWebKeyType.EllipticCurveHsm ) + { + } + + public override bool HasSecretKey => true; + + protected override void AddUsedProperties( ICollection usedProperties ) + { + base.AddUsedProperties( usedProperties ); + usedProperties.Add( JsonWebKey.Property_T ); + } + + public override bool IsPrivateKeyComplete( JsonWebKey webKey, ref ICollection missingProps ) + { + return true; + } + + public override bool IsPrivateKeyValid( JsonWebKey webKey, ref string errorMsg ) + { + return true; + } + + public override bool IsSecretKeyComplete( JsonWebKey webKey, ref ICollection missingProps ) + { + if ( webKey.T == null || webKey.T.Length == 0 ) + { + AddItem( ref missingProps, JsonWebKey.Property_T ); + return false; + } + + return true; + } + + public override bool IsSecretKeyValid( JsonWebKey webKey, ref string errorMsg ) + { + return true; + } + } + + internal abstract class RsaKeyVerifierBase : JsonWebKeyVerifier + { + protected RsaKeyVerifierBase( string kty ) : base( kty ) + { + } + + public override bool IsPublicKeyCrypto => true; + public override bool IsSymmetricKeyCrypto => false; + + protected override void AddCompatibleOperations( ICollection compatibleOperations ) + { + compatibleOperations.Add( JsonWebKeyOperation.Encrypt ); + compatibleOperations.Add( JsonWebKeyOperation.Decrypt ); + compatibleOperations.Add( JsonWebKeyOperation.Wrap ); + compatibleOperations.Add( JsonWebKeyOperation.Unwrap ); + compatibleOperations.Add( JsonWebKeyOperation.Sign ); + compatibleOperations.Add( JsonWebKeyOperation.Verify ); + } + + protected override void AddUsedProperties( ICollection usedProperties ) + { + usedProperties.Add( JsonWebKey.Property_E ); + usedProperties.Add( JsonWebKey.Property_N ); + } + + public override bool IsPublicKeyComplete( JsonWebKey webKey, ref ICollection missingProps ) + { + var result = true; + + if ( webKey.E == null || webKey.E.Length == 0 ) + { + AddItem( ref missingProps, JsonWebKey.Property_E ); + result = false; + } + + if ( webKey.N == null || webKey.N.Length == 0 ) + { + AddItem( ref missingProps, JsonWebKey.Property_N ); + result = false; + } + + return result; + } + + public override bool IsPublicKeyValid( JsonWebKey webKey, ref string errorMsg ) + { + return true; + } + } + + internal sealed class RsaKeyVerifier : RsaKeyVerifierBase + { + public static JsonWebKeyVerifier Instance { get; } = new RsaKeyVerifier(); + + private RsaKeyVerifier() : base( JsonWebKeyType.Rsa ) + { + } + + public override bool HasSecretKey => false; + + protected override void AddUsedProperties( ICollection usedProperties ) + { + base.AddUsedProperties( usedProperties ); + usedProperties.Add( JsonWebKey.Property_D ); + usedProperties.Add( JsonWebKey.Property_DP ); + usedProperties.Add( JsonWebKey.Property_DQ ); + usedProperties.Add( JsonWebKey.Property_P ); + usedProperties.Add( JsonWebKey.Property_Q ); + usedProperties.Add( JsonWebKey.Property_QI ); + } + + public override bool IsPrivateKeyComplete( JsonWebKey webKey, ref ICollection missingProps ) + { + var result = true; + + if ( webKey.D == null || webKey.D.Length == 0 ) + { + AddItem( ref missingProps, JsonWebKey.Property_D ); + result = false; + } + + if ( webKey.DP == null || webKey.DP.Length == 0 ) + { + AddItem( ref missingProps, JsonWebKey.Property_DP ); + result = false; + } + + if ( webKey.DQ == null || webKey.DQ.Length == 0 ) + { + AddItem( ref missingProps, JsonWebKey.Property_DQ ); + result = false; + } + + if ( webKey.P == null || webKey.P.Length == 0 ) + { + AddItem( ref missingProps, JsonWebKey.Property_P ); + result = false; + } + + if ( webKey.Q == null || webKey.Q.Length == 0 ) + { + AddItem( ref missingProps, JsonWebKey.Property_Q ); + result = false; + } + + if ( webKey.QI == null || webKey.QI.Length == 0 ) + { + AddItem( ref missingProps, JsonWebKey.Property_QI ); + result = false; + } + + return result; + } + + public override bool IsPrivateKeyValid( JsonWebKey webKey, ref string errorMsg ) + { + return true; + } + } + + internal sealed class RsaHsmKeyVerifier : RsaKeyVerifierBase + { + public static JsonWebKeyVerifier Instance { get; } = new RsaHsmKeyVerifier(); + + private RsaHsmKeyVerifier() : base( JsonWebKeyType.RsaHsm ) + { + } + + public override bool HasSecretKey => true; + + protected override void AddUsedProperties( ICollection usedProperties ) + { + base.AddUsedProperties( usedProperties ); + usedProperties.Add( JsonWebKey.Property_T ); + } + + public override bool IsPrivateKeyComplete( JsonWebKey webKey, ref ICollection missingProps ) + { + return true; + } + + public override bool IsPrivateKeyValid( JsonWebKey webKey, ref string errorMsg ) + { + return true; + } + + public override bool IsSecretKeyComplete( JsonWebKey webKey, ref ICollection missingProps ) + { + if ( webKey.T == null || webKey.T.Length == 0 ) + { + AddItem( ref missingProps, JsonWebKey.Property_T ); + return false; + } + + return true; + } + + public override bool IsSecretKeyValid( JsonWebKey webKey, ref string errorMsg ) + { + return true; + } + } +} \ No newline at end of file diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.WebKey/Microsoft.Azure.KeyVault.WebKey.csproj b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.WebKey/Microsoft.Azure.KeyVault.WebKey.csproj index 2d68d49d8896..233cb431594a 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.WebKey/Microsoft.Azure.KeyVault.WebKey.csproj +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.WebKey/Microsoft.Azure.KeyVault.WebKey.csproj @@ -5,9 +5,10 @@ Microsoft Azure Key Vault WebKey Class Library Microsoft Azure Key Vault WebKey Microsoft.Azure.KeyVault.WebKey - 2.0.7 - Microsoft Azure key vault WebKey + 2.1.0 + Microsoft Azure Key Vault WebKey + net452;netstandard1.4 @@ -15,15 +16,15 @@ - + - + - + - + \ No newline at end of file diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.sln b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.sln index 4e285375f22d..0593f783d778 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.sln +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26403.7 +VisualStudioVersion = 15.0.26430.16 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.KeyVault", "Microsoft.Azure.KeyVault\Microsoft.Azure.KeyVault.csproj", "{F0FBD614-4B4B-445B-B562-235CDB3844B7}" EndProject diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Customized/KeyVaultClientExtensions.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Customized/KeyVaultClientExtensions.cs index 6c6bc56157ea..1fa0a7174d55 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Customized/KeyVaultClientExtensions.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Customized/KeyVaultClientExtensions.cs @@ -31,13 +31,13 @@ public static partial class KeyVaultClientExtensions public static async Task EncryptAsync(this IKeyVaultClient operations, string keyIdentifier, string algorithm, byte[] plainText, CancellationToken cancellationToken = default(CancellationToken)) { if (string.IsNullOrEmpty(keyIdentifier)) - throw new ArgumentNullException("keyIdentifier"); + throw new ArgumentNullException(nameof( keyIdentifier )); if (string.IsNullOrEmpty(algorithm)) - throw new ArgumentNullException("algorithm"); + throw new ArgumentNullException(nameof( algorithm )); if (plainText == null) - throw new ArgumentNullException("plainText"); + throw new ArgumentNullException(nameof( plainText )); var keyId = new KeyIdentifier(keyIdentifier); @@ -58,13 +58,13 @@ public static partial class KeyVaultClientExtensions public static async Task DecryptAsync(this IKeyVaultClient operations, string keyIdentifier, string algorithm, byte[] cipherText, CancellationToken cancellationToken = default(CancellationToken)) { if (string.IsNullOrEmpty(keyIdentifier)) - throw new ArgumentNullException("keyIdentifier"); + throw new ArgumentNullException(nameof( keyIdentifier )); if (string.IsNullOrEmpty(algorithm)) - throw new ArgumentNullException("algorithm"); + throw new ArgumentNullException(nameof( algorithm )); if (cipherText == null) - throw new ArgumentNullException("cipherText"); + throw new ArgumentNullException(nameof( cipherText )); var keyId = new KeyIdentifier(keyIdentifier); @@ -87,13 +87,13 @@ public static partial class KeyVaultClientExtensions public static async Task SignAsync(this IKeyVaultClient operations, string keyIdentifier, string algorithm, byte[] digest, CancellationToken cancellationToken = default(CancellationToken)) { if (string.IsNullOrEmpty(keyIdentifier)) - throw new ArgumentNullException("keyIdentifier"); + throw new ArgumentNullException(nameof( keyIdentifier )); if (string.IsNullOrEmpty(algorithm)) - throw new ArgumentNullException("algorithm"); + throw new ArgumentNullException(nameof( algorithm )); if (digest == null) - throw new ArgumentNullException("digest"); + throw new ArgumentNullException(nameof( digest )); var keyId = new KeyIdentifier(keyIdentifier); @@ -115,16 +115,16 @@ public static partial class KeyVaultClientExtensions public static async Task VerifyAsync(this IKeyVaultClient operations, string keyIdentifier, string algorithm, byte[] digest, byte[] signature, CancellationToken cancellationToken = default(CancellationToken)) { if (string.IsNullOrEmpty(keyIdentifier)) - throw new ArgumentNullException("keyIdentifier"); + throw new ArgumentNullException(nameof( keyIdentifier )); if (string.IsNullOrEmpty(algorithm)) - throw new ArgumentNullException("algorithm"); + throw new ArgumentNullException(nameof( algorithm )); if (digest == null) - throw new ArgumentNullException("digest"); + throw new ArgumentNullException(nameof( digest )); if (signature == null) - throw new ArgumentNullException("signature"); + throw new ArgumentNullException(nameof( signature )); var keyId = new KeyIdentifier(keyIdentifier); @@ -146,13 +146,13 @@ public static partial class KeyVaultClientExtensions public static async Task WrapKeyAsync(this IKeyVaultClient operations, string keyIdentifier, string algorithm, byte[] key, CancellationToken cancellationToken = default(CancellationToken)) { if (string.IsNullOrEmpty(keyIdentifier)) - throw new ArgumentNullException("keyIdentifier"); + throw new ArgumentNullException(nameof( keyIdentifier )); if (string.IsNullOrEmpty(algorithm)) - throw new ArgumentNullException("algorithm"); + throw new ArgumentNullException(nameof( algorithm )); if (key == null) - throw new ArgumentNullException("key"); + throw new ArgumentNullException(nameof( key )); var keyId = new KeyIdentifier(keyIdentifier); @@ -174,13 +174,13 @@ public static partial class KeyVaultClientExtensions public static async Task UnwrapKeyAsync(this IKeyVaultClient operations, string keyIdentifier, string algorithm, byte[] wrappedKey, CancellationToken cancellationToken = default(CancellationToken)) { if (string.IsNullOrEmpty(keyIdentifier)) - throw new ArgumentNullException("keyIdentifier"); + throw new ArgumentNullException(nameof( keyIdentifier )); if (string.IsNullOrEmpty(algorithm)) - throw new ArgumentNullException("algorithm"); + throw new ArgumentNullException(nameof( algorithm )); if (wrappedKey == null) - throw new ArgumentNullException("wrappedKey"); + throw new ArgumentNullException(nameof( wrappedKey )); var keyId = new KeyIdentifier(keyIdentifier); @@ -204,10 +204,10 @@ public static partial class KeyVaultClientExtensions public static async Task GetKeyAsync(this IKeyVaultClient operations, string vaultBaseUrl, string keyName, CancellationToken cancellationToken = default(CancellationToken)) { if (string.IsNullOrEmpty(vaultBaseUrl)) - throw new ArgumentNullException("vaultBaseUrl"); + throw new ArgumentNullException(nameof( vaultBaseUrl )); if (string.IsNullOrEmpty(keyName)) - throw new ArgumentNullException("keyName"); + throw new ArgumentNullException(nameof( keyName )); using (var _result = await operations.GetKeyWithHttpMessagesAsync(vaultBaseUrl, keyName, string.Empty, null, cancellationToken).ConfigureAwait(false)) { @@ -224,7 +224,7 @@ public static partial class KeyVaultClientExtensions public static async Task GetKeyAsync(this IKeyVaultClient operations, string keyIdentifier, CancellationToken cancellationToken = default(CancellationToken)) { if (string.IsNullOrEmpty(keyIdentifier)) - throw new ArgumentNullException("keyIdentifier"); + throw new ArgumentNullException(nameof( keyIdentifier )); var keyId = new KeyIdentifier(keyIdentifier); @@ -246,10 +246,10 @@ public static partial class KeyVaultClientExtensions public static async Task UpdateKeyAsync(this IKeyVaultClient operations, string vaultBaseUrl, string keyName, string[] keyOps = null, KeyAttributes attributes = null, Dictionary tags = null, CancellationToken cancellationToken = default(CancellationToken)) { if (string.IsNullOrEmpty(vaultBaseUrl)) - throw new ArgumentNullException("vaultBaseUrl"); + throw new ArgumentNullException(nameof( vaultBaseUrl )); if (string.IsNullOrEmpty(keyName)) - throw new ArgumentNullException("keyName"); + throw new ArgumentNullException(nameof( keyName )); using (var _result = await operations.UpdateKeyWithHttpMessagesAsync(vaultBaseUrl, keyName, string.Empty, keyOps, attributes, tags, null, cancellationToken).ConfigureAwait(false)) { @@ -269,7 +269,7 @@ public static partial class KeyVaultClientExtensions public static async Task UpdateKeyAsync(this IKeyVaultClient operations, string keyIdentifier, string[] keyOps = null, KeyAttributes attributes = null, Dictionary tags = null, CancellationToken cancellationToken = default(CancellationToken)) { if (string.IsNullOrEmpty(keyIdentifier)) - throw new ArgumentNullException("keyIdentifier"); + throw new ArgumentNullException(nameof( keyIdentifier )); var keyId = new KeyIdentifier(keyIdentifier); @@ -279,6 +279,34 @@ public static partial class KeyVaultClientExtensions } } + public static async Task CreateKeyAsync( this IKeyVaultClient operations, string vaultBaseUrl, string keyName, NewKeyParameters parameters, CancellationToken cancellationToken = default( CancellationToken ) ) + { + if (string.IsNullOrEmpty( vaultBaseUrl )) + throw new ArgumentNullException( nameof( vaultBaseUrl ) ); + + if (string.IsNullOrEmpty( keyName )) + throw new ArgumentNullException( nameof( keyName ) ); + + if (parameters == null) + throw new ArgumentNullException( nameof( parameters ) ); + + using (var _result = await operations.CreateKeyWithHttpMessagesAsync( + vaultBaseUrl, + keyName, + parameters.Kty, + parameters.KeySize, + parameters.KeyOps, + parameters.Attributes, + parameters.Tags, + parameters.CurveName, + null, // customHeaders + cancellationToken + ).ConfigureAwait(false)) + { + return _result.Body; + } + } + /// /// Imports a key into the specified vault /// @@ -291,19 +319,18 @@ public static partial class KeyVaultClientExtensions public static async Task ImportKeyAsync(this IKeyVaultClient operations, string vaultBaseUrl, string keyName, KeyBundle keyBundle, bool? importToHardware = null, CancellationToken cancellationToken = default(CancellationToken)) { if (string.IsNullOrEmpty(vaultBaseUrl)) - throw new ArgumentNullException("vaultBaseUrl"); + throw new ArgumentNullException(nameof( vaultBaseUrl )); if (string.IsNullOrEmpty(keyName)) - throw new ArgumentNullException("keyName"); + throw new ArgumentNullException(nameof( keyName )); if (keyBundle == null) - throw new ArgumentNullException("keyBundle"); + throw new ArgumentNullException(nameof( keyBundle )); using (var _result = await operations.ImportKeyWithHttpMessagesAsync(vaultBaseUrl, keyName, keyBundle.Key, importToHardware, keyBundle.Attributes, keyBundle.Tags, null, cancellationToken).ConfigureAwait(false)) { return _result.Body; } - } #endregion @@ -319,10 +346,10 @@ public static partial class KeyVaultClientExtensions public static async Task GetSecretAsync(this IKeyVaultClient operations, string vaultBaseUrl, string secretName, CancellationToken cancellationToken = default(CancellationToken)) { if (string.IsNullOrEmpty(vaultBaseUrl)) - throw new ArgumentNullException("vaultBaseUrl"); + throw new ArgumentNullException(nameof( vaultBaseUrl )); if (string.IsNullOrEmpty(secretName)) - throw new ArgumentNullException("secretName"); + throw new ArgumentNullException(nameof( secretName )); using (var _result = await operations.GetSecretWithHttpMessagesAsync(vaultBaseUrl, secretName, string.Empty, null, cancellationToken).ConfigureAwait(false)) { @@ -339,7 +366,7 @@ public static partial class KeyVaultClientExtensions public static async Task GetSecretAsync(this IKeyVaultClient operations, string secretIdentifier, CancellationToken cancellationToken = default(CancellationToken)) { if (string.IsNullOrEmpty(secretIdentifier)) - throw new ArgumentNullException("secretIdentifier"); + throw new ArgumentNullException(nameof( secretIdentifier )); var secretId = new SecretIdentifier(secretIdentifier); using (var _result = await operations.GetSecretWithHttpMessagesAsync(secretId.Vault, secretId.Name, secretId.Version ?? string.Empty, null, cancellationToken).ConfigureAwait(false)) @@ -360,7 +387,7 @@ public static partial class KeyVaultClientExtensions public static async Task UpdateSecretAsync(this IKeyVaultClient operations, string secretIdentifier, string contentType = null, SecretAttributes secretAttributes = null, Dictionary tags = null, CancellationToken cancellationToken = default(CancellationToken)) { if (string.IsNullOrEmpty(secretIdentifier)) - throw new ArgumentNullException("secretIdentifier"); + throw new ArgumentNullException(nameof( secretIdentifier )); var secretId = new SecretIdentifier(secretIdentifier); @@ -501,10 +528,10 @@ public static partial class KeyVaultClientExtensions public static async Task GetCertificateAsync(this IKeyVaultClient operations, string vaultBaseUrl, string certificateName, CancellationToken cancellationToken = default(CancellationToken)) { if (string.IsNullOrEmpty(vaultBaseUrl)) - throw new ArgumentNullException("vaultBaseUrl"); + throw new ArgumentNullException(nameof( vaultBaseUrl )); if (string.IsNullOrEmpty(certificateName)) - throw new ArgumentNullException("certificateName"); + throw new ArgumentNullException(nameof( certificateName )); using (var _result = await operations.GetCertificateWithHttpMessagesAsync(vaultBaseUrl, certificateName, string.Empty, null, cancellationToken).ConfigureAwait(false)) { @@ -521,7 +548,7 @@ public static partial class KeyVaultClientExtensions public static async Task GetCertificateAsync(this IKeyVaultClient operations, string certificateIdentifier, CancellationToken cancellationToken = default(CancellationToken)) { if (string.IsNullOrEmpty(certificateIdentifier)) - throw new ArgumentNullException("certificateIdentifier"); + throw new ArgumentNullException(nameof( certificateIdentifier )); var certId = new CertificateIdentifier(certificateIdentifier); @@ -543,7 +570,7 @@ public static partial class KeyVaultClientExtensions public static async Task UpdateCertificateAsync(this IKeyVaultClient operations, string certificateIdentifier, CertificatePolicy certificatePolicy = default(CertificatePolicy), CertificateAttributes certificateAttributes = null, IDictionary tags = null, CancellationToken cancellationToken = default(CancellationToken)) { if (string.IsNullOrWhiteSpace(certificateIdentifier)) - throw new ArgumentNullException("certificateIdentifier"); + throw new ArgumentNullException(nameof( certificateIdentifier )); var certId = new CertificateIdentifier(certificateIdentifier); using (var _result = await operations.UpdateCertificateWithHttpMessagesAsync(certId.Vault, certId.Name, certId.Version ?? string.Empty, certificatePolicy, certificateAttributes, tags, null, cancellationToken).ConfigureAwait(false)) @@ -567,13 +594,13 @@ public static partial class KeyVaultClientExtensions public static async Task ImportCertificateAsync(this IKeyVaultClient operations, string vaultBaseUrl, string certificateName, X509Certificate2Collection certificateCollection, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes = null, IDictionary tags = null, CancellationToken cancellationToken = default(CancellationToken)) { if (string.IsNullOrWhiteSpace(vaultBaseUrl)) - throw new ArgumentNullException("vaultBaseUrl"); + throw new ArgumentNullException(nameof( vaultBaseUrl )); if (string.IsNullOrWhiteSpace(certificateName)) - throw new ArgumentNullException("certificateName"); + throw new ArgumentNullException(nameof( certificateName )); if (null == certificateCollection) - throw new ArgumentNullException("certificateCollection"); + throw new ArgumentNullException(nameof( certificateCollection )); var base64EncodedCertificate = Convert.ToBase64String(certificateCollection.Export(X509ContentType.Pfx)); using (var _result = await operations.ImportCertificateWithHttpMessagesAsync(vaultBaseUrl, certificateName, base64EncodedCertificate, string.Empty, certificatePolicy, certificateAttributes, tags, null, cancellationToken)) @@ -595,10 +622,10 @@ public static partial class KeyVaultClientExtensions public static async Task MergeCertificateAsync(this IKeyVaultClient operations, string vaultBaseUrl, string certificateName, X509Certificate2Collection x509Certificates, CertificateAttributes certificateAttributes = null, IDictionary tags = null, CancellationToken cancellationToken = default(CancellationToken)) { if (string.IsNullOrWhiteSpace(vaultBaseUrl)) - throw new ArgumentNullException("vaultBaseUrl"); + throw new ArgumentNullException(nameof( vaultBaseUrl )); if (string.IsNullOrWhiteSpace(certificateName)) - throw new ArgumentNullException("certificateName"); + throw new ArgumentNullException(nameof( certificateName )); if (x509Certificates == null || x509Certificates.Count == 0) throw new ArgumentException("x509Certificates"); @@ -625,10 +652,10 @@ public static partial class KeyVaultClientExtensions public static async Task GetPendingCertificateSigningRequestAsync(this IKeyVaultClient operations, string vaultBaseUrl, string certificateName, CancellationToken cancellationToken = default(CancellationToken)) { if (string.IsNullOrWhiteSpace(vaultBaseUrl)) - throw new ArgumentNullException("vaultBaseUrl"); + throw new ArgumentNullException(nameof( vaultBaseUrl )); if (string.IsNullOrWhiteSpace(certificateName)) - throw new ArgumentNullException("certificateName"); + throw new ArgumentNullException(nameof( certificateName )); using (var _result = await operations.GetPendingCertificateSigningRequestWithHttpMessagesAsync(vaultBaseUrl, certificateName, null, cancellationToken)) { diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Customized/NewKeyParameters.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Customized/NewKeyParameters.cs new file mode 100644 index 000000000000..a044fec63924 --- /dev/null +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Customized/NewKeyParameters.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. + +namespace Microsoft.Azure.KeyVault.Models +{ + using System.Collections.Generic; + + /// + /// Describes parameters used for creation of a new cryptographic key. + /// + public class NewKeyParameters + { + /// + /// Gets or sets the desired JsonWebKey key type. Possible values include: 'EC', 'EC-HSM', 'RSA', 'RSA-HSM', 'oct' + /// + public string Kty { get; set; } + + /// + /// Gets or sets the name of desired curve for used with Elliptic Curve Cryptography (ECC) algorithms. + /// + public string CurveName { get; set; } + + /// + /// Gets or sets the desired key size. + /// + public int? KeySize { get; set; } + + /// + /// Gets or sets the desired operations that the key will support. + /// + public IList KeyOps { get; set; } + + /// + /// Gets or sets the desired key management attributes. + /// + public KeyAttributes Attributes { get; set; } + + /// + /// Gets or sets application specific metadata in the form of key-value pairs. + /// + public IDictionary Tags { get; set; } + } +} \ No newline at end of file diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/IKeyVaultClient.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/IKeyVaultClient.cs index 67ceff07f160..5dd4a4f6e803 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/IKeyVaultClient.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/IKeyVaultClient.cs @@ -2,22 +2,22 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault { - using Azure; - using Rest; - using Rest.Azure; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault.WebKey; + using Microsoft.Rest; + using Microsoft.Rest.Azure; using Models; using Newtonsoft.Json; using System.Collections; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; - using Microsoft.Azure.KeyVault.WebKey; /// /// The key vault client performs cryptographic key operations and vault @@ -84,9 +84,8 @@ public partial interface IKeyVaultClient : System.IDisposable /// for the new key. /// /// - /// The type of key to create. For valid key types, see JsonWebKeyType. - /// Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, HSM, - /// Octet. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' + /// The type of key to create. For valid values, see JsonWebKeyType. + /// Possible values include: 'EC', 'EC-HSM', 'RSA', 'RSA-HSM', 'oct' /// /// /// The key size in bytes. For example, 1024 or 2048. @@ -98,13 +97,17 @@ public partial interface IKeyVaultClient : System.IDisposable /// /// Application specific metadata in the form of key-value pairs. /// + /// + /// Elliptic curve name. For valid values, see JsonWebKeyCurveName. + /// Possible values include: 'P-256', 'P-384', 'P-521', 'SECP256K1' + /// /// /// The headers that will be added to request. /// /// /// The cancellation token. /// - Task> CreateKeyWithHttpMessagesAsync(string vaultBaseUrl, string keyName, string kty, int? keySize = default(int?), IList keyOps = default(IList), KeyAttributes keyAttributes = default(KeyAttributes), IDictionary tags = default(IDictionary), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + Task> CreateKeyWithHttpMessagesAsync(string vaultBaseUrl, string keyName, string kty, int? keySize = default(int?), IList keyOps = default(IList), KeyAttributes keyAttributes = default(KeyAttributes), IDictionary tags = default(IDictionary), string curve = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// /// Imports an externally created key, stores it, and returns key @@ -438,7 +441,7 @@ public partial interface IKeyVaultClient : System.IDisposable /// The signing/verification algorithm identifier. For more information /// on possible algorithm types, see JsonWebKeySignatureAlgorithm. /// Possible values include: 'PS256', 'PS384', 'PS512', 'RS256', - /// 'RS384', 'RS512', 'RSNULL' + /// 'RS384', 'RS512', 'RSNULL', 'ES256', 'ES384', 'ES512', 'ECDSA256' /// /// /// @@ -474,7 +477,7 @@ public partial interface IKeyVaultClient : System.IDisposable /// The signing/verification algorithm. For more information on /// possible algorithm types, see JsonWebKeySignatureAlgorithm. /// Possible values include: 'PS256', 'PS384', 'PS512', 'RS256', - /// 'RS384', 'RS512', 'RSNULL' + /// 'RS384', 'RS512', 'RSNULL', 'ES256', 'ES384', 'ES512', 'ECDSA256' /// /// /// The digest used for signing. @@ -1999,4 +2002,3 @@ public partial interface IKeyVaultClient : System.IDisposable } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/KeyVaultClient.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/KeyVaultClient.cs index eb6695f2ef4b..43a39d47e610 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/KeyVaultClient.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/KeyVaultClient.cs @@ -2,19 +2,19 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault { - using Azure; - using Rest; - using Rest.Azure; - using Rest.Serialization; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault.WebKey; + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Serialization; using Models; using Newtonsoft.Json; - using System; using System.Collections; using System.Collections.Generic; using System.Linq; @@ -22,7 +22,6 @@ namespace Microsoft.Azure.KeyVault using System.Net.Http; using System.Threading; using System.Threading.Tasks; - using Microsoft.Azure.KeyVault.WebKey; /// /// The key vault client performs cryptographic key operations and vault @@ -78,7 +77,7 @@ public partial class KeyVaultClient : ServiceClient, IKeyVaultCl /// /// Optional. The delegating handlers to add to the http client pipeline. /// - protected KeyVaultClient(params System.Net.Http.DelegatingHandler[] handlers) : base(handlers) + protected KeyVaultClient(params DelegatingHandler[] handlers) : base(handlers) { Initialize(); } @@ -92,7 +91,7 @@ protected KeyVaultClient(params System.Net.Http.DelegatingHandler[] handlers) : /// /// Optional. The delegating handlers to add to the http client pipeline. /// - protected KeyVaultClient(System.Net.Http.HttpClientHandler rootHandler, params System.Net.Http.DelegatingHandler[] handlers) : base(rootHandler, handlers) + protected KeyVaultClient(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) { Initialize(); } @@ -109,7 +108,7 @@ protected KeyVaultClient(System.Net.Http.HttpClientHandler rootHandler, params S /// /// Thrown when a required parameter is null /// - public KeyVaultClient(ServiceClientCredentials credentials, params System.Net.Http.DelegatingHandler[] handlers) : this(handlers) + public KeyVaultClient(ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handlers) { if (credentials == null) { @@ -137,7 +136,7 @@ public KeyVaultClient(ServiceClientCredentials credentials, params System.Net.Ht /// /// Thrown when a required parameter is null /// - public KeyVaultClient(ServiceClientCredentials credentials, System.Net.Http.HttpClientHandler rootHandler, params System.Net.Http.DelegatingHandler[] handlers) : this(rootHandler, handlers) + public KeyVaultClient(ServiceClientCredentials credentials, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) { if (credentials == null) { @@ -166,11 +165,11 @@ private void Initialize() GenerateClientRequestId = true; SerializationSettings = new JsonSerializerSettings { - Formatting = Formatting.Indented, - DateFormatHandling = DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = DateTimeZoneHandling.Utc, - NullValueHandling = NullValueHandling.Ignore, - ReferenceLoopHandling = ReferenceLoopHandling.Serialize, + Formatting = Newtonsoft.Json.Formatting.Indented, + DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, + NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, + ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), Converters = new List { @@ -179,10 +178,10 @@ private void Initialize() }; DeserializationSettings = new JsonSerializerSettings { - DateFormatHandling = DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = DateTimeZoneHandling.Utc, - NullValueHandling = NullValueHandling.Ignore, - ReferenceLoopHandling = ReferenceLoopHandling.Serialize, + DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, + NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, + ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), Converters = new List { @@ -209,9 +208,8 @@ private void Initialize() /// new key. /// /// - /// The type of key to create. For valid key types, see JsonWebKeyType. - /// Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, HSM, Octet. - /// Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' + /// The type of key to create. For valid values, see JsonWebKeyType. Possible + /// values include: 'EC', 'EC-HSM', 'RSA', 'RSA-HSM', 'oct' /// /// /// The key size in bytes. For example, 1024 or 2048. @@ -223,6 +221,10 @@ private void Initialize() /// /// Application specific metadata in the form of key-value pairs. /// + /// + /// Elliptic curve name. For valid values, see JsonWebKeyCurveName. Possible + /// values include: 'P-256', 'P-384', 'P-521', 'SECP256K1' + /// /// /// Headers that will be added to request. /// @@ -244,7 +246,7 @@ private void Initialize() /// /// A response object containing the response body and response headers. /// - public async Task> CreateKeyWithHttpMessagesAsync(string vaultBaseUrl, string keyName, string kty, int? keySize = default(int?), IList keyOps = default(IList), KeyAttributes keyAttributes = default(KeyAttributes), IDictionary tags = default(IDictionary), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task> CreateKeyWithHttpMessagesAsync(string vaultBaseUrl, string keyName, string kty, int? keySize = default(int?), IList keyOps = default(IList), KeyAttributes keyAttributes = default(KeyAttributes), IDictionary tags = default(IDictionary), string curve = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (vaultBaseUrl == null) { @@ -277,13 +279,14 @@ private void Initialize() } } KeyCreateParameters parameters = new KeyCreateParameters(); - if (kty != null || keySize != null || keyOps != null || keyAttributes != null || tags != null) + if (kty != null || keySize != null || keyOps != null || keyAttributes != null || tags != null || curve != null) { parameters.Kty = kty; parameters.KeySize = keySize; parameters.KeyOps = keyOps; parameters.KeyAttributes = keyAttributes; parameters.Tags = tags; + parameters.Curve = curve; } // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; @@ -313,9 +316,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -349,7 +352,7 @@ private void Initialize() if(parameters != null) { _requestContent = SafeJsonConvert.SerializeObject(parameters, SerializationSettings); - _httpRequest.Content = new System.Net.Http.StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); } // Set Credentials @@ -543,9 +546,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -579,7 +582,7 @@ private void Initialize() if(parameters != null) { _requestContent = SafeJsonConvert.SerializeObject(parameters, SerializationSettings); - _httpRequest.Content = new System.Net.Http.StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); } // Set Credentials @@ -741,9 +744,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("DELETE"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -958,9 +961,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("PATCH"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PATCH"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -994,7 +997,7 @@ private void Initialize() if(parameters != null) { _requestContent = SafeJsonConvert.SerializeObject(parameters, SerializationSettings); - _httpRequest.Content = new System.Net.Http.StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); } // Set Credentials @@ -1163,9 +1166,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -1369,9 +1372,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -1571,9 +1574,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -1772,9 +1775,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -1976,9 +1979,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -2012,7 +2015,7 @@ private void Initialize() if(parameters != null) { _requestContent = SafeJsonConvert.SerializeObject(parameters, SerializationSettings); - _httpRequest.Content = new System.Net.Http.StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); } // Set Credentials @@ -2217,9 +2220,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -2253,7 +2256,7 @@ private void Initialize() if(parameters != null) { _requestContent = SafeJsonConvert.SerializeObject(parameters, SerializationSettings); - _httpRequest.Content = new System.Net.Http.StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); } // Set Credentials @@ -2455,9 +2458,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -2491,7 +2494,7 @@ private void Initialize() if(parameters != null) { _requestContent = SafeJsonConvert.SerializeObject(parameters, SerializationSettings); - _httpRequest.Content = new System.Net.Http.StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); } // Set Credentials @@ -2595,7 +2598,8 @@ private void Initialize() /// /// The signing/verification algorithm identifier. For more information on /// possible algorithm types, see JsonWebKeySignatureAlgorithm. Possible values - /// include: 'PS256', 'PS384', 'PS512', 'RS256', 'RS384', 'RS512', 'RSNULL' + /// include: 'PS256', 'PS384', 'PS512', 'RS256', 'RS384', 'RS512', 'RSNULL', + /// 'ES256', 'ES384', 'ES512', 'ECDSA256' /// /// /// @@ -2689,9 +2693,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -2725,7 +2729,7 @@ private void Initialize() if(parameters != null) { _requestContent = SafeJsonConvert.SerializeObject(parameters, SerializationSettings); - _httpRequest.Content = new System.Net.Http.StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); } // Set Credentials @@ -2833,7 +2837,8 @@ private void Initialize() /// /// The signing/verification algorithm. For more information on possible /// algorithm types, see JsonWebKeySignatureAlgorithm. Possible values include: - /// 'PS256', 'PS384', 'PS512', 'RS256', 'RS384', 'RS512', 'RSNULL' + /// 'PS256', 'PS384', 'PS512', 'RS256', 'RS384', 'RS512', 'RSNULL', 'ES256', + /// 'ES384', 'ES512', 'ECDSA256' /// /// /// The digest used for signing. @@ -2936,9 +2941,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -2972,7 +2977,7 @@ private void Initialize() if(parameters != null) { _requestContent = SafeJsonConvert.SerializeObject(parameters, SerializationSettings); - _httpRequest.Content = new System.Net.Http.StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); } // Set Credentials @@ -3174,9 +3179,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -3210,7 +3215,7 @@ private void Initialize() if(parameters != null) { _requestContent = SafeJsonConvert.SerializeObject(parameters, SerializationSettings); - _httpRequest.Content = new System.Net.Http.StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); } // Set Credentials @@ -3410,9 +3415,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -3446,7 +3451,7 @@ private void Initialize() if(parameters != null) { _requestContent = SafeJsonConvert.SerializeObject(parameters, SerializationSettings); - _httpRequest.Content = new System.Net.Http.StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); } // Set Credentials @@ -3611,9 +3616,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -3798,9 +3803,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -3982,9 +3987,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("DELETE"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -4151,9 +4156,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -4373,9 +4378,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -4409,7 +4414,7 @@ private void Initialize() if(parameters != null) { _requestContent = SafeJsonConvert.SerializeObject(parameters, SerializationSettings); - _httpRequest.Content = new System.Net.Http.StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); } // Set Credentials @@ -4569,9 +4574,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("DELETE"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -4787,9 +4792,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("PATCH"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PATCH"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -4823,7 +4828,7 @@ private void Initialize() if(parameters != null) { _requestContent = SafeJsonConvert.SerializeObject(parameters, SerializationSettings); - _httpRequest.Content = new System.Net.Http.StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); } // Set Credentials @@ -4991,9 +4996,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -5190,9 +5195,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -5399,9 +5404,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -5594,9 +5599,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -5781,9 +5786,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -5965,9 +5970,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("DELETE"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -6134,9 +6139,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -6321,9 +6326,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -6512,9 +6517,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -6548,7 +6553,7 @@ private void Initialize() if(parameters != null) { _requestContent = SafeJsonConvert.SerializeObject(parameters, SerializationSettings); - _httpRequest.Content = new System.Net.Http.StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); } // Set Credentials @@ -6716,9 +6721,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -6907,9 +6912,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("DELETE"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -7096,9 +7101,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -7132,7 +7137,7 @@ private void Initialize() if(contacts != null) { _requestContent = SafeJsonConvert.SerializeObject(contacts, SerializationSettings); - _httpRequest.Content = new System.Net.Http.StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); } // Set Credentials @@ -7283,9 +7288,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -7464,9 +7469,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("DELETE"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -7662,9 +7667,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -7877,9 +7882,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -7913,7 +7918,7 @@ private void Initialize() if(parameter != null) { _requestContent = SafeJsonConvert.SerializeObject(parameter, SerializationSettings); - _httpRequest.Content = new System.Net.Http.StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); } // Set Credentials @@ -8094,9 +8099,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("PATCH"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PATCH"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -8130,7 +8135,7 @@ private void Initialize() if(parameter != null) { _requestContent = SafeJsonConvert.SerializeObject(parameter, SerializationSettings); - _httpRequest.Content = new System.Net.Http.StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); } // Set Credentials @@ -8290,9 +8295,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -8480,9 +8485,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("DELETE"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -8697,9 +8702,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -8733,7 +8738,7 @@ private void Initialize() if(parameters != null) { _requestContent = SafeJsonConvert.SerializeObject(parameters, SerializationSettings); - _httpRequest.Content = new System.Net.Http.StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); } // Set Credentials @@ -8937,9 +8942,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -8973,7 +8978,7 @@ private void Initialize() if(parameters != null) { _requestContent = SafeJsonConvert.SerializeObject(parameters, SerializationSettings); - _httpRequest.Content = new System.Net.Http.StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); } // Set Credentials @@ -9150,9 +9155,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -9340,9 +9345,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -9537,9 +9542,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("PATCH"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PATCH"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -9573,7 +9578,7 @@ private void Initialize() if(certificatePolicy != null) { _requestContent = SafeJsonConvert.SerializeObject(certificatePolicy, SerializationSettings); - _httpRequest.Content = new System.Net.Http.StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); } // Set Credentials @@ -9764,9 +9769,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("PATCH"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PATCH"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -9800,7 +9805,7 @@ private void Initialize() if(parameters != null) { _requestContent = SafeJsonConvert.SerializeObject(parameters, SerializationSettings); - _httpRequest.Content = new System.Net.Http.StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); } // Set Credentials @@ -9966,9 +9971,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -10159,9 +10164,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("PATCH"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PATCH"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -10195,7 +10200,7 @@ private void Initialize() if(certificateOperation != null) { _requestContent = SafeJsonConvert.SerializeObject(certificateOperation, SerializationSettings); - _httpRequest.Content = new System.Net.Http.StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); } // Set Credentials @@ -10352,9 +10357,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -10539,9 +10544,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("DELETE"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -10752,9 +10757,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -10788,7 +10793,7 @@ private void Initialize() if(parameters != null) { _requestContent = SafeJsonConvert.SerializeObject(parameters, SerializationSettings); - _httpRequest.Content = new System.Net.Http.StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); } // Set Credentials @@ -10958,9 +10963,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -11149,9 +11154,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -11338,9 +11343,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("DELETE"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -11513,9 +11518,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -11707,9 +11712,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -11900,9 +11905,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("DELETE"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -12093,9 +12098,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -12323,9 +12328,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -12359,7 +12364,7 @@ private void Initialize() if(parameters != null) { _requestContent = SafeJsonConvert.SerializeObject(parameters, SerializationSettings); - _httpRequest.Content = new System.Net.Http.StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); } // Set Credentials @@ -12547,9 +12552,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("PATCH"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PATCH"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -12583,7 +12588,7 @@ private void Initialize() if(parameters != null) { _requestContent = SafeJsonConvert.SerializeObject(parameters, SerializationSettings); - _httpRequest.Content = new System.Net.Http.StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); } // Set Credentials @@ -12759,9 +12764,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -12795,7 +12800,7 @@ private void Initialize() if(parameters != null) { _requestContent = SafeJsonConvert.SerializeObject(parameters, SerializationSettings); - _httpRequest.Content = new System.Net.Http.StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); } // Set Credentials @@ -12975,9 +12980,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -13184,9 +13189,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("DELETE"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -13393,9 +13398,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -13623,9 +13628,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -13659,7 +13664,7 @@ private void Initialize() if(parameters1 != null) { _requestContent = SafeJsonConvert.SerializeObject(parameters1, SerializationSettings); - _httpRequest.Content = new System.Net.Http.StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); } // Set Credentials @@ -13855,9 +13860,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("PATCH"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PATCH"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -13891,7 +13896,7 @@ private void Initialize() if(parameters1 != null) { _requestContent = SafeJsonConvert.SerializeObject(parameters1, SerializationSettings); - _httpRequest.Content = new System.Net.Http.StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); } // Set Credentials @@ -14032,9 +14037,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -14208,9 +14213,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -14377,9 +14382,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -14550,9 +14555,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -14724,9 +14729,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -14893,9 +14898,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -15065,9 +15070,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -15237,9 +15242,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -15409,9 +15414,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -15583,9 +15588,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -15701,10 +15706,6 @@ private void Initialize() /// /// List storage accounts managed by specified key vault /// - /// - /// The GetCertificateVersions operation returns the versions of a certificate - /// in the specified key vault - /// /// /// The NextLink from the previous successful call to List operation. /// @@ -15755,9 +15756,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -15923,9 +15924,9 @@ private void Initialize() _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (GenerateClientRequestId != null && GenerateClientRequestId.Value) @@ -16040,4 +16041,3 @@ private void Initialize() } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/KeyVaultClientExtensions.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/KeyVaultClientExtensions.cs index d15ae5b2b3af..8c35ca76208a 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/KeyVaultClientExtensions.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/KeyVaultClientExtensions.cs @@ -2,21 +2,21 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault { - using Azure; - using Rest; - using Rest.Azure; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault.WebKey; + using Microsoft.Rest; + using Microsoft.Rest.Azure; using Models; using System.Collections; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; - using Microsoft.Azure.KeyVault.WebKey; /// /// Extension methods for KeyVaultClient. @@ -43,9 +43,8 @@ public static partial class KeyVaultClientExtensions /// new key. /// /// - /// The type of key to create. For valid key types, see JsonWebKeyType. - /// Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, HSM, Octet. - /// Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' + /// The type of key to create. For valid values, see JsonWebKeyType. Possible + /// values include: 'EC', 'EC-HSM', 'RSA', 'RSA-HSM', 'oct' /// /// /// The key size in bytes. For example, 1024 or 2048. @@ -62,7 +61,7 @@ public static partial class KeyVaultClientExtensions /// public static async Task CreateKeyAsync(this IKeyVaultClient operations, string vaultBaseUrl, string keyName, string kty, int? keySize = default(int?), IList keyOps = default(IList), KeyAttributes keyAttributes = default(KeyAttributes), IDictionary tags = default(IDictionary), CancellationToken cancellationToken = default(CancellationToken)) { - using (var _result = await operations.CreateKeyWithHttpMessagesAsync(vaultBaseUrl, keyName, kty, keySize, keyOps, keyAttributes, tags, null, cancellationToken).ConfigureAwait(false)) + using (var _result = await operations.CreateKeyWithHttpMessagesAsync(vaultBaseUrl, keyName, kty, keySize, keyOps, keyAttributes, tags, null, null, cancellationToken).ConfigureAwait(false)) { return _result.Body; } @@ -452,7 +451,8 @@ public static partial class KeyVaultClientExtensions /// /// The signing/verification algorithm identifier. For more information on /// possible algorithm types, see JsonWebKeySignatureAlgorithm. Possible values - /// include: 'PS256', 'PS384', 'PS512', 'RS256', 'RS384', 'RS512', 'RSNULL' + /// include: 'PS256', 'PS384', 'PS512', 'RS256', 'RS384', 'RS512', 'RSNULL', + /// 'ES256', 'ES384', 'ES512', 'ECDSA256' /// /// /// @@ -493,7 +493,8 @@ public static partial class KeyVaultClientExtensions /// /// The signing/verification algorithm. For more information on possible /// algorithm types, see JsonWebKeySignatureAlgorithm. Possible values include: - /// 'PS256', 'PS384', 'PS512', 'RS256', 'RS384', 'RS512', 'RSNULL' + /// 'PS256', 'PS384', 'PS512', 'RS256', 'RS384', 'RS512', 'RSNULL', 'ES256', + /// 'ES384', 'ES512', 'ECDSA256' /// /// /// The digest used for signing. @@ -659,7 +660,7 @@ public static partial class KeyVaultClientExtensions /// public static async Task PurgeDeletedKeyAsync(this IKeyVaultClient operations, string vaultBaseUrl, string keyName, CancellationToken cancellationToken = default(CancellationToken)) { - await operations.PurgeDeletedKeyWithHttpMessagesAsync(vaultBaseUrl, keyName, null, cancellationToken).ConfigureAwait(false); + (await operations.PurgeDeletedKeyWithHttpMessagesAsync(vaultBaseUrl, keyName, null, cancellationToken).ConfigureAwait(false)).Dispose(); } /// @@ -951,7 +952,7 @@ public static partial class KeyVaultClientExtensions /// public static async Task PurgeDeletedSecretAsync(this IKeyVaultClient operations, string vaultBaseUrl, string secretName, CancellationToken cancellationToken = default(CancellationToken)) { - await operations.PurgeDeletedSecretWithHttpMessagesAsync(vaultBaseUrl, secretName, null, cancellationToken).ConfigureAwait(false); + (await operations.PurgeDeletedSecretWithHttpMessagesAsync(vaultBaseUrl, secretName, null, cancellationToken).ConfigureAwait(false)).Dispose(); } /// @@ -1746,7 +1747,7 @@ public static partial class KeyVaultClientExtensions /// public static async Task PurgeDeletedCertificateAsync(this IKeyVaultClient operations, string vaultBaseUrl, string certificateName, CancellationToken cancellationToken = default(CancellationToken)) { - await operations.PurgeDeletedCertificateWithHttpMessagesAsync(vaultBaseUrl, certificateName, null, cancellationToken).ConfigureAwait(false); + (await operations.PurgeDeletedCertificateWithHttpMessagesAsync(vaultBaseUrl, certificateName, null, cancellationToken).ConfigureAwait(false)).Dispose(); } /// @@ -1852,9 +1853,6 @@ public static partial class KeyVaultClientExtensions /// /// Creates or updates a new storage account. /// - /// - /// The full key identifier, attributes, and tags are provided in the response. - /// /// /// The operations group for this extension method. /// @@ -2390,4 +2388,3 @@ public static partial class KeyVaultClientExtensions } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/Action.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/Action.cs index 37cd35ed1adc..0a2462349085 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/Action.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/Action.cs @@ -2,14 +2,14 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; using Newtonsoft.Json; using System.Linq; @@ -21,7 +21,10 @@ public partial class Action /// /// Initializes a new instance of the Action class. /// - public Action() { } + public Action() + { + CustomInit(); + } /// /// Initializes a new instance of the Action class. @@ -31,8 +34,14 @@ public Action() { } public Action(ActionType? actionType = default(ActionType?)) { ActionType = actionType; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets or sets the type of the action. Possible values include: /// 'EmailContacts', 'AutoRenew' @@ -42,4 +51,3 @@ public Action() { } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/ActionType.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/ActionType.cs index 34c70dbecedd..affc11cdc3f7 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/ActionType.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/ActionType.cs @@ -2,14 +2,14 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; using Newtonsoft.Json; using Newtonsoft.Json.Converters; using System.Runtime; @@ -26,5 +26,33 @@ public enum ActionType [EnumMember(Value = "AutoRenew")] AutoRenew } -} + internal static class ActionTypeEnumExtension + { + internal static string ToSerializedValue(this ActionType? value) => + value == null ? null : ((ActionType)value).ToSerializedValue(); + + internal static string ToSerializedValue(this ActionType value) + { + switch( value ) + { + case ActionType.EmailContacts: + return "EmailContacts"; + case ActionType.AutoRenew: + return "AutoRenew"; + } + return null; + } + internal static ActionType? ParseActionType(this string value) + { + switch( value ) + { + case "EmailContacts": + return ActionType.EmailContacts; + case "AutoRenew": + return ActionType.AutoRenew; + } + return null; + } + } +} diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/AdministratorDetails.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/AdministratorDetails.cs index 52412a3477af..ee6d97bb56f5 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/AdministratorDetails.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/AdministratorDetails.cs @@ -2,14 +2,14 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; using Newtonsoft.Json; using System.Linq; @@ -21,7 +21,10 @@ public partial class AdministratorDetails /// /// Initializes a new instance of the AdministratorDetails class. /// - public AdministratorDetails() { } + public AdministratorDetails() + { + CustomInit(); + } /// /// Initializes a new instance of the AdministratorDetails class. @@ -36,8 +39,14 @@ public AdministratorDetails() { } LastName = lastName; EmailAddress = emailAddress; Phone = phone; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets or sets first name. /// @@ -64,4 +73,3 @@ public AdministratorDetails() { } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/Attributes.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/Attributes.cs index 6ffb4fd6cb04..ba0ad3a28e61 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/Attributes.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/Attributes.cs @@ -2,16 +2,16 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; - using Rest; - using Rest.Serialization; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; + using Microsoft.Rest; + using Microsoft.Rest.Serialization; using Newtonsoft.Json; using System.Linq; @@ -23,7 +23,10 @@ public partial class Attributes /// /// Initializes a new instance of the Attributes class. /// - public Attributes() { } + public Attributes() + { + CustomInit(); + } /// /// Initializes a new instance of the Attributes class. @@ -41,8 +44,14 @@ public Attributes() { } Expires = expires; Created = created; Updated = updated; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets or sets determines whether the object is enabled. /// @@ -68,15 +77,14 @@ public Attributes() { } /// [JsonConverter(typeof(UnixTimeJsonConverter))] [JsonProperty(PropertyName = "created")] - public System.DateTime? Created { get; protected set; } + public System.DateTime? Created { get; private set; } /// /// Gets last updated time in UTC. /// [JsonConverter(typeof(UnixTimeJsonConverter))] [JsonProperty(PropertyName = "updated")] - public System.DateTime? Updated { get; protected set; } + public System.DateTime? Updated { get; private set; } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/BackupKeyResult.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/BackupKeyResult.cs index 8c31511e6a16..d3e33ec466be 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/BackupKeyResult.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/BackupKeyResult.cs @@ -2,16 +2,16 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; - using Rest; - using Rest.Serialization; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; + using Microsoft.Rest; + using Microsoft.Rest.Serialization; using Newtonsoft.Json; using System.Linq; @@ -23,7 +23,10 @@ public partial class BackupKeyResult /// /// Initializes a new instance of the BackupKeyResult class. /// - public BackupKeyResult() { } + public BackupKeyResult() + { + CustomInit(); + } /// /// Initializes a new instance of the BackupKeyResult class. @@ -33,15 +36,20 @@ public BackupKeyResult() { } public BackupKeyResult(byte[] value = default(byte[])) { Value = value; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets the backup blob containing the backed up key. /// [JsonConverter(typeof(Base64UrlJsonConverter))] [JsonProperty(PropertyName = "value")] - public byte[] Value { get; protected set; } + public byte[] Value { get; private set; } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/BackupSecretResult.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/BackupSecretResult.cs index c2e8f4acdad6..fb0420ecd9da 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/BackupSecretResult.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/BackupSecretResult.cs @@ -2,16 +2,16 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; - using Rest; - using Rest.Serialization; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; + using Microsoft.Rest; + using Microsoft.Rest.Serialization; using Newtonsoft.Json; using System.Linq; @@ -23,7 +23,10 @@ public partial class BackupSecretResult /// /// Initializes a new instance of the BackupSecretResult class. /// - public BackupSecretResult() { } + public BackupSecretResult() + { + CustomInit(); + } /// /// Initializes a new instance of the BackupSecretResult class. @@ -33,15 +36,20 @@ public BackupSecretResult() { } public BackupSecretResult(byte[] value = default(byte[])) { Value = value; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets the backup blob containing the backed up secret. /// [JsonConverter(typeof(Base64UrlJsonConverter))] [JsonProperty(PropertyName = "value")] - public byte[] Value { get; protected set; } + public byte[] Value { get; private set; } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/CertificateAttributes.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/CertificateAttributes.cs index ca835f44e73a..512629911571 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/CertificateAttributes.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/CertificateAttributes.cs @@ -2,14 +2,14 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; using Newtonsoft.Json; using System.Linq; @@ -21,7 +21,10 @@ public partial class CertificateAttributes : Attributes /// /// Initializes a new instance of the CertificateAttributes class. /// - public CertificateAttributes() { } + public CertificateAttributes() + { + CustomInit(); + } /// /// Initializes a new instance of the CertificateAttributes class. @@ -43,8 +46,14 @@ public CertificateAttributes() { } : base(enabled, notBefore, expires, created, updated) { RecoveryLevel = recoveryLevel; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets reflects the deletion recovery level currently in effect for /// certificates in the current vault. If it contains 'Purgeable', the @@ -55,8 +64,7 @@ public CertificateAttributes() { } /// 'Recoverable+ProtectedSubscription' /// [JsonProperty(PropertyName = "recoveryLevel")] - public string RecoveryLevel { get; protected set; } + public string RecoveryLevel { get; private set; } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/CertificateBundle.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/CertificateBundle.cs index 4b60bd384ae4..01ad147def73 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/CertificateBundle.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/CertificateBundle.cs @@ -2,16 +2,16 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; - using Rest; - using Rest.Serialization; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; + using Microsoft.Rest; + using Microsoft.Rest.Serialization; using Newtonsoft.Json; using System.Collections; using System.Collections.Generic; @@ -26,7 +26,10 @@ public partial class CertificateBundle /// /// Initializes a new instance of the CertificateBundle class. /// - public CertificateBundle() { } + public CertificateBundle() + { + CustomInit(); + } /// /// Initializes a new instance of the CertificateBundle class. @@ -52,38 +55,44 @@ public CertificateBundle() { } ContentType = contentType; Attributes = attributes; Tags = tags; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets the certificate id. /// [JsonProperty(PropertyName = "id")] - public string Id { get; protected set; } + public string Id { get; private set; } /// /// Gets the key id. /// [JsonProperty(PropertyName = "kid")] - public string Kid { get; protected set; } + public string Kid { get; private set; } /// /// Gets the secret id. /// [JsonProperty(PropertyName = "sid")] - public string Sid { get; protected set; } + public string Sid { get; private set; } /// /// Gets thumbprint of the certificate. /// [JsonConverter(typeof(Base64UrlJsonConverter))] [JsonProperty(PropertyName = "x5t")] - public byte[] X509Thumbprint { get; protected set; } + public byte[] X509Thumbprint { get; private set; } /// /// Gets the management policy. /// [JsonProperty(PropertyName = "policy")] - public CertificatePolicy Policy { get; protected set; } + public CertificatePolicy Policy { get; private set; } /// /// Gets or sets CER contents of x509 certificate. @@ -125,4 +134,3 @@ public virtual void Validate() } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/CertificateCreateParameters.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/CertificateCreateParameters.cs index 2e7a7db8ddc7..799ebb0f1d8a 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/CertificateCreateParameters.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/CertificateCreateParameters.cs @@ -2,14 +2,14 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; using Newtonsoft.Json; using System.Collections; using System.Collections.Generic; @@ -24,7 +24,10 @@ public partial class CertificateCreateParameters /// Initializes a new instance of the CertificateCreateParameters /// class. /// - public CertificateCreateParameters() { } + public CertificateCreateParameters() + { + CustomInit(); + } /// /// Initializes a new instance of the CertificateCreateParameters @@ -41,8 +44,14 @@ public CertificateCreateParameters() { } CertificatePolicy = certificatePolicy; CertificateAttributes = certificateAttributes; Tags = tags; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets or sets the management policy for the certificate. /// @@ -77,4 +86,3 @@ public virtual void Validate() } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/CertificateImportParameters.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/CertificateImportParameters.cs index b0f9321f70ed..139f465f25f9 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/CertificateImportParameters.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/CertificateImportParameters.cs @@ -2,15 +2,15 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; - using Rest; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; + using Microsoft.Rest; using Newtonsoft.Json; using System.Collections; using System.Collections.Generic; @@ -25,7 +25,10 @@ public partial class CertificateImportParameters /// Initializes a new instance of the CertificateImportParameters /// class. /// - public CertificateImportParameters() { } + public CertificateImportParameters() + { + CustomInit(); + } /// /// Initializes a new instance of the CertificateImportParameters @@ -50,8 +53,14 @@ public CertificateImportParameters() { } CertificatePolicy = certificatePolicy; CertificateAttributes = certificateAttributes; Tags = tags; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets or sets base64 encoded representation of the certificate /// object to import. This certificate needs to contain the private @@ -105,4 +114,3 @@ public virtual void Validate() } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/CertificateIssuerItem.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/CertificateIssuerItem.cs index c8dadd507cf2..0a2935f20fff 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/CertificateIssuerItem.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/CertificateIssuerItem.cs @@ -2,14 +2,14 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; using Newtonsoft.Json; using System.Linq; @@ -21,7 +21,10 @@ public partial class CertificateIssuerItem /// /// Initializes a new instance of the CertificateIssuerItem class. /// - public CertificateIssuerItem() { } + public CertificateIssuerItem() + { + CustomInit(); + } /// /// Initializes a new instance of the CertificateIssuerItem class. @@ -32,8 +35,14 @@ public CertificateIssuerItem() { } { Id = id; Provider = provider; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets or sets certificate Identifier. /// @@ -48,4 +57,3 @@ public CertificateIssuerItem() { } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/CertificateIssuerSetParameters.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/CertificateIssuerSetParameters.cs index 8d60aaba15b9..42d2e19da1e7 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/CertificateIssuerSetParameters.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/CertificateIssuerSetParameters.cs @@ -2,15 +2,15 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; - using Rest; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; + using Microsoft.Rest; using Newtonsoft.Json; using System.Linq; @@ -23,7 +23,10 @@ public partial class CertificateIssuerSetParameters /// Initializes a new instance of the CertificateIssuerSetParameters /// class. /// - public CertificateIssuerSetParameters() { } + public CertificateIssuerSetParameters() + { + CustomInit(); + } /// /// Initializes a new instance of the CertificateIssuerSetParameters @@ -41,8 +44,14 @@ public CertificateIssuerSetParameters() { } Credentials = credentials; OrganizationDetails = organizationDetails; Attributes = attributes; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets or sets the issuer provider. /// @@ -82,4 +91,3 @@ public virtual void Validate() } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/CertificateIssuerUpdateParameters.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/CertificateIssuerUpdateParameters.cs index b391b4e56283..b321a111e208 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/CertificateIssuerUpdateParameters.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/CertificateIssuerUpdateParameters.cs @@ -2,14 +2,14 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; using Newtonsoft.Json; using System.Linq; @@ -22,7 +22,10 @@ public partial class CertificateIssuerUpdateParameters /// Initializes a new instance of the CertificateIssuerUpdateParameters /// class. /// - public CertificateIssuerUpdateParameters() { } + public CertificateIssuerUpdateParameters() + { + CustomInit(); + } /// /// Initializes a new instance of the CertificateIssuerUpdateParameters @@ -40,8 +43,14 @@ public CertificateIssuerUpdateParameters() { } Credentials = credentials; OrganizationDetails = organizationDetails; Attributes = attributes; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets or sets the issuer provider. /// @@ -68,4 +77,3 @@ public CertificateIssuerUpdateParameters() { } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/CertificateItem.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/CertificateItem.cs index ebed0de04532..b73469a41ed9 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/CertificateItem.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/CertificateItem.cs @@ -2,16 +2,16 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; - using Rest; - using Rest.Serialization; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; + using Microsoft.Rest; + using Microsoft.Rest.Serialization; using Newtonsoft.Json; using System.Collections; using System.Collections.Generic; @@ -25,7 +25,10 @@ public partial class CertificateItem /// /// Initializes a new instance of the CertificateItem class. /// - public CertificateItem() { } + public CertificateItem() + { + CustomInit(); + } /// /// Initializes a new instance of the CertificateItem class. @@ -42,8 +45,14 @@ public CertificateItem() { } Attributes = attributes; Tags = tags; X509Thumbprint = x509Thumbprint; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets or sets certificate identifier. /// @@ -72,4 +81,3 @@ public CertificateItem() { } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/CertificateMergeParameters.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/CertificateMergeParameters.cs index dc25348b41f6..fca877f6099d 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/CertificateMergeParameters.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/CertificateMergeParameters.cs @@ -2,15 +2,15 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; - using Rest; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; + using Microsoft.Rest; using Newtonsoft.Json; using System.Collections; using System.Collections.Generic; @@ -24,7 +24,10 @@ public partial class CertificateMergeParameters /// /// Initializes a new instance of the CertificateMergeParameters class. /// - public CertificateMergeParameters() { } + public CertificateMergeParameters() + { + CustomInit(); + } /// /// Initializes a new instance of the CertificateMergeParameters class. @@ -40,8 +43,14 @@ public CertificateMergeParameters() { } X509Certificates = x509Certificates; CertificateAttributes = certificateAttributes; Tags = tags; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets or sets the certificate or the certificate chain to merge. /// @@ -76,4 +85,3 @@ public virtual void Validate() } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/CertificateOperation.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/CertificateOperation.cs index 1c7805705e0b..e64f9d8c4eea 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/CertificateOperation.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/CertificateOperation.cs @@ -2,14 +2,14 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; using Newtonsoft.Json; using System.Linq; @@ -21,7 +21,10 @@ public partial class CertificateOperation /// /// Initializes a new instance of the CertificateOperation class. /// - public CertificateOperation() { } + public CertificateOperation() + { + CustomInit(); + } /// /// Initializes a new instance of the CertificateOperation class. @@ -53,13 +56,19 @@ public CertificateOperation() { } Error = error; Target = target; RequestId = requestId; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets the certificate id. /// [JsonProperty(PropertyName = "id")] - public string Id { get; protected set; } + public string Id { get; private set; } /// /// Gets or sets parameters for the issuer of the X509 component of a @@ -116,4 +125,3 @@ public CertificateOperation() { } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/CertificateOperationUpdateParameter.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/CertificateOperationUpdateParameter.cs index cb3036fa99e7..9caa7c1a483a 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/CertificateOperationUpdateParameter.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/CertificateOperationUpdateParameter.cs @@ -2,14 +2,14 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; using Newtonsoft.Json; using System.Linq; @@ -22,7 +22,10 @@ public partial class CertificateOperationUpdateParameter /// Initializes a new instance of the /// CertificateOperationUpdateParameter class. /// - public CertificateOperationUpdateParameter() { } + public CertificateOperationUpdateParameter() + { + CustomInit(); + } /// /// Initializes a new instance of the @@ -33,8 +36,14 @@ public CertificateOperationUpdateParameter() { } public CertificateOperationUpdateParameter(bool cancellationRequested) { CancellationRequested = cancellationRequested; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets or sets indicates if cancellation was requested on the /// certificate operation. @@ -54,4 +63,3 @@ public virtual void Validate() } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/CertificatePolicy.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/CertificatePolicy.cs index 08f47efe9279..facfd5cdaa09 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/CertificatePolicy.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/CertificatePolicy.cs @@ -2,14 +2,14 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; using Newtonsoft.Json; using System.Collections; using System.Collections.Generic; @@ -23,7 +23,10 @@ public partial class CertificatePolicy /// /// Initializes a new instance of the CertificatePolicy class. /// - public CertificatePolicy() { } + public CertificatePolicy() + { + CustomInit(); + } /// /// Initializes a new instance of the CertificatePolicy class. @@ -49,13 +52,19 @@ public CertificatePolicy() { } LifetimeActions = lifetimeActions; IssuerParameters = issuerParameters; Attributes = attributes; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets the certificate id. /// [JsonProperty(PropertyName = "id")] - public string Id { get; protected set; } + public string Id { get; private set; } /// /// Gets or sets properties of the key backing a certificate. @@ -120,4 +129,3 @@ public virtual void Validate() } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/CertificateUpdateParameters.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/CertificateUpdateParameters.cs index d2f18011f825..3012e45dbeaf 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/CertificateUpdateParameters.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/CertificateUpdateParameters.cs @@ -2,14 +2,14 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; using Newtonsoft.Json; using System.Collections; using System.Collections.Generic; @@ -24,7 +24,10 @@ public partial class CertificateUpdateParameters /// Initializes a new instance of the CertificateUpdateParameters /// class. /// - public CertificateUpdateParameters() { } + public CertificateUpdateParameters() + { + CustomInit(); + } /// /// Initializes a new instance of the CertificateUpdateParameters @@ -41,8 +44,14 @@ public CertificateUpdateParameters() { } CertificatePolicy = certificatePolicy; CertificateAttributes = certificateAttributes; Tags = tags; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets or sets the management policy for the certificate. /// @@ -77,4 +86,3 @@ public virtual void Validate() } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/Contact.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/Contact.cs index 4fc9829141ac..a791c3754b7e 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/Contact.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/Contact.cs @@ -2,14 +2,14 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; using Newtonsoft.Json; using System.Linq; @@ -21,7 +21,10 @@ public partial class Contact /// /// Initializes a new instance of the Contact class. /// - public Contact() { } + public Contact() + { + CustomInit(); + } /// /// Initializes a new instance of the Contact class. @@ -34,8 +37,14 @@ public Contact() { } EmailAddress = emailAddress; Name = name; Phone = phone; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets or sets email addresss. /// @@ -56,4 +65,3 @@ public Contact() { } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/Contacts.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/Contacts.cs index 81e4eb44e4c6..0cf2481dfb9e 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/Contacts.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/Contacts.cs @@ -2,14 +2,14 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; using Newtonsoft.Json; using System.Collections; using System.Collections.Generic; @@ -23,7 +23,10 @@ public partial class Contacts /// /// Initializes a new instance of the Contacts class. /// - public Contacts() { } + public Contacts() + { + CustomInit(); + } /// /// Initializes a new instance of the Contacts class. @@ -35,13 +38,19 @@ public Contacts() { } { Id = id; ContactList = contactList; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets identifier for the contacts collection. /// [JsonProperty(PropertyName = "id")] - public string Id { get; protected set; } + public string Id { get; private set; } /// /// Gets or sets the contact list for the vault certificates. @@ -51,4 +60,3 @@ public Contacts() { } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/DeletedCertificateBundle.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/DeletedCertificateBundle.cs index ca2ab18678cc..f2ee87c64f01 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/DeletedCertificateBundle.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/DeletedCertificateBundle.cs @@ -2,16 +2,16 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; - using Rest; - using Rest.Serialization; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; + using Microsoft.Rest; + using Microsoft.Rest.Serialization; using Newtonsoft.Json; using System.Collections; using System.Collections.Generic; @@ -26,7 +26,10 @@ public partial class DeletedCertificateBundle : CertificateBundle /// /// Initializes a new instance of the DeletedCertificateBundle class. /// - public DeletedCertificateBundle() { } + public DeletedCertificateBundle() + { + CustomInit(); + } /// /// Initializes a new instance of the DeletedCertificateBundle class. @@ -53,8 +56,14 @@ public DeletedCertificateBundle() { } RecoveryId = recoveryId; ScheduledPurgeDate = scheduledPurgeDate; DeletedDate = deletedDate; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets or sets the url of the recovery object, used to identify and /// recover the deleted certificate. @@ -68,14 +77,14 @@ public DeletedCertificateBundle() { } /// [JsonConverter(typeof(UnixTimeJsonConverter))] [JsonProperty(PropertyName = "scheduledPurgeDate")] - public System.DateTime? ScheduledPurgeDate { get; protected set; } + public System.DateTime? ScheduledPurgeDate { get; private set; } /// /// Gets the time when the certificate was deleted, in UTC /// [JsonConverter(typeof(UnixTimeJsonConverter))] [JsonProperty(PropertyName = "deletedDate")] - public System.DateTime? DeletedDate { get; protected set; } + public System.DateTime? DeletedDate { get; private set; } /// /// Validate the object. @@ -89,4 +98,3 @@ public override void Validate() } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/DeletedCertificateItem.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/DeletedCertificateItem.cs index 3c54f1ffaed3..ae36f62c734c 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/DeletedCertificateItem.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/DeletedCertificateItem.cs @@ -2,16 +2,16 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; - using Rest; - using Rest.Serialization; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; + using Microsoft.Rest; + using Microsoft.Rest.Serialization; using Newtonsoft.Json; using System.Collections; using System.Collections.Generic; @@ -26,7 +26,10 @@ public partial class DeletedCertificateItem : CertificateItem /// /// Initializes a new instance of the DeletedCertificateItem class. /// - public DeletedCertificateItem() { } + public DeletedCertificateItem() + { + CustomInit(); + } /// /// Initializes a new instance of the DeletedCertificateItem class. @@ -49,8 +52,14 @@ public DeletedCertificateItem() { } RecoveryId = recoveryId; ScheduledPurgeDate = scheduledPurgeDate; DeletedDate = deletedDate; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets or sets the url of the recovery object, used to identify and /// recover the deleted certificate. @@ -64,15 +73,14 @@ public DeletedCertificateItem() { } /// [JsonConverter(typeof(UnixTimeJsonConverter))] [JsonProperty(PropertyName = "scheduledPurgeDate")] - public System.DateTime? ScheduledPurgeDate { get; protected set; } + public System.DateTime? ScheduledPurgeDate { get; private set; } /// /// Gets the time when the certificate was deleted, in UTC /// [JsonConverter(typeof(UnixTimeJsonConverter))] [JsonProperty(PropertyName = "deletedDate")] - public System.DateTime? DeletedDate { get; protected set; } + public System.DateTime? DeletedDate { get; private set; } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/DeletedKeyBundle.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/DeletedKeyBundle.cs index 8f5bb16ff86c..921719adccee 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/DeletedKeyBundle.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/DeletedKeyBundle.cs @@ -2,21 +2,21 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; - using Rest; - using Rest.Serialization; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; + using Microsoft.Azure.KeyVault.WebKey; + using Microsoft.Rest; + using Microsoft.Rest.Serialization; using Newtonsoft.Json; using System.Collections; using System.Collections.Generic; using System.Linq; - using Microsoft.Azure.KeyVault.WebKey; /// /// A DeletedKeyBundle consisting of a WebKey plus its Attributes and @@ -27,7 +27,10 @@ public partial class DeletedKeyBundle : KeyBundle /// /// Initializes a new instance of the DeletedKeyBundle class. /// - public DeletedKeyBundle() { } + public DeletedKeyBundle() + { + CustomInit(); + } /// /// Initializes a new instance of the DeletedKeyBundle class. @@ -51,8 +54,14 @@ public DeletedKeyBundle() { } RecoveryId = recoveryId; ScheduledPurgeDate = scheduledPurgeDate; DeletedDate = deletedDate; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets or sets the url of the recovery object, used to identify and /// recover the deleted key. @@ -65,15 +74,14 @@ public DeletedKeyBundle() { } /// [JsonConverter(typeof(UnixTimeJsonConverter))] [JsonProperty(PropertyName = "scheduledPurgeDate")] - public System.DateTime? ScheduledPurgeDate { get; protected set; } + public System.DateTime? ScheduledPurgeDate { get; private set; } /// /// Gets the time when the key was deleted, in UTC /// [JsonConverter(typeof(UnixTimeJsonConverter))] [JsonProperty(PropertyName = "deletedDate")] - public System.DateTime? DeletedDate { get; protected set; } + public System.DateTime? DeletedDate { get; private set; } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/DeletedKeyItem.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/DeletedKeyItem.cs index 58c21f7cc65c..310bf0408f61 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/DeletedKeyItem.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/DeletedKeyItem.cs @@ -2,16 +2,16 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; - using Rest; - using Rest.Serialization; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; + using Microsoft.Rest; + using Microsoft.Rest.Serialization; using Newtonsoft.Json; using System.Collections; using System.Collections.Generic; @@ -26,7 +26,10 @@ public partial class DeletedKeyItem : KeyItem /// /// Initializes a new instance of the DeletedKeyItem class. /// - public DeletedKeyItem() { } + public DeletedKeyItem() + { + CustomInit(); + } /// /// Initializes a new instance of the DeletedKeyItem class. @@ -50,8 +53,14 @@ public DeletedKeyItem() { } RecoveryId = recoveryId; ScheduledPurgeDate = scheduledPurgeDate; DeletedDate = deletedDate; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets or sets the url of the recovery object, used to identify and /// recover the deleted key. @@ -64,15 +73,14 @@ public DeletedKeyItem() { } /// [JsonConverter(typeof(UnixTimeJsonConverter))] [JsonProperty(PropertyName = "scheduledPurgeDate")] - public System.DateTime? ScheduledPurgeDate { get; protected set; } + public System.DateTime? ScheduledPurgeDate { get; private set; } /// /// Gets the time when the key was deleted, in UTC /// [JsonConverter(typeof(UnixTimeJsonConverter))] [JsonProperty(PropertyName = "deletedDate")] - public System.DateTime? DeletedDate { get; protected set; } + public System.DateTime? DeletedDate { get; private set; } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/DeletedSecretBundle.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/DeletedSecretBundle.cs index 117fa9f285df..9334c7254a37 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/DeletedSecretBundle.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/DeletedSecretBundle.cs @@ -2,16 +2,16 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; - using Rest; - using Rest.Serialization; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; + using Microsoft.Rest; + using Microsoft.Rest.Serialization; using Newtonsoft.Json; using System.Collections; using System.Collections.Generic; @@ -26,7 +26,10 @@ public partial class DeletedSecretBundle : SecretBundle /// /// Initializes a new instance of the DeletedSecretBundle class. /// - public DeletedSecretBundle() { } + public DeletedSecretBundle() + { + CustomInit(); + } /// /// Initializes a new instance of the DeletedSecretBundle class. @@ -55,8 +58,14 @@ public DeletedSecretBundle() { } RecoveryId = recoveryId; ScheduledPurgeDate = scheduledPurgeDate; DeletedDate = deletedDate; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets or sets the url of the recovery object, used to identify and /// recover the deleted secret. @@ -69,15 +78,14 @@ public DeletedSecretBundle() { } /// [JsonConverter(typeof(UnixTimeJsonConverter))] [JsonProperty(PropertyName = "scheduledPurgeDate")] - public System.DateTime? ScheduledPurgeDate { get; protected set; } + public System.DateTime? ScheduledPurgeDate { get; private set; } /// /// Gets the time when the secret was deleted, in UTC /// [JsonConverter(typeof(UnixTimeJsonConverter))] [JsonProperty(PropertyName = "deletedDate")] - public System.DateTime? DeletedDate { get; protected set; } + public System.DateTime? DeletedDate { get; private set; } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/DeletedSecretItem.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/DeletedSecretItem.cs index fb47c9f23c8a..111d02b3ab10 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/DeletedSecretItem.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/DeletedSecretItem.cs @@ -2,16 +2,16 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; - using Rest; - using Rest.Serialization; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; + using Microsoft.Rest; + using Microsoft.Rest.Serialization; using Newtonsoft.Json; using System.Collections; using System.Collections.Generic; @@ -25,7 +25,10 @@ public partial class DeletedSecretItem : SecretItem /// /// Initializes a new instance of the DeletedSecretItem class. /// - public DeletedSecretItem() { } + public DeletedSecretItem() + { + CustomInit(); + } /// /// Initializes a new instance of the DeletedSecretItem class. @@ -51,8 +54,14 @@ public DeletedSecretItem() { } RecoveryId = recoveryId; ScheduledPurgeDate = scheduledPurgeDate; DeletedDate = deletedDate; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets or sets the url of the recovery object, used to identify and /// recover the deleted secret. @@ -65,15 +74,14 @@ public DeletedSecretItem() { } /// [JsonConverter(typeof(UnixTimeJsonConverter))] [JsonProperty(PropertyName = "scheduledPurgeDate")] - public System.DateTime? ScheduledPurgeDate { get; protected set; } + public System.DateTime? ScheduledPurgeDate { get; private set; } /// /// Gets the time when the secret was deleted, in UTC /// [JsonConverter(typeof(UnixTimeJsonConverter))] [JsonProperty(PropertyName = "deletedDate")] - public System.DateTime? DeletedDate { get; protected set; } + public System.DateTime? DeletedDate { get; private set; } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/DeletionRecoveryLevel.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/DeletionRecoveryLevel.cs index 211604c6ca8b..1484cd794433 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/DeletionRecoveryLevel.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/DeletionRecoveryLevel.cs @@ -2,14 +2,14 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; /// /// Defines values for DeletionRecoveryLevel. @@ -22,4 +22,3 @@ public static class DeletionRecoveryLevel public const string RecoverableProtectedSubscription = "Recoverable+ProtectedSubscription"; } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/Error.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/Error.cs index c8c100ad496a..5ffde0a041d0 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/Error.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/Error.cs @@ -2,14 +2,14 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; using Newtonsoft.Json; using System.Linq; @@ -21,7 +21,10 @@ public partial class Error /// /// Initializes a new instance of the Error class. /// - public Error() { } + public Error() + { + CustomInit(); + } /// /// Initializes a new instance of the Error class. @@ -33,25 +36,30 @@ public Error() { } Code = code; Message = message; InnerError = innerError; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets the error code. /// [JsonProperty(PropertyName = "code")] - public string Code { get; protected set; } + public string Code { get; private set; } /// /// Gets the error message. /// [JsonProperty(PropertyName = "message")] - public string Message { get; protected set; } + public string Message { get; private set; } /// /// [JsonProperty(PropertyName = "innererror")] - public Error InnerError { get; protected set; } + public Error InnerError { get; private set; } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/IssuerAttributes.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/IssuerAttributes.cs index a6acf51ec93d..73308f78d008 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/IssuerAttributes.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/IssuerAttributes.cs @@ -2,16 +2,16 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; - using Rest; - using Rest.Serialization; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; + using Microsoft.Rest; + using Microsoft.Rest.Serialization; using Newtonsoft.Json; using System.Linq; @@ -23,7 +23,10 @@ public partial class IssuerAttributes /// /// Initializes a new instance of the IssuerAttributes class. /// - public IssuerAttributes() { } + public IssuerAttributes() + { + CustomInit(); + } /// /// Initializes a new instance of the IssuerAttributes class. @@ -37,8 +40,14 @@ public IssuerAttributes() { } Enabled = enabled; Created = created; Updated = updated; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets or sets determines whether the issuer is enabled. /// @@ -50,15 +59,14 @@ public IssuerAttributes() { } /// [JsonConverter(typeof(UnixTimeJsonConverter))] [JsonProperty(PropertyName = "created")] - public System.DateTime? Created { get; protected set; } + public System.DateTime? Created { get; private set; } /// /// Gets last updated time in UTC. /// [JsonConverter(typeof(UnixTimeJsonConverter))] [JsonProperty(PropertyName = "updated")] - public System.DateTime? Updated { get; protected set; } + public System.DateTime? Updated { get; private set; } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/IssuerBundle.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/IssuerBundle.cs index 23ed8ab176e6..f8680ff876af 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/IssuerBundle.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/IssuerBundle.cs @@ -2,14 +2,14 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; using Newtonsoft.Json; using System.Linq; @@ -21,7 +21,10 @@ public partial class IssuerBundle /// /// Initializes a new instance of the IssuerBundle class. /// - public IssuerBundle() { } + public IssuerBundle() + { + CustomInit(); + } /// /// Initializes a new instance of the IssuerBundle class. @@ -40,13 +43,19 @@ public IssuerBundle() { } Credentials = credentials; OrganizationDetails = organizationDetails; Attributes = attributes; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets identifier for the issuer object. /// [JsonProperty(PropertyName = "id")] - public string Id { get; protected set; } + public string Id { get; private set; } /// /// Gets or sets the issuer provider. @@ -74,4 +83,3 @@ public IssuerBundle() { } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/IssuerCredentials.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/IssuerCredentials.cs index 268981889ddb..3333666c9048 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/IssuerCredentials.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/IssuerCredentials.cs @@ -2,14 +2,14 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; using Newtonsoft.Json; using System.Linq; @@ -21,7 +21,10 @@ public partial class IssuerCredentials /// /// Initializes a new instance of the IssuerCredentials class. /// - public IssuerCredentials() { } + public IssuerCredentials() + { + CustomInit(); + } /// /// Initializes a new instance of the IssuerCredentials class. @@ -33,8 +36,14 @@ public IssuerCredentials() { } { AccountId = accountId; Password = password; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets or sets the user name/account name/account id. /// @@ -49,4 +58,3 @@ public IssuerCredentials() { } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/IssuerParameters.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/IssuerParameters.cs index e1d105ee3dad..485760b086b5 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/IssuerParameters.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/IssuerParameters.cs @@ -2,14 +2,14 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; using Newtonsoft.Json; using System.Linq; @@ -21,7 +21,10 @@ public partial class IssuerParameters /// /// Initializes a new instance of the IssuerParameters class. /// - public IssuerParameters() { } + public IssuerParameters() + { + CustomInit(); + } /// /// Initializes a new instance of the IssuerParameters class. @@ -34,8 +37,14 @@ public IssuerParameters() { } { Name = name; CertificateType = certificateType; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets or sets name of the referenced issuer object or reserved /// names; for example, 'Self' or 'Unknown'. @@ -52,4 +61,3 @@ public IssuerParameters() { } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeyAttributes.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeyAttributes.cs index 1107e5c76324..dcd8507d3037 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeyAttributes.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeyAttributes.cs @@ -2,14 +2,14 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; using Newtonsoft.Json; using System.Linq; @@ -21,7 +21,10 @@ public partial class KeyAttributes : Attributes /// /// Initializes a new instance of the KeyAttributes class. /// - public KeyAttributes() { } + public KeyAttributes() + { + CustomInit(); + } /// /// Initializes a new instance of the KeyAttributes class. @@ -43,8 +46,14 @@ public KeyAttributes() { } : base(enabled, notBefore, expires, created, updated) { RecoveryLevel = recoveryLevel; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets reflects the deletion recovery level currently in effect for /// keys in the current vault. If it contains 'Purgeable' the key can @@ -54,8 +63,7 @@ public KeyAttributes() { } /// 'Recoverable', 'Recoverable+ProtectedSubscription' /// [JsonProperty(PropertyName = "recoveryLevel")] - public string RecoveryLevel { get; protected set; } + public string RecoveryLevel { get; private set; } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeyBundle.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeyBundle.cs index 3415eac03347..b55b92589165 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeyBundle.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeyBundle.cs @@ -2,14 +2,14 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; using Microsoft.Azure.KeyVault.WebKey; using Newtonsoft.Json; using System.Collections; @@ -24,7 +24,10 @@ public partial class KeyBundle /// /// Initializes a new instance of the KeyBundle class. /// - public KeyBundle() { } + public KeyBundle() + { + CustomInit(); + } /// /// Initializes a new instance of the KeyBundle class. @@ -42,8 +45,14 @@ public KeyBundle() { } Attributes = attributes; Tags = tags; Managed = managed; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets or sets the Json web key. /// @@ -68,8 +77,7 @@ public KeyBundle() { } /// a key backing a certificate, then managed will be true. /// [JsonProperty(PropertyName = "managed")] - public bool? Managed { get; protected set; } + public bool? Managed { get; private set; } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeyCreateParameters.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeyCreateParameters.cs index 3f4a1152cec6..bcaa95dd5523 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeyCreateParameters.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeyCreateParameters.cs @@ -2,15 +2,15 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; - using Rest; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; + using Microsoft.Rest; using Newtonsoft.Json; using System.Collections; using System.Collections.Generic; @@ -24,32 +24,43 @@ public partial class KeyCreateParameters /// /// Initializes a new instance of the KeyCreateParameters class. /// - public KeyCreateParameters() { } + public KeyCreateParameters() + { + CustomInit(); + } /// /// Initializes a new instance of the KeyCreateParameters class. /// - /// The type of key to create. For valid key types, - /// see JsonWebKeyType. Supported JsonWebKey key types (kty) for - /// Elliptic Curve, RSA, HSM, Octet. Possible values include: 'EC', - /// 'RSA', 'RSA-HSM', 'oct' + /// The type of key to create. For valid values, see + /// JsonWebKeyType. Possible values include: 'EC', 'EC-HSM', 'RSA', + /// 'RSA-HSM', 'oct' /// The key size in bytes. For example, 1024 or /// 2048. /// Application specific metadata in the form of /// key-value pairs. - public KeyCreateParameters(string kty, int? keySize = default(int?), IList keyOps = default(IList), KeyAttributes keyAttributes = default(KeyAttributes), IDictionary tags = default(IDictionary)) + /// Elliptic curve name. For valid values, see + /// JsonWebKeyCurveName. Possible values include: 'P-256', 'P-384', + /// 'P-521', 'SECP256K1' + public KeyCreateParameters(string kty, int? keySize = default(int?), IList keyOps = default(IList), KeyAttributes keyAttributes = default(KeyAttributes), IDictionary tags = default(IDictionary), string curve = default(string)) { Kty = kty; KeySize = keySize; KeyOps = keyOps; KeyAttributes = keyAttributes; Tags = tags; + Curve = curve; + CustomInit(); } /// - /// Gets or sets the type of key to create. For valid key types, see - /// JsonWebKeyType. Supported JsonWebKey key types (kty) for Elliptic - /// Curve, RSA, HSM, Octet. Possible values include: 'EC', 'RSA', + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the type of key to create. For valid values, see + /// JsonWebKeyType. Possible values include: 'EC', 'EC-HSM', 'RSA', /// 'RSA-HSM', 'oct' /// [JsonProperty(PropertyName = "kty")] @@ -78,6 +89,14 @@ public KeyCreateParameters() { } [JsonProperty(PropertyName = "tags")] public IDictionary Tags { get; set; } + /// + /// Gets or sets elliptic curve name. For valid values, see + /// JsonWebKeyCurveName. Possible values include: 'P-256', 'P-384', + /// 'P-521', 'SECP256K1' + /// + [JsonProperty(PropertyName = "crv")] + public string Curve { get; set; } + /// /// Validate the object. /// @@ -100,4 +119,3 @@ public virtual void Validate() } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeyImportParameters.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeyImportParameters.cs index 76a306c569a4..48846de5cfb1 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeyImportParameters.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeyImportParameters.cs @@ -2,20 +2,20 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; - using Rest; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; + using Microsoft.Azure.KeyVault.WebKey; + using Microsoft.Rest; using Newtonsoft.Json; using System.Collections; using System.Collections.Generic; using System.Linq; - using Microsoft.Azure.KeyVault.WebKey; /// /// The key import parameters. @@ -25,7 +25,10 @@ public partial class KeyImportParameters /// /// Initializes a new instance of the KeyImportParameters class. /// - public KeyImportParameters() { } + public KeyImportParameters() + { + CustomInit(); + } /// /// Initializes a new instance of the KeyImportParameters class. @@ -42,8 +45,14 @@ public KeyImportParameters() { } Key = key; KeyAttributes = keyAttributes; Tags = tags; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets or sets whether to import as a hardware key (HSM) or software /// key. @@ -85,4 +94,3 @@ public virtual void Validate() } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeyItem.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeyItem.cs index 3c84926da646..ca54979a5b73 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeyItem.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeyItem.cs @@ -2,14 +2,14 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; using Newtonsoft.Json; using System.Collections; using System.Collections.Generic; @@ -23,7 +23,10 @@ public partial class KeyItem /// /// Initializes a new instance of the KeyItem class. /// - public KeyItem() { } + public KeyItem() + { + CustomInit(); + } /// /// Initializes a new instance of the KeyItem class. @@ -41,8 +44,14 @@ public KeyItem() { } Attributes = attributes; Tags = tags; Managed = managed; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets or sets key identifier. /// @@ -67,8 +76,7 @@ public KeyItem() { } /// a key backing a certificate, then managed will be true. /// [JsonProperty(PropertyName = "managed")] - public bool? Managed { get; protected set; } + public bool? Managed { get; private set; } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeyOperationResult.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeyOperationResult.cs index e6e9423950a0..871afc05c853 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeyOperationResult.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeyOperationResult.cs @@ -2,16 +2,16 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; - using Rest; - using Rest.Serialization; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; + using Microsoft.Rest; + using Microsoft.Rest.Serialization; using Newtonsoft.Json; using System.Linq; @@ -23,7 +23,10 @@ public partial class KeyOperationResult /// /// Initializes a new instance of the KeyOperationResult class. /// - public KeyOperationResult() { } + public KeyOperationResult() + { + CustomInit(); + } /// /// Initializes a new instance of the KeyOperationResult class. @@ -33,20 +36,25 @@ public KeyOperationResult() { } { Kid = kid; Result = result; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets key identifier /// [JsonProperty(PropertyName = "kid")] - public string Kid { get; protected set; } + public string Kid { get; private set; } /// /// [JsonConverter(typeof(Base64UrlJsonConverter))] [JsonProperty(PropertyName = "value")] - public byte[] Result { get; protected set; } + public byte[] Result { get; private set; } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeyOperationsParameters.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeyOperationsParameters.cs index ba8a603c354b..250af9c31e20 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeyOperationsParameters.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeyOperationsParameters.cs @@ -2,16 +2,16 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; - using Rest; - using Rest.Serialization; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; + using Microsoft.Rest; + using Microsoft.Rest.Serialization; using Newtonsoft.Json; using System.Linq; @@ -23,7 +23,10 @@ public partial class KeyOperationsParameters /// /// Initializes a new instance of the KeyOperationsParameters class. /// - public KeyOperationsParameters() { } + public KeyOperationsParameters() + { + CustomInit(); + } /// /// Initializes a new instance of the KeyOperationsParameters class. @@ -34,8 +37,14 @@ public KeyOperationsParameters(string algorithm, byte[] value) { Algorithm = algorithm; Value = value; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets or sets algorithm identifier. Possible values include: /// 'RSA-OAEP', 'RSA-OAEP-256', 'RSA1_5' @@ -75,4 +84,3 @@ public virtual void Validate() } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeyProperties.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeyProperties.cs index 6902bf6da543..86b3ffebc770 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeyProperties.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeyProperties.cs @@ -2,14 +2,14 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; using Newtonsoft.Json; using System.Linq; @@ -21,7 +21,10 @@ public partial class KeyProperties /// /// Initializes a new instance of the KeyProperties class. /// - public KeyProperties() { } + public KeyProperties() + { + CustomInit(); + } /// /// Initializes a new instance of the KeyProperties class. @@ -39,8 +42,14 @@ public KeyProperties() { } KeyType = keyType; KeySize = keySize; ReuseKey = reuseKey; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets or sets indicates if the private key can be exported. /// @@ -68,4 +77,3 @@ public KeyProperties() { } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeyRestoreParameters.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeyRestoreParameters.cs index 75be262d0743..a546b41948d7 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeyRestoreParameters.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeyRestoreParameters.cs @@ -2,16 +2,16 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; - using Rest; - using Rest.Serialization; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; + using Microsoft.Rest; + using Microsoft.Rest.Serialization; using Newtonsoft.Json; using System.Linq; @@ -23,7 +23,10 @@ public partial class KeyRestoreParameters /// /// Initializes a new instance of the KeyRestoreParameters class. /// - public KeyRestoreParameters() { } + public KeyRestoreParameters() + { + CustomInit(); + } /// /// Initializes a new instance of the KeyRestoreParameters class. @@ -33,8 +36,14 @@ public KeyRestoreParameters() { } public KeyRestoreParameters(byte[] keyBundleBackup) { KeyBundleBackup = keyBundleBackup; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets or sets the backup blob associated with a key bundle. /// @@ -57,4 +66,3 @@ public virtual void Validate() } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeySignParameters.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeySignParameters.cs index 98fdf2b6f8a1..8398430e51ab 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeySignParameters.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeySignParameters.cs @@ -2,16 +2,16 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; - using Rest; - using Rest.Serialization; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; + using Microsoft.Rest; + using Microsoft.Rest.Serialization; using Newtonsoft.Json; using System.Linq; @@ -23,7 +23,10 @@ public partial class KeySignParameters /// /// Initializes a new instance of the KeySignParameters class. /// - public KeySignParameters() { } + public KeySignParameters() + { + CustomInit(); + } /// /// Initializes a new instance of the KeySignParameters class. @@ -31,18 +34,26 @@ public KeySignParameters() { } /// The signing/verification algorithm /// identifier. For more information on possible algorithm types, see /// JsonWebKeySignatureAlgorithm. Possible values include: 'PS256', - /// 'PS384', 'PS512', 'RS256', 'RS384', 'RS512', 'RSNULL' + /// 'PS384', 'PS512', 'RS256', 'RS384', 'RS512', 'RSNULL', 'ES256', + /// 'ES384', 'ES512', 'ECDSA256' public KeySignParameters(string algorithm, byte[] value) { Algorithm = algorithm; Value = value; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets or sets the signing/verification algorithm identifier. For /// more information on possible algorithm types, see /// JsonWebKeySignatureAlgorithm. Possible values include: 'PS256', - /// 'PS384', 'PS512', 'RS256', 'RS384', 'RS512', 'RSNULL' + /// 'PS384', 'PS512', 'RS256', 'RS384', 'RS512', 'RSNULL', 'ES256', + /// 'ES384', 'ES512', 'ECDSA256' /// [JsonProperty(PropertyName = "alg")] public string Algorithm { get; set; } @@ -79,4 +90,3 @@ public virtual void Validate() } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeyUpdateParameters.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeyUpdateParameters.cs index 7974eb1bf333..8cd4009c159d 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeyUpdateParameters.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeyUpdateParameters.cs @@ -2,14 +2,14 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; using Newtonsoft.Json; using System.Collections; using System.Collections.Generic; @@ -23,7 +23,10 @@ public partial class KeyUpdateParameters /// /// Initializes a new instance of the KeyUpdateParameters class. /// - public KeyUpdateParameters() { } + public KeyUpdateParameters() + { + CustomInit(); + } /// /// Initializes a new instance of the KeyUpdateParameters class. @@ -37,8 +40,14 @@ public KeyUpdateParameters() { } KeyOps = keyOps; KeyAttributes = keyAttributes; Tags = tags; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets or sets json web key operations. For more information on /// possible key operations, see JsonWebKeyOperation. @@ -60,4 +69,3 @@ public KeyUpdateParameters() { } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeyUsageType.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeyUsageType.cs index 3442736f6fd6..65ed4afdbe92 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeyUsageType.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeyUsageType.cs @@ -2,14 +2,14 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; /// /// Defines values for KeyUsageType. @@ -27,4 +27,3 @@ public static class KeyUsageType public const string DecipherOnly = "decipherOnly"; } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeyVaultError.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeyVaultError.cs index b25cc49c11f5..f7348ac26861 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeyVaultError.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeyVaultError.cs @@ -2,14 +2,14 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; using Newtonsoft.Json; using System.Linq; @@ -21,7 +21,10 @@ public partial class KeyVaultError /// /// Initializes a new instance of the KeyVaultError class. /// - public KeyVaultError() { } + public KeyVaultError() + { + CustomInit(); + } /// /// Initializes a new instance of the KeyVaultError class. @@ -29,13 +32,18 @@ public KeyVaultError() { } public KeyVaultError(Error error = default(Error)) { Error = error; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// [JsonProperty(PropertyName = "error")] - public Error Error { get; protected set; } + public Error Error { get; private set; } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeyVaultErrorException.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeyVaultErrorException.cs index cc9154d49976..cf404fb95f45 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeyVaultErrorException.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeyVaultErrorException.cs @@ -2,26 +2,20 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; - using Rest; - using System.Runtime; - using System.Runtime.Serialization; - using System.Security; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; + using Microsoft.Rest; /// /// Exception thrown for an invalid response with KeyVaultError /// information. /// -#if NET45 - [System.Serializable] -#endif public class KeyVaultErrorException : RestException { /// @@ -46,7 +40,7 @@ public override string Message { get { - if(Body != null && Body.Error != null && !string.IsNullOrWhiteSpace(Body.Error.Message)) + if (Body != null && Body.Error != null && !string.IsNullOrWhiteSpace(Body.Error.Message)) return Body.Error.Message; return base.Message; } @@ -77,40 +71,5 @@ public KeyVaultErrorException(string message, System.Exception innerException) : base(message, innerException) { } - -#if NET45 - /// - /// Initializes a new instance of the KeyVaultErrorException class. - /// - /// Serialization info. - /// Streaming context. - protected KeyVaultErrorException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } - - /// - /// Serializes content of the exception. - /// - /// Serialization info. - /// Streaming context. - /// - /// Thrown when a required parameter is null - /// - [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand, SerializationFormatter = true)] - public override void GetObjectData(SerializationInfo info, StreamingContext context) - { - base.GetObjectData(info, context); - if (info == null) - { - throw new System.ArgumentNullException("info"); - } - - info.AddValue("Request", Request); - info.AddValue("Response", Response); - info.AddValue("Body", Body); - } -#endif } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeyVerifyParameters.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeyVerifyParameters.cs index 3e4ed6a3fec9..9f7ed04d2caf 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeyVerifyParameters.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeyVerifyParameters.cs @@ -2,16 +2,16 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; - using Rest; - using Rest.Serialization; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; + using Microsoft.Rest; + using Microsoft.Rest.Serialization; using Newtonsoft.Json; using System.Linq; @@ -23,7 +23,10 @@ public partial class KeyVerifyParameters /// /// Initializes a new instance of the KeyVerifyParameters class. /// - public KeyVerifyParameters() { } + public KeyVerifyParameters() + { + CustomInit(); + } /// /// Initializes a new instance of the KeyVerifyParameters class. @@ -31,7 +34,8 @@ public KeyVerifyParameters() { } /// The signing/verification algorithm. For /// more information on possible algorithm types, see /// JsonWebKeySignatureAlgorithm. Possible values include: 'PS256', - /// 'PS384', 'PS512', 'RS256', 'RS384', 'RS512', 'RSNULL' + /// 'PS384', 'PS512', 'RS256', 'RS384', 'RS512', 'RSNULL', 'ES256', + /// 'ES384', 'ES512', 'ECDSA256' /// The digest used for signing. /// The signature to be verified. public KeyVerifyParameters(string algorithm, byte[] digest, byte[] signature) @@ -39,13 +43,20 @@ public KeyVerifyParameters(string algorithm, byte[] digest, byte[] signature) Algorithm = algorithm; Digest = digest; Signature = signature; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets or sets the signing/verification algorithm. For more /// information on possible algorithm types, see /// JsonWebKeySignatureAlgorithm. Possible values include: 'PS256', - /// 'PS384', 'PS512', 'RS256', 'RS384', 'RS512', 'RSNULL' + /// 'PS384', 'PS512', 'RS256', 'RS384', 'RS512', 'RSNULL', 'ES256', + /// 'ES384', 'ES512', 'ECDSA256' /// [JsonProperty(PropertyName = "alg")] public string Algorithm { get; set; } @@ -94,4 +105,3 @@ public virtual void Validate() } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeyVerifyResult.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeyVerifyResult.cs index 5f13690bc272..a8bfed204fdd 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeyVerifyResult.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/KeyVerifyResult.cs @@ -2,14 +2,14 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; using Newtonsoft.Json; using System.Linq; @@ -21,7 +21,10 @@ public partial class KeyVerifyResult /// /// Initializes a new instance of the KeyVerifyResult class. /// - public KeyVerifyResult() { } + public KeyVerifyResult() + { + CustomInit(); + } /// /// Initializes a new instance of the KeyVerifyResult class. @@ -31,14 +34,19 @@ public KeyVerifyResult() { } public KeyVerifyResult(bool? value = default(bool?)) { Value = value; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets true if the signature is verified, otherwise false. /// [JsonProperty(PropertyName = "value")] - public bool? Value { get; protected set; } + public bool? Value { get; private set; } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/LifetimeAction.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/LifetimeAction.cs index 46b822c4040e..4042e2453018 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/LifetimeAction.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/LifetimeAction.cs @@ -2,14 +2,14 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; using Newtonsoft.Json; using System.Linq; @@ -22,7 +22,10 @@ public partial class LifetimeAction /// /// Initializes a new instance of the LifetimeAction class. /// - public LifetimeAction() { } + public LifetimeAction() + { + CustomInit(); + } /// /// Initializes a new instance of the LifetimeAction class. @@ -34,8 +37,14 @@ public LifetimeAction() { } { Trigger = trigger; Action = action; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets or sets the condition that will execute the action. /// @@ -63,4 +72,3 @@ public virtual void Validate() } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/OrganizationDetails.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/OrganizationDetails.cs index b4910b4c1c06..66557ecf76a3 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/OrganizationDetails.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/OrganizationDetails.cs @@ -2,14 +2,14 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; using Newtonsoft.Json; using System.Collections; using System.Collections.Generic; @@ -23,7 +23,10 @@ public partial class OrganizationDetails /// /// Initializes a new instance of the OrganizationDetails class. /// - public OrganizationDetails() { } + public OrganizationDetails() + { + CustomInit(); + } /// /// Initializes a new instance of the OrganizationDetails class. @@ -35,8 +38,14 @@ public OrganizationDetails() { } { Id = id; AdminDetails = adminDetails; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets or sets id of the organization. /// @@ -51,4 +60,3 @@ public OrganizationDetails() { } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/Page.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/Page.cs index 4958035ce031..f847d9650f43 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/Page.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/Page.cs @@ -2,16 +2,16 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; - using Rest; - using Rest.Azure; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; + using Microsoft.Rest; + using Microsoft.Rest.Azure; using Newtonsoft.Json; using System.Collections; using System.Collections.Generic; @@ -51,4 +51,3 @@ IEnumerator IEnumerable.GetEnumerator() } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/PendingCertificateSigningRequestResult.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/PendingCertificateSigningRequestResult.cs index 139d0226e463..753d9c9fc73e 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/PendingCertificateSigningRequestResult.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/PendingCertificateSigningRequestResult.cs @@ -2,14 +2,14 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; using Newtonsoft.Json; using System.Linq; @@ -22,7 +22,10 @@ public partial class PendingCertificateSigningRequestResult /// Initializes a new instance of the /// PendingCertificateSigningRequestResult class. /// - public PendingCertificateSigningRequestResult() { } + public PendingCertificateSigningRequestResult() + { + CustomInit(); + } /// /// Initializes a new instance of the @@ -33,15 +36,20 @@ public PendingCertificateSigningRequestResult() { } public PendingCertificateSigningRequestResult(string value = default(string)) { Value = value; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets the pending certificate signing request as Base64 encoded /// string. /// [JsonProperty(PropertyName = "value")] - public string Value { get; protected set; } + public string Value { get; private set; } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/SasDefinitionAttributes.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/SasDefinitionAttributes.cs index 54ede989192f..b3f03bc9b4a8 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/SasDefinitionAttributes.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/SasDefinitionAttributes.cs @@ -2,16 +2,16 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; - using Rest; - using Rest.Serialization; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; + using Microsoft.Rest; + using Microsoft.Rest.Serialization; using Newtonsoft.Json; using System.Linq; @@ -23,7 +23,10 @@ public partial class SasDefinitionAttributes /// /// Initializes a new instance of the SasDefinitionAttributes class. /// - public SasDefinitionAttributes() { } + public SasDefinitionAttributes() + { + CustomInit(); + } /// /// Initializes a new instance of the SasDefinitionAttributes class. @@ -36,8 +39,14 @@ public SasDefinitionAttributes() { } Enabled = enabled; Created = created; Updated = updated; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets or sets the enabled state of the object. /// @@ -49,15 +58,14 @@ public SasDefinitionAttributes() { } /// [JsonConverter(typeof(UnixTimeJsonConverter))] [JsonProperty(PropertyName = "created")] - public System.DateTime? Created { get; protected set; } + public System.DateTime? Created { get; private set; } /// /// Gets last updated time in UTC. /// [JsonConverter(typeof(UnixTimeJsonConverter))] [JsonProperty(PropertyName = "updated")] - public System.DateTime? Updated { get; protected set; } + public System.DateTime? Updated { get; private set; } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/SasDefinitionBundle.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/SasDefinitionBundle.cs index a40df9332e76..1c7fba67de69 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/SasDefinitionBundle.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/SasDefinitionBundle.cs @@ -2,14 +2,14 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; using Newtonsoft.Json; using System.Collections; using System.Collections.Generic; @@ -24,7 +24,10 @@ public partial class SasDefinitionBundle /// /// Initializes a new instance of the SasDefinitionBundle class. /// - public SasDefinitionBundle() { } + public SasDefinitionBundle() + { + CustomInit(); + } /// /// Initializes a new instance of the SasDefinitionBundle class. @@ -44,38 +47,43 @@ public SasDefinitionBundle() { } Parameters = parameters; Attributes = attributes; Tags = tags; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets the SAS definition id. /// [JsonProperty(PropertyName = "id")] - public string Id { get; protected set; } + public string Id { get; private set; } /// /// Gets storage account SAS definition secret id. /// [JsonProperty(PropertyName = "sid")] - public string SecretId { get; protected set; } + public string SecretId { get; private set; } /// /// Gets the SAS definition metadata in the form of key-value pairs. /// [JsonProperty(PropertyName = "parameters")] - public IDictionary Parameters { get; protected set; } + public IDictionary Parameters { get; private set; } /// /// Gets the SAS definition attributes. /// [JsonProperty(PropertyName = "attributes")] - public SasDefinitionAttributes Attributes { get; protected set; } + public SasDefinitionAttributes Attributes { get; private set; } /// /// Gets application specific metadata in the form of key-value pairs /// [JsonProperty(PropertyName = "tags")] - public IDictionary Tags { get; protected set; } + public IDictionary Tags { get; private set; } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/SasDefinitionCreateParameters.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/SasDefinitionCreateParameters.cs index 7b874973e226..6c3a8f9062da 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/SasDefinitionCreateParameters.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/SasDefinitionCreateParameters.cs @@ -2,15 +2,15 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; - using Rest; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; + using Microsoft.Rest; using Newtonsoft.Json; using System.Collections; using System.Collections.Generic; @@ -25,7 +25,10 @@ public partial class SasDefinitionCreateParameters /// Initializes a new instance of the SasDefinitionCreateParameters /// class. /// - public SasDefinitionCreateParameters() { } + public SasDefinitionCreateParameters() + { + CustomInit(); + } /// /// Initializes a new instance of the SasDefinitionCreateParameters @@ -42,8 +45,14 @@ public SasDefinitionCreateParameters() { } Parameters = parameters; SasDefinitionAttributes = sasDefinitionAttributes; Tags = tags; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets or sets sas definition creation metadata in the form of /// key-value pairs. @@ -79,4 +88,3 @@ public virtual void Validate() } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/SasDefinitionItem.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/SasDefinitionItem.cs index d0ac37d46067..625cefe807a3 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/SasDefinitionItem.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/SasDefinitionItem.cs @@ -2,14 +2,14 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; using Newtonsoft.Json; using System.Collections; using System.Collections.Generic; @@ -23,7 +23,10 @@ public partial class SasDefinitionItem /// /// Initializes a new instance of the SasDefinitionItem class. /// - public SasDefinitionItem() { } + public SasDefinitionItem() + { + CustomInit(); + } /// /// Initializes a new instance of the SasDefinitionItem class. @@ -41,32 +44,37 @@ public SasDefinitionItem() { } SecretId = secretId; Attributes = attributes; Tags = tags; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets the storage SAS identifier. /// [JsonProperty(PropertyName = "id")] - public string Id { get; protected set; } + public string Id { get; private set; } /// /// Gets the storage account SAS definition secret id. /// [JsonProperty(PropertyName = "sid")] - public string SecretId { get; protected set; } + public string SecretId { get; private set; } /// /// Gets the SAS definition management attributes. /// [JsonProperty(PropertyName = "attributes")] - public SasDefinitionAttributes Attributes { get; protected set; } + public SasDefinitionAttributes Attributes { get; private set; } /// /// Gets application specific metadata in the form of key-value pairs. /// [JsonProperty(PropertyName = "tags")] - public IDictionary Tags { get; protected set; } + public IDictionary Tags { get; private set; } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/SasDefinitionUpdateParameters.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/SasDefinitionUpdateParameters.cs index 494c03562eef..4d639f53dc14 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/SasDefinitionUpdateParameters.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/SasDefinitionUpdateParameters.cs @@ -2,14 +2,14 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; using Newtonsoft.Json; using System.Collections; using System.Collections.Generic; @@ -24,7 +24,10 @@ public partial class SasDefinitionUpdateParameters /// Initializes a new instance of the SasDefinitionUpdateParameters /// class. /// - public SasDefinitionUpdateParameters() { } + public SasDefinitionUpdateParameters() + { + CustomInit(); + } /// /// Initializes a new instance of the SasDefinitionUpdateParameters @@ -41,8 +44,14 @@ public SasDefinitionUpdateParameters() { } Parameters = parameters; SasDefinitionAttributes = sasDefinitionAttributes; Tags = tags; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets or sets sas definition update metadata in the form of /// key-value pairs. @@ -65,4 +74,3 @@ public SasDefinitionUpdateParameters() { } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/SecretAttributes.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/SecretAttributes.cs index 8eb051f9d7b2..4a93ea074f4d 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/SecretAttributes.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/SecretAttributes.cs @@ -2,14 +2,14 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; using Newtonsoft.Json; using System.Linq; @@ -21,7 +21,10 @@ public partial class SecretAttributes : Attributes /// /// Initializes a new instance of the SecretAttributes class. /// - public SecretAttributes() { } + public SecretAttributes() + { + CustomInit(); + } /// /// Initializes a new instance of the SecretAttributes class. @@ -43,8 +46,14 @@ public SecretAttributes() { } : base(enabled, notBefore, expires, created, updated) { RecoveryLevel = recoveryLevel; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets reflects the deletion recovery level currently in effect for /// secrets in the current vault. If it contains 'Purgeable', the @@ -55,8 +64,7 @@ public SecretAttributes() { } /// 'Recoverable+ProtectedSubscription' /// [JsonProperty(PropertyName = "recoveryLevel")] - public string RecoveryLevel { get; protected set; } + public string RecoveryLevel { get; private set; } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/SecretBundle.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/SecretBundle.cs index 8c59a2ccb500..2fb09f338cad 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/SecretBundle.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/SecretBundle.cs @@ -2,14 +2,14 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; using Newtonsoft.Json; using System.Collections; using System.Collections.Generic; @@ -23,7 +23,10 @@ public partial class SecretBundle /// /// Initializes a new instance of the SecretBundle class. /// - public SecretBundle() { } + public SecretBundle() + { + CustomInit(); + } /// /// Initializes a new instance of the SecretBundle class. @@ -49,8 +52,14 @@ public SecretBundle() { } Tags = tags; Kid = kid; Managed = managed; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets or sets the secret value. /// @@ -87,15 +96,14 @@ public SecretBundle() { } /// specifies the corresponding key backing the KV certificate. /// [JsonProperty(PropertyName = "kid")] - public string Kid { get; protected set; } + public string Kid { get; private set; } /// /// Gets true if the secret's lifetime is managed by key vault. If this /// is a secret backing a certificate, then managed will be true. /// [JsonProperty(PropertyName = "managed")] - public bool? Managed { get; protected set; } + public bool? Managed { get; private set; } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/SecretItem.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/SecretItem.cs index d2434881711c..f9c827519dfc 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/SecretItem.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/SecretItem.cs @@ -2,14 +2,14 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; using Newtonsoft.Json; using System.Collections; using System.Collections.Generic; @@ -23,7 +23,10 @@ public partial class SecretItem /// /// Initializes a new instance of the SecretItem class. /// - public SecretItem() { } + public SecretItem() + { + CustomInit(); + } /// /// Initializes a new instance of the SecretItem class. @@ -44,8 +47,14 @@ public SecretItem() { } Tags = tags; ContentType = contentType; Managed = managed; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets or sets secret identifier. /// @@ -76,8 +85,7 @@ public SecretItem() { } /// is a key backing a certificate, then managed will be true. /// [JsonProperty(PropertyName = "managed")] - public bool? Managed { get; protected set; } + public bool? Managed { get; private set; } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/SecretProperties.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/SecretProperties.cs index da6f7a1a7f51..69b84bf4fbdb 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/SecretProperties.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/SecretProperties.cs @@ -2,14 +2,14 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; using Newtonsoft.Json; using System.Linq; @@ -21,7 +21,10 @@ public partial class SecretProperties /// /// Initializes a new instance of the SecretProperties class. /// - public SecretProperties() { } + public SecretProperties() + { + CustomInit(); + } /// /// Initializes a new instance of the SecretProperties class. @@ -30,8 +33,14 @@ public SecretProperties() { } public SecretProperties(string contentType = default(string)) { ContentType = contentType; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets or sets the media type (MIME type). /// @@ -40,4 +49,3 @@ public SecretProperties() { } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/SecretRestoreParameters.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/SecretRestoreParameters.cs index 0509adb4b256..b76b0cf791ce 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/SecretRestoreParameters.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/SecretRestoreParameters.cs @@ -2,16 +2,16 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; - using Rest; - using Rest.Serialization; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; + using Microsoft.Rest; + using Microsoft.Rest.Serialization; using Newtonsoft.Json; using System.Linq; @@ -23,7 +23,10 @@ public partial class SecretRestoreParameters /// /// Initializes a new instance of the SecretRestoreParameters class. /// - public SecretRestoreParameters() { } + public SecretRestoreParameters() + { + CustomInit(); + } /// /// Initializes a new instance of the SecretRestoreParameters class. @@ -33,8 +36,14 @@ public SecretRestoreParameters() { } public SecretRestoreParameters(byte[] secretBundleBackup) { SecretBundleBackup = secretBundleBackup; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets or sets the backup blob associated with a secret bundle. /// @@ -57,4 +66,3 @@ public virtual void Validate() } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/SecretSetParameters.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/SecretSetParameters.cs index 3d4d0bdf00fd..fc28dd416b84 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/SecretSetParameters.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/SecretSetParameters.cs @@ -2,15 +2,15 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; - using Rest; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; + using Microsoft.Rest; using Newtonsoft.Json; using System.Collections; using System.Collections.Generic; @@ -24,7 +24,10 @@ public partial class SecretSetParameters /// /// Initializes a new instance of the SecretSetParameters class. /// - public SecretSetParameters() { } + public SecretSetParameters() + { + CustomInit(); + } /// /// Initializes a new instance of the SecretSetParameters class. @@ -42,8 +45,14 @@ public SecretSetParameters() { } Tags = tags; ContentType = contentType; SecretAttributes = secretAttributes; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets or sets the value of the secret. /// @@ -84,4 +93,3 @@ public virtual void Validate() } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/SecretUpdateParameters.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/SecretUpdateParameters.cs index b45bea5986de..77e90370fc3f 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/SecretUpdateParameters.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/SecretUpdateParameters.cs @@ -2,14 +2,14 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; using Newtonsoft.Json; using System.Collections; using System.Collections.Generic; @@ -23,7 +23,10 @@ public partial class SecretUpdateParameters /// /// Initializes a new instance of the SecretUpdateParameters class. /// - public SecretUpdateParameters() { } + public SecretUpdateParameters() + { + CustomInit(); + } /// /// Initializes a new instance of the SecretUpdateParameters class. @@ -39,8 +42,14 @@ public SecretUpdateParameters() { } ContentType = contentType; SecretAttributes = secretAttributes; Tags = tags; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets or sets type of the secret value such as a password. /// @@ -62,4 +71,3 @@ public SecretUpdateParameters() { } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/StorageAccountAttributes.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/StorageAccountAttributes.cs index 446e99c4eab1..a9b8c0164342 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/StorageAccountAttributes.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/StorageAccountAttributes.cs @@ -2,16 +2,16 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; - using Rest; - using Rest.Serialization; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; + using Microsoft.Rest; + using Microsoft.Rest.Serialization; using Newtonsoft.Json; using System.Linq; @@ -23,7 +23,10 @@ public partial class StorageAccountAttributes /// /// Initializes a new instance of the StorageAccountAttributes class. /// - public StorageAccountAttributes() { } + public StorageAccountAttributes() + { + CustomInit(); + } /// /// Initializes a new instance of the StorageAccountAttributes class. @@ -36,8 +39,14 @@ public StorageAccountAttributes() { } Enabled = enabled; Created = created; Updated = updated; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets or sets the enabled state of the object. /// @@ -49,15 +58,14 @@ public StorageAccountAttributes() { } /// [JsonConverter(typeof(UnixTimeJsonConverter))] [JsonProperty(PropertyName = "created")] - public System.DateTime? Created { get; protected set; } + public System.DateTime? Created { get; private set; } /// /// Gets last updated time in UTC. /// [JsonConverter(typeof(UnixTimeJsonConverter))] [JsonProperty(PropertyName = "updated")] - public System.DateTime? Updated { get; protected set; } + public System.DateTime? Updated { get; private set; } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/StorageAccountCreateParameters.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/StorageAccountCreateParameters.cs index f2b41089d5f9..f639f8bc17cb 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/StorageAccountCreateParameters.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/StorageAccountCreateParameters.cs @@ -2,15 +2,15 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; - using Rest; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; + using Microsoft.Rest; using Newtonsoft.Json; using System.Collections; using System.Collections.Generic; @@ -25,7 +25,10 @@ public partial class StorageAccountCreateParameters /// Initializes a new instance of the StorageAccountCreateParameters /// class. /// - public StorageAccountCreateParameters() { } + public StorageAccountCreateParameters() + { + CustomInit(); + } /// /// Initializes a new instance of the StorageAccountCreateParameters @@ -50,8 +53,14 @@ public StorageAccountCreateParameters() { } RegenerationPeriod = regenerationPeriod; StorageAccountAttributes = storageAccountAttributes; Tags = tags; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets or sets storage account resource id. /// @@ -110,4 +119,3 @@ public virtual void Validate() } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/StorageAccountItem.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/StorageAccountItem.cs index 3ac5d758ddf7..fec2fe602d39 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/StorageAccountItem.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/StorageAccountItem.cs @@ -2,14 +2,14 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; using Newtonsoft.Json; using System.Collections; using System.Collections.Generic; @@ -23,7 +23,10 @@ public partial class StorageAccountItem /// /// Initializes a new instance of the StorageAccountItem class. /// - public StorageAccountItem() { } + public StorageAccountItem() + { + CustomInit(); + } /// /// Initializes a new instance of the StorageAccountItem class. @@ -40,32 +43,37 @@ public StorageAccountItem() { } ResourceId = resourceId; Attributes = attributes; Tags = tags; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets storage identifier. /// [JsonProperty(PropertyName = "id")] - public string Id { get; protected set; } + public string Id { get; private set; } /// /// Gets storage account resource Id. /// [JsonProperty(PropertyName = "resourceId")] - public string ResourceId { get; protected set; } + public string ResourceId { get; private set; } /// /// Gets the storage account management attributes. /// [JsonProperty(PropertyName = "attributes")] - public StorageAccountAttributes Attributes { get; protected set; } + public StorageAccountAttributes Attributes { get; private set; } /// /// Gets application specific metadata in the form of key-value pairs. /// [JsonProperty(PropertyName = "tags")] - public IDictionary Tags { get; protected set; } + public IDictionary Tags { get; private set; } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/StorageAccountRegenerteKeyParameters.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/StorageAccountRegenerteKeyParameters.cs index a71d7764cc23..2e9b882d3931 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/StorageAccountRegenerteKeyParameters.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/StorageAccountRegenerteKeyParameters.cs @@ -2,15 +2,15 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; - using Rest; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; + using Microsoft.Rest; using Newtonsoft.Json; using System.Linq; @@ -23,7 +23,10 @@ public partial class StorageAccountRegenerteKeyParameters /// Initializes a new instance of the /// StorageAccountRegenerteKeyParameters class. /// - public StorageAccountRegenerteKeyParameters() { } + public StorageAccountRegenerteKeyParameters() + { + CustomInit(); + } /// /// Initializes a new instance of the @@ -33,8 +36,14 @@ public StorageAccountRegenerteKeyParameters() { } public StorageAccountRegenerteKeyParameters(string keyName) { KeyName = keyName; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets or sets the storage account key name. /// @@ -56,4 +65,3 @@ public virtual void Validate() } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/StorageAccountUpdateParameters.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/StorageAccountUpdateParameters.cs index 1ccec036d612..6a8b9f49448c 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/StorageAccountUpdateParameters.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/StorageAccountUpdateParameters.cs @@ -2,14 +2,14 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; using Newtonsoft.Json; using System.Collections; using System.Collections.Generic; @@ -24,7 +24,10 @@ public partial class StorageAccountUpdateParameters /// Initializes a new instance of the StorageAccountUpdateParameters /// class. /// - public StorageAccountUpdateParameters() { } + public StorageAccountUpdateParameters() + { + CustomInit(); + } /// /// Initializes a new instance of the StorageAccountUpdateParameters @@ -47,8 +50,14 @@ public StorageAccountUpdateParameters() { } RegenerationPeriod = regenerationPeriod; StorageAccountAttributes = storageAccountAttributes; Tags = tags; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets or sets the current active storage account key name. /// @@ -84,4 +93,3 @@ public StorageAccountUpdateParameters() { } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/StorageBundle.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/StorageBundle.cs index 2dd7b091c1e4..de2dd8c92c9f 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/StorageBundle.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/StorageBundle.cs @@ -2,14 +2,14 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; using Newtonsoft.Json; using System.Collections; using System.Collections.Generic; @@ -24,7 +24,10 @@ public partial class StorageBundle /// /// Initializes a new instance of the StorageBundle class. /// - public StorageBundle() { } + public StorageBundle() + { + CustomInit(); + } /// /// Initializes a new instance of the StorageBundle class. @@ -49,52 +52,57 @@ public StorageBundle() { } RegenerationPeriod = regenerationPeriod; Attributes = attributes; Tags = tags; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets the storage account id. /// [JsonProperty(PropertyName = "id")] - public string Id { get; protected set; } + public string Id { get; private set; } /// /// Gets the storage account resource id. /// [JsonProperty(PropertyName = "resourceId")] - public string ResourceId { get; protected set; } + public string ResourceId { get; private set; } /// /// Gets the current active storage account key name. /// [JsonProperty(PropertyName = "activeKeyName")] - public string ActiveKeyName { get; protected set; } + public string ActiveKeyName { get; private set; } /// /// Gets whether keyvault should manage the storage account for the /// user. /// [JsonProperty(PropertyName = "autoRegenerateKey")] - public bool? AutoRegenerateKey { get; protected set; } + public bool? AutoRegenerateKey { get; private set; } /// /// Gets the key regeneration time duration specified in ISO-8601 /// format. /// [JsonProperty(PropertyName = "regenerationPeriod")] - public string RegenerationPeriod { get; protected set; } + public string RegenerationPeriod { get; private set; } /// /// Gets the storage account attributes. /// [JsonProperty(PropertyName = "attributes")] - public StorageAccountAttributes Attributes { get; protected set; } + public StorageAccountAttributes Attributes { get; private set; } /// /// Gets application specific metadata in the form of key-value pairs /// [JsonProperty(PropertyName = "tags")] - public IDictionary Tags { get; protected set; } + public IDictionary Tags { get; private set; } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/SubjectAlternativeNames.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/SubjectAlternativeNames.cs index 55d0a6bdf9eb..46ee371ee24d 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/SubjectAlternativeNames.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/SubjectAlternativeNames.cs @@ -2,14 +2,14 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; using Newtonsoft.Json; using System.Collections; using System.Collections.Generic; @@ -23,7 +23,10 @@ public partial class SubjectAlternativeNames /// /// Initializes a new instance of the SubjectAlternativeNames class. /// - public SubjectAlternativeNames() { } + public SubjectAlternativeNames() + { + CustomInit(); + } /// /// Initializes a new instance of the SubjectAlternativeNames class. @@ -36,8 +39,14 @@ public SubjectAlternativeNames() { } Emails = emails; DnsNames = dnsNames; Upns = upns; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets or sets email addresses. /// @@ -58,4 +67,3 @@ public SubjectAlternativeNames() { } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/Trigger.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/Trigger.cs index a224cad0a81f..e18cdd19ffd2 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/Trigger.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/Trigger.cs @@ -2,15 +2,15 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; - using Rest; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; + using Microsoft.Rest; using Newtonsoft.Json; using System.Linq; @@ -22,7 +22,10 @@ public partial class Trigger /// /// Initializes a new instance of the Trigger class. /// - public Trigger() { } + public Trigger() + { + CustomInit(); + } /// /// Initializes a new instance of the Trigger class. @@ -34,8 +37,14 @@ public Trigger() { } { LifetimePercentage = lifetimePercentage; DaysBeforeExpiry = daysBeforeExpiry; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets or sets percentage of lifetime at which to trigger. Value /// should be between 1 and 99. @@ -68,4 +77,3 @@ public virtual void Validate() } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/X509CertificateProperties.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/X509CertificateProperties.cs index d33b320de7d1..2f1878a959c8 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/X509CertificateProperties.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Generated/Models/X509CertificateProperties.cs @@ -2,15 +2,15 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is // regenerated. namespace Microsoft.Azure.KeyVault.Models { - using Azure; - using KeyVault; - using Rest; + using Microsoft.Azure; + using Microsoft.Azure.KeyVault; + using Microsoft.Rest; using Newtonsoft.Json; using System.Collections; using System.Collections.Generic; @@ -24,7 +24,10 @@ public partial class X509CertificateProperties /// /// Initializes a new instance of the X509CertificateProperties class. /// - public X509CertificateProperties() { } + public X509CertificateProperties() + { + CustomInit(); + } /// /// Initializes a new instance of the X509CertificateProperties class. @@ -44,8 +47,14 @@ public X509CertificateProperties() { } SubjectAlternativeNames = subjectAlternativeNames; KeyUsage = keyUsage; ValidityInMonths = validityInMonths; + CustomInit(); } + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + /// /// Gets or sets the subject name. Should be a valid X509 distinguished /// Name. @@ -92,4 +101,3 @@ public virtual void Validate() } } } - diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Microsoft.Azure.KeyVault.csproj b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Microsoft.Azure.KeyVault.csproj index 5de6baae0e49..c48ecd69ded5 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Microsoft.Azure.KeyVault.csproj +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Microsoft.Azure.KeyVault.csproj @@ -3,10 +3,10 @@ Microsoft.Azure.KeyVault Azure Key Vault enables users to store and use cryptographic keys within the Microsoft Azure environment. Azure Key Vault supports multiple key types and algorithms and enables the use of Hardware Security Modules (HSM) for high value customer keys. In addition, Azure Key Vault allows users to securely store secrets in a Key Vault; secrets are limited size octet objects and Azure Key Vault applies no specific semantics to these objects. A Key Vault may contain a mix of keys and secrets at the same time, and access control for the two types of object is independently controlled. Users, subject to appropriate authorization, may: 1) Manage cryptographic keys using Create, Import, Update, Delete and other operations 2) Manage secrets using Get, Set, Delete and other operations 3) Use cryptographic keys with Sign/Verify, WrapKey/UnwrapKey and Encrypt/Decrypt operations. Operations against Key Vaults are authenticated and authorized using Azure Active Directory. Key Vault now supports certificates, a complex type that makes use of existing key and secret infrastructure for certificate operations. KV certificates also support notification and auto-renewal as well as other management features. - Microsoft Azure key vault - 2.3.2 + Microsoft Azure Key Vault + 2.4.0 Microsoft.Azure.KeyVault - Microsoft Azure key vault;Key Vault;REST HTTP client;azureofficial;windowsazureofficial + Microsoft Azure Key Vault;Key Vault;REST HTTP client;azureofficial;windowsazureofficial This is a preview release of the Azure Key Vault .NET SDK, based on version 2016-10-01 of the Azure Key Vault REST API. For migration guide from version 1.0, please visit https://azure.microsoft.com/en-us/documentation/articles/key-vault-dotnet2api-release-notes/. diff --git a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Properties/AssemblyInfo.cs b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Properties/AssemblyInfo.cs index eb61efae39e6..ef3bb2b3cdb6 100644 --- a/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Properties/AssemblyInfo.cs +++ b/src/SDKs/KeyVault/dataPlane/Microsoft.Azure.KeyVault/Properties/AssemblyInfo.cs @@ -6,7 +6,7 @@ using System.Reflection; using System.Resources; -[assembly: AssemblyTitle("Microsoft Azure key vault")] +[assembly: AssemblyTitle("Microsoft Azure Key Vault")] [assembly: AssemblyDescription("Azure Key Vault enables users to store and use cryptographic keys within the Microsoft Azure environment. Azure Key Vault supports multiple key types and algorithms and enables the use of Hardware Security Modules (HSM) for high value customer keys. In addition, Azure Key Vault allows users to securely store secrets in a Key Vault; secrets are limited size octet objects and Azure Key Vault applies no specific semantics to these objects. A Key Vault may contain a mix of keys and secrets at the same time, and access control for the two types of object is independently controlled. Users, subject to appropriate authorization, may: 1) Manage cryptographic keys using Create, Import, Update, Delete and other operations 2) Manage secrets using Get, Set, Delete and other operations 3) Use cryptographic keys with Sign/Verify, WrapKey/UnwrapKey and Encrypt/Decrypt operations. Operations against Key Vaults are authenticated and authorized using Azure Active Directory.")] [assembly: AssemblyVersion("2.0.0.0")]