Open hugolgst opened 1 year ago
Does this reproduce for native code or any other platform?
@dgryski The code works well on my machine but does not either on the board I am adding to TinyGo nor the Raspberry Pico.
I am struggling to reproduce the issue on the RP2040 (pico). I've come up with the following:
package main
import (
"crypto/sha512"
"time"
"golang.org/x/crypto/pbkdf2"
)
func main() {
const last = 4 * 256
time.Sleep(time.Second)
println("start program")
var (
salt = []byte("add some salt and pepper")
)
for i := 0; i < 10000; i++ {
b := make([]byte, last+i)
for j := 0; j < last+i; j++ {
b[j] = byte(i)
}
b = pbkdf2.Key(b, salt, 2048, 64, sha512.New)
println(string(b))
time.Sleep(time.Second / 4)
}
}
This is a Go program that generates and prints 10,000 PBKDF2 hashed keys. PBKDF2 is a key derivation function that is used to generate cryptographic keys from a password. In this program, the PBKDF2 function takes a byte slice and a salt as inputs, along with a few other parameters like the number of iterations and the length of the output key. The program generates a byte slice of increasing length on each iteration and hashes it using PBKDF2. The resulting hash is printed to the console, and the program waits for a quarter of a second before continuing to the next iteration.
Hello,
I am building on ATSAMD21E18A and for some reason when I use
sha512.New
inpbkdf2.Key
, my program crashes and prints a single "f" in the logs. I tried usingsha256
and it works perfectly.I identified that the problem happens when
pbkdf2.Key
is calling theSum
function, here: https://cs.opensource.google/go/x/crypto/+/refs/tags/v0.7.0:pbkdf2/pbkdf2.go;l=61 https://cs.opensource.google/go/go/+/refs/tags/go1.20.2:src/crypto/sha512/sha512.go;l=282I cannot seem to get more information on this issue, anyone got an idea? Thank you in advance
–hugo