AWS's S3 SDK for Ruby allows for client-side ('envelope') encryption of the file. It's a combination of AES CBC/ECB encryption for the client-side key where the envelope key and initialization vector are stored in the metadata.
I have a Ruby developer that has encrypted various files in an S3 bucket that I need to retrieve and decrypted with Python. The Python S3 AWS SDK doesn't currently have this client-side feature.
Assuming the file was encrypted using the encryption_key
parameter of the Ruby bucket.write
S3 API:
#!/usr/bin/ruby
# coding: utf-8
require 'aws-sdk'
require 'openssl'
access_key = '<aws_access_key>'
secret_access_key = '<secret_access_key>'
encryption_key = "passwordpassword"
s3 = AWS::S3.new
storage_host = "our_bucket"
storage_path = "prod/master_report/test.txt"
bucket_obj = s3.buckets[storage_host].objects[storage_path]
bucket_obj.write(file: 'test.txt', encryption_key: encryption_key)
Is there a way to decrypt the files with Python instead of using the Ruby SDK?