| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using System.Text.Json; |
| | 5 | |
|
| | 6 | | namespace Azure.Security.KeyVault.Keys.Cryptography |
| | 7 | | { |
| | 8 | | /// <summary> |
| | 9 | | /// Represents information about a sign operation. |
| | 10 | | /// </summary> |
| | 11 | | public class SignResult : IJsonDeserializable |
| | 12 | | { |
| | 13 | | private const string KeyIdPropertyName = "kid"; |
| | 14 | | private const string SignaturePropertyName = "value"; |
| | 15 | |
|
| 260 | 16 | | internal SignResult() |
| | 17 | | { |
| 260 | 18 | | } |
| | 19 | |
|
| | 20 | | /// <summary> |
| | 21 | | /// Gets the <see cref="KeyProperties.Id"/> of the <see cref="KeyVaultKey"/> used to sign. This must be stored a |
| | 22 | | /// </summary> |
| 494 | 23 | | public string KeyId { get; internal set; } |
| | 24 | |
|
| | 25 | | /// <summary> |
| | 26 | | /// Gets the signature. |
| | 27 | | /// </summary> |
| 728 | 28 | | public byte[] Signature { get; internal set; } |
| | 29 | |
|
| | 30 | | /// <summary> |
| | 31 | | /// Gets the algorithm used to sign. This must be stored alongside the <see cref="Signature"/> as the same algor |
| | 32 | | /// </summary> |
| 494 | 33 | | public SignatureAlgorithm Algorithm { get; internal set; } |
| | 34 | |
|
| | 35 | | void IJsonDeserializable.ReadProperties(JsonElement json) |
| | 36 | | { |
| 1320 | 37 | | foreach (JsonProperty prop in json.EnumerateObject()) |
| | 38 | | { |
| 440 | 39 | | switch (prop.Name) |
| | 40 | | { |
| | 41 | | case KeyIdPropertyName: |
| 220 | 42 | | KeyId = prop.Value.GetString(); |
| 220 | 43 | | break; |
| | 44 | | case SignaturePropertyName: |
| 220 | 45 | | Signature = Base64Url.Decode(prop.Value.GetString()); |
| | 46 | | break; |
| | 47 | | } |
| | 48 | | } |
| 220 | 49 | | } |
| | 50 | | } |
| | 51 | | } |