@@ -40,7 +40,7 @@ type state struct {
40
40
// Extendable-Output Functions (May 2014)"
41
41
dsbyte byte
42
42
43
- storage storageBuf
43
+ storage [ maxRate ] byte
44
44
45
45
// Specific to SHA-3 and SHAKE.
46
46
outputLen int // the default output size in bytes
@@ -61,15 +61,15 @@ func (d *state) Reset() {
61
61
d .a [i ] = 0
62
62
}
63
63
d .state = spongeAbsorbing
64
- d .buf = d .storage . asBytes () [:0 ]
64
+ d .buf = d .storage [:0 ]
65
65
}
66
66
67
67
func (d * state ) clone () * state {
68
68
ret := * d
69
69
if ret .state == spongeAbsorbing {
70
- ret .buf = ret .storage . asBytes () [:len (ret .buf )]
70
+ ret .buf = ret .storage [:len (ret .buf )]
71
71
} else {
72
- ret .buf = ret .storage . asBytes () [d .rate - cap (d .buf ) : d .rate ]
72
+ ret .buf = ret .storage [d .rate - cap (d .buf ) : d .rate ]
73
73
}
74
74
75
75
return & ret
@@ -83,13 +83,13 @@ func (d *state) permute() {
83
83
// If we're absorbing, we need to xor the input into the state
84
84
// before applying the permutation.
85
85
xorIn (d , d .buf )
86
- d .buf = d .storage . asBytes () [:0 ]
86
+ d .buf = d .storage [:0 ]
87
87
keccakF1600 (& d .a )
88
88
case spongeSqueezing :
89
89
// If we're squeezing, we need to apply the permutation before
90
90
// copying more output.
91
91
keccakF1600 (& d .a )
92
- d .buf = d .storage . asBytes () [:d .rate ]
92
+ d .buf = d .storage [:d .rate ]
93
93
copyOut (d , d .buf )
94
94
}
95
95
}
@@ -98,15 +98,15 @@ func (d *state) permute() {
98
98
// the multi-bitrate 10..1 padding rule, and permutes the state.
99
99
func (d * state ) padAndPermute (dsbyte byte ) {
100
100
if d .buf == nil {
101
- d .buf = d .storage . asBytes () [:0 ]
101
+ d .buf = d .storage [:0 ]
102
102
}
103
103
// Pad with this instance's domain-separator bits. We know that there's
104
104
// at least one byte of space in d.buf because, if it were full,
105
105
// permute would have been called to empty it. dsbyte also contains the
106
106
// first one bit for the padding. See the comment in the state struct.
107
107
d .buf = append (d .buf , dsbyte )
108
108
zerosStart := len (d .buf )
109
- d .buf = d .storage . asBytes () [:d .rate ]
109
+ d .buf = d .storage [:d .rate ]
110
110
for i := zerosStart ; i < d .rate ; i ++ {
111
111
d .buf [i ] = 0
112
112
}
@@ -117,7 +117,7 @@ func (d *state) padAndPermute(dsbyte byte) {
117
117
// Apply the permutation
118
118
d .permute ()
119
119
d .state = spongeSqueezing
120
- d .buf = d .storage . asBytes () [:d .rate ]
120
+ d .buf = d .storage [:d .rate ]
121
121
copyOut (d , d .buf )
122
122
}
123
123
@@ -128,7 +128,7 @@ func (d *state) Write(p []byte) (written int, err error) {
128
128
panic ("sha3: Write after Read" )
129
129
}
130
130
if d .buf == nil {
131
- d .buf = d .storage . asBytes () [:0 ]
131
+ d .buf = d .storage [:0 ]
132
132
}
133
133
written = len (p )
134
134
0 commit comments