~ubuntu-branches/ubuntu/vivid/golang/vivid

« back to all changes in this revision

Viewing changes to src/pkg/crypto/x509/x509.go

  • Committer: Bazaar Package Importer
  • Author(s): Ondřej Surý
  • Date: 2011-08-03 17:04:59 UTC
  • mfrom: (14.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20110803170459-wzd99m3567y80ila
Tags: 1:59-1
* Imported Upstream version 59
* Refresh patches to a new release
* Fix FTBFS on ARM (Closes: #634270)
* Update version.bash to work with Debian packaging and not hg
  repository

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
        P       *big.Int
31
31
        Q       *big.Int
32
32
        // We ignore these values, if present, because rsa will calculate them.
33
 
        Dp   *big.Int "optional"
34
 
        Dq   *big.Int "optional"
35
 
        Qinv *big.Int "optional"
 
33
        Dp   *big.Int `asn1:"optional"`
 
34
        Dq   *big.Int `asn1:"optional"`
 
35
        Qinv *big.Int `asn1:"optional"`
36
36
 
37
 
        AdditionalPrimes []pkcs1AdditionalRSAPrime "optional"
 
37
        AdditionalPrimes []pkcs1AdditionalRSAPrime `asn1:"optional"`
38
38
}
39
39
 
40
40
type pkcs1AdditionalRSAPrime struct {
58
58
        }
59
59
 
60
60
        if priv.Version > 1 {
61
 
                return nil, os.ErrorString("x509: unsupported private key version")
 
61
                return nil, os.NewError("x509: unsupported private key version")
62
62
        }
63
63
 
64
64
        if priv.N.Sign() <= 0 || priv.D.Sign() <= 0 || priv.P.Sign() <= 0 || priv.Q.Sign() <= 0 {
65
 
                return nil, os.ErrorString("private key contains zero or negative value")
 
65
                return nil, os.NewError("private key contains zero or negative value")
66
66
        }
67
67
 
68
68
        key = new(rsa.PrivateKey)
77
77
        key.Primes[1] = priv.Q
78
78
        for i, a := range priv.AdditionalPrimes {
79
79
                if a.Prime.Sign() <= 0 {
80
 
                        return nil, os.ErrorString("private key contains zero or negative prime")
 
80
                        return nil, os.NewError("private key contains zero or negative prime")
81
81
                }
82
82
                key.Primes[i+2] = a.Prime
83
83
                // We ignore the other two values because rsa will calculate
136
136
 
137
137
type tbsCertificate struct {
138
138
        Raw                asn1.RawContent
139
 
        Version            int "optional,explicit,default:1,tag:0"
 
139
        Version            int `asn1:"optional,explicit,default:1,tag:0"`
140
140
        SerialNumber       *big.Int
141
141
        SignatureAlgorithm pkix.AlgorithmIdentifier
142
142
        Issuer             pkix.RDNSequence
143
143
        Validity           validity
144
144
        Subject            pkix.RDNSequence
145
145
        PublicKey          publicKeyInfo
146
 
        UniqueId           asn1.BitString   "optional,tag:1"
147
 
        SubjectUniqueId    asn1.BitString   "optional,tag:2"
148
 
        Extensions         []pkix.Extension "optional,explicit,tag:3"
 
146
        UniqueId           asn1.BitString   `asn1:"optional,tag:1"`
 
147
        SubjectUniqueId    asn1.BitString   `asn1:"optional,tag:2"`
 
148
        Extensions         []pkix.Extension `asn1:"optional,explicit,tag:3"`
149
149
}
150
150
 
151
151
type dsaAlgorithmParameters struct {
168
168
 
169
169
// RFC 5280,  4.2.1.1
170
170
type authKeyId struct {
171
 
        Id []byte "optional,tag:0"
 
171
        Id []byte `asn1:"optional,tag:0"`
172
172
}
173
173
 
174
174
type SignatureAlgorithm int
457
457
                        return err
458
458
                }
459
459
                if dsaSig.R.Sign() <= 0 || dsaSig.S.Sign() <= 0 {
460
 
                        return os.ErrorString("DSA signature contained zero or negative values")
 
460
                        return os.NewError("DSA signature contained zero or negative values")
461
461
                }
462
462
                if !dsa.Verify(pub, digest, dsaSig.R, dsaSig.S) {
463
 
                        return os.ErrorString("DSA verification failure")
 
463
                        return os.NewError("DSA verification failure")
464
464
                }
465
465
                return
466
466
        }
480
480
}
481
481
 
482
482
type basicConstraints struct {
483
 
        IsCA       bool "optional"
484
 
        MaxPathLen int  "optional"
 
483
        IsCA       bool `asn1:"optional"`
 
484
        MaxPathLen int  `asn1:"optional"`
485
485
}
486
486
 
487
487
type rsaPublicKey struct {
497
497
 
498
498
// RFC 5280, 4.2.1.10
499
499
type nameConstraints struct {
500
 
        Permitted []generalSubtree "optional,tag:0"
501
 
        Excluded  []generalSubtree "optional,tag:1"
 
500
        Permitted []generalSubtree `asn1:"optional,tag:0"`
 
501
        Excluded  []generalSubtree `asn1:"optional,tag:1"`
502
502
}
503
503
 
504
504
type generalSubtree struct {
505
 
        Name string "tag:2,optional,ia5"
506
 
        Min  int    "optional,tag:0"
507
 
        Max  int    "optional,tag:1"
 
505
        Name string `asn1:"tag:2,optional,ia5"`
 
506
        Min  int    `asn1:"optional,tag:0"`
 
507
        Max  int    `asn1:"optional,tag:1"`
508
508
}
509
509
 
510
510
func parsePublicKey(algo PublicKeyAlgorithm, keyData *publicKeyInfo) (interface{}, os.Error) {
535
535
                        return nil, err
536
536
                }
537
537
                if p.Sign() <= 0 || params.P.Sign() <= 0 || params.Q.Sign() <= 0 || params.G.Sign() <= 0 {
538
 
                        return nil, os.ErrorString("zero or negative DSA parameter")
 
538
                        return nil, os.NewError("zero or negative DSA parameter")
539
539
                }
540
540
                pub := &dsa.PublicKey{
541
541
                        Parameters: dsa.Parameters{
571
571
        }
572
572
 
573
573
        if in.TBSCertificate.SerialNumber.Sign() < 0 {
574
 
                return nil, os.ErrorString("negative serial number")
 
574
                return nil, os.NewError("negative serial number")
575
575
        }
576
576
 
577
577
        out.Version = in.TBSCertificate.Version + 1