Skip to content
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

Merged
merged 1 commit into from
Mar 14, 2018

Conversation

harshavardhana
Copy link
Member

@harshavardhana harshavardhana commented Mar 13, 2018

Fixes #945

@deekoder deekoder requested review from vadmeste, aead and poornas and removed request for vadmeste March 13, 2018 20:13
@deekoder
Copy link
Contributor

but encryption is still server side here?

Copy link
Contributor

@poornas poornas left a 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.
Copy link
Contributor

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dare -> DARE

@aead
Copy link
Member

aead commented Mar 13, 2018

@deekoder No, the encrypted reader returned from sio.Encrypt(....) encrypts everything. So encryption happens on client side.

@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)?

@harshavardhana harshavardhana changed the title Add putObject() client side encryption example Add putObject/getObject() client side encryption examples Mar 13, 2018
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),
Copy link
Member

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.

Copy link
Contributor

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),
	})

Copy link
Member Author

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated @poornas

Copy link
Member

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)

Copy link
Contributor

@poornas poornas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@nitisht nitisht merged commit 6564446 into minio:master Mar 14, 2018
@harshavardhana harshavardhana deleted the fix-client branch March 14, 2018 01:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants