Documentation
¶
Overview ¶
Package algo is the catalogue of cryptographic algorithms the program is allowed to put in a CBOM: a total lookup table from a canonical algorithm ID to its CycloneDX representation.
CycloneDX enumerations are closed, and a single out-of-vocabulary value invalidates the whole document. So plugins never hand-write algorithm components: they ask this package for one by ID. An algorithm that is not in the catalogue cannot be emitted, and every field that has no authoritative source for an entry is left unset (and therefore omitted from the output).
Index ¶
- Constants
- func CurveStrength(curve string) (int, bool)
- func ECCStrength(orderBits int) int
- func FFCStrength(bits int) int
- func GNFSEstimate(bits int) float64
- func HMACStrength(hash string) (int, bool)
- func HashStrength(hash string) (bits int, broken bool)
- func IFCStrength(bits int) int
- func RoundToEight(e float64) int
- func SignatureParts(name string) (hash, key string, ok bool)
- func SymmetricStrength(cipher string, keyBits int) (bits int, broken bool)
- type Algorithm
- type Class
- type Legacy
- type Strength
Constants ¶
const ( ClassAsymmetric = "asymmetric" ClassSymmetric = "symmetric" ClassHash = "hash" RoleKeyExchange = "key exchange" RoleSignature = "signature" RoleCipher = "cipher" RoleMAC = "MAC" RoleHash = "hash" )
The three classes an algorithm belongs to (PRD-011 §2), and the roles within them.
const ( StrengthRated = "rated" StrengthDisallowed = "disallowed" StrengthBroken = "broken" StrengthNotRated = "not-rated" )
The statuses of a Strength.
const MaxStrength = 256
MaxStrength is the largest security strength NIST assigns (SP 800-57 Part 1 Table 2).
Variables ¶
This section is empty.
Functions ¶
func CurveStrength ¶ added in v0.4.0
CurveStrength is ECCStrength for a named curve; false when the curve is not one listed above.
func ECCStrength ¶ added in v0.4.0
ECCStrength is the classical security strength of elliptic-curve cryptography whose base point has an order of orderBits bits: about half the bit length (SP 800-186 section 3; the work of Pollard's rho), taken to the nearest of the strengths SP 800-186 Table 1 assigns. That reproduces every row of the table: P-224 (224 → 112), K-233 (232 → 116 → 112), P-256 (128), Curve25519 (253 → 126.5 → 128), K-283 (281 → 140.5 → 128), P-384 (192), K-409 (407 → 203.5 → 192), Curve448 (446 → 223 → 224), P-521 (521 → 260.5 → 256), K-571 (570 → 285 → 256). Rounding to a multiple of eight, as for RSA, would not: K-233 would read 120.
func FFCStrength ¶ added in v0.4.0
FFCStrength is the classical security strength of finite-field Diffie-Hellman (or DSA) with a prime of bits bits. NIST uses the same GNFS estimate (SP 800-56A Rev. 3 Table 26). The private key must also be at least twice the strength; the named groups (RFC 7919, RFC 3526) meet that.
func GNFSEstimate ¶ added in v0.4.0
GNFSEstimate is E(L), the work in bits of factoring an L-bit RSA modulus, or of computing a discrete logarithm in an L-bit prime field, with the General Number Field Sieve:
E(L) = ( 1.923 · ∛(L·ln 2) · ∛( (ln(L·ln 2))² ) − 4.69 ) / ln 2
This is the heuristic GNFS running time exp((64/9)^⅓ · (ln N)^⅓ · (ln ln N)^⅔), with (64/9)^⅓ ≈ 1.923 and ln N = L·ln 2, converted to bits; the constant 4.69 calibrates it so that L = 1024 gives 80 bits, the strength SP 800-57 assigns to 1024-bit RSA.
func HMACStrength ¶ added in v0.4.0
HMACStrength is SP 800-57 Part 1 Table 3's strength for HMAC (and KDFs) with the hash, assuming a key at least that strong: SHA-1 128, SHA-224 192, SHA-256 and longer 256.
func HashStrength ¶ added in v0.4.0
HashStrength gives the strength of a hash function where collision resistance is needed (digital signatures, certificate signatures): half the output length, and SHA-1 below 80 bits because of published collision attacks (SP 800-57 Part 1 Table 3, footnote 74). MD5 is broken (RFC 6151). HMACStrength is the strength in HMAC and key derivation, from the same table.
func IFCStrength ¶ added in v0.4.0
IFCStrength is the classical security strength of an RSA key with a modulus of bits bits, held to MaxStrength: the formula keeps climbing (15360 bits gives 262.6 → 264), but NIST assigns no strength above 256 (SP 800-57 Part 1 Table 2 lists k = 15360 at 256).
func RoundToEight ¶ added in v0.4.0
RoundToEight is NIST's rounding of an estimate to a security strength: "the value of E will be rounded to the nearest integer multiple of eight" (SP 800-56B Rev. 2 Appendix D).
func SignatureParts ¶ added in v0.4.0
SignatureParts splits a signature algorithm into its hash (in the catalogue's spelling, SHA-256) and its key algorithm (RSA, ECDSA, DSA). Ed25519, Ed448, ML-DSA and SLH-DSA are not split: their hash is part of their definition.
func SymmetricStrength ¶ added in v0.4.0
SymmetricStrength gives the classical strength of a symmetric cipher from SP 800-57 Part 1 Table 2, or the key-search bound for one NIST no longer lists. Broken reports a cipher whose strength is below anything NIST approves (under 80 bits) or that has a cited practical break; it then has no strength to compare, only the reason.
AES-128/192/256: 128/192/256 (Table 2) 3TDEA: 112 (Table 2; deprecated through 2023, then disallowed, SP 800-131A Rev. 2) 2TDEA: 80 (Table 2) DES: 56-bit key, exhaustive key search: broken RC4: broken (RFC 7465), whatever its key length ChaCha20: 256-bit key (RFC 8439); NIST does not list it, so this is the key length, stated as such
Types ¶
type Algorithm ¶
type Algorithm struct {
// ID is the canonical name; it becomes the component name, e.g. "ML-KEM-768".
ID string
// Primitive is the CycloneDX cryptographic primitive.
Primitive cdx.CryptoPrimitive
// OID is the dotted object identifier, or "" when no single authoritative
// OID identifies this algorithm (e.g. ECDSA and AES have none of their own).
OID string
// ParameterSet is the CycloneDX parameterSetIdentifier: the key or parameter
// size that distinguishes one variant of a family from another ("128" for
// AES-128-GCM). Empty for an entry that is a whole family.
ParameterSet string
// Mode is the block-cipher / AEAD mode of operation, when the entry names one.
Mode cdx.CryptoAlgorithmMode
// Curve is the SECG name of the elliptic curve an entry is defined on (RFC 5480
// section 2.1.1.1), for an entry that is one curve of a family: ECDH-P256 is ECDH on
// secp256r1. Empty otherwise.
Curve string
// QuantumLevel is the NIST PQC security category (1-5) that the algorithm's
// defining standard assigns to it, or 0 when no standard asserts one. It is
// never inferred: 0 means "omit nistQuantumSecurityLevel".
QuantumLevel int
// NoPQCVerdict, when set, is the reason this algorithm is deliberately given no
// post-quantum verdict (the question is not a quantum one, or no citation supports
// one). Every other algorithm MUST match a rule in internal/pqc, and a test enforces
// both directions, so forgetting a verdict fails and choosing none is written down.
NoPQCVerdict string
// Legacy, when set, says the algorithm is retired or broken for CLASSICAL
// reasons, with the source. It is separate from the post-quantum verdict: a broken
// hash is not "quantum-vulnerable", it is unsafe against today's computers.
Legacy *Legacy
}
Algorithm is one catalogue entry.
func MustGet ¶
MustGet is Lookup for IDs that are compile-time constants in plugin tables; an unknown ID is a programming error.
func (Algorithm) Asset ¶
func (a Algorithm) Asset() collector.CryptoAsset
Asset renders the algorithm as a finding a collector can return.
type Class ¶ added in v0.4.0
Class is an algorithm's class and its role within it. The zero value means the name is not one this program knows.
func ClassOf ¶ added in v0.4.0
ClassOf is the class of an algorithm by any name this program gives it: a catalogue ID, a derived size or curve variant (RSA-2048, ECDSA-P256, DSA-2048), a TLS group name (x25519, secp256r1, ffdhe2048, X25519MLKEM768) or a signature algorithm in any common spelling.
func ClassOfPrimitive ¶ added in v0.4.0
func ClassOfPrimitive(p cdx.CryptoPrimitive) Class
ClassOfPrimitive maps a CycloneDX primitive to its class (PRD-011 §2).
type Legacy ¶
Legacy is a cited statement that an algorithm is retired or broken, with the citation. Only what the cited source itself says may be put in Summary.
type Strength ¶ added in v0.4.0
type Strength struct {
// Bits is the security strength, 0 when Status is not rated or broken.
Bits int `json:"bits,omitempty"`
// Status is rated, disallowed (rated, but NIST no longer allows it for protection), broken (a
// cited practical break, or below anything NIST rates) or not-rated (no source gives a strength
// for it, or it depends on a size or parameter not known here).
Status string `json:"status"`
// Basis is the source, or the reason for the status.
Basis string `json:"basis"`
}
Strength is the classical security strength of one algorithm as this program states it (PRD-010 REQ-STR-1): a number of bits with the source it comes from, or a reason there is none.
func GroupStrength ¶ added in v0.4.0
GroupStrength is the classical strength of a TLS supported group (IANA name) or an SSH key exchange method's group: named curves by SP 800-186, RFC 7919 and RFC 3526 finite-field groups by the GNFS estimate of their prime, ML-KEM and the hybrids as in StrengthOf.
func HashKDFStrength ¶ added in v0.4.0
HashKDFStrength rates a hash where it is used in HMAC, a KDF or a PRF (the TLS PRF and HKDF), not where collisions matter: SP 800-57 Part 1 Rev. 5 Table 3 rates that use separately.
func KeyStrength ¶ added in v0.4.0
KeyStrength is the classical strength of a public key: RSA by its modulus (GNFS), DSA and DH by their prime (GNFS), EC by its curve (SP 800-186), Ed25519 and Ed448 by theirs, ML-DSA by its parameter set. A key of unknown size is not rated.
func SignatureStrength ¶ added in v0.4.0
SignatureStrength rates a signature algorithm as the weaker of its hash's collision strength (SP 800-57 Part 1 Table 3) and its key (PRD-011 REQ-CLS-3). key is the signer's key strength when it is known; without it the hash alone is rated and the basis says the key was not given. A name that is not a hash-and-key signature is rated as StrengthOf rates it.
func StrengthOf ¶ added in v0.4.0
StrengthOf is the classical strength of an algorithm by the name this program gives it: a catalogue ID, a size or curve variant it derives (RSA-2048, ECDSA-P256, DSA-2048), or a certificate signature variant (ecdsa-with-SHA256). It never guesses: a name it does not know is not rated.