File tree Expand file tree Collapse file tree 2 files changed +14
-15
lines changed
Expand file tree Collapse file tree 2 files changed +14
-15
lines changed Original file line number Diff line number Diff line change @@ -307,19 +307,14 @@ fileprivate extension AES {
307307 var rk2 : Array < Array < UInt32 > > = expandKey ( key, variant: variant)
308308
309309 for r in 1 ..< rounds {
310- var w : UInt32
311-
312- w = rk2 [ r] [ 0 ]
313- rk2 [ r] [ 0 ] = U1 [ Int ( B0 ( w) ) ] ^ U2 [ Int ( B1 ( w) ) ] ^ U3 [ Int ( B2 ( w) ) ] ^ U4 [ Int ( B3 ( w) ) ]
314-
315- w = rk2 [ r] [ 1 ]
316- rk2 [ r] [ 1 ] = U1 [ Int ( B0 ( w) ) ] ^ U2 [ Int ( B1 ( w) ) ] ^ U3 [ Int ( B2 ( w) ) ] ^ U4 [ Int ( B3 ( w) ) ]
317-
318- w = rk2 [ r] [ 2 ]
319- rk2 [ r] [ 2 ] = U1 [ Int ( B0 ( w) ) ] ^ U2 [ Int ( B1 ( w) ) ] ^ U3 [ Int ( B2 ( w) ) ] ^ U4 [ Int ( B3 ( w) ) ]
320-
321- w = rk2 [ r] [ 3 ]
322- rk2 [ r] [ 3 ] = U1 [ Int ( B0 ( w) ) ] ^ U2 [ Int ( B1 ( w) ) ] ^ U3 [ Int ( B2 ( w) ) ] ^ U4 [ Int ( B3 ( w) ) ]
310+ for i in 0 ..< 4 {
311+ let w = rk2 [ r] [ i]
312+ let u1 = U1 [ Int ( B0 ( w) ) ]
313+ let u2 = U2 [ Int ( B1 ( w) ) ]
314+ let u3 = U3 [ Int ( B2 ( w) ) ]
315+ let u4 = U4 [ Int ( B3 ( w) ) ]
316+ rk2 [ r] [ i] = u1^u2^u3^u4
317+ }
323318 }
324319
325320 return rk2
Original file line number Diff line number Diff line change @@ -101,8 +101,12 @@ public final class MD5: DigestType {
101101
102102 // break chunk into sixteen 32-bit words M[j], 0 ≤ j ≤ 15 and get M[g] value
103103 let gAdvanced = g << 2
104- var Mg = UInt32 ( chunk [ chunk. startIndex &+ gAdvanced] ) | UInt32 ( chunk [ chunk. startIndex &+ gAdvanced &+ 1 ] ) << 8 | UInt32 ( chunk [ chunk. startIndex &+ gAdvanced &+ 2 ] ) << 16
105- Mg = Mg | UInt32 ( chunk [ chunk. startIndex &+ gAdvanced &+ 3 ] ) << 24
104+
105+ let Mg0 = UInt32 ( chunk [ chunk. startIndex &+ gAdvanced] )
106+ let Mg1 = UInt32 ( chunk [ chunk. startIndex &+ gAdvanced &+ 1 ] ) << 8
107+ let Mg2 = UInt32 ( chunk [ chunk. startIndex &+ gAdvanced &+ 2 ] ) << 16
108+ let Mg3 = UInt32 ( chunk [ chunk. startIndex &+ gAdvanced &+ 3 ] ) << 24
109+ let Mg = ( Mg0 | Mg1 | Mg2) | Mg3
106110
107111 B = B &+ rotateLeft ( A &+ F &+ k [ j] &+ Mg, by: s [ j] )
108112 A = dTemp
You can’t perform that action at this time.
0 commit comments