Пример #1
0
 private static void ReadPropertyValue(EncryptionAgent agent, JsonProperty property)
 {
     if (property.NameEquals(nameof(agent.EncryptionAlgorithm)))
     {
         agent.EncryptionAlgorithm = new ClientSideEncryptionAlgorithm(property.Value.GetString());
     }
     else if (property.NameEquals(EncryptionAgent_EncryptionVersionName))
     {
         agent.EncryptionVersion = property.Value.GetString().ToClientSideEncryptionVersion();
     }
 }
Пример #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 WriteEncryptionAgent(Utf8JsonWriter json, EncryptionAgent encryptionAgent)
 {
     json.WriteString(EncryptionAgent_EncryptionVersionName, encryptionAgent.EncryptionVersion.Serialize());
     json.WriteString(nameof(encryptionAgent.EncryptionAlgorithm), encryptionAgent.EncryptionAlgorithm.ToString());
 }