Skip to content
Snippets Groups Projects
Commit 841d17b2 authored by ale's avatar ale
Browse files

Set sane parameters for scrypt

parent 7d7b86fd
No related branches found
No related tags found
No related merge requests found
package server
import (
"errors"
"github.com/miscreant/miscreant/go"
"golang.org/x/crypto/scrypt"
)
const (
scryptN = 32768
scryptR = 8
scryptP = 1
keyLen = 64
saltLen = 32
)
func decrypt(data, pw []byte) ([]byte, error) {
// The KDF salt is prepended to the encrypted key.
if len(data) < saltLen {
return nil, errors.New("short data")
}
salt := data[:saltLen]
data = data[saltLen:]
// Apply the key derivation function to the password to obtain
// a 64 byte key.
dk, err := scrypt.Key(pw, nil, 16384, 1, 8, 64)
dk, err := scrypt.Key(pw, salt, scryptN, scryptR, scryptP, keySize)
if err != nil {
return nil, err
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment