Why a CBOM leaves classicalSecurityLevel out instead of interpolating it
A CycloneDX cryptography bill of materials has one field for key size and a separate field for security strength in bits. The two are not the same number. An inventory tool that fills the strength field by scaling the key size hands every downstream reader a figure no standard ever published, and that includes whoever is sizing a post-quantum migration off the document. Nothing in the serialized output marks it as derived.
I hit this while writing cbomscope, which reads the cryptography in Go sources and in what a TLS endpoint actually negotiates, then writes it out as a CycloneDX 1.6 CBOM. People expect the classification half to be the hard part. The thing that took me the most deciding was a single int.
Two fields that look like one#
The block comes straight out of the spec. The comment in internal/cbom/cbom.go exists because I kept confusing the two fields myself:
// AlgorithmProperties describes one algorithm the way CycloneDX 1.6 defines it.
// Every field keeps its spec meaning: parameterSetIdentifier names the variant
// that was used, and classicalSecurityLevel is strength in bits, which is a
// different number from the key size.
type AlgorithmProperties struct {
Primitive string `json:"primitive,omitempty"`
ParameterSetIdentifier string `json:"parameterSetIdentifier,omitempty"`
Curve string `json:"curve,omitempty"`
Mode string `json:"mode,omitempty"`
ClassicalSecurityLevel int `json:"classicalSecurityLevel,omitempty"`
NISTQuantumSecurityLevel int `json:"nistQuantumSecurityLevel,omitempty"`
}The two numbers come from different places, and the code keeps them apart:
func algorithmProperties(a asset.Asset) *AlgorithmProperties {
props := &AlgorithmProperties{
Primitive: string(a.Primitive),
Curve: a.Curve,
Mode: string(a.Mode),
ClassicalSecurityLevel: classicalSecurityLevel(a),
NISTQuantumSecurityLevel: quantumSecurityLevel(a),
}
if a.KeySize > 0 {
props.ParameterSetIdentifier = strconv.Itoa(a.KeySize)
}
return props
}ParameterSetIdentifier is an observation. The size was read off a function name, an elliptic.P256() argument, a cipher suite string, or a certificate's modulus. If it is above zero it goes in, converted and nothing more. ClassicalSecurityLevel is a claim about how much work an attacker does, and you cannot observe that in source code. It has to be looked up, or derived from the mathematics of the family, or left alone.
For AES-128 both numbers are 128, which is exactly why they get conflated. For almost everything else they are not.
3DES, where the rule outranks the size#
classicalSecurityLevel starts by normalizing the name through a helper that upper-cases it and prefers the Algorithm field over the Name field, so a negotiated suite string and a crypto/des call land on the same token. Then, before it looks at any size at all:
func classicalSecurityLevel(a asset.Asset) int {
name := family(a)
if strings.HasPrefix(name, "3DES") || strings.Contains(name, "TRIPLEDES") {
// Meet-in-the-middle costs two encryptions, not three.
return 112
}
if a.KeySize == 0 {
return 0
}
switch {
case strings.HasPrefix(name, "RSA"),
strings.HasPrefix(name, "DSA"),
strings.HasPrefix(name, "DH"):
return modulusStrength[a.KeySize]
case strings.HasPrefix(name, "EC"),
strings.HasPrefix(name, "ED"),
strings.HasPrefix(name, "X25519"),
strings.HasPrefix(name, "X448"):
return a.KeySize / 2
}
switch a.Primitive {
case asset.BlockCipher, asset.AE, asset.MAC:
return a.KeySize
}
return 0
}The ordering is what I find interesting here. Both the source scanner and the TLS probe record three-key EDE as 168 bits of key. That is genuinely how much key there is, and it is what crypto/des's NewTripleDESCipher and a 3DES cipher suite both imply. But 3DES is a block cipher, and if it fell through to the asset.BlockCipher branch the document would report 168 bits of strength. The real figure is 112, because a meet-in-the-middle attack buys back one of the three encryptions. Fifty-six bits of error, in the optimistic direction: the direction that gets a migration deadline pushed out a year.
So the family check sits above the size lookup, and the comment says why. This is the one case in the tool where a name beats a measurement, and it earns that by being a theorem rather than a convention.
The table has five rows, and that is all it has#
RSA, DSA and finite-field DH do not get a formula. They get a lookup:
// modulusStrength pairs a modulus size with the strength NIST SP 800-57 gives
// it. Sizes between the published rows are not interpolated.
var modulusStrength = map[int]int{
1024: 80,
2048: 112,
3072: 128,
7680: 192,
15360: 256,
}Five pairs. That is what the standard states, and a Go map returns the zero value for a missing key, so a modulus outside those five reads as no answer rather than a nearby one.
This is not hypothetical, because the probe does not get to choose its inputs. When it reads a leaf certificate it takes the modulus straight from the key:
case *rsa.PublicKey:
key.Algorithm, key.KeySize = "RSA", pub.N.BitLen()
key.Name = fmt.Sprintf("RSA-%d", key.KeySize)A 4096-bit RSA certificate is ordinary. It is also not a row in SP 800-57. So it ships like this:
{
"name": "RSA-4096",
"cryptoProperties": {
"assetType": "algorithm",
"algorithmProperties": {
"primitive": "signature",
"parameterSetIdentifier": "4096"
}
},
"properties": [
{"name": "cbomscope:posture", "value": "quantum_vulnerable"}
]
}The size is there because it was observed. The strength is absent because nobody published it. I could have put 140-something in that field by drawing a line between 3072 and 7680, and the document would have looked more complete and been worth less.
Curves get a formula, hashes get nothing#
Elliptic families are the one place a division is defensible: a prefix of EC, ED, X25519 or X448 returns KeySize / 2, because the best known classical attack on a well-chosen curve group is generic and square-root. P-256 reads as 128, Ed25519 as 128, P-384 as 192. That is a property of the family rather than a row somebody tabulated, so it survives sizes the standard never enumerated.
After that, only three primitives return the key size itself: asset.BlockCipher, asset.AE and asset.MAC. Everything else returns zero, and hashes sit in "everything else" on purpose, even though SHA-256 is wearing its size in its name. A digest does not have one classical strength. It has collision resistance at roughly half the output and preimage resistance at roughly the full output, and a single integer cannot say which one it means. So the CBOM says neither.
It does still carry the quantum side, which is a lookup from a small table of named parameter sets: ten entries, where ML-KEM-768 is category 3 and SHA-256 is category 2, plus AES at 128, 192 and 256 bits mapping to 1, 3 and 5. So the SHA-256 the tool finds in its own source comes out looking like this, with the quantum field populated and the classical field simply gone:
{
"cryptoProperties": {
"assetType": "algorithm",
"algorithmProperties": {
"primitive": "hash",
"nistQuantumSecurityLevel": 2
}
},
"properties": [
{"name": "cbomscope:posture", "value": "quantum_reduced"}
],
"evidence": {"occurrences": [{"location": "internal/cbom/cbom.go:137"}]}
}Zero is the sentinel, omitempty is the eraser#
Nothing in the computation knows about absence. Both functions return int, and both return 0 when they cannot source an answer. The erasure happens in the struct tags: classicalSecurityLevel,omitempty and nistQuantumSecurityLevel,omitempty, so a zero never reaches the file.
Collapsing "unknown" onto "zero" is usually a bug waiting to happen. It is safe here for a specific reason: zero bits of security strength and NIST category zero are not values anyone would ever report. The sentinel cannot collide with a real reading. If the field were a count, or a fee, or a retry number, the same shape would be indefensible, and I have spent enough years on money systems to have seen what a zero-as-missing does to a reconciliation report.
The same discipline shows up one level out, where the quantum posture is written as cbomscope:posture in the generic properties array instead of into a spec field. The reason is recorded in the code: CycloneDX has no field for it, and inventing a meaning for a standard field would make the document lie to anything that reads it by the spec. Absence and namespacing are the two ways a document declines to overstate what it knows.
The cost, and why I pay it#
A CBOM full of holes looks like a tool that did not finish. Open one and you will find components with a parameter set and no strength, hashes with a quantum category and no classical level, and a 4096-bit key that the document declines to grade. That reads as a gap, and gaps invite someone to go fill them.
The asymmetry is what settles it for me. A reader who finds the field missing can open SP 800-57 and have the number in a minute, or decide the question does not matter for their purposes. A reader who finds the field present has no way, ever, to tell an interpolated number from a cited one: the serialized integer carries no provenance, and the document will be diffed, attached to a release, and read by people who were not in the room. One of those failures is recoverable by the reader. The other is not.
What I would change#
Not the table. Widening it would mean inventing rows, and the whole argument above says not to.
What I would add is provenance for the absence. Right now an omitted classicalSecurityLevel means one of two things, either the standard has no row for this size or the primitive is one where a single integer would be meaningless, and the file does not distinguish them. The tool knows which. The reader of the JSON does not. A namespaced property recording why the level is absent would cost one more string per component and would turn a hole into a statement. That is probably the honest fix: not a number, a note.
An inventory is worth exactly what its weakest field is worth. Leaving one empty is cheaper than making one up.