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

« back to all changes in this revision

Viewing changes to src/pkg/crypto/rsa/rsa.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:
64
64
        // easy for an attack to generate composites that pass this test.
65
65
        for _, prime := range priv.Primes {
66
66
                if !big.ProbablyPrime(prime, 20) {
67
 
                        return os.ErrorString("prime factor is composite")
 
67
                        return os.NewError("prime factor is composite")
68
68
                }
69
69
        }
70
70
 
74
74
                modulus.Mul(modulus, prime)
75
75
        }
76
76
        if modulus.Cmp(priv.N) != 0 {
77
 
                return os.ErrorString("invalid modulus")
 
77
                return os.NewError("invalid modulus")
78
78
        }
79
79
        // Check that e and totient(Πprimes) are coprime.
80
80
        totient := new(big.Int).Set(bigOne)
88
88
        y := new(big.Int)
89
89
        big.GcdInt(gcd, x, y, totient, e)
90
90
        if gcd.Cmp(bigOne) != 0 {
91
 
                return os.ErrorString("invalid public exponent E")
 
91
                return os.NewError("invalid public exponent E")
92
92
        }
93
93
        // Check that de ≡ 1 (mod totient(Πprimes))
94
94
        de := new(big.Int).Mul(priv.D, e)
95
95
        de.Mod(de, totient)
96
96
        if de.Cmp(bigOne) != 0 {
97
 
                return os.ErrorString("invalid private exponent D")
 
97
                return os.NewError("invalid private exponent D")
98
98
        }
99
99
        return nil
100
100
}
127
127
        priv.E = 3
128
128
 
129
129
        if nprimes < 2 {
130
 
                return nil, os.ErrorString("rsa.GenerateMultiPrimeKey: nprimes must be >= 2")
 
130
                return nil, os.NewError("rsa.GenerateMultiPrimeKey: nprimes must be >= 2")
131
131
        }
132
132
 
133
133
        primes := make([]*big.Int, nprimes)