-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
service/s3/s3crypto: Add support for client-side S3 encryption using Asymmetric key #1241
Comments
Hello @ByteFlinger, currently only |
Thank you.
So I spent a few hours looking into it and I really would like avoiding
going over to the Java SDK if I can.
I believe I have an idea of what is needed to implement my own wrapper and
it looks simple enough but there are a few things I would like to know
before doing that so I don't implement it differently than what might be
supported later by you guys.
It seems that the KMS solution will do something like this
### Encryption
1. Generate Symmetric AES 256 key and encrypt it with an asymmetric key
(RSA??) hosted inside KMS
2. Use Symmetric key to encrypt data and push encrypted data along with
metadata including the encrypted Symmetric key and a Wrapper ID so the
client can know how to decode it
### Decryption
1. Get S3 object which includes the asymmetric encrypted key and the
wrapper id
2. Send encrypted key to Kms and retrieve decrypted Symmetric key back
3. Decrypt data using Symmetric key
Is this about correct?
So my question is how would the local asymmetric key flow look like when
the lib supports it?
I could implement a simple wrapper that supplies my own custom ID and keeps
the whole Symmetric key part but rather than using Kms, it simply uses a
local private/public key pair to perform the encryption/decryption of the
symetric key. Would that be what you would do or is that flow meant to not
use the hybrid model at all and just encrypt decrypt using the local
private/public key pair? If the latter what do I store in the encryptedkey
part of `CipherData`, ignore it?
…On Tue, 2 May 2017, 22:17 xibz, ***@***.***> wrote:
Hello @ByteFlinger <https://github.com/ByteFlinger>, currently only kms
is supported. We have this in our backlog, but I'll mark this as a feature
request. You can also implement your own key wrap handler, if needed. I
will bring this up in our next planning meeting. Cheers!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1241 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACn1S4DXLuisRgJ242YIGnZ5s-bewceUks5r149hgaJpZM4NOnef>
.
|
@ByteFlinger, yea that is a good high level explanation. The RSA algorithm would be The |
@xibz I have taken a look at the whole thing and am left wondering one thing. Do you guys have any specification on what you usually as the label when calling DecryptOAEP/EncryptOAEP? Also, how does one upload encrypted data using the s3Manager.NewUploaderWithClient? It seems that the Encryption and Decryption client do not embedding of the S3Client therefore they do not qualify as a client for the NewUploaderWithClient function |
@ByteFlinger - The label that is supported for Currently the crypto client does not support being used in |
I was not able to find any label information on the Java SDK so I am uncertain whether this is a Go implementation or the algorithm itself. Can you confirm that when you mention I have had some success implementing the whole thing and will be verifying it against the Java SDK. One thing which I am uncertain of if the MGF1 padding. While Go has sha256 which can be used with OAEP, I am not sure where MGF1 fits in the whole picture. I should add that while familiar with PKI I am by no means a crypto expert. I believe that MGF1 padding is already used by Go when using OAEP but uncertain so any guidelines on the matter are welcome (and I suppose any issues will arise when testing against the Java SDK). Regarding the s3manager support, I was able to basically wrap the Encryption and Decryption clients in a standard s3.S3 client (since they implement some of the APIs of the s3.S3API) and use that with the s3manager upload and download and it seemed to work although I have not performed any extensive verification. Should I refrain from doing that? Do you think it might be an issue? |
For paragraph 1, yes, that is the label that is used for decryption. Here is the Java SDK label. Paragraph 2: Yes, Golang's Paragraph 3: Yea, I don't see any issues with using the crypto client with |
Hi I spend some time going through everything and digging into the JDK SDK. The example I linked in the original post ends up encrypting using Setting encryption mode in the Java SDK to Authenticated solves the issue and it uses Having done all that I cannot seem to verify encryption/decrpytion using the JDK SDK. I get the following error when trying to decrypt a go encrypted value in Java
And doing the reverse (decrypting Java encrypted value in Go)
The key handler implementation Go code is rather simple so I don't quite see where I could be maknig a mistake. Here are some snippets
I also tried setting the label to The java error seems to tell me that there might be some issue witht the Padding which I also noticed that it is not actually PKCS5Padding as per comments in the code. Before I give this up, would there be any chance you can take a quick look at the above and see if you can spot any issue? |
@ByteFlinger - With encryption and decryption it is going to be pretty difficult to see whether or not this is encrypting/decrypting properly. Do you have some tests in place to see if it is encrypting and decrypting properly? I would also run those test vectors in Java to ensure you are getting the appropriate values as expected. Have you pushed this code up? I want to take a look at the overall implementation to see if I can see anything. |
I have tested that go can encrypt and decrypt back and forth to/from S3 and I have also tested to
make sure it is actually encrypting by looking at the actual data in the S3
bucket and making sure it is not in clear text in there.
I do not have this code pushed anywhere and sadly it is not something I can
do at the moment but I think the code snippets I posted above covers pretty
much the jist of it. Everything else is boiler plate such as implementing
the KeyHandler to fulfill the KeyGenerator interface in pretty much the
same way the KMS KeyHandler does but using local keys.
I guess I'll spend some time writing some unit tests to make sure
everything is working as intended. Discounting ant potential issues with boiler plate code (like a pointer being used instead of value or something of the sort) do you see any issue with the flow above and the methods being used?
…On Wed, 17 May 2017, 23:06 xibz, ***@***.***> wrote:
@ByteFlinger <https://github.com/byteflinger> - With encryption and
decryption it is going to be pretty difficult to see whether or not this is
encrypting/decrypting properly. Do you have some tests in place to see if
it is encrypting and decrypting properly? I would also run those test
vectors in Java to ensure you are getting the appropriate values as
expected. Have you pushed this code up? I want to take a look at the
overall implementation to see if I can see anything.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1241 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACn1S5AFjhWpKhuw38l00P86hH8ofq_Qks5r62FCgaJpZM4NOnef>
.
|
@ByteFlinger In my project, I experienced the exact same problem as yours. Thanks to your code skeleton, I was able to encrypt/decrypt files in S3 with RSA key pairs. But my Java program gave the exact same error. Did you figure out the reason? |
Unfortunately not. I did not have the time to spend on this a lot more and layed the issue aside for the moment. |
Any updates here? Is java the only official |
@rogaha - Currently there is a limitation in Go's RSA crypto library which doesn't allow specification of the MGF1 hash separate from the cipher hash. See here. The cleanest solution would be to wait until Go's standard library has support for the distinction of which hashes to use for the padding and cipher. @ByteFlinger @tfeng - This is the reason to why you guys were receiving that Java error. Java uses |
@xibz An update on the matter is much appreciated and explains the issue. Here's hoping it does not take another year for this feature to be added in Go |
And another year has gone by... |
We have noticed this issue has not received attention in 1 year. We will close this issue for now. If you think this is in error, please feel free to comment and reopen the issue. |
Please fill out the sections below to help us address your issue.
Version of AWS SDK for Go?
master 984e0dc
Version of Go (
go version
)?1.8
What issue did you see?
Attempting to perform client side s3 encryption as explained here
http://docs.aws.amazon.com/AmazonS3/latest/dev/encrypt-client-side-asymmetric-master-key.html
However it seems the library only supports kms keys and not any client side keys. Is this just not implemented yet or am I missing something?
Steps to reproduce
Looked at s3crypto.NewEncryptionClient API and it seems to only support kms keys.
The text was updated successfully, but these errors were encountered: