mirror of
https://github.com/bpmforge/kryptkeeper.git
synced 2026-11-24 00:46:55 +00:00
6ca9f70072
Rebuilt from the private main after the 1.1.0 lab regression: ML-DSA verification needs Go 1.27, the hub image ships writable state directories for Docker volumes, issued leaves follow RFC 5280/8813 key usage, Opsgenie is deprecated, and LICENSE is the verbatim Apache text.
48 lines
1.3 KiB
Go
48 lines
1.3 KiB
Go
// Copyright 2026 Kryptkeeper Authors
|
|
//
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package est
|
|
|
|
import (
|
|
"bytes"
|
|
"crypto/ecdsa"
|
|
"crypto/elliptic"
|
|
"crypto/rand"
|
|
"crypto/x509"
|
|
"crypto/x509/pkix"
|
|
"encoding/base64"
|
|
"encoding/pem"
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"testing"
|
|
)
|
|
|
|
// FuzzParseCSRFromRequest feeds the RFC 7030 simpleenroll body parser (PEM,
|
|
// base64 DER or raw DER) the bytes a network client controls. A rejection is
|
|
// fine; a panic, or success with a nil request, is not.
|
|
func FuzzParseCSRFromRequest(f *testing.F) {
|
|
key, _ := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
|
|
der, err := x509.CreateCertificateRequest(rand.Reader, &x509.CertificateRequest{
|
|
Subject: pkix.Name{CommonName: "fuzz.example.com"},
|
|
DNSNames: []string{"fuzz.example.com"},
|
|
}, key)
|
|
if err != nil {
|
|
f.Fatal(err)
|
|
}
|
|
f.Add(der)
|
|
f.Add([]byte(base64.StdEncoding.EncodeToString(der)))
|
|
f.Add(pem.EncodeToMemory(&pem.Block{Type: "CERTIFICATE REQUEST", Bytes: der}))
|
|
f.Add([]byte("-----BEGIN CERTIFICATE REQUEST-----\n!!!\n-----END CERTIFICATE REQUEST-----\n"))
|
|
f.Add([]byte{})
|
|
|
|
s := &Server{}
|
|
f.Fuzz(func(t *testing.T, body []byte) {
|
|
r := httptest.NewRequest(http.MethodPost, "/.well-known/est/simpleenroll", bytes.NewReader(body))
|
|
csr, err := s.parseCSRFromRequest(r)
|
|
if err == nil && csr == nil {
|
|
t.Fatal("nil CSR with nil error")
|
|
}
|
|
})
|
|
}
|