mirror of
https://github.com/bpmforge/kryptkeeper.git
synced 2026-11-23 16:02:01 +00:00
5ebfc7dc3e
ML-DSA certificates are stored (signed-but-not-recorded on SQLite and PostgreSQL in 0.9.0); standard OpenSSL ML-DSA CSRs issue; ML-DSA CAs can be created; PQC readiness numbers share one definition; 400/409 instead of 503 on issue and renew; template issued counts; UI shows names instead of IDs. See CHANGELOG.md and docs/release/RELEASE_NOTES_v0.9.1.md.
53 lines
1.7 KiB
Go
53 lines
1.7 KiB
Go
// Copyright 2026 Kryptkeeper Authors
|
|
//
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package ca
|
|
|
|
import (
|
|
"encoding/asn1"
|
|
"fmt"
|
|
)
|
|
|
|
// csrInfoHead is CertificationRequestInfo (RFC 2986 §4) up to and including
|
|
// subjectPKInfo. Attributes are not declared: encoding/asn1 ignores unread
|
|
// trailing elements of a SEQUENCE, and this reader must not depend on them.
|
|
type csrInfoHead struct {
|
|
Version int `asn1:"default:0"`
|
|
Subject asn1.RawValue
|
|
PublicKey certSPKI
|
|
}
|
|
|
|
// CSRPublicKeyAlgorithmOID returns the subjectPKInfo algorithm OID of a
|
|
// PKCS#10 CertificationRequest DER without verifying anything. It exists so
|
|
// callers can route a CSR to the right parser deterministically, by the OID
|
|
// the structure itself declares, rather than by PEM label or by trying
|
|
// parsers in turn.
|
|
func CSRPublicKeyAlgorithmOID(der []byte) (asn1.ObjectIdentifier, error) {
|
|
var outer outerCSR
|
|
rest, err := asn1.Unmarshal(der, &outer)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("unmarshal CertificationRequest: %w", err)
|
|
}
|
|
if len(rest) != 0 {
|
|
return nil, fmt.Errorf("trailing data after CertificationRequest")
|
|
}
|
|
var head csrInfoHead
|
|
if _, err := asn1.Unmarshal(outer.CertificationRequestInfo.FullBytes, &head); err != nil {
|
|
return nil, fmt.Errorf("unmarshal CertificationRequestInfo: %w", err)
|
|
}
|
|
return head.PublicKey.Algorithm.Algorithm, nil
|
|
}
|
|
|
|
// IsMLDSACSR reports whether der declares an ML-DSA subject public key
|
|
// (FIPS 204 OIDs). Malformed DER reports false: it then takes the stdlib
|
|
// path, which rejects it with its own parse error.
|
|
func IsMLDSACSR(der []byte) bool {
|
|
oid, err := CSRPublicKeyAlgorithmOID(der)
|
|
if err != nil {
|
|
return false
|
|
}
|
|
_, ok := mldsaAlgoFromOID(oid)
|
|
return ok
|
|
}
|