Ejemplo
golang.org/x/crypto v0.19.0: pbkdf2.Key
Muestra verificada para golang golang.org/x/crypto v0.19.0: pbkdf2.Key. El contrato se ejecutó en go 1.26 · linux alpine/x64 · docker y pasó.
sha256:ba54b8a7fafbfb2b14b0e0a029bc954e8db4ecd5c4ad5f25b62d77bb58507eac
Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido.
Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas.
MIT-0
Evidencia de ejecución
El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.
- Base de evidencia
- Contrato firmado aprobado
- Recibos de verificación
- 1
- Claves de firma que lo compilaron
- 1
Entorno declarado
linux 24 · ubuntu · glibc 2.39 x64 go
Entornos de las ejecuciones de verificación
| Entorno | Contrato | Etapas | Ejecución |
|---|---|---|---|
| go 1.26 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · golang@1golang:1.26-alpine@sha256:28d89ee9cc0f… |
2026-08-27 |
Caso
HOW- Objetivo
- verify pbkdf2.Key in pkg:golang/golang.org/x/crypto@v0.19.0
- Paquetes
- Símbolos
-
- pbkdf2.Key
- Creado
- 2026-08-27T12:50:08Z
Contrato
- pbkdf2.Key derives deterministic key bytes matching the specified key length
- pbkdf2.Key produces different derived keys for different passwords with identical salt and iteration count
- pbkdf2.Key produces different derived keys for different salts with identical password and iteration count
- pbkdf2.Key produces different derived keys when iteration count is varied
- pbkdf2.Key matches RFC 6070 test vector output for PBKDF2 with HMAC-SHA1
- pbkdf2.Key matches PBKDF2 test vector output for HMAC-SHA256
Archivos
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- spec.json
- test/contract.go
Código fuente
Clean-room public code sample — generation instructions
Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.
A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.
Goal: verify pbkdf2.Key in pkg:golang/golang.org/x/crypto@v0.19.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/golang.org/x/crypto@v0.19.0
Demonstrate these symbols/APIs:
- pbkdf2.Key
Rules:
- One focused purpose; the smallest project that proves the goal.
- Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
- Pin every dependency with a lockfile so resolution is reproducible.
- No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
- No personal names, emails, company names, or project identifiers of any kind.
- No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
- Keep it under 200 files and 256KB packed.
{"case":{"caseId":"case:sha256:caa8bbe930dcc2d09e52141165eae9c1b8810298d24ea7d98384b2c37a0280fe","contract":["pbkdf2.Key derives deterministic key bytes matching the specified key length","pbkdf2.Key produces different derived keys for different passwords with identical salt and iteration count","pbkdf2.Key produces different derived keys for different salts with identical password and iteration count","pbkdf2.Key produces different derived keys when iteration count is varied","pbkdf2.Key matches RFC 6070 test vector output for PBKDF2 with HMAC-SHA1","pbkdf2.Key matches PBKDF2 test vector output for HMAC-SHA256"],"goal":"verify pbkdf2.Key in pkg:golang/golang.org/x/crypto@v0.19.0","kind":"HOW","packages":["pkg:golang/golang.org/x/crypto@v0.19.0"],"schemaVersion":1,"symbols":["pbkdf2.Key"]},"contractCommand":["go","run","./test"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"golang","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"go","schemaVersion":1},"license":"MIT-0","packages":["pkg:golang/golang.org/x/crypto@v0.19.0"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/crypto@v0.19.0","symbols":["pbkdf2.Key"],"verifierAdapter":"golang@1"}
module example.com/sample
go 1.26.6
require golang.org/x/crypto v0.19.0 // indirect
golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo=
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
package main
import (
"crypto/sha256"
"encoding/hex"
"fmt"
"golang.org/x/crypto/pbkdf2"
)
func main() {
password := []byte("example-passphrase")
salt := []byte("random-salt-bytes")
iterations := 10000
keyLen := 32 // 256 bits
// Derive a 32-byte key using PBKDF2 with HMAC-SHA256
derivedKey := pbkdf2.Key(password, salt, iterations, keyLen, sha256.New)
fmt.Printf("Derived key (%d bytes): %s\n", len(derivedKey), hex.EncodeToString(derivedKey))
}
{
"schemaVersion": 1,
"goal": "verify pbkdf2.Key in pkg:golang/golang.org/x/crypto@v0.19.0",
"kind": "HOW",
"packages": [
"pkg:golang/golang.org/x/crypto@v0.19.0"
],
"symbols": [
"pbkdf2.Key"
]
}
package main
import (
"bytes"
"crypto/sha1"
"crypto/sha256"
"encoding/hex"
"fmt"
"os"
"golang.org/x/crypto/pbkdf2"
)
func main() {
password := []byte("password")
salt := []byte("salt")
// 1. pbkdf2.Key derives deterministic key bytes matching the specified key length
key1 := pbkdf2.Key(password, salt, 1000, 32, sha256.New)
key2 := pbkdf2.Key(password, salt, 1000, 32, sha256.New)
if len(key1) != 32 {
fmt.Fprintf(os.Stderr, "Expected key length 32, got %d\n", len(key1))
os.Exit(1)
}
if !bytes.Equal(key1, key2) {
fmt.Fprintf(os.Stderr, "pbkdf2.Key is not deterministic for identical inputs\n")
os.Exit(1)
}
key64 := pbkdf2.Key(password, salt, 1000, 64, sha256.New)
if len(key64) != 64 {
fmt.Fprintf(os.Stderr, "Expected key length 64, got %d\n", len(key64))
os.Exit(1)
}
// 2. pbkdf2.Key produces different derived keys for different passwords with identical salt and iteration count
diffPassKey := pbkdf2.Key([]byte("different-password"), salt, 1000, 32, sha256.New)
if bytes.Equal(key1, diffPassKey) {
fmt.Fprintf(os.Stderr, "pbkdf2.Key produced identical keys for different passwords\n")
os.Exit(1)
}
// 3. pbkdf2.Key produces different derived keys for different salts with identical password and iteration count
diffSaltKey := pbkdf2.Key(password, []byte("different-salt"), 1000, 32, sha256.New)
if bytes.Equal(key1, diffSaltKey) {
fmt.Fprintf(os.Stderr, "pbkdf2.Key produced identical keys for different salts\n")
os.Exit(1)
}
// 4. pbkdf2.Key produces different derived keys when iteration count is varied
diffIterKey := pbkdf2.Key(password, salt, 2000, 32, sha256.New)
if bytes.Equal(key1, diffIterKey) {
fmt.Fprintf(os.Stderr, "pbkdf2.Key produced identical keys for different iteration counts\n")
os.Exit(1)
}
// 5. pbkdf2.Key matches RFC 6070 test vector output for PBKDF2 with HMAC-SHA1
// RFC 6070 test vector 1: P="password", S="salt", c=1, dkLen=20
// DK = 0c60c80f961f0e71f3a9b524af6012062fe037a6
rfcVec1 := pbkdf2.Key([]byte("password"), []byte("salt"), 1, 20, sha1.New)
expectedRfc1, _ := hex.DecodeString("0c60c80f961f0e71f3a9b524af6012062fe037a6")
if !bytes.Equal(rfcVec1, expectedRfc1) {
fmt.Fprintf(os.Stderr, "RFC 6070 vector 1 mismatch: got %x, want %x\n", rfcVec1, expectedRfc1)
os.Exit(1)
}
// RFC 6070 test vector 2: P="password", S="salt", c=2, dkLen=20
// DK = ea6c014dc72d6f8ccd1ed92ace1d41f0d8de8957
rfcVec2 := pbkdf2.Key([]byte("password"), []byte("salt"), 2, 20, sha1.New)
expectedRfc2, _ := hex.DecodeString("ea6c014dc72d6f8ccd1ed92ace1d41f0d8de8957")
if !bytes.Equal(rfcVec2, expectedRfc2) {
fmt.Fprintf(os.Stderr, "RFC 6070 vector 2 mismatch: got %x, want %x\n", rfcVec2, expectedRfc2)
os.Exit(1)
}
// RFC 6070 test vector 3: P="password", S="salt", c=4096, dkLen=20
// DK = 4b007901b765489abead49d926f721d065a429c1
rfcVec3 := pbkdf2.Key([]byte("password"), []byte("salt"), 4096, 20, sha1.New)
expectedRfc3, _ := hex.DecodeString("4b007901b765489abead49d926f721d065a429c1")
if !bytes.Equal(rfcVec3, expectedRfc3) {
fmt.Fprintf(os.Stderr, "RFC 6070 vector 3 mismatch: got %x, want %x\n", rfcVec3, expectedRfc3)
os.Exit(1)
}
// 6. pbkdf2.Key matches PBKDF2 test vector output for HMAC-SHA256
// SHA256 test vector 1: P="password", S="salt", c=1, dkLen=32
// DK = 120fb6cffcf8b32c43e7225256c4f837a86548c92ccc35480805987cb70be17b
sha256Vec1 := pbkdf2.Key([]byte("password"), []byte("salt"), 1, 32, sha256.New)
expectedSha256Vec1, _ := hex.DecodeString("120fb6cffcf8b32c43e7225256c4f837a86548c92ccc35480805987cb70be17b")
if !bytes.Equal(sha256Vec1, expectedSha256Vec1) {
fmt.Fprintf(os.Stderr, "HMAC-SHA256 vector 1 mismatch: got %x, want %x\n", sha256Vec1, expectedSha256Vec1)
os.Exit(1)
}
// SHA256 test vector 2: P="password", S="salt", c=2, dkLen=32
// DK = ae4d0c95af6b46d32d0adff928f06dd02a303f8ef3c251dfd6e2d85a95474c43
sha256Vec2 := pbkdf2.Key([]byte("password"), []byte("salt"), 2, 32, sha256.New)
expectedSha256Vec2, _ := hex.DecodeString("ae4d0c95af6b46d32d0adff928f06dd02a303f8ef3c251dfd6e2d85a95474c43")
if !bytes.Equal(sha256Vec2, expectedSha256Vec2) {
fmt.Fprintf(os.Stderr, "HMAC-SHA256 vector 2 mismatch: got %x, want %x\n", sha256Vec2, expectedSha256Vec2)
os.Exit(1)
}
// SHA256 test vector 3: P="password", S="salt", c=4096, dkLen=32
// DK = c5e478d59288c841aa530db6845c4c8d962893a001ce4e11a4963873aa98134a
sha256Vec3 := pbkdf2.Key([]byte("password"), []byte("salt"), 4096, 32, sha256.New)
expectedSha256Vec3, _ := hex.DecodeString("c5e478d59288c841aa530db6845c4c8d962893a001ce4e11a4963873aa98134a")
if !bytes.Equal(sha256Vec3, expectedSha256Vec3) {
fmt.Fprintf(os.Stderr, "HMAC-SHA256 vector 3 mismatch: got %x, want %x\n", sha256Vec3, expectedSha256Vec3)
os.Exit(1)
}
fmt.Println("All contract assertions passed.")
}
Seeder de origen
anónimo