~ubuntu-branches/ubuntu/trusty/golang/trusty

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2013-08-20 14:06:23 UTC
  • mfrom: (14.1.23 saucy-proposed)
  • Revision ID: package-import@ubuntu.com-20130820140623-b414jfxi3m0qkmrq
Tags: 2:1.1.2-2ubuntu1
* Merge from Debian unstable (LP: #1211749, #1202027). Remaining changes:
  - 016-armhf-elf-header.patch: Use correct ELF header for armhf binaries.
  - d/control,control.cross: Update Breaks/Replaces for Ubuntu
    versions to ensure smooth upgrades, regenerate control file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
        return
50
50
}
51
51
 
52
 
// GenerateKey generates a public&private key pair.
 
52
// GenerateKey generates a public and private key pair.
53
53
func GenerateKey(c elliptic.Curve, rand io.Reader) (priv *PrivateKey, err error) {
54
54
        k, err := randFieldElement(c, rand)
55
55
        if err != nil {
140
140
        w := new(big.Int).ModInverse(s, N)
141
141
 
142
142
        u1 := e.Mul(e, w)
 
143
        u1.Mod(u1, N)
143
144
        u2 := w.Mul(r, w)
 
145
        u2.Mod(u2, N)
144
146
 
145
147
        x1, y1 := c.ScalarBaseMult(u1.Bytes())
146
148
        x2, y2 := c.ScalarMult(pub.X, pub.Y, u2.Bytes())
147
 
        if x1.Cmp(x2) == 0 {
 
149
        x, y := c.Add(x1, y1, x2, y2)
 
150
        if x.Sign() == 0 && y.Sign() == 0 {
148
151
                return false
149
152
        }
150
 
        x, _ := c.Add(x1, y1, x2, y2)
151
153
        x.Mod(x, N)
152
154
        return x.Cmp(r) == 0
153
155
}