static private BuildInstructionsFromObjectMetadata ( |
||
response | /// A non-null object response that contains encryption information in its metadata. /// | |
materials | /// The non-null encryption materials to be used to encrypt and decrypt Envelope key. /// | |
Résultat |
internal static EncryptionInstructions BuildInstructionsFromObjectMetadata(GetObjectResponse response, EncryptionMaterials materials)
{
MetadataCollection metadata = response.Metadata;
string base64EncodedEncryptedEnvelopeKey = metadata[keyInMetadata];
byte[] encryptedEvelopeKey = Convert.FromBase64String(base64EncodedEncryptedEnvelopeKey);
byte[] decryptedEnvelopeKey = DecryptEnvelopeKey(encryptedEvelopeKey, materials);
string base64EncodedIV = metadata[initVectorInMetadata];
byte[] IV = Convert.FromBase64String(base64EncodedIV);
return new EncryptionInstructions(EncryptionMaterials.EmptyMaterialsDescription, decryptedEnvelopeKey, encryptedEvelopeKey, IV);
}
/// <summary> /// Updates object where the object input stream contains the decrypted contents. /// </summary> /// <param name="objectResponse"> /// The getObject response whose contents are to be decrypted. /// </param> private void DecryptObjectUsingMetadata(GetObjectResponse objectResponse) { // Create an instruction object from the object metadata EncryptionInstructions instructions = EncryptionUtils.BuildInstructionsFromObjectMetadata(objectResponse, this.encryptionMaterials); // Decrypt the object with the instruction EncryptionUtils.DecryptObjectUsingInstructions(objectResponse, instructions); }