コード例 #1
0
 private static void ReadPropertyValue(EncryptedRegionInfo info, JsonProperty property)
 {
     if (property.NameEquals(nameof(info.NonceLength)))
     {
         info.NonceLength = property.Value.GetInt32();
     }
     else if (property.NameEquals(nameof(info.DataLength)))
     {
         info.DataLength = property.Value.GetInt32();
     }
 }
コード例 #2
0
 private static void ReadPropertyValue(EncryptionData data, JsonProperty property)
 {
     if (property.NameEquals(nameof(data.EncryptionMode)))
     {
         data.EncryptionMode = property.Value.GetString();
     }
     else if (property.NameEquals(nameof(data.WrappedContentKey)))
     {
         var key = new KeyEnvelope();
         foreach (var subProperty in property.Value.EnumerateObject())
         {
             ReadPropertyValue(key, subProperty);
         }
         data.WrappedContentKey = key;
     }
     else if (property.NameEquals(nameof(data.EncryptionAgent)))
     {
         var agent = new EncryptionAgent();
         foreach (var subProperty in property.Value.EnumerateObject())
         {
             ReadPropertyValue(agent, subProperty);
         }
         data.EncryptionAgent = agent;
     }
     else if (property.NameEquals(nameof(data.ContentEncryptionIV)))
     {
         data.ContentEncryptionIV = Convert.FromBase64String(property.Value.GetString());
     }
     else if (property.NameEquals(nameof(data.KeyWrappingMetadata)))
     {
         var metadata = new Dictionary <string, string>();
         foreach (var entry in property.Value.EnumerateObject())
         {
             metadata.Add(entry.Name, entry.Value.GetString());
         }
         data.KeyWrappingMetadata = metadata;
     }
     else if (property.NameEquals(nameof(data.EncryptedRegionInfo)))
     {
         var info = new EncryptedRegionInfo();
         foreach (var subProperty in property.Value.EnumerateObject())
         {
             ReadPropertyValue(info, subProperty);
         }
         data.EncryptedRegionInfo = info;
     }
 }
コード例 #3
0
 private static void WriteEncryptedRegionInfo(Utf8JsonWriter json, EncryptedRegionInfo encryptedRegionInfo)
 {
     json.WriteNumber(nameof(encryptedRegionInfo.DataLength), encryptedRegionInfo.DataLength);
     json.WriteNumber(nameof(encryptedRegionInfo.NonceLength), encryptedRegionInfo.NonceLength);
 }