| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | namespace Azure.Security.KeyVault.Keys.Cryptography |
| | 5 | | { |
| | 6 | | internal static class LocalCryptographyProviderFactory |
| | 7 | | { |
| | 8 | | public static ICryptographyProvider Create(KeyVaultKey key) |
| | 9 | | { |
| 204 | 10 | | JsonWebKey keyMaterial = key?.Key; |
| 204 | 11 | | if (keyMaterial != null) |
| | 12 | | { |
| 200 | 13 | | if (keyMaterial.KeyType == KeyType.Rsa || keyMaterial.KeyType == KeyType.RsaHsm) |
| | 14 | | { |
| 96 | 15 | | return new RsaCryptographyProvider(key); |
| | 16 | | } |
| | 17 | |
|
| 104 | 18 | | if (keyMaterial.KeyType == KeyType.Ec || keyMaterial.KeyType == KeyType.EcHsm) |
| | 19 | | { |
| 40 | 20 | | return new EcCryptographyProvider(key); |
| | 21 | | } |
| | 22 | |
|
| 64 | 23 | | if (keyMaterial.KeyType == KeyType.Oct) |
| | 24 | | { |
| 14 | 25 | | return new AesCryptographyProvider(key); |
| | 26 | | } |
| | 27 | | } |
| | 28 | |
|
| 54 | 29 | | return null; |
| | 30 | | } |
| | 31 | | } |
| | 32 | | } |