| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using System; |
| | 5 | | using Azure.Core; |
| | 6 | |
|
| | 7 | | namespace Azure.Security.KeyVault.Keys |
| | 8 | | { |
| | 9 | | /// <summary> |
| | 10 | | /// The properties needed to create an Elliptic Curve key using the <see cref="KeyClient"/>. |
| | 11 | | /// </summary> |
| | 12 | | public class CreateEcKeyOptions : CreateKeyOptions |
| | 13 | | { |
| | 14 | | /// <summary> |
| | 15 | | /// Gets the name of the key to create. |
| | 16 | | /// </summary> |
| 340 | 17 | | public string Name { get; } |
| | 18 | |
|
| | 19 | | /// <summary> |
| | 20 | | /// Gets the key type of the <see cref="JsonWebKey"/> to create, including <see cref="KeyType.Ec"/> and <see cre |
| | 21 | | /// </summary> |
| 108 | 22 | | public KeyType KeyType { get; } |
| | 23 | |
|
| | 24 | | /// <summary> |
| | 25 | | /// Gets or sets the elliptic curve name. See <see cref="KeyCurveName"/> for possible values. If null, the servi |
| | 26 | | /// </summary> |
| 228 | 27 | | public KeyCurveName? CurveName { get; set; } |
| | 28 | |
|
| | 29 | | /// <summary> |
| | 30 | | /// Gets a value indicating whether to create a hardware-protected key in a hardware security module (HSM). |
| | 31 | | /// </summary> |
| | 32 | | /// <value><c>true</c> to create a hardware-protected key; otherwise, <c>false</c> to create a software key.</va |
| 0 | 33 | | public bool HardwareProtected { get; } |
| | 34 | |
|
| | 35 | | /// <summary> |
| | 36 | | /// Initializes a new instance of the <see cref="CreateEcKeyOptions"/> class. |
| | 37 | | /// </summary> |
| | 38 | | /// <param name="name">The name of the key to create.</param> |
| | 39 | | /// <param name="hardwareProtected">True to create a hardware-protected key in a hardware security module (HSM). |
| | 40 | | /// <exception cref="ArgumentException"><paramref name="name"/> is empty.</exception> |
| | 41 | | /// <exception cref="ArgumentNullException"><paramref name="name"/> is null.</exception> |
| 108 | 42 | | public CreateEcKeyOptions(string name, bool hardwareProtected = false) |
| | 43 | | { |
| 108 | 44 | | Argument.AssertNotNullOrEmpty(name, nameof(name)); |
| | 45 | |
|
| 108 | 46 | | Name = name; |
| 108 | 47 | | HardwareProtected = hardwareProtected; |
| 108 | 48 | | if (hardwareProtected) |
| | 49 | | { |
| 36 | 50 | | KeyType = KeyType.EcHsm; |
| | 51 | | } |
| | 52 | | else |
| | 53 | | { |
| 72 | 54 | | KeyType = KeyType.Ec; |
| | 55 | | } |
| 72 | 56 | | } |
| | 57 | | } |
| | 58 | | } |