[squeak-dev] The Trunk: System-nice.430.mcz
commits at source.squeak.org
commits at source.squeak.org
Mon Apr 11 15:03:40 UTC 2011
Nicolas Cellier uploaded a new version of System to project The Trunk:
http://source.squeak.org/trunk/System-nice.430.mcz
==================== Summary ====================
Name: System-nice.430
Author: nice
Time: 11 April 2011, 5:03:27.259 pm
UUID: 4cfe09e7-697d-9b44-bd8e-b066be9d6b8c
Ancestors: System-ul.429
Use #repeat instead of [true] whileTrue
=============== Diff against System-ul.429 ===============
Item was changed:
----- Method: DigitalSignatureAlgorithm>>generateQandP (in category 'private') -----
generateQandP
"Generate the two industrial-grade primes, q (160-bits) and p (512-bit) needed to build a key set. Answer the array (q, p, s), where s is the seed that from which q and p were created. This seed is normally discarded, but can be used to verify the key generation process if desired."
| pBits halfTwoToTheP chunkCount sAndq q twoQ n c w x p s |
pBits := 512. "desired size of p in bits"
halfTwoToTheP := 2 raisedTo: (pBits - 1).
chunkCount := pBits // 160.
Transcript show: 'Searching for primes q and p...'; cr.
+ [
- [true] whileTrue: [
sAndq := self generateSandQ.
Transcript show: ' Found a candidate q.'; cr.
s := sAndq first.
q := sAndq last.
twoQ := q bitShift: 1.
n := 2.
c := 0.
[c < 4096] whileTrue: [
w := self generateRandomLength: pBits s: s n: n.
x := w + halfTwoToTheP.
p := (x - ( x \\ twoQ)) + 1.
p highBit = pBits ifTrue: [
Transcript show: ' Testing potential p ', (c + 1) printString, '...'; cr.
(self isProbablyPrime: p) ifTrue: [
Transcript show: ' Found p!!'; cr.
^ Array with: q with: p with: s]].
n := n + chunkCount + 1.
+ c := c + 1]] repeat!
- c := c + 1]].
- !
Item was changed:
----- Method: DigitalSignatureAlgorithm>>generateSandQ (in category 'private') -----
generateSandQ
"Generate a 160-bit random seed s and an industrial grade prime q."
| hasher s sPlusOne u q |
hasher := SecureHashAlgorithm new.
+ [
- [true] whileTrue: [
s := self nextRandom160.
sPlusOne := s + 1.
+ sPlusOne highBit > 160 ifTrue: [sPlusOne := sPlusOne bitAnd: (1 bitShift: 160) - 1].
- sPlusOne highBit > 160 ifTrue: [sPlusOne := sPlusOne \\ (2 raisedTo: 160)].
u := (hasher hashInteger: s) bitXor: (hasher hashInteger: sPlusOne).
q := u bitOr: ((1 bitShift: 159) bitOr: 1).
+ (self isProbablyPrime: q) ifTrue: [^ Array with: s with: q]] repeat!
- (self isProbablyPrime: q) ifTrue: [^ Array with: s with: q]].
- !
More information about the Squeak-dev
mailing list
|