|
Jsing |
at Oct 25, 2012 at 3:21 pm
|
⇧ |
| |
https://codereview.appspot.com/6767045/diff/8001/src/pkg/crypto/x509/sec1.goFile src/pkg/crypto/x509/sec1.go (right):
https://codereview.appspot.com/6767045/diff/8001/src/pkg/crypto/x509/sec1.go#newcode32src/pkg/crypto/x509/sec1.go:32: func ParseSEC1PrivateKey(der []byte)
(key *ecdsa.PrivateKey, err error) {
On 2012/10/25 14:19:03, agl1 wrote:
Where is this format from? It's odd to have two ASN.1 values
concatenated,
rather than in a SEQUENCE and SEC1 C.2 doesn't seem to specify this
format.
Agreed. It appears that 'openssl ecparam' writes out an
ECDomainParameters immediately followed by the ECPrivateKey structure.
This is similar to what it does in the PEM case, where there are two PEM
blocks in the same file (the first an 'EC PARAMS' block, the second an
'EC PRIVATE KEY' block). In the case of a named curve, the ASN.1 can
simply be an OID. I'm not entirely sure how we should handle this...
https://codereview.appspot.com/6767045/diff/8001/src/pkg/crypto/x509/sec1.go#newcode52src/pkg/crypto/x509/sec1.go:52: return nil, fmt.Errorf("crypto/x509:
failed to parse EC private key: %v", err)
On 2012/10/25 14:19:03, agl1 wrote:
errors.New("crypto/x509: failed to parse EC private key: " +
err.Error())
Done.
https://codereview.appspot.com/6767045/diff/8001/src/pkg/crypto/x509/sec1.go#newcode52src/pkg/crypto/x509/sec1.go:52: return nil, fmt.Errorf("crypto/x509:
failed to parse EC private key: %v", err)
On 2012/10/25 14:19:03, agl1 wrote:
errors.New("crypto/x509: failed to parse EC private key: " +
err.Error())
Done.
https://codereview.appspot.com/6767045/diff/8001/src/pkg/crypto/x509/sec1.go#newcode55src/pkg/crypto/x509/sec1.go:55: return nil, fmt.Errorf("crypto/x509:
unknown version %d\n", privKey.Version)
On 2012/10/25 14:19:03, agl1 wrote:
no \n at the end
s/unknown version/unknown EC private key version/
Done.
https://codereview.appspot.com/6767045/diff/8001/src/pkg/crypto/x509/sec1.go#newcode58src/pkg/crypto/x509/sec1.go:58: var namedCurve elliptic.Curve
On 2012/10/25 14:19:03, agl1 wrote:
s/namedCurve/curve/
Done.
https://codereview.appspot.com/6767045/diff/8001/src/pkg/crypto/x509/sec1.go#newcode69src/pkg/crypto/x509/sec1.go:69: priv := new(ecdsa.PrivateKey)
On 2012/10/25 14:19:03, agl1 wrote:
if k.Cmp(curve.Params().N) >= 0 {
return nil, errors.New("crypto/x509: invalid elliptic curve private key
value")
}
Done.
https://codereview.appspot.com/6767045/diff/8001/src/pkg/crypto/x509/sec1.go#newcode72src/pkg/crypto/x509/sec1.go:72: priv.X, priv.Y =
namedCurve.ScalarBaseMult(k.Bytes())
On 2012/10/25 14:19:03, agl1 wrote:
s/k.Bytes()/privKey/PrivateKey/
Done.
https://codereview.appspot.com/6767045/