summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2024-07-17 11:45:31 -0300
committerEuAndreh <eu@euandre.org>2024-07-17 11:45:31 -0300
commit5193809342c63078dc17bb142ad50beae34b9331 (patch)
tree978daaaaf38c2afabae201d0a40d2a6cb0da9f0f /src
parentsrc/lib.go, tests/lib_test.go: Tweak indentation (diff)
downloadpapod-5193809342c63078dc17bb142ad50beae34b9331.tar.gz
papod-5193809342c63078dc17bb142ad50beae34b9331.tar.xz
src/lib.go, tests/lib_test.go: Normaline function argument declarations
Diffstat (limited to 'src')
-rw-r--r--src/lib.go19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/lib.go b/src/lib.go
index bf3337c..d537b34 100644
--- a/src/lib.go
+++ b/src/lib.go
@@ -417,12 +417,12 @@ func PBKDF2Key(
const maxInt = int(^uint(0) >> 1)
// blockCopy copies n numbers from src into dst.
-func blockCopy(dst, src []uint32, n int) {
+func blockCopy(dst []uint32, src []uint32, n int) {
copy(dst, src[:n])
}
// blockXOR XORs numbers from dst with n numbers from src.
-func blockXOR(dst, src []uint32, n int) {
+func blockXOR(dst []uint32, src []uint32, n int) {
for i, v := range src[:n] {
dst[i] ^= v
}
@@ -430,7 +430,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 tmp and out.
-func salsaXOR(tmp *[16]uint32, in, out []uint32) {
+func salsaXOR(tmp *[16]uint32, in []uint32, out []uint32) {
w0 := tmp[0] ^ in[0]
w1 := tmp[1] ^ in[1]
w2 := tmp[2] ^ in[2]
@@ -542,7 +542,7 @@ func salsaXOR(tmp *[16]uint32, in, out []uint32) {
out[15], tmp[15] = x15, x15
}
-func blockMix(tmp *[16]uint32, in, out []uint32, r int) {
+func blockMix(tmp *[16]uint32, in []uint32, out []uint32, r int) {
blockCopy(tmp[:], in[(2*r-1)*16:], 16)
for i := 0; i < 2*r; i += 2 {
salsaXOR(tmp, in[i*16:], out[i*8:])
@@ -555,7 +555,7 @@ func integer(b []uint32, r int) uint64 {
return uint64(b[j]) | uint64(b[j+1])<<32
}
-func smix(b []byte, r, N int, v, xy []uint32) {
+func smix(b []byte, r int, N int, v []uint32, xy []uint32) {
var tmp [16]uint32
R := 32 * r
x := xy
@@ -605,7 +605,14 @@ func smix(b []byte, r, N int, v, xy []uint32) {
// 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 Scrypt(password, salt []byte, N, r, p, keyLen int) ([]byte, error) {
+func Scrypt(
+ password []byte,
+ salt []byte,
+ N int,
+ r int,
+ p int,
+ 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")
}