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

change encryption key parsing to allow spaces in sse-c key #2408

Merged
merged 1 commit into from Mar 14, 2018

Conversation

poornas
Copy link
Contributor

@poornas poornas commented Mar 8, 2018

The base64 encryption key passed in command line could have spaces. Earlier implementation was splitting on spaces, which could lead to erroneous parsing.

cmd/cat-main.go Outdated
@@ -243,7 +243,7 @@ func mainCat(ctx *cli.Context) error {
}

encKeyDB, err := parseEncryptionKeys(sseKeys)
fatalIf(err, "Unable to parse encryption keys")
fatalIf(err, "Unable to parse encryption keys:")
Copy link
Member

Choose a reason for hiding this comment

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

You don't need to add ":" we do not follow that syntax. any particular reason for this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

looked more readable. can revert

Copy link
Member

@krisis krisis left a comment

Choose a reason for hiding this comment

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

Could you add unit tests for parseEncryptionKeys?

cmd/utils.go Outdated
vs := 0 // start index of sse-c key
sseKeyLen := 32
delim := 1
l := len(sseKeys)
Copy link
Member

Choose a reason for hiding this comment

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

suggestion: can we use a different single letter variable? l can be easily mistaken for 1.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

cmd/utils.go Outdated
encMap[alias] = append(encMap[alias], ps)
// advance index 33 bytes for the next key start
Copy link
Member

Choose a reason for hiding this comment

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

the comment should be,
// advance index by (sseKeyLen + delim) bytes for the next key start index

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@krisis
Copy link
Member

krisis commented Mar 12, 2018

We can use https://golang.org/pkg/encoding/csv/ which supports comma-separated values with spaces in them. This will simplify our encryption keys parsing code.

@poornas
Copy link
Contributor Author

poornas commented Mar 13, 2018

@krisis, the encryption key can come in with "," as part of the values - which is why the current implementation has been used to reliably take the first 32 bytes from encountering the first '=' sign as the encryption key.

@codecov-io
Copy link

codecov-io commented Mar 13, 2018

Codecov Report

Merging #2408 into master will increase coverage by 0.42%.
The diff coverage is 46.77%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2408      +/-   ##
==========================================
+ Coverage    10.2%   10.63%   +0.42%     
==========================================
  Files         107      107              
  Lines        8347     8362      +15     
==========================================
+ Hits          852      889      +37     
+ Misses       7351     7325      -26     
- Partials      144      148       +4
Impacted Files Coverage Δ
cmd/stat-main.go 0% <0%> (ø) ⬆️
cmd/mirror-main.go 0% <0%> (ø) ⬆️
cmd/pipe-main.go 0% <0%> (ø) ⬆️
cmd/rm-main.go 0% <0%> (ø) ⬆️
cmd/cp-main.go 0% <0%> (ø) ⬆️
cmd/cat-main.go 17.77% <0%> (ø) ⬆️
cmd/client-s3.go 14.37% <50%> (+0.22%) ⬆️
cmd/utils.go 34.92% <52.94%> (+21.03%) ⬆️
cmd/client-url.go 64.54% <0%> (+5.45%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0ede95b...b4d470f. Read the comment docs.

@poornas
Copy link
Contributor Author

poornas commented Mar 13, 2018

@krisis, added unit tests - PTAL.

cmd/client-s3.go Outdated
for k, v := range key.GetSSEHeaders() {
opts.Set(k, v)
}
key := encrypt.DefaultPBKDF([]byte(sseKey), []byte(bucket+object))
Copy link
Member

Choose a reason for hiding this comment

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

this is not correct @poornas DefaultPBKDF means we are taking password not sseKey as input. This would mean that 32byte long string is no longer a requirement. So you can simplify the code even further if you wish to use password-based style. If not you should use encrypt.NewSSEC for now and we need to think about the UI again to support both key and password styles with @abperiasamy

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed. will discuss password-based style with @abperiasamy

appveyor.yml Outdated
@@ -17,6 +17,7 @@ install:
- go version
- go env
- python --version
- go get -u golang.org/x/crypto/argon2
Copy link
Member

Choose a reason for hiding this comment

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

this is not needed if you have vendorized it already what is the error that you see? @poornas

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed this.

@poornas poornas force-pushed the encrypt branch 2 times, most recently from 088f080 to 02bf49c Compare March 13, 2018 17:20
Copy link
Member

@harshavardhana harshavardhana left a comment

Choose a reason for hiding this comment

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

LGTM

@harshavardhana harshavardhana merged commit fe82b03 into minio:master Mar 14, 2018
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.

None yet

4 participants