Pure Go library and CLI to access the Raspberry Pi's firmware cryptographic functions. The implementation was based on the utility rpifwcrypto. This CLI provides additional features such as signing JWTs and exporting public keys in JWKS or PEM format.
Usage:
go-rpi-crypto [flags]
go-rpi-crypto [command]
Available Commands:
completion Generate the autocompletion script for the specified shell
get-key-status Gets the status of a specified key
get-num-otp-keys Gets the number of OTP keys
help Help about any command
hmac Calculates HMAC-SHA256 of an input file
jwks Exports the public key as a JWKS document
jwt Signs a JWT using an OTP ECDSA key
pubkey Retrieves the public key in DER, PEM, or hex format
sign Signs a file hash using an OTP key
import (
"fmt"
"crypto/sha256"
"github.com/ezoidc/go-rpi-crypto/api"
)
func main() {
keyID := 1
data := []byte("data to sign")
hash := sha256.Sum256(data)
sigBytes, err := api.ECDSASign(0, uint32(keyID), hash[:])
if err != nil {
println("Error signing data:", err)
return
}
println("Signature:", fmt.Sprintf("%x", sigBytes))
}