Beispiel
golang.org/x/crypto v0.27.0: hkdf.Expand
Verifiziertes Beispiel für golang golang.org/x/crypto v0.27.0: hkdf.Expand. Der Vertrag lief auf go 1.26 · linux alpine/x64 · docker und bestand.
sha256:ee94fe6b48089ffd60ddd5c5014a7d8b4227db03a3a4da5526cd6989ab0b4597
Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen.
Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen.
MIT-0
Ausführungsbelege
Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.
- Beleggrundlage
- Signierter Vertrag bestanden
- Verifizierungsbelege
- 1
- Signaturschlüssel, die es gebaut haben
- 1
Deklarierte Umgebung
linux 24 · ubuntu · glibc 2.39 x64 go
Umgebungen der Verifizierungsläufe
| Umgebung | Contract | Stufen | Lauf |
|---|---|---|---|
| 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-30 |
Fall
HOW- Ziel
- verify golang.org/x/crypto/hkdf.Expand in pkg:golang/golang.org/x/crypto@v0.27.0
- Pakete
- Symbole
-
- golang.org/x/crypto/hkdf.Expand
- Erstellt
- 2026-08-30T17:31:24Z
Contract
- hkdf.Expand expands pseudorandom key into key stream matching RFC 5869 test vector
- hkdf.Expand with distinct info produces distinct key streams
- hkdf.Expand returns error when reading beyond 255 times hash size
- hkdf.Expand supports sequential reads matching single full read
Dateien
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- spec.json
- test/contract.go
Quelltext
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 golang.org/x/crypto/hkdf.Expand in pkg:golang/golang.org/x/crypto@v0.27.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/golang.org/x/crypto@v0.27.0
Demonstrate these symbols/APIs:
- golang.org/x/crypto/hkdf.Expand
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:05e6a98004fb4c7bd80dab47497f72e59c1faf35d6f748e05adacee7d940d80b","contract":["hkdf.Expand expands pseudorandom key into key stream matching RFC 5869 test vector","hkdf.Expand with distinct info produces distinct key streams","hkdf.Expand returns error when reading beyond 255 times hash size","hkdf.Expand supports sequential reads matching single full read"],"goal":"verify golang.org/x/crypto/hkdf.Expand in pkg:golang/golang.org/x/crypto@v0.27.0","kind":"HOW","packages":["pkg:golang/golang.org/x/crypto@v0.27.0"],"schemaVersion":1,"symbols":["golang.org/x/crypto/hkdf.Expand"]},"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.27.0"],"schemaVersion":1,"subject":"pkg:golang/golang.org/x/crypto@v0.27.0","symbols":["golang.org/x/crypto/hkdf.Expand"],"verifierAdapter":"golang@1"}
module example.com/sample
go 1.22
require golang.org/x/crypto v0.27.0
golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
package main
import (
"crypto/sha256"
"fmt"
"io"
"log"
"golang.org/x/crypto/hkdf"
)
func main() {
// Pseudorandom key (PRK) typically obtained from an extraction step or key exchange
prk := []byte{
0x07, 0x77, 0x09, 0x36, 0x2c, 0x2e, 0x32, 0xdf,
0x0d, 0xdc, 0x3f, 0x0d, 0xc4, 0x7b, 0xba, 0x63,
0x90, 0xb6, 0xc7, 0x3b, 0xb5, 0x0f, 0x9c, 0x31,
0x22, 0xec, 0x84, 0x4a, 0xd7, 0xc2, 0xb3, 0xe5,
}
info := []byte("example.com/sample/v1/aes-key")
// Expand the PRK into application-specific output keying material (OKM)
expandReader := hkdf.Expand(sha256.New, prk, info)
derivedKey := make([]byte, 32) // 256-bit AES key
if _, err := io.ReadFull(expandReader, derivedKey); err != nil {
log.Fatalf("Failed to expand key: %v", err)
}
fmt.Printf("Derived key: %x\n", derivedKey)
}
{
"schemaVersion": 1,
"goal": "verify golang.org/x/crypto/hkdf.Expand in pkg:golang/golang.org/x/crypto@v0.27.0",
"kind": "HOW",
"packages": [
"pkg:golang/golang.org/x/crypto@v0.27.0"
],
"symbols": [
"golang.org/x/crypto/hkdf.Expand"
]
}
package main
import (
"bytes"
"crypto/sha256"
"encoding/hex"
"fmt"
"io"
"os"
"golang.org/x/crypto/hkdf"
)
func main() {
// RFC 5869 Test Case 1 (SHA-256)
prk1, _ := hex.DecodeString("077709362c2e32df0ddc3f0dc47bba6390b6c73bb50f9c3122ec844ad7c2b3e5")
info1, _ := hex.DecodeString("f0f1f2f3f4f5f6f7f8f9")
expectedOKM1, _ := hex.DecodeString("3cb25f25faacd57a90434f64d0362f2a2d2d0a90cf1a5a4c5db02d56ecc4c5bf34007208d5b887185865")
// 1. hkdf.Expand expands pseudorandom key into key stream matching RFC 5869 test vector
expandReader1 := hkdf.Expand(sha256.New, prk1, info1)
okm1 := make([]byte, len(expectedOKM1))
if _, err := io.ReadFull(expandReader1, okm1); err != nil {
fmt.Fprintf(os.Stderr, "hkdf.Expand read failed: %v\n", err)
os.Exit(1)
}
if !bytes.Equal(okm1, expectedOKM1) {
fmt.Fprintf(os.Stderr, "hkdf.Expand OKM mismatch: got %x, want %x\n", okm1, expectedOKM1)
os.Exit(1)
}
// 2. hkdf.Expand with distinct info produces distinct key streams
expandReader2A := hkdf.Expand(sha256.New, prk1, info1)
expandReader2B := hkdf.Expand(sha256.New, prk1, []byte("different info parameter"))
bufA := make([]byte, 32)
bufB := make([]byte, 32)
if _, err := io.ReadFull(expandReader2A, bufA); err != nil {
fmt.Fprintf(os.Stderr, "expandReader2A read failed: %v\n", err)
os.Exit(1)
}
if _, err := io.ReadFull(expandReader2B, bufB); err != nil {
fmt.Fprintf(os.Stderr, "expandReader2B read failed: %v\n", err)
os.Exit(1)
}
if bytes.Equal(bufA, bufB) {
fmt.Fprintf(os.Stderr, "hkdf.Expand produced identical output for different info\n")
os.Exit(1)
}
// 3. hkdf.Expand returns error when reading beyond 255 times hash size
maxBytes := 255 * sha256.Size // 8160 bytes for SHA-256
limitReader := hkdf.Expand(sha256.New, prk1, info1)
maxBuf := make([]byte, maxBytes)
if _, err := io.ReadFull(limitReader, maxBuf); err != nil {
fmt.Fprintf(os.Stderr, "Failed to read max allowed HKDF bytes (%d): %v\n", maxBytes, err)
os.Exit(1)
}
extraByte := make([]byte, 1)
if _, err := limitReader.Read(extraByte); err == nil {
fmt.Fprintf(os.Stderr, "hkdf.Expand unexpectedly allowed reading beyond 255 * hash.Size\n")
os.Exit(1)
}
// 4. hkdf.Expand supports sequential reads matching single full read
seqReader := hkdf.Expand(sha256.New, prk1, info1)
part1 := make([]byte, 10)
part2 := make([]byte, 16)
part3 := make([]byte, len(expectedOKM1)-26)
if _, err := io.ReadFull(seqReader, part1); err != nil {
fmt.Fprintf(os.Stderr, "seqReader part1 failed: %v\n", err)
os.Exit(1)
}
if _, err := io.ReadFull(seqReader, part2); err != nil {
fmt.Fprintf(os.Stderr, "seqReader part2 failed: %v\n", err)
os.Exit(1)
}
if _, err := io.ReadFull(seqReader, part3); err != nil {
fmt.Fprintf(os.Stderr, "seqReader part3 failed: %v\n", err)
os.Exit(1)
}
combined := append(append(part1, part2...), part3...)
if !bytes.Equal(combined, expectedOKM1) {
fmt.Fprintf(os.Stderr, "Sequential reads mismatch with single read: got %x, want %x\n", combined, expectedOKM1)
os.Exit(1)
}
fmt.Println("All contract assertions passed.")
}
Ursprungs-Seeder
anonym