↓ Skip to main content
Security

Where is my crypto?

Getting ready for quantum computers - This article is part of a series.
Part 4: This Article
In part 1 I admitted that I couldn’t list the cryptography in my own projects. An SBOM didn’t help: it tells me which libraries I ship, not that line 13 of one file signs with ECDSA on P-256, or that an old certificate is still sitting in a container image. A CBOM is the list that does.
Four sources feed one CBOM: source code (API calls, found by a static scanner such as CBOMkit’s sonar-cryptography), files and images (certificates, keys, openssl.cnf, found by cbomkit-theia), dependencies (which crypto libraries, from an SBOM) and the network (protocols and cipher suites, from a TLS scanner). The CBOM holds four asset types: algorithm, certificate, protocol, related-crypto-material, linked by dependencies, for example private key to ECDSA-secp256r1-SHA-384 to SHA-384.
Where a CBOM’s data comes from, and what it holds

Part 3 ended with the PQCA’s first recommendation: start with an inventory. A CBOM is the standard format for that inventory. This part explains the format and how to read it.

What a CBOM is
#

The CycloneDX CBOM page describes it as a detailed representation of “algorithms, keys, certificates, and their relationships to software components”, so that you can find “deprecated algorithms or expired certificates” and plan the move to quantum-safe ones. PQCA’s CBOMkit page puts it in SBOM terms: it extends an SBOM with “algorithms, protocols, certificates, keys, tokens, secrets, and passwords”.

A CBOM is a CycloneDX JSON file ("specVersion": "1.6") whose components have "type": "cryptographic-asset". Each one has a cryptoProperties.assetType, one of four values in the 1.6 schema:

assetTypeWhat it describesExample
algorithmA cryptographic algorithm as usedECDSA-secp256r1-SHA-384, AES-256-GCM
certificateA certificate and its validity, signature and keyAn X.509 file in an image
protocolA protocol and its versions and cipher suitesTLS 1.2 and 1.3 from an openssl.cnf
related-crypto-materialKeys, secrets, tokens, salts, signatures…A private key, a JWT

Where the data comes from
#

No single tool sees everything. The US federal migration memo, OMB M-26-15, names the sources: software composition analysis of SBOMs, “Static/Dynamic Application Security Testing (SAST/DAST) to find cryptographic functions in code”, and “network scanners to detect protocols and cipher suites”, all feeding “a central Cryptographic Bill of Materials”. Mapped to open-source tools:

SourceWhat it can seeWhat it can’tOpen-source tool
Source code (SAST)Calls to a crypto API, with file and lineAlgorithms chosen at runtime or by configurationCBOMkit’s sonar-cryptography (also packaged as cbomkit-action)
Files and imagesCertificates, keys, secrets, openssl.cnf, java.securityWhat the code does with themcbomkit-theia
Dependencies (SCA)Which crypto libraries and versions shipWhich of their algorithms you callAny SBOM generator
Network (DAST)Protocols and cipher suites actually negotiatedAnything not exposed on a port; and behind an inspecting proxy it measures the proxy (as I found out)A TLS scanner

The source scanner currently covers Java (JCA and BouncyCastle), Python (pyca/cryptography) and Go (the standard crypto packages, partly golang.org/x/crypto), according to the CBOMkit README. C# is “not yet meant for active usage”, and C/C++ with OpenSSL is an open pull request from an LFX mentorship. So a Rust service, a Node.js app or anything calling OpenSSL directly produces no source-code findings today.

Reading one, field by field
#

To learn the format I wrote a small Python file where I knew the answer in advance. It uses seven algorithms directly (RSA-PSS, SHA-256, ECDSA on P-256, SHA-384, Ed25519, X25519 and AES-256-GCM), plus one trap: an ECDSA P-384 key whose hash the caller passes in as a default argument. Then I scanned it with CBOMkit (how I ran it is in the next post). Here is one component from the result:

{
  "type": "cryptographic-asset",
  "bom-ref": "843b9719-68b7-483f-b402-c4105e9b12f0",
  "name": "ECDSA-secp256r1-SHA-384",
  "evidence": {
    "occurrences": [
      { "location": "app/crypto_demo.py", "line": 13, "offset": 4, "additionalContext": "sign" }
    ]
  },
  "cryptoProperties": {
    "assetType": "algorithm",
    "algorithmProperties": {
      "primitive": "signature",
      "curve": "secp256r1",
      "cryptoFunctions": ["keygen", "sign"]
    },
    "oid": "1.2.840.10045.4.3.3"
  }
}

How I read it, top to bottom:

  1. name is the tool’s label. Useful for people, but don’t match on it alone: the same algorithm appears as RSA, RSA-2048 or SHA256-RSA depending on the tool and context.
  2. evidence.occurrences is the part I act on: crypto_demo.py, line 13, a sign call. Every fix starts here.
  3. primitive decides the quantum question. signature, pke, kem and key-agree are public-key and need a plan; hash, ae, block-cipher and mac don’t (see part 1).
  4. curve or parameterSetIdentifier gives the size: secp256r1, 2048, 256.
  5. cryptoFunctions says what the code does with it. Treat it as a hint; in the next post the scanner labelled RSA key loading as keygen.
  6. oid is the precise identifier, and what policy checks prefer to match on.
  7. nistQuantumSecurityLevel (0 to 6) exists in the schema, but none of the CBOMs I generated filled it in, so I don’t rely on it.

The dependencies section at the end links components together. In this file, a private key depends on ECDSA-secp256r1-SHA-384, which depends on SHA-384. That is how you get from “a key was created on line 13” to “which algorithm it belongs to”.

A short reader
#

Raw CBOM JSON is long; the file above is 15 components and over 400 lines. This prints one line per algorithm and flags the public-key ones:

"""Print a CycloneDX 1.6 CBOM as one line per algorithm, with where it was found."""
import json
import sys

ASYMMETRIC = {"signature", "pke", "kem", "key-agree"}

bom = json.load(open(sys.argv[1], encoding="utf-8"))
for c in bom.get("components", []):
    props = c.get("cryptoProperties", {})
    if props.get("assetType") != "algorithm":
        continue
    prim = props.get("algorithmProperties", {}).get("primitive", "?")
    flag = "PUBLIC-KEY" if prim in ASYMMETRIC else ""
    where = ", ".join(f'{o["location"].split("/")[-1]}:{o.get("line", "?")}'
                      for o in c.get("evidence", {}).get("occurrences", []))
    print(f'{c["name"]:<26} {prim:<10} {flag:<10} {where}')
$ python cbom_summary.py cbom.json
MGF1                       other                 crypto_demo.py:10
AES-256-GCM                ae                    crypto_demo.py:17
ECDSA-secp384r1            signature  PUBLIC-KEY crypto_demo.py:22
SHA-384                    hash                  crypto_demo.py:13
RSA-PSS                    signature  PUBLIC-KEY crypto_demo.py:10
Ed25519                    signature  PUBLIC-KEY crypto_demo.py:14
SHA-256                    hash                  crypto_demo.py:10, crypto_demo.py:11
ECDSA-secp256r1-SHA-384    signature  PUBLIC-KEY crypto_demo.py:13
x25519                     key-agree  PUBLIC-KEY crypto_demo.py:15, crypto_demo.py:15
SHA-512                    hash                  crypto_demo.py:14

Against what I put in the file: all seven direct uses were found, with the right sizes and lines. The P-384 key on line 22 was found too, but not the hash that the caller passes in as a default argument. (The SHA-512 on line 14 is the one inside Ed25519, which is correct.) Five public-key algorithms to plan for; the other five (hashes, AES-GCM and the MGF1 padding helper) can stay.

What a CBOM doesn’t tell you
#

  • Whether the code runs. A finding in a test helper or an unused branch looks the same as one in production.
  • What a library’s callers choose. A library offers algorithms; the application picks one at runtime. The next post shows how much this hides.
  • Whether it’s quantum-safe. That is a policy applied to the CBOM, not a field in it. CBOMkit ships one such policy; the next post shows what it does and doesn’t grade.
  • Your secrets, safely. A CBOM from files can list private keys and tokens, and the source scanner wrote absolute paths from my machine into location. Treat a CBOM like a log file before sharing it.

Keywords
#

KeywordMeaning here
SBOMSoftware Bill of Materials: the list of components (libraries, versions) in a piece of software
CBOMCryptography Bill of Materials: the list of cryptographic assets in it, and where each is used
CycloneDXAn OWASP standard for bills of materials; version 1.6 added the cryptography fields a CBOM uses
Cryptographic assetAnything cryptographic the CBOM lists: an algorithm, certificate, protocol, key, token or secret
PrimitiveThe kind of algorithm: signature, kem, key-agree, pke, hash, ae (authenticated encryption) and so on
OIDObject identifier, a dotted number that names an algorithm precisely, such as 1.2.840.10045.4.3.3 for ECDSA with SHA-384
bom-refA component’s ID inside the file; other entries point at it
Evidence / occurrenceWhere an asset was found: file, line, and the call that gave it away
SAST / SCA / DASTStatic analysis of code, software composition analysis of dependencies, dynamic testing of a running system

Next in this series: What broke when I scanned a repo

Takeaways
#

  • A CBOM is a CycloneDX 1.6 file listing cryptographic assets: algorithms, certificates, protocols and key material.
  • It takes several sources to fill one: code, files and images, dependencies, and the network.
  • Read the evidence (where), primitive (does quantum matter) and dependencies (which key belongs to which algorithm) first.
  • Test the scanner on a file where you know the answer before trusting it on a real repository.
  • “Quantum-safe or not” is a policy you run on a CBOM, not something the CBOM says.

References
#

Related on this site: Learning OSV, part 2, which reads an SBOM-based vulnerability scan the same way.

Author
Samarthya
Engineer, learner, tinkerer. This is my trophy shelf of everyday work and leisure.
Getting ready for quantum computers - This article is part of a series.
Part 4: This Article

Related

Who's already working on it?

The new locks I ran in the last post didn’t appear by themselves. Somebody wrote that code, tested it, proved parts of it correct, and built the tools that tell you where the old locks are hiding. When I went looking for who, a lot of roads led to one place: the PQCA. Four projects, four recommendations Part 1 covered what breaks and what replaces it, and part 2 ran the replacements. Standards bodies decide which algorithms to use; this part is about who builds them in the open, and what they tell the rest of us to do.

Saved today, read tomorrow

In 1943 the US Army started keeping copies of Soviet telegrams it couldn’t read. Some of them were read years later, and they named spies. I think of that story every time someone tells me quantum computers are “still years away”. If names like RSA, X25519 or ECDSA are new to you, the primer explains what each one does, in plain words.

Holding the new locks in my hand

I can read about a lock all day. I only trust it once I’ve turned the key myself. So before looking for the old locks in my code, I ran the new ones on my own machine. The new locks, measured Part 1 ended with three names: ML-KEM (FIPS 203) to agree a key, ML-DSA (FIPS 204) to sign, and SLH-DSA (FIPS 205) as the hash-based backup signer. This post puts each of them to work. You need a recent Go or OpenSSL 3.5 or later; I used Go 1.27.4 and OpenSSL 3.5.9.