20
20
* is designed to be timing-attack resistant. The speed hit from this
21
21
* is in line with a "safety first" API, but be aware of it.
22
22
*
23
- * Fortuna was originally described in
23
+ * Fortuna was originally described in
24
24
* Practical Cryptography, Niels Ferguson and Bruce Schneier.
25
25
* John Wiley & Sons, 2003.
26
26
*
@@ -147,7 +147,7 @@ impl FortunaGenerator {
147
147
148
148
149
149
/// A single entropy pool (not public)
150
- #[ derive( Copy ) ]
150
+ #[ derive( Clone , Copy ) ]
151
151
struct Pool {
152
152
state : Sha256 ,
153
153
count : usize
@@ -194,7 +194,7 @@ impl Fortuna {
194
194
}
195
195
}
196
196
197
- /// Adds a random event `e` from source `s` to entropy pool `i` (PC 9.5.6)
197
+ /// Adds a random event `e` from source `s` to entropy pool `i` (PC 9.5.6)
198
198
pub fn add_random_event ( & mut self , s : u8 , i : usize , e : & [ u8 ] ) {
199
199
assert ! ( i <= NUM_POOLS ) ;
200
200
// These restrictions (and `s` in [0, 255]) are part of the Fortuna spec.
@@ -352,7 +352,7 @@ mod tests {
352
352
50 , 68 , 236 , 107 , 133 , 18 , 217 , 219 , 46 , 134 ,
353
353
169 , 156 , 211 , 74 , 163 , 17 , 100 , 173 , 26 , 70 ,
354
354
246 , 193 , 57 , 164 , 167 , 175 , 233 , 220 , 160 , 114 ,
355
- 2 , 200 , 215 , 80 , 207 , 218 , 85 , 58 , 235 , 117 ,
355
+ 2 , 200 , 215 , 80 , 207 , 218 , 85 , 58 , 235 , 117 ,
356
356
177 , 223 , 87 , 192 , 50 , 251 , 61 , 65 , 141 , 100 ,
357
357
59 , 228 , 23 , 215 , 58 , 107 , 248 , 248 , 103 , 57 ,
358
358
127 , 31 , 241 , 91 , 230 , 33 , 0 , 164 , 77 , 46 ] ;
@@ -411,7 +411,7 @@ mod tests {
411
411
412
412
// from Crypto.Random.Fortuna import FortunaAccumulator
413
413
// x = FortunaAccumulator.FortunaAccumulator()
414
- // x.add_random_event(0, 0, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0")
414
+ // x.add_random_event(0, 0, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0")
415
415
// x.add_random_event(0, 0, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0")
416
416
// x.add_random_event(1, 0, "\1\2")
417
417
// x.add_random_event(1, 1, "\1\2")
@@ -433,7 +433,7 @@ mod tests {
433
433
f. add_random_event ( 0 , 0 , & [ 0 ; 32 ] ) ;
434
434
f. add_random_event ( 0 , 0 , & [ 0 ; 32 ] ) ;
435
435
436
- // x.add_random_event(0, 0, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0")
436
+ // x.add_random_event(0, 0, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0")
437
437
// x.add_random_event(0, 0, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0")
438
438
// print list(bytearray(x.random_data(100)))
439
439
let expected = [ 101 , 123 , 175 , 157 , 142 , 202 , 211 , 47 , 149 , 214 ,
@@ -513,4 +513,3 @@ mod bench {
513
513
bh. bytes = bytes. len ( ) as u64 ;
514
514
}
515
515
}
516
-
0 commit comments