| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | | using System.Text.Json; |
| | 4 | |
|
| | 5 | | namespace Azure.Security.KeyVault.Keys.Cryptography |
| | 6 | | { |
| | 7 | | internal struct KeyEncryptParameters : IJsonSerializable |
| | 8 | | { |
| 2 | 9 | | private static readonly JsonEncodedText s_algorithmPropertyNameBytes = JsonEncodedText.Encode("alg"); |
| 2 | 10 | | private static readonly JsonEncodedText s_valuePropertyNameBytes = JsonEncodedText.Encode("value"); |
| 2 | 11 | | private static readonly JsonEncodedText s_ivPropertyNameBytes = JsonEncodedText.Encode("iv"); |
| 2 | 12 | | private static readonly JsonEncodedText s_authenticationDataPropertyNameBytes = JsonEncodedText.Encode("aad"); |
| 2 | 13 | | private static readonly JsonEncodedText s_authenticationTagPropertyNameBytes = JsonEncodedText.Encode("tag"); |
| | 14 | |
|
| 156 | 15 | | public string Algorithm { get; set; } |
| | 16 | |
|
| 156 | 17 | | public byte[] Value { get; set; } |
| | 18 | |
|
| 0 | 19 | | public byte[] Iv { get; set; } |
| | 20 | |
|
| 0 | 21 | | public byte[] AuthenticationData { get; set; } |
| | 22 | |
|
| 0 | 23 | | public byte[] AuthenticationTag { get; set; } |
| | 24 | |
|
| | 25 | | void IJsonSerializable.WriteProperties(Utf8JsonWriter json) |
| | 26 | | { |
| 52 | 27 | | if (Algorithm != null) |
| | 28 | | { |
| 52 | 29 | | json.WriteString(s_algorithmPropertyNameBytes, Algorithm); |
| | 30 | | } |
| 52 | 31 | | if (Value != null) |
| | 32 | | { |
| 52 | 33 | | json.WriteString(s_valuePropertyNameBytes, Base64Url.Encode(Value)); |
| | 34 | | } |
| 52 | 35 | | if (Iv != null) |
| | 36 | | { |
| 0 | 37 | | json.WriteString(s_ivPropertyNameBytes, Base64Url.Encode(Iv)); |
| | 38 | | } |
| 52 | 39 | | if (AuthenticationData != null) |
| | 40 | | { |
| 0 | 41 | | json.WriteString(s_authenticationDataPropertyNameBytes, Base64Url.Encode(AuthenticationData)); |
| | 42 | | } |
| 52 | 43 | | if (AuthenticationTag != null) |
| | 44 | | { |
| 0 | 45 | | json.WriteString(s_authenticationTagPropertyNameBytes, Base64Url.Encode(AuthenticationTag)); |
| | 46 | | } |
| 52 | 47 | | } |
| | 48 | | } |
| | 49 | | } |