Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
id
keystore
Commits
841d17b2
Commit
841d17b2
authored
Dec 15, 2017
by
ale
Browse files
Set sane parameters for scrypt
parent
7d7b86fd
Changes
1
Hide whitespace changes
Inline
Side-by-side
server/decrypt.go
View file @
841d17b2
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
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment