FAQ
PTAL


https://codereview.appspot.com/6555052/diff/11001/src/pkg/crypto/x509/pem_decrypt.go
File src/pkg/crypto/x509/pem_decrypt.go (right):

https://codereview.appspot.com/6555052/diff/11001/src/pkg/crypto/x509/pem_decrypt.go#newcode57
src/pkg/crypto/x509/pem_decrypt.go:57:
On 2012/09/24 22:08:11, agl1 wrote:
Do we need an IsEncryptedPEMBlock(b *pem.Block) bool function so that users of
x509 know whether to prompt for a password?
I figured most clients would attempt to load the file and if there was
an error just assume it was password protected. The helper would
probably just check the existence of the DEK-Info header which I'm not
sure is worth the wait of the extra API. It's your call though.

https://codereview.appspot.com/6555052/diff/11001/src/pkg/crypto/x509/pem_decrypt.go#newcode62
src/pkg/crypto/x509/pem_decrypt.go:62: func DecryptPEMBlock(b
*pem.Block, pass []byte) ([]byte, error) {
On 2012/09/24 22:08:11, agl1 wrote:
Should it return an error if the PEM block is unencrypted, or should it simply
return b.Bytes? I'm leaning towards the latter, although I'm not sure.
At first I had it return the bytes but then depending on if the block
was encrypted you would either get a copy of the bytes or a slice
referencing the blocks data. It felt ugly to have it return a copy for
essentially no work done, so I left it as an error.

https://codereview.appspot.com/6555052/diff/11001/src/pkg/crypto/x509/pem_decrypt.go#newcode106
src/pkg/crypto/x509/pem_decrypt.go:106: return nil, errors.New("x509:
invalid padding")
On 2012/09/24 22:08:11, agl1 wrote:
If the password is incorrect then the padding will be invalid with
probability
~= 1/256. I think that's probably accurate enough that we could do:
var IncorrectPasswordError = errors.New("x509: decryption password
incorrect")
and return that rather than an "invalid padding" error.
Done. I left the first one as in invalid padding because having zero
bytes would imply no padding which is invalid, not an incorrect
password.

https://codereview.appspot.com/6555052/

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-dev @
categoriesgo
postedSep 25, '12 at 1:48a
activeSep 27, '12 at 1:44p
posts3
users2
websitegolang.org

2 users in discussion

Jeff: 2 posts Adam Langley: 1 post

People

Translate

site design / logo © 2022 Grokbase