-
Notifications
You must be signed in to change notification settings - Fork 4.6k
/
WrapResult.cs
52 lines (45 loc) · 1.75 KB
/
WrapResult.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 wrap operation.
/// </summary>
public class WrapResult : IJsonDeserializable
{
private const string KeyIdPropertyName = "kid";
private const string EncryptedKeyPropertyName = "value";
internal WrapResult()
{
}
/// <summary>
/// Gets the key identifier of the <see cref="KeyVaultKey"/> used to wrap the <see cref="EncryptedKey"/>. This must be stored alongside the <see cref="EncryptedKey"/> as the same key must be used to unwrap it.
/// </summary>
public string KeyId { get; internal set; }
/// <summary>
/// Gets the wrapped key.
/// </summary>
public byte[] EncryptedKey { get; internal set; }
/// <summary>
/// Gets the <see cref="KeyWrapAlgorithm"/> used. This must be stored alongside the <see cref="EncryptedKey"/> as the same key must be used to unwrap it.
/// </summary>
public KeyWrapAlgorithm 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 EncryptedKeyPropertyName:
EncryptedKey = Base64Url.Decode(prop.Value.GetString());
break;
}
}
}
}
}