-
Notifications
You must be signed in to change notification settings - Fork 670
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
Add putObject/getObject() client side encryption examples #948
Conversation
but encryption is still server side here? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggest also having a getobject-client-encryption example. The get-encrypted-object.go shows a server side example.
) | ||
|
||
const ( | ||
// SSE dare package block size. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dare -> DARE
// SSE dare package block size. | ||
sseDAREPackageBlockSize = 64 * 1024 // 64KiB bytes | ||
|
||
// SSE dare package meta padding bytes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dare -> DARE
@deekoder No, the encrypted reader returned from @harshavardhana Should we use a password-based key derivation (maybe easier for users and if the use secret keys it would still be perfectly fine)? |
defd679
to
1f09c5f
Compare
1f09c5f
to
a1bc454
Compare
password := "myfavoritepassword" // Change as per your needs. | ||
salt := path.Join("my-bucketname", "my-objectname") // Change as per your needs. | ||
decrypted, err := sio.DecryptReader(obj, sio.Config{ | ||
Key: argon2.IDKey(password, salt, 1, sseDAREPackageBlockSize, 4, sseDAREPackageMetaSize), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use encrypt.DefaultPBKDF
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in both examples the argon2.IDKey method needs to have password and salt converted to byte array
encrypted, err := sio.EncryptReader(object, sio.Config{
Key: argon2.IDKey([]byte(password), []byte(salt), 1, sseDAREPackageBlockSize, 4, sseDAREPackageMetaSize),
})
decrypted, err := sio.DecryptReader(obj, sio.Config{
Key: argon2.IDKey([]byte(password), []byte(salt), 1, sseDAREPackageBlockSize, 4, sseDAREPackageMetaSize),
})
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use encrypt.DefaultPBKDF here.
I don't want to use code from server-side.go which has special methods attached to it - which will confuse the user @aead - here PBKDF is all about client side and how they can leverage it using argon2.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated @poornas
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@harshavardhana Okay - than one last thing. The parameters for argon2 (sseDAREPackageBlockSize
, sseDAREPackageMetaSize
) look like they are somehow tied to DARE / sio - but they are not. 64 MB is a (recommended) value from the RFC draft and the 32 is the key size. I see you are using constants here instead of literals but IMO the constants give a wrong impression of the meaning of these values. Maybe we can use literals or properly named constants. (I didn't mentioned it before because of PBKDF
suggestion)
a1bc454
to
9b0fea1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
9b0fea1
to
60f63ca
Compare
Fixes #945