Nicolas Cellier uploaded a new version of System to project The Trunk:
http://source.squeak.org/trunk/System-nice.368.mcz==================== Summary ====================
Name: System-nice.368
Author: nice
Time: 2 September 2010, 9:51:25.307 pm
UUID: fc293865-b653-4d57-a521-24b6f2c81c07
Ancestors: System-ar.367
Use brand new faster #reciprocalModulo: in DSA
=============== Diff against System-ar.367 ===============
Item was changed:
----- Method: DigitalSignatureAlgorithm>>verifySignature:ofMessageHash:publicKey: (in category 'public') -----
verifySignature: aSignature ofMessageHash: hash publicKey: publicKey
"Answer true if the given signature is the authentic signature of the given message hash. That is, if the signature must have been computed using the private key set corresponding to the given public key. The public key is an array of four large integers: (p, q, g, y)."
| p q g y r s w u1 u2 v0 v |
p := publicKey first.
q := publicKey second.
g := publicKey third.
y := publicKey fourth.
r := aSignature first.
s := aSignature last.
((r > 0) and: [r < q]) ifFalse: [^ false]. "reject"
((s > 0) and: [s < q]) ifFalse: [^ false]. "reject"
+ w := s reciprocalModulo: q.
- w := self inverseOf: s mod: q.
u1 := (hash * w) \\ q.
u2 := (r * w) \\ q.
v0 := (g raisedTo: u1 modulo: p) * (y raisedTo: u2 modulo: p).
v := ( v0 \\ p) \\ q.
^ v = r
!
Item was changed:
----- Method: DigitalSignatureAlgorithm>>computeSignatureForMessageHash:privateKey: (in category 'public') -----
computeSignatureForMessageHash: hash privateKey: privateKey
"Answer the digital signature of the given message hash using the given private key. A signature is a pair of large integers. The private key is an array of four large integers: (p, q, g, x)."
| p q g x r s k tmp |
p := privateKey first.
q := privateKey second.
g := privateKey third.
x := privateKey fourth.
r := s := 0.
[r = 0 or: [s = 0]] whileTrue: [
k := self nextRandom160 \\ q.
r := (g raisedTo: k modulo: p) \\ q.
tmp := (hash + (x * r)) \\ q.
+ s := ((k reciprocalModulo: q) * tmp) \\ q].
- s := ((self inverseOf: k mod: q) * tmp) \\ q].
^ Array with: r with: s
!