mirror of
https://github.com/rwinkhart/rcw.git
synced 2026-09-03 23:57:28 -04:00
Use all available threads for argon2
This commit is contained in:
@@ -1,21 +1,24 @@
|
|||||||
package wrappers
|
package wrappers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"runtime"
|
||||||
|
|
||||||
"golang.org/x/crypto/argon2"
|
"golang.org/x/crypto/argon2"
|
||||||
"golang.org/x/crypto/chacha20poly1305"
|
"golang.org/x/crypto/chacha20poly1305"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// parameters for Argon2
|
// parameters for Argon2
|
||||||
argonTime = 1
|
argonTime = 1
|
||||||
argonMemory = 64 * 1024
|
argonMemory = 64 * 1024
|
||||||
argonThreads = 4
|
argonKeyLen = chacha20poly1305.KeySize
|
||||||
argonKeyLen = chacha20poly1305.KeySize
|
|
||||||
|
|
||||||
// general constants
|
// general constants
|
||||||
saltSize = 16
|
saltSize = 16
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var argonThreads = uint8(runtime.NumCPU())
|
||||||
|
|
||||||
// DeriveKey derives an encryption key from a passphrase using Argon2.
|
// DeriveKey derives an encryption key from a passphrase using Argon2.
|
||||||
func deriveKey(passphrase []byte, salt []byte) []byte {
|
func deriveKey(passphrase []byte, salt []byte) []byte {
|
||||||
return argon2.IDKey(passphrase, salt, argonTime, argonMemory, argonThreads, argonKeyLen)
|
return argon2.IDKey(passphrase, salt, argonTime, argonMemory, argonThreads, argonKeyLen)
|
||||||
|
|||||||
Reference in New Issue
Block a user