mirror of
https://github.com/fumiama/blake2b-simd.git
synced 2026-06-08 12:00:28 +08:00
Detect SSE automatically and enable corresponding optimized code path.
With this change, following happens.
```
if sse {
compressSSE()
return
}
compressGeneric()
```
compressGeneric is used as a fallback when SSE is not detected.
This commit is contained in:
committed by
Harshavardhana
parent
83ff4cf5f4
commit
3a46db1cb4
12
blake2b.go
12
blake2b.go
@@ -143,6 +143,7 @@ func (d *digest) initialize(c *Config) {
|
||||
p[2] = 1
|
||||
p[3] = 1
|
||||
}
|
||||
|
||||
// Initialize.
|
||||
d.size = c.Size
|
||||
for i := 0; i < 8; i++ {
|
||||
@@ -151,6 +152,7 @@ func (d *digest) initialize(c *Config) {
|
||||
if c.Tree != nil && c.Tree.IsLastNode {
|
||||
d.isLastNode = true
|
||||
}
|
||||
|
||||
// Process key.
|
||||
if c.Key != nil {
|
||||
copy(d.paddedKey[:], c.Key)
|
||||
@@ -231,11 +233,11 @@ func (d *digest) Write(p []byte) (nn int, err error) {
|
||||
}
|
||||
|
||||
// Sum returns the calculated checksum.
|
||||
func (d0 *digest) Sum(in []byte) []byte {
|
||||
// Make a copy of d0 so that caller can keep writing and summing.
|
||||
d := *d0
|
||||
hash := d.checkSum()
|
||||
return append(in, hash[:d.size]...)
|
||||
func (d *digest) Sum(in []byte) []byte {
|
||||
// Make a copy of d so that caller can keep writing and summing.
|
||||
d0 := *d
|
||||
hash := d0.checkSum()
|
||||
return append(in, hash[:d0.size]...)
|
||||
}
|
||||
|
||||
func (d *digest) checkSum() [Size]byte {
|
||||
|
||||
Reference in New Issue
Block a user