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