-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Microsoft Azure Key Vault Extensions
- Loading branch information
1 parent
d7d5c57
commit d85c6b1
Showing
43 changed files
with
4,118 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
// | ||
// Copyright © Microsoft Corporation, All Rights Reserved | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS | ||
// OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION | ||
// ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A | ||
// PARTICULAR PURPOSE, MERCHANTABILITY OR NON-INFRINGEMENT. | ||
// | ||
// See the Apache License, Version 2.0 for the specific language | ||
// governing permissions and limitations under the License. | ||
|
||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace Microsoft.Azure.KeyVault.Core | ||
{ | ||
/// <summary> | ||
/// Interface for Keys | ||
/// </summary> | ||
public interface IKey : IDisposable | ||
{ | ||
/// <summary> | ||
/// The default encryption algorithm for this key | ||
/// </summary> | ||
string DefaultEncryptionAlgorithm { get; } | ||
|
||
/// <summary> | ||
/// The default key wrap algorithm for this key | ||
/// </summary> | ||
string DefaultKeyWrapAlgorithm { get; } | ||
|
||
/// <summary> | ||
/// The default signature algorithm for this key | ||
/// </summary> | ||
string DefaultSignatureAlgorithm { get; } | ||
|
||
/// <summary> | ||
/// The key identifier | ||
/// </summary> | ||
string Kid { get; } | ||
|
||
/// <summary> | ||
/// Decrypts the specified cipher text. | ||
/// </summary> | ||
/// <param name="ciphertext">The cipher text to decrypt</param> | ||
/// <param name="iv">The initialization vector</param> | ||
/// <param name="authenticationData">The authentication data</param> | ||
/// <param name="algorithm">The algorithm to use</param> | ||
/// <param name="token">Cancellation token</param> | ||
/// <returns>The plain text</returns> | ||
/// <remarks>If algorithm is not specified, an implementation should use its default algorithm. | ||
/// Not all algorithms require, or support, all parameters.</remarks> | ||
Task<byte[]> DecryptAsync( byte[] ciphertext, byte[] iv, byte[] authenticationData, byte[] authenticationTag, string algorithm, CancellationToken token ); | ||
|
||
/// <summary> | ||
/// Encrypts the specified plain text. | ||
/// </summary> | ||
/// <param name="plaintext">The plain text to encrypt</param> | ||
/// <param name="iv">The initialization vector</param> | ||
/// <param name="authenticationData">The authentication data</param> | ||
/// <param name="algorithm">The algorithm to use</param> | ||
/// <param name="token">Cancellation token</param> | ||
/// <returns>A Tuple consisting of the cipher text, the authentication tag (if applicable), the algorithm used</returns> | ||
/// <remarks>If the algorithm is not specified, an implementation should use its default algorithm. | ||
/// Not all algorithyms require, or support, all parameters.</remarks> | ||
Task<Tuple<byte[], byte[], string>> EncryptAsync( byte[] plaintext, byte[] iv, byte[] authenticationData, string algorithm, CancellationToken token ); | ||
|
||
/// <summary> | ||
/// Encrypts the specified key material. | ||
/// </summary> | ||
/// <param name="key">The key material to encrypt</param> | ||
/// <param name="algorithm">The algorithm to use</param> | ||
/// <param name="token">Cancellation token</param> | ||
/// <returns>A Tuple consisting of the encrypted key and the algorithm used</returns> | ||
/// <remarks>If the algorithm is not specified, an implementation should use its default algorithm</remarks> | ||
Task<Tuple<byte[], string>> WrapKeyAsync( byte[] key, string algorithm, CancellationToken token ); | ||
|
||
/// <summary> | ||
/// Decrypts the specified key material. | ||
/// </summary> | ||
/// <param name="encryptedKey">The encrypted key material</param> | ||
/// <param name="algorithm">The algorithm to use</param> | ||
/// <param name="token">Cancellation token</param> | ||
/// <returns>The decrypted key material</returns> | ||
/// <remarks>If the algorithm is not specified, an implementation should use its default algorithm</remarks> | ||
Task<byte[]> UnwrapKeyAsync( byte[] encryptedKey, string algorithm, CancellationToken token ); | ||
|
||
/// <summary> | ||
/// Signs the specified digest. | ||
/// </summary> | ||
/// <param name="digest">The digest to sign</param> | ||
/// <param name="algorithm">The algorithm to use</param> | ||
/// <param name="token">Cancellation token</param> | ||
/// <returns>A Tuple consisting of the signature and the algorithm used</returns> | ||
/// <remarks>If the algorithm is not specified, an implementation should use its default algorithm</remarks> | ||
Task<Tuple<byte[], string>> SignAsync( byte[] digest, string algorithm, CancellationToken token ); | ||
|
||
/// <summary> | ||
/// Verifies the specified signature value | ||
/// </summary> | ||
/// <param name="digest">The digest</param> | ||
/// <param name="signature">The signature value</param> | ||
/// <param name="algorithm">The algorithm to use</param> | ||
/// <param name="token">Cancellation token</param> | ||
/// <returns>A bool indicating whether the signature was successfully verified</returns> | ||
Task<bool> VerifyAsync( byte[] digest, byte[] signature, string algorithm, CancellationToken token ); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
src/KeyVault/Microsoft.Azure.KeyVault.Core/IKeyResolver.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// | ||
// Copyright © Microsoft Corporation, All Rights Reserved | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS | ||
// OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION | ||
// ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A | ||
// PARTICULAR PURPOSE, MERCHANTABILITY OR NON-INFRINGEMENT. | ||
// | ||
// See the Apache License, Version 2.0 for the specific language | ||
// governing permissions and limitations under the License. | ||
|
||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace Microsoft.Azure.KeyVault.Core | ||
{ | ||
/// <summary> | ||
/// Interface for key resolvers. | ||
/// </summary> | ||
public interface IKeyResolver | ||
{ | ||
/// <summary> | ||
/// Provides an IKey implementation for the specified key identifier. | ||
/// </summary> | ||
/// <param name="kid">The key identifier to resolve</param> | ||
/// <param name="token">Cancellation token</param> | ||
/// <returns>The resolved IKey implementation or null</returns> | ||
/// <remarks>Implementations should check the format of the kid to ensure that it is recognized. Null, rather than | ||
/// an exception, should be returned for unrecognized key identifiers to enable chaining of key resolvers.</remarks> | ||
Task<IKey> ResolveKeyAsync( string kid, CancellationToken token ); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
src/KeyVault/Microsoft.Azure.KeyVault.Core/KeyVault.Core.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\..\</SolutionDir> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{B419782D-CA57-40F9-9322-340A4E852E82}</ProjectGuid> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>Microsoft.Azure.KeyVault.Core</RootNamespace> | ||
<AssemblyName>Microsoft.Azure.KeyVault.Core</AssemblyName> | ||
<OutputType>Library</OutputType> | ||
<RestorePackages>true</RestorePackages> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
</PropertyGroup> | ||
<Import Project="$(SolutionDir)\tools\Library.Settings.targets" /> | ||
<ItemGroup> | ||
<Compile Include="Generated\**\*.cs" /> | ||
<Compile Include="IKey.cs" /> | ||
<Compile Include="IKeyResolver.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="Microsoft.Azure.KeyVault.Core.nuspec" /> | ||
<None Include="Microsoft.Azure.KeyVault.Core.nuget.proj"> | ||
<SubType>Designer</SubType> | ||
</None> | ||
<None Include="packages.config" /> | ||
</ItemGroup> | ||
<ItemGroup Condition="'$(LibraryFxTarget)' == 'net40'"> | ||
<Reference Include="Microsoft.Threading.Tasks, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> | ||
<SpecificVersion>False</SpecificVersion> | ||
<HintPath>..\..\..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Microsoft.Threading.Tasks.Extensions, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> | ||
<SpecificVersion>False</SpecificVersion> | ||
<HintPath>..\..\..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.dll</HintPath> | ||
</Reference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Reference Include="System.Net" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" Condition=" '$(LibraryFxTarget)' == 'portable' " /> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" Condition=" '$(LibraryFxTarget)' != 'portable' " /> | ||
<Import Project="..\..\..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets" Condition="Exists('..\..\..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" /> | ||
<Target Name="EnsureBclBuildImported" BeforeTargets="BeforeBuild" Condition="'$(BclBuildImported)' == ''"> | ||
<Error Condition="!Exists('..\..\..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=317567." HelpKeyword="BCLBUILD2001" /> | ||
<Error Condition="Exists('..\..\..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="The build restored NuGet packages. Build the project again to include these packages in the build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317568." HelpKeyword="BCLBUILD2002" /> | ||
</Target> | ||
</Project> |
12 changes: 12 additions & 0 deletions
12
src/KeyVault/Microsoft.Azure.KeyVault.Core/Microsoft.Azure.KeyVault.Core.nuget.proj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<ItemGroup> | ||
<!-- | ||
Microsoft.Azure.KeyVault.Core | ||
--> | ||
<SdkNuGetPackage Include="Microsoft.Azure.KeyVault.Core"> | ||
<PackageVersion>0.9.0-preview</PackageVersion> | ||
<Folder>$(MSBuildThisFileDirectory)</Folder> | ||
</SdkNuGetPackage> | ||
</ItemGroup> | ||
</Project> |
43 changes: 43 additions & 0 deletions
43
src/KeyVault/Microsoft.Azure.KeyVault.Core/Microsoft.Azure.KeyVault.Core.nuspec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?xml version="1.0"?> | ||
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd"> | ||
<metadata minClientVersion="2.5"> | ||
<id>Microsoft.Azure.KeyVault.Core</id> | ||
<title>Microsoft Azure Key Vault Core Library</title> | ||
<releaseNotes>Initial release</releaseNotes> | ||
<version>$version$</version> | ||
<authors>Microsoft</authors> | ||
<owners>azure-sdk, Microsoft</owners> | ||
<licenseUrl>http://aka.ms/windowsazureapache2</licenseUrl> | ||
<projectUrl>https://github.com/Azure/azure-sdk-for-net</projectUrl> | ||
<iconUrl>http://go.microsoft.com/fwlink/?LinkID=288890</iconUrl> | ||
<requireLicenseAcceptance>false</requireLicenseAcceptance> | ||
<summary>IKey and IKeyResolver interfaces.</summary> | ||
<description>Provides IKey and IKeyResolver interfaces for locating keys from identifiers | ||
and performing operations with keys.</description> | ||
<copyright>Copyright © Microsoft Corporation</copyright> | ||
<tags>Microsoft Azure key vault "key vault" azureofficial windowsazureofficial</tags> | ||
<references> | ||
<group targetFramework="net45"> | ||
<reference file="Microsoft.Azure.KeyVault.Core.dll" /> | ||
</group> | ||
<group targetFramework="net40"> | ||
<reference file="Microsoft.Azure.KeyVault.Core.dll" /> | ||
</group> | ||
<group targetFramework="portable-net45+wp8+wpa81+win"> | ||
<reference file="Microsoft.Azure.KeyVault.Core.dll" /> | ||
</group> | ||
</references> | ||
</metadata> | ||
<files> | ||
<file src="KeyVault\Microsoft.Azure.KeyVault.Core\**\*.cs" target="src" /> | ||
<file src="..\binaries\net45\Microsoft.Azure.KeyVault.Core.dll" target="lib\portable-net45+wp8+wpa81+win" /> | ||
<file src="..\binaries\net45\Microsoft.Azure.KeyVault.Core.pdb" target="lib\portable-net45+wp8+wpa81+win" /> | ||
<file src="..\binaries\net45\Microsoft.Azure.KeyVault.Core.xml" target="lib\portable-net45+wp8+wpa81+win" /> | ||
<file src="..\binaries\net40\Microsoft.Azure.KeyVault.Core.dll" target="lib\net40" /> | ||
<file src="..\binaries\net40\Microsoft.Azure.KeyVault.Core.pdb" target="lib\net40" /> | ||
<file src="..\binaries\net40\Microsoft.Azure.KeyVault.Core.xml" target="lib\net40" /> | ||
<file src="..\binaries\net45\Microsoft.Azure.KeyVault.Core.dll" target="lib\net45" /> | ||
<file src="..\binaries\net45\Microsoft.Azure.KeyVault.Core.pdb" target="lib\net45" /> | ||
<file src="..\binaries\net45\Microsoft.Azure.KeyVault.Core.xml" target="lib\net45" /> | ||
</files> | ||
</package> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="Microsoft.Bcl" version="1.1.8" targetFramework="net45" /> | ||
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net45" /> | ||
<package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net45" /> | ||
</packages> |
Oops, something went wrong.