You've already forked nyx
mirror of
https://github.com/rls-moe/nyx
synced 2025-08-20 12:04:16 +00:00
updated dependencies
This commit is contained in:
110
vendor/golang.org/x/crypto/scrypt/scrypt.go
generated
vendored
110
vendor/golang.org/x/crypto/scrypt/scrypt.go
generated
vendored
@@ -4,12 +4,13 @@
|
||||
|
||||
// Package scrypt implements the scrypt key derivation function as defined in
|
||||
// Colin Percival's paper "Stronger Key Derivation via Sequential Memory-Hard
|
||||
// Functions" (http://www.tarsnap.com/scrypt/scrypt.pdf).
|
||||
// Functions" (https://www.tarsnap.com/scrypt/scrypt.pdf).
|
||||
package scrypt // import "golang.org/x/crypto/scrypt"
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"errors"
|
||||
"math/bits"
|
||||
|
||||
"golang.org/x/crypto/pbkdf2"
|
||||
)
|
||||
@@ -29,7 +30,7 @@ func blockXOR(dst, src []uint32, n int) {
|
||||
}
|
||||
|
||||
// salsaXOR applies Salsa20/8 to the XOR of 16 numbers from tmp and in,
|
||||
// and puts the result into both both tmp and out.
|
||||
// and puts the result into both tmp and out.
|
||||
func salsaXOR(tmp *[16]uint32, in, out []uint32) {
|
||||
w0 := tmp[0] ^ in[0]
|
||||
w1 := tmp[1] ^ in[1]
|
||||
@@ -52,77 +53,45 @@ func salsaXOR(tmp *[16]uint32, in, out []uint32) {
|
||||
x9, x10, x11, x12, x13, x14, x15 := w9, w10, w11, w12, w13, w14, w15
|
||||
|
||||
for i := 0; i < 8; i += 2 {
|
||||
u := x0 + x12
|
||||
x4 ^= u<<7 | u>>(32-7)
|
||||
u = x4 + x0
|
||||
x8 ^= u<<9 | u>>(32-9)
|
||||
u = x8 + x4
|
||||
x12 ^= u<<13 | u>>(32-13)
|
||||
u = x12 + x8
|
||||
x0 ^= u<<18 | u>>(32-18)
|
||||
x4 ^= bits.RotateLeft32(x0+x12, 7)
|
||||
x8 ^= bits.RotateLeft32(x4+x0, 9)
|
||||
x12 ^= bits.RotateLeft32(x8+x4, 13)
|
||||
x0 ^= bits.RotateLeft32(x12+x8, 18)
|
||||
|
||||
u = x5 + x1
|
||||
x9 ^= u<<7 | u>>(32-7)
|
||||
u = x9 + x5
|
||||
x13 ^= u<<9 | u>>(32-9)
|
||||
u = x13 + x9
|
||||
x1 ^= u<<13 | u>>(32-13)
|
||||
u = x1 + x13
|
||||
x5 ^= u<<18 | u>>(32-18)
|
||||
x9 ^= bits.RotateLeft32(x5+x1, 7)
|
||||
x13 ^= bits.RotateLeft32(x9+x5, 9)
|
||||
x1 ^= bits.RotateLeft32(x13+x9, 13)
|
||||
x5 ^= bits.RotateLeft32(x1+x13, 18)
|
||||
|
||||
u = x10 + x6
|
||||
x14 ^= u<<7 | u>>(32-7)
|
||||
u = x14 + x10
|
||||
x2 ^= u<<9 | u>>(32-9)
|
||||
u = x2 + x14
|
||||
x6 ^= u<<13 | u>>(32-13)
|
||||
u = x6 + x2
|
||||
x10 ^= u<<18 | u>>(32-18)
|
||||
x14 ^= bits.RotateLeft32(x10+x6, 7)
|
||||
x2 ^= bits.RotateLeft32(x14+x10, 9)
|
||||
x6 ^= bits.RotateLeft32(x2+x14, 13)
|
||||
x10 ^= bits.RotateLeft32(x6+x2, 18)
|
||||
|
||||
u = x15 + x11
|
||||
x3 ^= u<<7 | u>>(32-7)
|
||||
u = x3 + x15
|
||||
x7 ^= u<<9 | u>>(32-9)
|
||||
u = x7 + x3
|
||||
x11 ^= u<<13 | u>>(32-13)
|
||||
u = x11 + x7
|
||||
x15 ^= u<<18 | u>>(32-18)
|
||||
x3 ^= bits.RotateLeft32(x15+x11, 7)
|
||||
x7 ^= bits.RotateLeft32(x3+x15, 9)
|
||||
x11 ^= bits.RotateLeft32(x7+x3, 13)
|
||||
x15 ^= bits.RotateLeft32(x11+x7, 18)
|
||||
|
||||
u = x0 + x3
|
||||
x1 ^= u<<7 | u>>(32-7)
|
||||
u = x1 + x0
|
||||
x2 ^= u<<9 | u>>(32-9)
|
||||
u = x2 + x1
|
||||
x3 ^= u<<13 | u>>(32-13)
|
||||
u = x3 + x2
|
||||
x0 ^= u<<18 | u>>(32-18)
|
||||
x1 ^= bits.RotateLeft32(x0+x3, 7)
|
||||
x2 ^= bits.RotateLeft32(x1+x0, 9)
|
||||
x3 ^= bits.RotateLeft32(x2+x1, 13)
|
||||
x0 ^= bits.RotateLeft32(x3+x2, 18)
|
||||
|
||||
u = x5 + x4
|
||||
x6 ^= u<<7 | u>>(32-7)
|
||||
u = x6 + x5
|
||||
x7 ^= u<<9 | u>>(32-9)
|
||||
u = x7 + x6
|
||||
x4 ^= u<<13 | u>>(32-13)
|
||||
u = x4 + x7
|
||||
x5 ^= u<<18 | u>>(32-18)
|
||||
x6 ^= bits.RotateLeft32(x5+x4, 7)
|
||||
x7 ^= bits.RotateLeft32(x6+x5, 9)
|
||||
x4 ^= bits.RotateLeft32(x7+x6, 13)
|
||||
x5 ^= bits.RotateLeft32(x4+x7, 18)
|
||||
|
||||
u = x10 + x9
|
||||
x11 ^= u<<7 | u>>(32-7)
|
||||
u = x11 + x10
|
||||
x8 ^= u<<9 | u>>(32-9)
|
||||
u = x8 + x11
|
||||
x9 ^= u<<13 | u>>(32-13)
|
||||
u = x9 + x8
|
||||
x10 ^= u<<18 | u>>(32-18)
|
||||
x11 ^= bits.RotateLeft32(x10+x9, 7)
|
||||
x8 ^= bits.RotateLeft32(x11+x10, 9)
|
||||
x9 ^= bits.RotateLeft32(x8+x11, 13)
|
||||
x10 ^= bits.RotateLeft32(x9+x8, 18)
|
||||
|
||||
u = x15 + x14
|
||||
x12 ^= u<<7 | u>>(32-7)
|
||||
u = x12 + x15
|
||||
x13 ^= u<<9 | u>>(32-9)
|
||||
u = x13 + x12
|
||||
x14 ^= u<<13 | u>>(32-13)
|
||||
u = x14 + x13
|
||||
x15 ^= u<<18 | u>>(32-18)
|
||||
x12 ^= bits.RotateLeft32(x15+x14, 7)
|
||||
x13 ^= bits.RotateLeft32(x12+x15, 9)
|
||||
x14 ^= bits.RotateLeft32(x13+x12, 13)
|
||||
x15 ^= bits.RotateLeft32(x14+x13, 18)
|
||||
}
|
||||
x0 += w0
|
||||
x1 += w1
|
||||
@@ -218,11 +187,12 @@ func smix(b []byte, r, N int, v, xy []uint32) {
|
||||
// For example, you can get a derived key for e.g. AES-256 (which needs a
|
||||
// 32-byte key) by doing:
|
||||
//
|
||||
// dk, err := scrypt.Key([]byte("some password"), salt, 16384, 8, 1, 32)
|
||||
// dk, err := scrypt.Key([]byte("some password"), salt, 32768, 8, 1, 32)
|
||||
//
|
||||
// The recommended parameters for interactive logins as of 2009 are N=16384,
|
||||
// r=8, p=1. They should be increased as memory latency and CPU parallelism
|
||||
// increases. Remember to get a good random salt.
|
||||
// The recommended parameters for interactive logins as of 2017 are N=32768, r=8
|
||||
// and p=1. The parameters N, r, and p should be increased as memory latency and
|
||||
// CPU parallelism increases; consider setting N to the highest power of 2 you
|
||||
// can derive within 100 milliseconds. Remember to get a good random salt.
|
||||
func Key(password, salt []byte, N, r, p, keyLen int) ([]byte, error) {
|
||||
if N <= 1 || N&(N-1) != 0 {
|
||||
return nil, errors.New("scrypt: N must be > 1 and a power of 2")
|
||||
|
Reference in New Issue
Block a user