]> Cypherpunks repositories - gostls13.git/commitdiff
crypto/x509: rename and reposition rsaPublicKey struct declaration
authorAndrew Benton <andrewmbenton@gmail.com>
Tue, 7 Mar 2017 07:17:58 +0000 (23:17 -0800)
committerBrad Fitzpatrick <bradfitz@golang.org>
Tue, 7 Mar 2017 16:49:28 +0000 (16:49 +0000)
For consistency with the other named types in this package, this
change renames the unexported rsaPublicKey struct to pkcs1PublicKey
and positions the declaration up with the other similarly-named
types in pkcs1.go.

See the final comment of #19355 for discussion.

Change-Id: I1fa0366a8efa01602b81bc69287ef747abce84f5
Reviewed-on: https://go-review.googlesource.com/37885
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/crypto/x509/pkcs1.go
src/crypto/x509/x509.go

index df20a4420498e458e080d08c3e491c86e5b828e1..73bc7623a5aaffa46703e203334747b34ca44f76 100644 (file)
@@ -35,6 +35,12 @@ type pkcs1AdditionalRSAPrime struct {
        Coeff *big.Int
 }
 
+// pkcs1PublicKey reflects the ASN.1 structure of a PKCS#1 public key.
+type pkcs1PublicKey struct {
+       N *big.Int
+       E int
+}
+
 // ParsePKCS1PrivateKey returns an RSA private key from its ASN.1 PKCS#1 DER encoded form.
 func ParsePKCS1PrivateKey(der []byte) (*rsa.PrivateKey, error) {
        var priv pkcs1PrivateKey
@@ -113,9 +119,3 @@ func MarshalPKCS1PrivateKey(key *rsa.PrivateKey) []byte {
        b, _ := asn1.Marshal(priv)
        return b
 }
-
-// rsaPublicKey reflects the ASN.1 structure of a PKCS#1 public key.
-type rsaPublicKey struct {
-       N *big.Int
-       E int
-}
index 2934168c744fbe2c2cbddee954552bf2823b7efa..f572e7f2e99a847393cc867132fa3373ad0f6c93 100644 (file)
@@ -59,7 +59,7 @@ func ParsePKIXPublicKey(derBytes []byte) (pub interface{}, err error) {
 func marshalPublicKey(pub interface{}) (publicKeyBytes []byte, publicKeyAlgorithm pkix.AlgorithmIdentifier, err error) {
        switch pub := pub.(type) {
        case *rsa.PublicKey:
-               publicKeyBytes, err = asn1.Marshal(rsaPublicKey{
+               publicKeyBytes, err = asn1.Marshal(pkcs1PublicKey{
                        N: pub.N,
                        E: pub.E,
                })
@@ -941,7 +941,7 @@ func parsePublicKey(algo PublicKeyAlgorithm, keyData *publicKeyInfo) (interface{
                        return nil, errors.New("x509: RSA key missing NULL parameters")
                }
 
-               p := new(rsaPublicKey)
+               p := new(pkcs1PublicKey)
                rest, err := asn1.Unmarshal(asn1Data, p)
                if err != nil {
                        return nil, err