File tree Expand file tree Collapse file tree 1 file changed +20
-8
lines changed Expand file tree Collapse file tree 1 file changed +20
-8
lines changed Original file line number Diff line number Diff line change @@ -87,7 +87,6 @@ function Gamma1256 (x) {
87
87
88
88
Sha256 . prototype . _update = function ( M ) {
89
89
var W = this . _w
90
- var T1 , T2
91
90
92
91
var a = this . _a | 0
93
92
var b = this . _b | 0
@@ -98,17 +97,30 @@ Sha256.prototype._update = function(M) {
98
97
var g = this . _g | 0
99
98
var h = this . _h | 0
100
99
101
- for ( var j = 0 ; j < 64 ; j ++ ) {
102
- var w = W [ j ] = j < 16
103
- ? M . readInt32BE ( j * 4 )
104
- : Gamma1256 ( W [ j - 2 ] ) + W [ j - 7 ] + Gamma0256 ( W [ j - 15 ] ) + W [ j - 16 ]
100
+ var j = 0
105
101
106
- T1 = h + Sigma1256 ( e ) + Ch ( e , f , g ) + K [ j ] + w
102
+ function calcW ( ) { return Gamma1256 ( W [ j - 2 ] ) + W [ j - 7 ] + Gamma0256 ( W [ j - 15 ] ) + W [ j - 16 ] }
103
+ function loop ( w ) {
104
+ W [ j ] = w
107
105
108
- T2 = Sigma0256 ( a ) + Maj ( a , b , c ) ;
109
- h = g ; g = f ; f = e ; e = d + T1 ; d = c ; c = b ; b = a ; a = T1 + T2 ;
106
+ var T1 = h + Sigma1256 ( e ) + Ch ( e , f , g ) + K [ j ] + w
107
+ var T2 = Sigma0256 ( a ) + Maj ( a , b , c ) ;
108
+
109
+ h = g ;
110
+ g = f ;
111
+ f = e ;
112
+ e = d + T1 ;
113
+ d = c ;
114
+ c = b ;
115
+ b = a ;
116
+ a = T1 + T2 ;
117
+
118
+ j ++
110
119
}
111
120
121
+ while ( j < 16 ) loop ( M . readInt32BE ( j * 4 ) )
122
+ while ( j < 64 ) loop ( calcW ( ) )
123
+
112
124
this . _a = ( a + this . _a ) | 0
113
125
this . _b = ( b + this . _b ) | 0
114
126
this . _c = ( c + this . _c ) | 0
You can’t perform that action at this time.
0 commit comments