<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Shubham Kumar on Medium]]></title>
        <description><![CDATA[Stories by Shubham Kumar on Medium]]></description>
        <link>https://medium.com/@chmodshubham?source=rss-a79607172f9d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*cMKqfNgYp28cpuc-snMJ8A.jpeg</url>
            <title>Stories by Shubham Kumar on Medium</title>
            <link>https://medium.com/@chmodshubham?source=rss-a79607172f9d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 18:25:22 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@chmodshubham/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Sonar Cryptography Plugin]]></title>
            <link>https://medium.com/@chmodshubham/sonar-cryptography-plugin-cb2a772b61ff?source=rss-a79607172f9d------2</link>
            <guid isPermaLink="false">https://medium.com/p/cb2a772b61ff</guid>
            <category><![CDATA[cbomkit]]></category>
            <category><![CDATA[sonar-cryptography]]></category>
            <category><![CDATA[pqca]]></category>
            <category><![CDATA[cryptography]]></category>
            <category><![CDATA[sonarqube]]></category>
            <dc:creator><![CDATA[Shubham Kumar]]></dc:creator>
            <pubDate>Sat, 07 Mar 2026 13:42:17 GMT</pubDate>
            <atom:updated>2026-04-15T18:18:06.580Z</atom:updated>
            <content:encoded><![CDATA[<p>The <strong>Sonar Cryptography Plugin (CBOMkit-hyperion)</strong> is a <a href="https://www.sonarsource.com/products/sonarqube/">SonarQube</a> plugin that performs static analysis on source code to identify cryptographic assets and generate a <strong>Cryptographic Bill of Materials (CBOM)</strong> in <a href="https://cyclonedx.org/">CycloneDX</a> format. It is part of the broader <a href="https://github.com/cbomkit">CBOMKit</a> toolset.</p><p>The plugin integrates with SonarQube by registering language-specific sensors and rule checks. During analysis, it scans source files, detects cryptographic usage patterns, extracts structured metadata, and serializes the results into a CycloneDX-compliant CBOM JSON document.</p><p>Currently supported languages and libraries include:</p><ul><li><strong>Java</strong>: Java Cryptography Architecture (JCA), BouncyCastle Lightweight API</li><li><strong>Python</strong>: pyca/cryptography</li><li><strong>Go</strong>: Standard library crypto/, golang.org/x/crypto</li></ul><p>The project is implemented as a multi-module Maven build (Java 17), with a clear separation of responsibilities across modules:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JWT5kzkTgShYBsDCEBuTgQ.png" /></figure><p>Each module is built as an independent Maven artifact. The root pom.xml defines dependency management and aggregates all submodules. The final plugin is assembled in the <a href="https://github.com/cbomkit/sonar-cryptography/tree/main/sonar-cryptography-plugin">sonar-cryptography-plugin/</a> module, which packages all the modules into a single JAR (excluding language parsers) that can be installed directly into SonarQube.</p><h3>Data Flow</h3><p>The plugin processes source code through a 5-stage pipeline to produce a structured CBOM document.</p><p>Each stage is implemented as a separate module with well-defined interfaces, allowing the system to be extended to additional languages or output formats without major architectural changes.</p><h3>Stage 1: Detection</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WFPNxAUMQSu9MHp5fymk1A.jpeg" /></figure><h3>Execution Paths</h3><p>The cryptographic detection engine can be used in two ways:</p><ol><li>As a SonarQube plugin (sonar-cryptography)</li><li>As a standalone library (cbomkit-lib)</li></ol><p>Both use the same engine, mapper, output, and enricher modules, but they differ only in how the sonar language parsers are started and who orchestrates the analysis lifecycle.</p><h4>Path 1: SonarQube Plugin (sonar-cryptography)</h4><p>A running SonarQube server is required.</p><p>The sonar-cryptography-plugin module:</p><ul><li>Uses sonar-packaging-maven-plugin to declare the plugin entry point <a href="https://github.com/cbomkit/sonar-cryptography/blob/main/sonar-cryptography-plugin/src/main/java/com/ibm/plugin/CryptographyPlugin.java">CryptographyPlugin.java</a>. This class implements org.sonar.api.Plugin and registers the plugin’s extensions with SonarQube.</li><li>Uses maven-shade-plugin to bundle internal modules (java, python, go, cpp, engine, mapper, output, enricher, rules) into a single fat JAR</li><li>Is deployed to SonarQube’s extensions/plugins/ directory</li></ul><p>In this mode:</p><ul><li>SonarQube’s language plugins perform parsing.</li><li>The sonar-cryptography plugin injects cryptographic detection rules.</li></ul><p>Each language exposes a different extension mechanism:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S1VGWw_76MPKzlkmDWSLgQ.png" /></figure><p>Go is an exception. Since sonar-go does not expose a CheckRegistrar-style extension, CryptoGoSensor performs parsing and rule execution directly.</p><h4>Path 2: Standalone Library (cbomkit-lib)</h4><p>This mode does not require a SonarQube server.</p><p>cbomkit-lib declares sonar-cryptography-plugin as a Maven dependency, bringing the detection engine (fat JAR) onto the classpath.</p><p>The Sonar language parser libraries (sonar-java, sonar-python, sonar-go) are pulled as separate transitive dependencies (<em>when cbomkit-lib imports the sonar-cryptography plugin, maven automatically walks down the dependency tree and downloads sonar-java, sonar-python, and all the other required Sonar parsers into cbomkit-lib’s classpath</em>), they are not bundled inside the fat JAR, but are used directly.</p><p>SonarQube parsers expect the server to give them SensorContext at runtime. Becausecbomkit-lib runs without a server, it uses SonarQube&#39;s <strong>unit-testing utilities</strong> to manually construct a &quot;fake&quot; server environment from scratch.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KoKp4xzOwzXMJwdBxPs6sQ.png" /></figure><blockquote><strong>Note:</strong> SensorContext in SonarQube is the working environment provided to a plugin (e.g. sonar-java) during code analysis. It acts like a container that holds everything the plugin needs to perform its job such as access to the project’s source files, configuration settings, and execution state while also giving it a way to report results like bugs or issues back to the SonarQube.</blockquote><p>When developers build SonarQube plugins, they use testing utilities like SensorContextTester to test their code locally, without needing to start a massive SonarQube database or server just for a 5-second test. This tester class implements the exact same interface as the real server context, but keeps all files and settings temporarily in local computer memory.</p><p>cbomkit-lib relies on this testing infrastructure to act as a standalone application. It pulls in these testing utilities (like sonar-plugin-api-impl), creates a SensorContextTester in memory, and manually packs it with your project&#39;s code files and configuration.</p><p>When cbomkit-lib hands this interface to the language parsers, the parsers see an object that successfully implements the SensorContext interface. This effectively tricks the parsers into believing they are running in the real SonarQube server, allowing them to happily analyze the code completely offline.</p><h3>Detection Engine</h3><p>The <a href="https://github.com/cbomkit/sonar-cryptography/blob/main/engine/">engine/</a> module provides the language-agnostic detection logic. It does not parse source code itself; instead, it operates on Abstract Syntax Trees (ASTs) provided by the language-specific SonarQube plugins (sonar-java, sonar-python, sonar-go).</p><p>The detection rule is defined by the IDetectionRule&lt;T&gt; interface (<a href="https://github.com/cbomkit/sonar-cryptography/blob/main/engine/src/main/java/com/ibm/engine/rule/IDetectionRule.java">IDetectionRule.java</a>). A detection rule specifies:</p><ul><li>Which object types to match (by fully-qualified class or module name)</li><li>Which method names to target</li><li>Which parameter types to match</li><li>How to extract a value from a matched expression (IValueFactory)</li><li>The semantic context of the detection (IDetectionContext)</li><li>Which child rules to apply on the matched arguments or return values</li><li>A bundle identifier that groups related rules</li></ul><p>Rules are constructed using DetectionRuleBuilder&lt;T&gt;, which implements a staged fluent builder. This enforces rule completeness at compile time by requiring object type, method, parameters, and context to be defined in order before the rule can be built. For example:</p><pre>DetectionRuleBuilder.&lt;Tree&gt;detect()<br>    .forObjectTypes(&quot;javax.crypto.Cipher&quot;)<br>    .forMethods(&quot;getInstance&quot;)<br>    .withMethodParameter(&quot;java.lang.String&quot;)<br>        .shouldBeDetectedAs(new AlgorithmFactory&lt;&gt;())<br>    .buildForContext(new CipherContext())<br>    .inBundle(() -&gt; &quot;Jca&quot;);</pre><p>The builder produces immutable IDetectionRule instances, which the detection engine evaluates against AST nodes during analysis. Parent rules may declare depending rules (child rules), allowing rule trees to form when matched arguments originate from other method calls.</p><blockquote><strong>Tip:</strong> The I in IDetectionRule stands for Interface.</blockquote><h3>Detection Contexts</h3><p>Every detection rule carries an IDetectionContext that classifies the semantic meaning of the match. The context is used downstream by translators to determine which INode types to produce.</p><p>The context hierarchy is defined in <a href="https://github.com/cbomkit/sonar-cryptography/blob/main/engine/src/main/java/com/ibm/engine/model/context/">engine/model/context/</a>. The base DetectionContext stores arbitrary string properties in a map, allowing subclasses to carry additional structured data without breaking the interface contract. Key context types include:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*41Pu9j6Eb-dTPcJm6ugoMA.png" /></figure><h3>Detection Store</h3><p>When a rule matches an AST node, the result is recorded in a DetectionStore (<a href="https://github.com/cbomkit/sonar-cryptography/blob/main/engine/src/main/java/com/ibm/engine/detection/DetectionStore.java">DetectionStore.java</a>). The detection store is the central intermediate representation of the detection phase.</p><p>DetectionStore&lt;R, T, S, P&gt; is generic over four type parameters:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BFOk0f03s1hHgnlmD_bOsw.png" /></figure><p>The store holds:</p><ul><li>Extracted parameter values (detectionValues)</li><li>Child detection stores (children)</li><li>Optional invocation action (actionValue)</li><li>Tree depth (level)</li></ul><p>When a detection rule matches, DetectionStore.onReceivingNewDetection() is invoked. It applies value factories and action factories to extract typed values from the AST node, and recursively creates child stores for any depending rules. The result is a tree mirroring the cryptographic call graph relevant to the detection (not the entire program call graph).</p><blockquote><strong>Note:</strong> Value extraction and action capture are done by factories defined in the rule. IValueFactory&lt;T&gt; extracts resolved data such as algorithm names, key sizes, modes, padding schemes, curves, or digest lengths. IActionFactory&lt;T&gt; captures the semantic operation being performed (e.g., encrypt, decrypt, sign, verify). The extracted values are stored in detectionValues, while the captured action is stored in actionValue for later translation into the CBOM model.</blockquote><h3>Hook System</h3><p>Not all cryptographic parameters appear directly in a single method call. Some APIs use configuration objects, enums, or chained method calls to pass values such as key sizes, modes, or algorithm specifications. These cases cannot always be captured by a single detection rule. The hook system handles these indirect patterns.</p><p>A hook registers interest in a specific method invocation or enum constant. When that invocation appears anywhere in the relevant call context, the hook is triggered and its value is captured into the current DetectionStore.</p><p>There are two main types of hooks:</p><ol><li><strong>Enum hooks: </strong>match enum constant accesses and extract the selected value.</li></ol><p><strong>2. Method invocation hooks:</strong> match specific method calls and capture either:</p><ul><li>a resolved parameter value, or</li><li>a resolved return value.</li></ul><p>HookRepository manages active hooks during a scan. When the CallStackAgent records a method invocation, the repository checks whether any registered hook matches it. If a match is found, the corresponding value is added to the current detection result.</p><blockquote><strong>Note:</strong> CallStackAgent records method invocations during AST traversal and notifies the HookRepository when new calls are observed. This enables hooks to capture indirect cryptographic parameters. It also tracks visited nodes to prevent duplicate detections.</blockquote><p>This mechanism allows the detection engine to capture cryptographic configuration that is defined outside the primary method call being analyzed.</p><p>For example:</p><pre>RSAKeyGenParameterSpec spec =<br>    new RSAKeyGenParameterSpec(2048, RSAKeyGenParameterSpec.F4);<br><br>KeyPairGenerator kpg = KeyPairGenerator.getInstance(&quot;RSA&quot;);<br>kpg.initialize(spec);</pre><p>The primary detection rule may match KeyPairGenerator.getInstance(&quot;RSA&quot;).<br>However, the key size (2048) is not passed directly in that call. It is embedded inside the RSAKeyGenParameterSpec object.</p><p>A method invocation hook can register interest in the constructor call of RSAKeyGenParameterSpec and capture the key size parameter. When kpg.initialize(spec) is analyzed, the previously captured value is associated with the detection.</p><h3>DetectionExecutive</h3><p>DetectionExecutive&lt;R, T, S, P&gt; (<a href="https://github.com/cbomkit/sonar-cryptography/blob/main/engine/src/main/java/com/ibm/engine/executive/DetectionExecutive.java">DetectionExecutive.java</a>) manages the lifecycle of a detection run for a single source file. It:</p><ol><li>Keeps track of which detection rules should run and which ones have already matched.</li><li>Collects DetectionStore results as rules are matched.</li><li>It filters out partial matches and only keeps fully formed detection trees that actually contain extracted cryptographic values.</li><li>Emits a Finding domain event for each completed detection.</li></ol><blockquote><strong>Note:</strong> Partial matches like this, Cipher c = Cipher.getInstance(algorithmVar), are discarded if the algorithmVar is not resolved to a specific algorithm name.</blockquote><p>Finding&lt;R, T, S, P&gt; (<a href="https://github.com/cbomkit/sonar-cryptography/blob/main/engine/src/main/java/com/ibm/engine/detection/Finding.java">Finding.java</a>) is simply a wrapper around the root DetectionStore and carries the detection level, rule bundle, and source location marker. Two findings are considered equal if their entire detection trees are identical. This prevents duplicate results when the same cryptographic usage is detected through different code paths.</p><p>DetectionExecutive publishes findings as events. Language-specific components (such as JavaInventoryRule) listen for these events and start the translation phase once a finding is received.</p><blockquote><strong>Note:</strong> InventoryRule is the SonarQube rule that drives the entire cryptographic analysis for a source file. When Sonar processes a file, this rule triggers the detection engine, receives completed findings, runs the translation pipeline, adds the resulting cryptographic nodes to the language aggregator for CBOM generation, and reports top-level assets such as algorithms, protocols, and keys as SonarQube issues in the UI.</blockquote><h3>Language Abstraction Interfaces</h3><p>Each language module (Java, Python, Go) implements a small set of interfaces so the detection engine can work independently of the underlying AST types.</p><p><strong>ILanguageSupport&lt;R, T, S, P&gt;</strong> (<a href="https://github.com/cbomkit/sonar-cryptography/blob/main/engine/src/main/java/com/ibm/engine/language/ILanguageSupport.java">ILanguageSupport.java</a>) connects the engine to a specific language. It creates the language-specific detection engine, provides the AST visitor, and supplies helpers for resolving methods, enums, and scopes.</p><p><strong>ILanguageTranslation&lt;T&gt;</strong> (<a href="https://github.com/cbomkit/sonar-cryptography/blob/main/engine/src/main/java/com/ibm/engine/language/ILanguageTranslation.java">ILanguageTranslation.java</a>) extracts structural information from AST nodes, such as method names, object types, return types, parameter types, and resolved identifier values.</p><p><strong>IDetectionEngine&lt;T, S&gt;</strong> (<a href="https://github.com/cbomkit/sonar-cryptography/blob/main/engine/src/main/java/com/ibm/engine/detection/IDetectionEngine.java">IDetectionEngine.java</a>) applies detection rules to AST nodes. It runs the rules, resolves symbols, and traces variable assignments when needed.</p><p>The concrete Java implementations (JavaLanguageSupport, JavaLanguageTranslation, JavaDetectionEngine) use the sonar-java SemanticModel for type resolution. The Python implementations use sonar-python&#39;s symbol tables. Go uses sonar-go&#39;s type resolution system.</p><h3>Language Modules</h3><p><strong>Java</strong> (<a href="https://github.com/cbomkit/sonar-cryptography/blob/main/java/">java/</a>) rules are organized by API. There are rules for standard JCA classes (such as Cipher, MessageDigest, Signature, Mac, KeyGenerator, etc.) and separate rules for BouncyCastle’s lightweight API.</p><p><strong>Python</strong> (<a href="https://github.com/cbomkit/sonar-cryptography/blob/main/python/">python/</a>) rules target the cryptography library (pyca). They are grouped by category (e.g., symmetric, asymmetric, hash, KDF, MAC). The module also includes helper logic to track variable assignments, since Python often stores crypto objects in intermediate variables before use.. The module also includes a resolve/ package with helpers for tracking symbol assignments across multiple statements, which is necessary because Python code frequently assigns configuration objects to intermediate variables before passing them to cipher constructors.</p><p><strong>Go</strong> (<a href="https://github.com/cbomkit/sonar-cryptography/blob/main/go/">go/</a>) uses a custom CryptoGoSensor instead of a registrar because sonar-go does not provide a CheckRegistrar. The sensor directly processes Go files and applies detection logic. It also supports partial parameter matching to handle Go’s struct-based configuration style.</p><h3>Stage 2: Translation</h3><p>The <a href="https://github.com/cbomkit/sonar-cryptography/blob/main/mapper/">mapper/</a> module is responsible for converting the engine’s DetectionStore tree into a structured domain model. The abstract base class for this process is ITranslator&lt;R, T, S, P&gt; (<a href="https://github.com/cbomkit/sonar-cryptography/blob/main/mapper/src/main/java/com/ibm/mapper/ITranslator.java">ITranslator.java</a>).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CHCKwviBpvVOdMzVBuAAOg.png" /></figure><h3>Translation Pipeline</h3><p>Language modules do not call ITranslator directly. Instead, they extend ITranslationProcess&lt;R, T, S, P&gt;, which coordinates the post-detection steps in sequence:</p><ol><li>ITranslator.translate(DetectionStore) — converts the DetectionStore tree into domain nodes ( INode)</li><li>Reorganizer.reorganize(List&lt;INode&gt;) — restructures nodes using declarative rules</li><li>Enricher.enrich(List&lt;INode&gt;) — adds metadata and derived properties</li></ol><p>For Java, this is implemented by JavaTranslationProcess, which is invoked by JavaInventoryRule upon receiving a Finding.</p><h3>Translation Entry Point</h3><p>ITranslator.translate(DetectionStore&lt;R, T, S, P&gt;) is the entry point of the translation phase.</p><p>Internally, it uses a Traverser to walk the DetectionStore tree. For each node in the tree, the traverser:</p><ol><li>Invokes the language-specific<br>translate(IBundle, IValue&lt;T&gt;, IDetectionContext, filePath) method to convert detected values into domain nodes (INode).</li><li>Applies merging logic to combine or override nodes derived from parent and child stores.</li></ol><p>The result is a List&lt;INode&gt;, where each node represents a detected cryptographic asset prepared for reorganization, enrichment, and final serialization.</p><p>In the Java module, JavaTranslator delegates to context-specific translators based on the IDetectionContext. For example, detections with CipherContext are handled by JavaCipherContextTranslator, which uses JcaMapper to parse the algorithm string. Other contexts are mapped by dedicated classes such as JavaSecretKeyContextTranslator, JavaDigestContextTranslator, JavaSignatureContextTranslator, JavaMacContextTranslator, and JavaProtocolContextTranslator.</p><p>This design keeps mapping logic isolated per cryptographic category, improving modularity and maintainability.</p><h3>INode Model</h3><p>All domain objects implement INode (<a href="https://github.com/cbomkit/sonar-cryptography/blob/main/mapper/src/main/java/com/ibm/mapper/model/INode.java">INode.java</a>). The model defines top-level cryptographic asset types:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*41pPEz3cTvIkhz5_esUPKg.png" /></figure><p>Each node may contain child nodes that represent configuration properties, such as:</p><ul><li>Mode (e.g., CBC, GCM)</li><li>Padding (e.g., PKCS1, OAEP)</li><li>KeyLength</li><li>BlockSize</li><li>DigestSize</li><li>NonceLength</li><li>SaltLength</li><li>ParameterSetIdentifier</li><li>TagLength</li></ul><p>Each node also carries a NodeOrigin enum value:</p><ul><li>DETECTED (from source code),</li><li>DEFAULT (inferred from library defaults), or</li><li>ENRICHED (added by the enricher)</li></ul><p>NodeOrigin is used during merging. When two nodes of the same type conflict, a DETECTED node overrides a DEFAULT placeholder. This ensures that explicitly specified parameters in source code take precedence over inferred assumptions.</p><h3>Mapper</h3><p>Language-specific name parsers implement IMapper (<a href="https://github.com/cbomkit/sonar-cryptography/blob/main/mapper/src/main/java/com/ibm/mapper/mapper/IMapper.java">IMapper.java</a>):</p><pre>IMapper.parse(String algorithmName, DetectionLocation) → Optional&lt;INode&gt;</pre><p>An IMapper converts a language-specific algorithm identifier into a structured INode.</p><p>Concrete mappers include:</p><ul><li>JcaMapper — parses JCA algorithm strings such as &quot;AES/GCM/NoPadding&quot;, splitting on / to extract cipher, mode, and padding</li><li>BcMapper — parses BouncyCastle algorithm names, which use a different naming convention for the same algorithms</li><li>PyCAMapper — parses pyca/cryptography class names (e.g., AES, AESGCM, PBKDF2HMAC)</li><li>GoMapper — parses Go crypto/* package identifiers</li></ul><p>These mappers are called from within the language-specific translate() implementations. They normalize ecosystem-specific naming conventions and produce consistent INode structures for downstream processing.</p><h3>Detection Location Tracking</h3><p>Every INode carries a DetectionLocation record (<a href="https://github.com/cbomkit/sonar-cryptography/blob/main/mapper/src/main/java/com/ibm/mapper/utils/DetectionLocation.java">DetectionLocation.java</a>) with fields: filePath, lineNumber, offset, keywords (a list of detected string literals), and bundle. This metadata is preserved through translation, reorganization, enrichment, and output, so that the final CBOM component retains a reference to the precise source location where the cryptographic usage was found.</p><h3>Stage 3: Reorganization</h3><p>After translation and before enrichment, the mapper module applies a <strong>reorganization pass</strong> using <a href="https://github.com/cbomkit/sonar-cryptography/blob/main/mapper/src/main/java/com/ibm/mapper/reorganizer/Reorganizer.java">Reorganizer.java</a>. The translation phase produces a relatively flat set of INode objects. Reorganization restructures these nodes into the final semantic tree shape expected by the enricher and output module.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DSeBcO6N77MWocF0oTKoVQ.png" /></figure><p>The reorganizer executes a sequence of IReorganizerRule instances. Each rule defines:</p><ul><li>A <strong>condition function</strong> (IFunctionDetectionCondition) that checks whether a node matches</li><li>A <strong>transformation function</strong> (IFunctionPerformReorganization) that restructures matching nodes</li></ul><p>Concrete reorganizer rules include:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-qKBk83rxRkX0a8CrgRd8g.png" /></figure><p>The reorganizer enables the translation stage to remain context-independent (each detection produces a simple node) while still producing the rich, nested tree structure that accurately represents the cryptographic asset.</p><h3>Stage 4: Enrichment</h3><p>The <a href="https://github.com/cbomkit/sonar-cryptography/blob/main/enricher/">enricher/</a> module adds metadata to the INode tree that cannot be directly observed in source code but is defined by the cryptographic specifications or library defaults.</p><p>The Enricher class (<a href="https://github.com/cbomkit/sonar-cryptography/blob/main/enricher/src/main/java/com/ibm/enricher/Enricher.java">Enricher.java</a>) provides a static enrich(Collection&lt;INode&gt;) method that traverses the node tree and dispatches each node to a type-appropriate enricher implementation via IEnricher.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fk74mxX0yATq6LNMogf-vg.png" /></figure><p>Examples of enrichment:</p><ul><li>AESEnricher — sets the default key length to 128 bits when not specified</li><li>RSAEnricher — attaches the OID for RSA and default key lengths</li><li>SHA2Enricher — maps algorithm variant names to their digest sizes</li><li>HMACEnricher — derives key size requirements from the underlying hash function</li><li>PBKDF2Enricher — associates default iteration counts and output lengths</li><li>SignatureEnricher — resolves signature algorithm components from combined names (e.g., SHA256withRSA)</li><li>KEMEnricher — adds parameter set identifiers for post-quantum KEM algorithms</li><li>TagOrDigestEnricher — computes tag or digest size from the algorithm variant</li></ul><p>All derived values are marked with NodeOrigin.ENRICHED, keeping them distinguishable from DETECTED and DEFAULT values. The enrichment process is recursive. Child nodes are enriched independently, ensuring that nested structures such as an Algorithm containing a KeyDerivationFunction, are fully enriched throughout the tree.</p><h3>Stage 5: Serialization</h3><p>Serialization occurs after all source files have been analyzed, translated, reorganized, and enriched.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1013/1*NCjFwG8eL2WudmDEqCaBug.png" /></figure><h3>Cross-File Result Accumulation</h3><p>SonarQube analyzes source files independently, so cryptographic findings must be aggregated before serialization. Each language module maintains a static aggregator:</p><ul><li>JavaAggregator — collects List&lt;INode&gt; from all analyzed Java files</li><li>PythonAggregator — same for Python</li><li>GoAggregator — same for Go</li></ul><p>Each aggregator holds a static List&lt;INode&gt; and is reset at the start of each scan. Translated and enriched nodes from each file&#39;s ITranslationProcess are added to the aggregator after the file-level translation is complete.</p><h3>Post-Scan Job</h3><p>After all source files are analyzed, OutputFileJob (<a href="https://github.com/cbomkit/sonar-cryptography/blob/main/sonar-cryptography-plugin/src/main/java/com/ibm/plugin/OutputFileJob.java">OutputFileJob.java</a>) is invoked as a SonarQube PostJob. It retrieves the accumulated INode lists from all language aggregators, adds them to a CBOMOutputFile, writes the CBOM JSON to disk, and prints scan statistics (component counts, timing, output path).</p><h3>CBOM Generation</h3><p>The <a href="https://github.com/cbomkit/sonar-cryptography/blob/main/output/">output/</a> module converts the enriched INode tree into a CycloneDX-format CBOM document.</p><p>CBOMOutputFile (<a href="https://github.com/cbomkit/sonar-cryptography/blob/main/output/src/main/java/com/ibm/output/cyclonedx/CBOMOutputFile.java">CBOMOutputFile.java</a>) accumulates INode instances via its add(List&lt;INode&gt;) method and serializes them when saveTo(File) is called. Internally it uses the <strong>cyclonedx-core-java</strong> library targeting schema version 1.6.</p><p>Node-to-component conversion is handled by dedicated builder classes:</p><ul><li>AlgorithmComponentBuilder — converts Algorithm nodes into CycloneDX CryptoComponent entries of type algorithm, attaching mode, padding, key length, OID, and other properties</li><li>ProtocolComponentBuilder — converts Protocol and CipherSuite nodes into structured protocol components with nested cipher suite entries</li><li>RelatedCryptoMaterialComponentBuilder — handles related cryptographic material such as keys and certificates</li></ul><p>Each component is assigned a stable BOM reference. Dependencies between components (for example, a protocol depending on specific algorithms) are recorded in the CycloneDX dependencies section, enabling downstream tools to analyze relationships between cryptographic assets.</p><h3>End-to-End Example</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/779/1*EdNTL3GNRQZPmm9K-s5DQA.png" /></figure><h3>Adding a New Language</h3><p>Follow <a href="https://github.com/cbomkit/sonar-cryptography/blob/main/docs/LANGUAGE_SUPPORT.md">LANGUAGE_SUPPORT.md</a> to implement support for a new programming language. The architecture is designed to be extensible, allowing new languages to be added by implementing the required interfaces and integrating with the detection engine and translation pipeline.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cb2a772b61ff" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PQCA CBOM Kit (formerly IBM)]]></title>
            <link>https://medium.com/@chmodshubham/pqca-cbom-kit-formerly-ibm-74d21bf46e12?source=rss-a79607172f9d------2</link>
            <guid isPermaLink="false">https://medium.com/p/74d21bf46e12</guid>
            <category><![CDATA[ibm]]></category>
            <category><![CDATA[post-quantum-cryptography]]></category>
            <category><![CDATA[cyclonedx]]></category>
            <category><![CDATA[cbomkit]]></category>
            <category><![CDATA[lf-pqca]]></category>
            <dc:creator><![CDATA[Shubham Kumar]]></dc:creator>
            <pubDate>Sun, 01 Mar 2026 03:51:00 GMT</pubDate>
            <atom:updated>2026-03-08T10:27:25.276Z</atom:updated>
            <content:encoded><![CDATA[<p>CBOM Kit is a collection of tools built by IBM (now under the Post-Quantum Cryptography Alliance) for generating and managing Cryptographic Bills of Materials (CBOMs).</p><p>A CBOM is a structured inventory of the cryptographic assets present in a software system: algorithms, keys, protocols, and their properties. The kit enables organizations to discover what cryptographic mechanisms their code depends on, how they are configured, and whether those configurations meet defined security standards, including readiness for post-quantum cryptography.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*NSdKMpWw4hNLY7EX1t9G0Q.png" /></figure><p>The system is organized into five interconnected components, each with a distinct role:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QMra3RZ3t_vaGxdzUDXOdg.png" /></figure><p><strong><em>Reference:</em></strong><em> </em><a href="https://github.com/cbomkit/sonar-cryptography"><em>[1]</em></a><em>, </em><a href="https://github.com/cbomkit/cbomkit-lib"><em>[2]</em></a><em>, </em><a href="https://github.com/cbomkit/cbomkit-action"><em>[3]</em></a><em>, </em><a href="https://github.com/cbomkit/cbomkit"><em>[4]</em></a><em>, </em><a href="https://github.com/cbomkit/cbomkit-theia"><em>[5]</em></a></p><p>The first four components form a layered dependency hierarchy. The detection engine (sonar-cryptography) sits at the base and is consumed by cbomkit-lib, which in turn is consumed by both cbomkit-action and cbomkit.</p><p>cbomkit-theia operates independently as a complementary tool. While the source code stack detects cryptographic API usage in code, Theia detects cryptographic assets present in deployment artifacts such as certificates, keys, secrets, configuration files, and container images.</p><h3>Component Architecture</h3><h3>1. Detection Engine: sonar-cryptography</h3><p>The detection engine is a SonarQube plugin that identifies cryptographic usage in source code. It supports Java, Python, and Go. The engine operates on Abstract Syntax Trees (ASTs) generated by the respective SonarQube language plugins, not on raw source text.</p><p><strong>Internal structure:</strong></p><p>The plugin is organized into Maven submodules, each responsible for a specific stage of the analysis process:</p><ul><li>engine/ - Language-agnostic detection framework. Defines core abstractions such as DetectionStore, DetectionExecutive, and IDetectionRule.</li><li>java/, python/, go/ - Language-specific modules. Each provides detection rules, an AST translator, and a check registrar that integrates with the corresponding SonarQube language plugin.</li><li>mapper/ - Converts raw detections into a structured semantic model based on the INode hierarchy representing algorithms, keys, and protocols.</li><li>enricher/ - Adds derived metadata such as OIDs, default parameters, and algorithm-specific properties not explicitly present in source code.</li><li>output/ - Generates a CycloneDX CBOM JSON file from the enriched INode tree.</li><li>common/ - Shared utilities, including observer pattern infrastructure for event-driven communication.</li><li>sonar-cryptography-plugin/ - Plugin entry point. Registers language extensions and defines the post-job that triggers CBOM generation after analysis.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qpIqx75a5URp6F9J-4-GKg.png" /></figure><p><strong>Detection pipeline:</strong></p><p>The detection process follows a multi-stage pipeline for each supported language.</p><ol><li><strong>AST construction:</strong> SonarQube language plugins parse source files and produce typed ASTs with resolved symbols.</li><li><strong>Rule application:</strong> Detection rules, defined using DetectionRuleBuilder, are applied to the AST. Each rule targets a specific API usage pattern, such as javax.crypto.Cipher#getInstance in Java or Cipher from cryptography.hazmat.primitives.ciphers in Python. Rules define which parameters contain cryptographic values and how they are extracted.</li><li><strong>Detection store construction:</strong> Matched rules populate a DetectionStore, a tree structure that records the detection location and captured parameters. Nested detections are represented as child stores.</li><li><strong>Mapping:</strong> A language-specific ITranslator converts entries in the DetectionStore into nodes of the INode semantic model. The model includes types such as Algorithm, Key, Protocol, Mode, Padding, KeyLength, and DigestSize. Each node includes an origin attribute indicating whether it was detected, inferred, or enriched.</li><li><strong>Enrichment:</strong> The Enricher ⁣traverses the INode tree and applies algorithm-specific enrichment. For example, it may add an OID for AES-128-GCM or assign a default mode when none is explicitly defined in source code.</li><li><strong>Output generation:</strong> CBOMOutputFile converts the enriched INode tree into a CycloneDX v1.6 CBOM. Each cryptographic asset is represented as a component of type cryptographic-asset. Evidence entries record file paths and line numbers. Dependency relationships reflect structural associations, such as a key used with a specific algorithm.</li></ol><pre>{<br>  &quot;bomFormat&quot;: &quot;CycloneDX&quot;,<br>  &quot;specVersion&quot;: &quot;1.6&quot;,<br>  &quot;version&quot;: 1,<br>  &quot;metadata&quot;: {<br>    &quot;timestamp&quot;: &quot;2026-01-20T10:58:39Z&quot;,<br>    &quot;tools&quot;: {<br>      &quot;services&quot;: [<br>        {<br>          &quot;name&quot;: &quot;CBOMkit&quot;,<br>          &quot;provider&quot;: { &quot;name&quot;: &quot;PQCA&quot; }<br>        }<br>      ]<br>    }<br>  },<br>  &quot;components&quot;: [<br>    {<br>      &quot;name&quot;: &quot;SHA256&quot;,<br>      &quot;type&quot;: &quot;cryptographic-asset&quot;,<br>      &quot;bom-ref&quot;: &quot;0f4f522b-ef99-43b7-9f98-6e83b3b233ca&quot;,<br>      &quot;evidence&quot;: {<br>        &quot;occurrences&quot;: [<br>          {<br>            &quot;line&quot;: 51,<br>            &quot;location&quot;: &quot;src/main/java/com/example/EncryptionConfig.java&quot;,<br>            &quot;additionalContext&quot;: &quot;java.security.MessageDigest#getInstance&quot;<br>          }<br>        ]<br>      },<br>      &quot;cryptoProperties&quot;: {<br>        &quot;oid&quot;: &quot;2.16.840.1.101.3.4.2.1&quot;,<br>        &quot;assetType&quot;: &quot;algorithm&quot;,<br>        &quot;algorithmProperties&quot;: {<br>          &quot;primitive&quot;: &quot;hash&quot;,<br>          &quot;cryptoFunctions&quot;: [&quot;digest&quot;],<br>          &quot;parameterSetIdentifier&quot;: &quot;256&quot;<br>        }<br>      }<br>    },<br>    {<br>      &quot;name&quot;: &quot;AES128-GCM&quot;,<br>      &quot;type&quot;: &quot;cryptographic-asset&quot;,<br>      &quot;bom-ref&quot;: &quot;e006c3f1-912a-4de5-8399-79bf0f350cb9&quot;,<br>      &quot;evidence&quot;: {<br>        &quot;occurrences&quot;: [<br>          {<br>            &quot;line&quot;: 29,<br>            &quot;location&quot;: &quot;src/main/java/com/example/aes/AESGCM.java&quot;,<br>            &quot;additionalContext&quot;: &quot;javax.crypto.Cipher#getInstance&quot;<br>          }<br>        ]<br>      },<br>      &quot;cryptoProperties&quot;: {<br>        &quot;oid&quot;: &quot;2.16.840.1.101.3.4.1&quot;,<br>        &quot;assetType&quot;: &quot;algorithm&quot;,<br>        &quot;algorithmProperties&quot;: {<br>          &quot;mode&quot;: &quot;gcm&quot;,<br>          &quot;primitive&quot;: &quot;ae&quot;,<br>          &quot;cryptoFunctions&quot;: [&quot;decrypt&quot;],<br>          &quot;parameterSetIdentifier&quot;: &quot;128&quot;<br>        }<br>      }<br>    },<br>    {<br>      &quot;name&quot;: &quot;RSA-OAEP&quot;,<br>      &quot;type&quot;: &quot;cryptographic-asset&quot;,<br>      &quot;bom-ref&quot;: &quot;ff238e09-dd3d-44c4-ad49-34350f1d9cc7&quot;,<br>      &quot;cryptoProperties&quot;: {<br>        &quot;oid&quot;: &quot;1.2.840.113549.1.1.7&quot;,<br>        &quot;assetType&quot;: &quot;algorithm&quot;,<br>        &quot;algorithmProperties&quot;: {<br>          &quot;mode&quot;: &quot;ecb&quot;,<br>          &quot;padding&quot;: &quot;oaep&quot;,<br>          &quot;primitive&quot;: &quot;pke&quot;,<br>          &quot;parameterSetIdentifier&quot;: &quot;2048&quot;<br>        }<br>      }<br>    }<br>  ],<br>  &quot;dependencies&quot;: [<br>    {<br>      &quot;ref&quot;: &quot;secret-key-ref&quot;,<br>      &quot;dependsOn&quot;: [&quot;AES128-ref&quot;]<br>    }<br>  ]<br>}</pre><p><strong>Cryptographic libraries covered:</strong></p><ul><li><strong>Java: </strong>Java Cryptography Architecture (JCA), BouncyCastle Lightweight API</li><li><strong>Python: </strong>pyca/cryptography</li><li><strong>Golang: </strong>Standard library crypto/*, golang.org/x/crypto</li></ul><p><strong>SonarQube integration:</strong></p><p>The plugin integrates with SonarQube through CryptographyPlugin.java, which implements the Plugin interface. During initialization, it registers rule definitions and check registrars for each supported language.</p><p>After the scan completes, OutputFileJob (a PostJob) collects detections from all language-specific Aggregator instances through ScannerManager and writes the final CBOM file. The default output filename is cbom.json. This can be configured using the sonar.cryptoScanner.cbom property.</p><h3>2. Scanning Library: cbomkit-lib</h3><p>cbomkit-lib is a Java library that wraps the Sonar Cryptography Plugin and exposes a standalone programmatic API for cryptographic scanning without requiring a running SonarQube installation. Consumers invoke it directly from Java code to scan a local directory and receive a CBOM as output.</p><blockquote><strong>NOTE:</strong> The sonar-cryptography plugin is designed to run inside a SonarQube server. Without cbomkit-lib, you would need to deploy a SonarQube instance, install the plugin, configure a project, and run SonarScanner to produce a CBOM. cbomkit-lib removes this requirement by reusing the core detection, translation, enrichment, and serialization modules directly as Java library dependencies. However, it still relies on SonarQube’s language parser libraries (sonar-java, sonar-python, sonar-go) for AST generation, these run as embedded dependencies, not as part of a SonarQube server.</blockquote><p>The library provides a two-phase API structured around indexing and scanning.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CtU6F1HCCgOcArbHiFR6Rw.png" /></figure><p><strong>Indexing phase:</strong></p><p>IndexingService (abstract) is the base class for language-specific module discovery. Concrete implementations (JavaIndexService, PythonIndexService, GoIndexService) walk a project directory tree, locate language-specific build files (for example, pom.xml, build.gradle, go.mod), and construct a list of ProjectModule records. Each ProjectModule contains the module identifier, its base path, and the list of source files (InputFile objects from the Sonar plugin API) that belong to it.</p><p>The indexing step serves two purposes: it decomposes a repository into logical units aligned with the project’s build structure, and it filters files for each language, excluding test directories, generated code, and non-source artifacts.</p><p><strong>Scanning phase:</strong></p><p>ScannerService (abstract) is the base class for language-specific scanners. Each concrete implementation accepts a list of ProjectModule objects and runs the corresponding detection rules from the Sonar Cryptography Plugin against the source files within those modules. Results are returned as ScanResultDTO, an immutable record containing the resulting CBOM, the number of files and lines scanned, and timing information.</p><p>The CBOM class is a record that wraps CycloneDX’s Bom object. It provides utilities for merging multiple CBOM instances (for example, one per language), enriching them with metadata such as git URL, revision, and commit hash, serializing to JSON, and writing to disk.</p><p>Java scanning requires additional consideration. Since Java cryptographic API usage often depends on compile-time symbol resolution, the Java scanner can optionally require that the project be built beforehand. When compiled class files or dependency JARs are provided, symbol resolution accuracy improves. The JavaScannerService accepts paths to JAR directories and class directories for this purpose.</p><p><strong>Progress reporting:</strong></p><p>The library includes an optional progress reporting mechanism via the IProgressDispatcher interface. Implementations receive ProgressMessage records during scanning, enabling real-time feedback to the caller. The message type system (ProgressMessageType enum) includes LABEL, DETECTION, WARNING, ERROR, GITURL, and BRANCH. If the dispatcher detects that the client has disconnected, it raises ClientDisconnected, which the scanner handles as a controlled interruption.</p><h3>3. GitHub Action: cbomkit-action</h3><p>cbomkit-action packages cbomkit-lib into a GitHub Action that developers can include in their CI/CD workflows. It runs as a Docker container built on Red Hat UBI 8 with OpenJDK 21.</p><h3>4. Full Application: cbomkit</h3><p>cbomkit is a full-stack application that provides a persistent and queryable store of CBOMs (Mnemosyne), a web interface for visualization (Coeus), and a compliance evaluation engine for policy assessment (Themis). The application supports scanning source code directly and importing externally generated CBOM files.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RVDhqiJ2hxykSxDv3dP7nQ.png" /></figure><p><strong>Scan lifecycle:</strong></p><p>A scan begins when a client sends a POST request to /api/v1/scan (synchronous) or establishes a WebSocket connection to /v1/scan/{clientId} (asynchronous with live progress). The presentation layer dispatches a RequestScanCommand to the CommandBus.</p><p>RequestScanCommandHandler creates a ScanAggregate, the root aggregate for a scan operation, and emits either ScanRequestedEvent (for Git URLs) or PurlScanRequestedEvent (for Package URLs, which must first be resolved to a Git URL).</p><p>ScanEventHandler listens to these events and issues sub-commands to the ScanProcessManager:</p><ol><li>ResolvePurlCommand - Resolves a Package URL to a Git repository URL using GitHub API or deps.dev</li><li>CloneGitRepositoryCommand - Clones the repository to a temporary directory using JGit, with optional authentication</li><li>IdentifyPackageFolderCommand - Identifies the relevant subdirectory when scanning a specific package</li><li>IndexModulesCommand - Executes language-specific IndexingService</li><li>ScanCommand - Executes language-specific ScannerService</li></ol><p>After each step, ScanProcessManager updates the ScanAggregate by applying domain events through ScanRepository. The aggregate state is reconstructed from its event log. Progress updates are dispatched via WebSocketProgressDispatcher for WebSocket scans or retained in memory for synchronous responses.</p><p>When all language scans complete, ScanFinishedEvent is emitted. CBOMProjector handles this event, merges per-language CBOMs using CBOM.merge(), and persists the result as a CBOMReadModel in PostgreSQL.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NHEr0sr7tYnc9p6yah0J4A.png" /></figure><p><strong>CBOM storage and retrieval:</strong></p><p>The system separates scan state (event-sourced via ScanRepository) from query state (stored in CBOMReadModel). Clients retrieve CBOMs using the query-side API:</p><ul><li>GET /api/v1/cbom/{projectIdentifier} - Retrieve a CBOM by project</li><li>GET /api/v1/cbom/last/{limit} - Retrieve most recent CBOMs</li><li>POST /api/v1/cbom/{projectIdentifier} - Upload an externally generated CBOM</li><li>DELETE /api/v1/cbom/{projectIdentifier} - Delete a stored CBOM</li></ul><p><strong>Compliance evaluation:</strong></p><p>The compliance endpoint (/api/v1/compliance/check) evaluates a CBOM against defined cryptographic policies. The built-in BasicQuantumSafeComplianceService checks detected algorithms and keys against a whitelist of approved quantum-safe OIDs and algorithm names. Assets not in the whitelist are marked non-compliant. Assets that cannot be classified are marked as unknown.</p><p>For advanced policy evaluation, the application supports an external regulator service configured via CBOMKIT_REGULATOR_API_BASE and optional integration with Open Policy Agent (OPA) through a sidecar container.</p><p><strong>Frontend:</strong></p><p>The Vue.js frontend communicates with the backend over HTTP and WebSocket. It provides interfaces to initiate scans, browse stored CBOMs, visualize cryptographic asset hierarchies, and review compliance results. The IBM Carbon Design System is used as the UI component library.</p><h3>5. Filesystem and Image Scanner: cbomkit-theia</h3><p>cbomkit-theia is a Go CLI tool that detects cryptographic assets in container images and local directories. Unlike the source-code-focused detection performed by sonar-cryptography, Theia operates on deployment artifacts. It inspects files in a filesystem or container image to identify certificates, keys, secrets, and cryptography-related configuration files. It produces or enriches CycloneDX v1.6 CBOMs.</p><p>Theia addresses a limitation in the CBOM pipeline. Source code scanning identifies cryptographic API usage but does not capture runtime cryptographic materials such as deployed TLS certificates, private keys stored on disk, java.security policy files, or OpenSSL configuration that defines cipher suites. Theia detects these artifacts.</p><p><strong>Supported data sources:</strong></p><p>Theia accepts multiple input types through a unified Filesystem abstraction:</p><ul><li>Local directory (plain filesystem)</li><li>Local Docker image from daemon, TAR archive, or Dockerfile (built dynamically)</li><li>Local OCI image as directory or TAR archive</li><li>OCI image from a remote registry</li><li>Docker image from DockerHub</li><li>Singularity image</li></ul><p>For container images, Theia uses <a href="https://github.com/anchore/stereoscope">Anchore Stereoscope</a> to resolve the image, squash layers into a single virtual filesystem, and expose it through the same Filesystem interface used for local directories.</p><p><strong>Architecture:</strong></p><p>Theia consists of four packages:</p><ol><li>cmd/ - CLI layer built with <a href="https://github.com/spf13/cobra">Cobra</a>. Exposes two subcommands: dir (scan a local directory) and image (scan a container image). Each subcommand builds a dependency injection container using <a href="https://github.com/uber-go/dig">Uber Dig</a>, configures a Filesystem implementation, and invokes the scanner.</li></ol><p>2. provider/ - Data source abstractions. Contains three sub-packages:</p><ul><li>provider/filesystem/ - Defines the Filesystem interface (WalkDir, Open, Exists, GetConfig, GetIdentifier) and implementations PlainFilesystem (local directories) and FilteredFilesystem (adds glob-based ignore patterns via .cbomkitignore, configuration, or CLI flags).</li><li>provider/docker/ - Provides GetImage and BuildImage functions for resolving container images via Stereoscope and the Docker client. GetSquashedFilesystem returns a Layer implementing the Filesystem interface.</li><li>provider/cyclonedx/ - BOM parsing, creation, serialization, and component/dependency merge utilities. Handles CycloneDX JSON encoding and decoding.</li></ul><p>3. scanner/ - Core scanning engine. RunScan orchestrates the pipeline: parse optional input BOM, instantiate configured plugins, execute plugins against the filesystem, attach tool metadata, and write the resulting BOM to stdout. The scanner struct manages ordered plugin execution based on PluginType (append plugins first, then verification plugins, then others).</p><p>4. scanner/plugins/ - Plugin implementations. Each plugin implements the Plugin interface:</p><pre>type Plugin interface {<br>    GetName() string<br>    GetExplanation() string<br>    GetType() PluginType<br>    UpdateBOM(fs filesystem.Filesystem, bom *cdx.BOM) error<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-KADzmTKo16ZZTXNNsMKeg.jpeg" /></figure><p><strong>Plugins:</strong></p><ol><li>certificates:Walks the filesystem for X.509 certificates, parses each certificate, and adds it to the CBOM with signature algorithm, public key, and key algorithm details.</li><li>secrets:Uses Gitleaks to detect secrets and cryptographic key material (private, public, symmetric keys). Detected items are added as CBOM components.</li><li>javasecurity:Locates the java.security file, reads jdk.tls.disabledAlgorithms, and cross-references against an input CBOM. Assigns a confidence score (0–1) indicating executability. Requires --bom.</li><li>opensslconf:Locates OpenSSL configuration files (for example, openssl.cnf), extracts TLS versions and cipher suites, and adds them as protocol and configuration components.</li><li>problematicca:Identifies certificates issued by known problematic or untrusted certificate authorities and flags them in the CBOM.</li></ol><p><strong>Integration with source-code CBOMs:</strong></p><p>Theia is designed to operate with sonar-cryptography. A typical workflow is:</p><ol><li>Run a source-code scanner (cbomkit-lib, cbomkit-action, or cbomkit) to produce a CBOM describing cryptographic API usage.</li><li>Run cbomkit-theia image &lt;image&gt; --bom cbom.json to enrich that CBOM with runtime artifacts from the deployment image.</li></ol><p>If a BOM is provided via --bom, Theia parses it, executes all plugins (including verification plugins such as javasecurity), and outputs the enriched CBOM. If no BOM is provided, Theia generates a new BOM containing only filesystem-detected assets.</p><h3>Data Flow Across the System</h3><p>The following describes how data moves through the components when a scan is triggered from the full application, illustrating all layers together:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9OO_hOM5TugEdBvebzKsYw.jpeg" /></figure><p>When using Theia, the flow is independent of the source-code pipeline:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fD_mxe_KTW1ZhPz5HT87Hg.png" /></figure><p>Theia’s output can be consumed directly by compliance tools, or it can be uploaded to cbomkit via POST /api/v1/cbom/{projectIdentifier} for storage and compliance evaluation alongside source-code CBOMs.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=74d21bf46e12" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Message Exchange between Alice and Bob maintaining Authenticity, Integrity, and Confidentiality]]></title>
            <link>https://systemweakness.com/message-exchange-between-alice-and-bob-maintaining-authenticity-integrity-and-confidentiality-f0764f5b6ba7?source=rss-a79607172f9d------2</link>
            <guid isPermaLink="false">https://medium.com/p/f0764f5b6ba7</guid>
            <category><![CDATA[cryptography]]></category>
            <category><![CDATA[authenticity]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[integrity]]></category>
            <category><![CDATA[confidentiality]]></category>
            <dc:creator><![CDATA[Shubham Kumar]]></dc:creator>
            <pubDate>Thu, 26 Feb 2026 07:08:13 GMT</pubDate>
            <atom:updated>2026-03-03T12:25:42.550Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q1yO6xMOhCxyK3qSWDqscw.jpeg" /></figure><h3><strong>1. Key Generation and Identity Establishment</strong></h3><h4>Key Pair Generation</h4><p><strong>Alice</strong> generates:</p><ul><li>Public key: <strong>PK_a</strong></li><li>Private key: <strong>SK_a</strong></li></ul><p><strong>Bob</strong> generates:</p><ul><li>Public key: <strong>PK_b</strong></li><li>Private key: <strong>SK_b</strong></li></ul><h4>Certificate Creation (PKI Process)</h4><ol><li>Alice prepares identity data (public key, domain, organization details, etc.).</li><li>She hashes this data and signs it with <strong>SK_a</strong>, creating a <strong>Certificate Signing Request (CSR)</strong>.</li><li>The CSR is sent to a Certificate Authority (CA).</li><li>The CA verifies her identity and issues an <strong>X.509 certificate</strong> binding <strong>PK_a</strong> to Alice.</li></ol><p>Bob performs the same process and receives a certificate binding <strong>PK_b</strong> to his identity.</p><p>Alice and Bob obtain each other’s authenticated public keys via CA-issued certificates (or pre-shared trusted channels).</p><p>This establishes <strong>identity authenticity</strong>.</p><blockquote><strong>Note: </strong>The use of X.509 Certificates and a CA addresses the Man-in-the-Middle (MitM) vulnerability inherent in raw public key exchange. By binding a public key (PK) to a specific identity through a trusted third party, the system ensures that Bob is communicating with Alice and not an imposter. This process establishes a verifiable chain of trust, where the CA’s signature guarantees the authenticity of the certificate holder’s information.</blockquote><h3>2. Authenticated Key Exchange</h3><h4>Shared Secret Derivation</h4><h4>Key Agreement (e.g., ECDH — Curve25519)</h4><ul><li>Alice computes a shared secret:<br> ss = ECDH(SK_a, PK_b)</li><li>Bob computes the same shared secret:<br> ss = ECDH(SK_b, PK_a)</li></ul><p>Both now possess the same shared secret <strong>ss</strong>.</p><blockquote><strong>Note: </strong>Curve25519 is selected for Elliptic Curve Diffie-Hellman (ECDH) because it offers 128-bit security with high resistance to side-channel attacks and “twist” vulnerabilities. This mechanism allows two parties to derive a Shared Secret (ss) over an insecure channel without ever transmitting the secret itself. By using the recipient’s authenticated public key from the PKI step, the exchange remains protected against interception.</blockquote><h4>Alternative: Key Encapsulation (KEM)</h4><p>Alice can:</p><p>Encapsulate using <strong>PK_b</strong>, producing Shared secret (<strong>ss) </strong>and Ciphertext.</p><p>Bob:</p><p>Decapsulates the ciphertext using <strong>SK_b </strong>and recovers the same shared secret (<strong>ss).</strong></p><blockquote><strong>Note: </strong>A Key Encapsulation Mechanism (KEM) provides an alternative to Diffie-Hellman, where Alice generates a shared secret and “wraps” it using Bob’s public key. This approach is highly efficient and is increasingly favored with Post-Quantum Cryptography (PQC) because it simplifies the key exchange process into a single asymmetric encryption step. Once Bob decapsulates the ciphertext with his private key, both parties reach the same secret state without interactive negotiation.</blockquote><h3>3. Key Derivation</h3><p>Both parties run the shared secret through a Key Derivation Function (KDF), e.g., ANSI X9.63.</p><p>Input:</p><ul><li>Shared secret (ss)</li><li>PK_a</li></ul><p>Output:</p><ul><li>Encryption/Decryption key: <strong>K_enc/K_dec</strong></li><li>MAC key: <strong>K_mac</strong></li></ul><p>Now both parties share identical symmetric keys.</p><blockquote><strong>Note: </strong>A KDF, such as ANSI X9.63 or HKDF, is used because raw shared secrets from Diffie-Hellman often have non-uniform entropy and are not suitable as direct symmetric keys. The KDF “stretches” and “smooths” the shared secret into distinct, high-entropy keys for encryption/decryption (K_enc/K_dec) and authentication (K_mac). This prevents key reuse vulnerabilities by ensuring that a compromise of one key does not automatically compromise the other.</blockquote><h3>4. Message Protection (Performed by Alice)</h3><h4>Step 1 — Encryption (Confidentiality)</h4><p>Alice encrypts the plaintext using <strong>K_enc</strong> (e.g., AES-256 in CTR mode):</p><p>ct = Encrypt(K_enc, plaintext)</p><p>This ensures <strong>confidentiality</strong>.</p><blockquote><strong>Note: </strong>Confidentiality is provided by AES-256 in CTR mode, which transforms the block cipher into a high-speed stream cipher that is computationally infeasible to break.</blockquote><h4>Step 2 — Message Authentication Code (Integrity)</h4><p>Alice computes:</p><p>Alice_MAC = HMAC(K_mac, ct)</p><p>This provides:</p><ul><li><strong>Integrity</strong> (modification changes the MAC)</li><li><strong>Symmetric authenticity</strong> (only someone with K_mac can generate a valid MAC)</li></ul><p>However:</p><ul><li>This does <strong>not</strong> provide non-repudiation.</li><li>Since Bob also knows K_mac, he cannot prove Alice generated the message.</li></ul><blockquote><strong>Note: </strong>To ensure integrity, an HMAC (Hash-based Message Authentication Code) is computed over the ciphertext. This Encrypt-then-MAC (EtM) allows the receiver to verify the MAC and discard tampered data before attempting decryption.</blockquote><h4>Step 3 — Digital Signature (Non-Repudiation)</h4><p>Alice computes:</p><p>h = Hash(ct || Alice_MAC)</p><p>s = Sign(h, SK_a)</p><p>Because only Alice has <strong>SK_a</strong>, only she can create this signature.</p><blockquote><strong>Note: </strong>While HMAC proves that a message was sent by someone possessing the symmetric key, it cannot distinguish between Alice and Bob. A Digital Signature using Alice’s private key (SK_a) is required to achieve non-repudiation. Because Alice is the sole possessor of SK_a, the signature serves as unique cryptographic proof of origin that she cannot later deny, providing a level of accountability that symmetric authentication cannot offer.</blockquote><h4>Alice Sends to Bob:</h4><ul><li>Ciphertext (ct)</li><li>MAC (Alice_MAC)</li><li>Digital signature (s)</li></ul><h3>5. Verification and Decryption (Performed by Bob)</h3><h4>Step 1 — Verify Integrity</h4><p>Bob computes:</p><p>Bob_MAC = HMAC(K_mac, ct)</p><p>If:</p><p>Bob_MAC == Alice_MAC</p><p>Then:</p><ul><li>Integrity is confirmed</li><li>Symmetric authenticity is confirmed</li></ul><h4>Step 2 — Verify Digital Signature</h4><p>Bob computes:</p><p>h = Hash(ct || Alice_MAC)</p><p>Then verifies:</p><p>Verify(s, h, PK_a)</p><p>If valid:</p><ul><li>The message is authenticated</li><li>Non-repudiation is achieved</li></ul><h4>Step 3 — Decrypt Message</h4><p>Bob decrypts:</p><p>plaintext = Decrypt(K_dec, ct)</p><p>The original message is recovered.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f0764f5b6ba7" width="1" height="1" alt=""><hr><p><a href="https://systemweakness.com/message-exchange-between-alice-and-bob-maintaining-authenticity-integrity-and-confidentiality-f0764f5b6ba7">Message Exchange between Alice and Bob maintaining Authenticity, Integrity, and Confidentiality</a> was originally published in <a href="https://systemweakness.com/">System Weakness</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[OpenSSL Jostle vs Bouncy Castle Cryptography Benchmarking]]></title>
            <link>https://medium.com/@chmodshubham/openssl-jostle-vs-bouncy-castle-cryptography-benchmarking-6c8bc5def05c?source=rss-a79607172f9d------2</link>
            <guid isPermaLink="false">https://medium.com/p/6c8bc5def05c</guid>
            <category><![CDATA[bouncy-castles]]></category>
            <category><![CDATA[cryptography]]></category>
            <category><![CDATA[benchmark]]></category>
            <category><![CDATA[jostle]]></category>
            <category><![CDATA[openssl]]></category>
            <dc:creator><![CDATA[Shubham Kumar]]></dc:creator>
            <pubDate>Wed, 04 Feb 2026 05:06:01 GMT</pubDate>
            <atom:updated>2026-02-04T05:06:01.160Z</atom:updated>
            <content:encoded><![CDATA[<h2>OpenSSL Jostle vs Bouncy Castle Crypto Benchmarking</h2><p>Co-Author: <a href="https://medium.com/u/778d95bb4dcb">Aditya Koranga</a></p><p>This project (<a href="https://github.com/ngkore/jostle-bc-crypto-benchmarking">ngkore/jostle-bc-crypto-benchmarking</a>) is a micro-benchmarking suite built on the Java Microbenchmark Harness (JMH) that measures the performance of cryptographic operations across two Java security providers: <a href="https://github.com/bcgit/bc-java">Bouncy Castle (BC)</a>, a pure-Java implementation, and <a href="https://github.com/openssl-projects/openssl-jostle">OpenSSL Jostle</a>, a JNI bridge to the native OpenSSL library. The suite covers symmetric ciphers (AES, ARIA, Camellia, SM4), post-quantum algorithms standardized by NIST (ML-DSA, SLH-DSA, ML-KEM), and key derivation functions (PBKDF2, Scrypt). This blog provides an in-depth technical analysis of the system architecture, the Java Cryptography Architecture (JCA) provider model, and the specific implementation challenges encountered with post-quantum key encapsulation mechanisms and key derivation functions.</p><h2>System Architecture</h2><p>The benchmarking environment is organized into three layers, each with a distinct responsibility.</p><h3>Layer 1 — Benchmarking (JMH)</h3><p>JMH orchestrates the entire execution lifecycle. It manages JVM forks, warmup phases, measurement iterations, and result collection. All benchmark classes are annotated with JMH annotations that control trial setup, parameterization, and result consumption.</p><h3>Layer 2 — Application (Java)</h3><p>This layer contains the benchmark definitions in the com.benchmark package and the two cryptographic providers under test. Bouncy Castle executes all cryptographic operations in pure Java. The Jostle provider defines Java-side JNI wrappers that delegate to native code.</p><h3>Layer 3 — Native (OpenSSL)</h3><p>The Jostle provider loads two native shared libraries at runtime. libssl.so is the standard OpenSSL cryptographic library. libinterface_jni.so is a bridge library that translates Java JNI calls into OpenSSL API invocations. The JVM loads these via System.loadLibrary, controlled by the java.library.path system property and the LD_LIBRARY_PATH environment variable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*CoxBrgP39bEJ8-9Q.png" /></figure><h2>JMH Benchmarking Framework</h2><h3>Why using JMH?</h3><p>Standard Java benchmarking using System.nanoTime() produces unreliable results for three reasons.</p><ol><li>JIT compilation causes a performance profile that changes over time. The JVM interprets bytecode during early invocations and later compiles hot methods into optimized native code. Measurements taken during interpretation do not represent steady-state performance.</li><li>Garbage collection introduces non-deterministic pauses. A GC event during a measurement window can inflate the reported time by orders of magnitude.</li><li>Dead code elimination allows the JVM to optimize away computations whose results are unused. A naive benchmark that discards its output may measure nothing at all.</li></ol><p>JMH addresses these problems through three mechanisms. It runs each benchmark in a separate JVM fork, isolating it from the parent process and prior benchmark state. It provides configurable warmup iterations that are executed but discarded, allowing the JIT compiler to reach steady state before measurement begins. It supplies Blackhole objects that consume computed results in a way the JVM cannot optimize away.</p><h3>Configuration Parameters</h3><p>JMH exposes several parameters that control the statistical quality of results.</p><p><strong>Forks:</strong> determine how many independent JVM processes execute the benchmark. Multiple forks reduce the impact of OS scheduling, ASLR, and other process-level variance.</p><p><strong>Warmup Iterations:</strong> are benchmark cycles that execute before measurement begins. They exist solely to trigger JIT compilation and allow the JVM to reach thermal equilibrium.</p><p><strong>Measurement Iterations:</strong> are the cycles where timing data is collected. More iterations reduce the standard error of the reported mean.</p><p><strong>Benchmark Modes:</strong> control what metric is reported:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/797/1*xpbJWtT8DecU7fYOfXa9Kw.png" /></figure><h3>Benchmark Execution Script</h3><p>The project provides a shell script that configures and launches the benchmarks. The relevant parameters are passed to Gradle as project properties.</p><p>Source: <a href="https://github.com/ngkore/jostle-bc-crypto-benchmarking/blob/main/scripts/run_benchmarks.sh">scripts/run_benchmarks.sh</a></p><pre>WARMUP=1<br>ITERATIONS=3<br>TIME=&quot;1s&quot;<br>FORK=1<br>MODE=&quot;all&quot;<br><br>GRADLE_ARGS=&quot;-PjmhWarmup=$WARMUP -PjmhIterations=$ITERATIONS -PjmhTime=$TIME -PjmhForks=$FORK -PjmhMode=$MODE&quot;<br>./gradlew jmh $GRADLE_ARGS --console=plain 2&gt;&amp;1 | tee &quot;$LOG_FILE&quot;</pre><p>The script also configures the NATIVE_LIB_PATH environment variable, which the Gradle build passes to the JVM as java.library.path. This is required for the Jostle provider to locate and load libinterface_jni.so and libssl.so at runtime.</p><blockquote><strong>Note:</strong> The above values were being used for generating the current benchmarking results (JSON).</blockquote><h2>JCA Provider Model</h2><p>The Java Cryptography Architecture (JCA) defines a provider-independent API for cryptographic operations. Applications call factory methods such as Cipher.getInstance(&quot;AES&quot;) or Signature.getInstance(&quot;ML-DSA&quot;), and the JCA runtime resolves these to provider-specific implementations through the Service Provider Interface (SPI).</p><h3>SPI Contract</h3><p>For each cryptographic service, the JCA defines two classes:</p><ul><li>An <strong>application-facing class</strong> (e.g., javax.crypto.Cipher) that provides the public API.</li><li>An <strong>SPI class</strong> (e.g., javax.crypto.CipherSpi) that defines the methods a provider must implement.</li></ul><p>When application code calls Cipher.getInstance(&quot;AES&quot;, provider), the JCA:</p><ol><li>Looks up the provider object&#39;s service registry.</li><li>Finds the implementation class mapped to &quot;Cipher.AES&quot;.</li><li>Instantiates that class (which must extend CipherSpi) via reflection.</li><li>Wraps it inside a Cipher object and returns it to the caller.</li></ol><p>This indirection allows application code to remain provider-agnostic. The same Cipher.doFinal() call executes Bouncy Castle&#39;s pure-Java AES engine or Jostle&#39;s native OpenSSL AES implementation depending on which provider was specified.</p><h3>Provider Registration</h3><p>Both providers in this project implement the registration step differently, reflecting their distinct architectural philosophies.</p><blockquote><strong>Note:</strong> This is not a part of the project itself, this is something I get aware of during the project. Consider this a pre-requisite for beginners.</blockquote><h2>Benchmark Class</h2><p>The project might look big but the main source code lies around only 4 files which is organized as a class hierarchy rooted at CryptoBenchmark.</p><pre>CryptoBenchmark (abstract)<br>  |-- SymmetricBenchmark (abstract)<br>  |     |-- aes<br>  |     |-- aria<br>  |     |-- camellia<br>  |     |-- sm4<br>  |<br>  |-- PqcBenchmark (abstract)<br>  |     |-- mldsa<br>  |     |-- slhdsa<br>  |     |-- mlkem<br>  |<br>  |-- KdfBenchmark (abstract)<br>        |-- pbkdf2<br>        |-- scrypt</pre><h3>1. CryptoBenchmark.java — Provider Initialization</h3><p>The base class holds the provider instance and the parameterized provider name. JMH’s @Param annotation causes the benchmark to be executed once per listed value, producing results for both providers from a single run.</p><p>Source: <a href="https://github.com/ngkore/jostle-bc-crypto-benchmarking/blob/main/src/main/java/com/benchmark/CryptoBenchmark.java">src/main/java/com/benchmark/CryptoBenchmark.java</a></p><pre>@State(Scope.Benchmark)<br>public abstract class CryptoBenchmark {<br>@Param({&quot;BC&quot;, &quot;Jostle&quot;})<br>    public String providerName;<br>    public Provider provider;<br>    public void initProvider() {<br>        if (&quot;BC&quot;.equalsIgnoreCase(providerName)) {<br>            provider = new BouncyCastleProvider();<br>        } else if (&quot;Jostle&quot;.equalsIgnoreCase(providerName)) {<br>            provider = new JostleProvider();<br>        } else {<br>            throw new IllegalArgumentException(&quot;Unknown provider: &quot; + providerName);<br>        }<br>        Security.addProvider(provider);<br>    }<br>}</pre><p>The @State(Scope.Benchmark) annotation tells JMH that a single instance of this class is shared across all threads executing a given benchmark method. The initProvider() method is called from each subclass&#39;s @Setup method before any benchmark iteration begins.</p><h3>2. SymmetricBenchmark.java — Cipher Operations</h3><p>The symmetric benchmark subclass parameterizes over cipher transformations (algorithm/mode/padding) and key sizes. The commonSetup method constructs a key, generates test data, and pre-computes the ciphertext used by the decryption benchmark.</p><p>Source: <a href="https://github.com/ngkore/jostle-bc-crypto-benchmarking/blob/main/src/main/java/com/benchmark/SymmetricBenchmark.java">src/main/java/com/benchmark/SymmetricBenchmark.java</a></p><pre>public abstract class SymmetricBenchmark extends CryptoBenchmark {<br>protected SecretKey key;<br>    protected byte[] data;<br>    protected byte[] encryptedData;<br>    protected AlgorithmParameterSpec params;<br>    protected String transform;<br>    protected void commonSetup(String transform, int keySize) throws Exception {<br>        this.transform = transform;<br>        initProvider();<br>        String[] parts = transform.split(&quot;/&quot;);<br>        String algorithm = parts[0];<br>        String mode = parts[1];<br>        // ... key generation and IV/nonce setup ...<br>        Cipher encryptCipher = Cipher.getInstance(transform, provider);<br>        // ... encrypt test data for decryption benchmark ...<br>    }<br>    @Benchmark<br>    public void encrypt(Blackhole bh) throws Exception {<br>        Cipher cipher = Cipher.getInstance(transform, provider);<br>        if (params != null) {<br>            cipher.init(Cipher.ENCRYPT_MODE, key, params);<br>        } else {<br>            cipher.init(Cipher.ENCRYPT_MODE, key);<br>        }<br>        bh.consume(cipher.doFinal(data));<br>    }<br>    @Benchmark<br>    public void decrypt(Blackhole bh) throws Exception {<br>        Cipher cipher = Cipher.getInstance(transform, provider);<br>        if (params != null) {<br>            cipher.init(Cipher.DECRYPT_MODE, key, params);<br>        } else {<br>            cipher.init(Cipher.DECRYPT_MODE, key);<br>        }<br>        bh.consume(cipher.doFinal(encryptedData));<br>    }<br>}</pre><p>Each concrete subclass declares its own @Param sets. For example, the Aes subclass benchmarks AES across GCM, ECB, CBC, CTR, OFB, and CFB modes with 128, 192, and 256-bit keys. The Sm4 subclass is restricted to 128-bit keys per the SM4 specification.</p><blockquote><strong>Note:</strong> Cipher.getInstance(transform, provider) is called inside the @Benchmark method itself, not in @Setup. This is intentional: the benchmark measures the full cost of provider lookup, cipher instantiation, initialization, and execution.</blockquote><h3>3. KdfBenchmark.java — KDF Operations</h3><p>The KdfBenchmark abstract class extends CryptoBenchmark and provides shared state for both PBKDF2 and Scrypt benchmarks: a password and a salt. The commonSetup method initializes the provider and sets fixed input values used across all KDF benchmark iterations.</p><p>Source: <a href="https://github.com/ngkore/jostle-bc-crypto-benchmarking/blob/main/src/main/java/com/benchmark/KdfBenchmark.java">src/main/java/com/benchmark/KdfBenchmark.java</a></p><pre>public abstract class KdfBenchmark extends CryptoBenchmark {<br>protected char[] password;<br>    protected byte[] salt;<br>    protected void commonSetup() throws Exception {<br>        initProvider();<br>        password = &quot;password&quot;.toCharArray();<br>        salt = new byte[16]; // 128-bit salt<br>    }</pre><p>The password and salt are fixed across iterations. This is intentional: the benchmark measures the computational cost of the derivation function itself, not the variance introduced by different inputs. A 128-bit (16-byte) salt is standard for both PBKDF2 and Scrypt.</p><h4>3.1 PBKDF2 Benchmark</h4><p>PBKDF2 derives a key by iteratively applying a pseudorandom function (PRF), typically HMAC with a chosen hash algorithm to the password and salt. The iteration count is the primary cost parameter: higher counts produce slower derivations.</p><p>Source: <a href="https://github.com/ngkore/jostle-bc-crypto-benchmarking/blob/main/src/main/java/com/benchmark/KdfBenchmark.java">src/main/java/com/benchmark/KdfBenchmark.java</a></p><pre>public static class Pbkdf2 extends KdfBenchmark {<br>@Benchmark<br>    public void deriveKey(Blackhole bh) throws Exception {<br>        SecretKeyFactory skf = SecretKeyFactory.getInstance(algorithm, provider);<br>        PBEKeySpec spec = new PBEKeySpec(password, salt, iterations, 256);<br>        bh.consume(skf.generateSecret(spec));<br>    }<br>}</pre><p>The benchmark parameterizes over 11 HMAC-based PRF variants spanning three hash families: SHA-2 , SHA-3, and SM3. Each variant is benchmarked at two iteration counts — 1,000 and 10,000, producing 22 benchmark configurations per provider.</p><p>The PBKDF2 benchmark code is entirely provider-agnostic. Both SecretKeyFactory and PBEKeySpec are standard JCA classes (javax.crypto.SecretKeyFactory and javax.crypto.spec.PBEKeySpec). No provider-specific imports or conditional branches are needed. This is possible because the SecretKeyFactory.generateSecret(KeySpec) method accepts a standard PBEKeySpec and returns a standard SecretKey - a single input, single output contract that maps cleanly onto the SPI model.</p><h4>3.2 Scrypt Benchmark</h4><p>Scrypt (RFC 7914) is a memory-hard KDF designed to be expensive to parallelize on custom hardware (ASICs/FPGAs). It achieves this by requiring a large amount of memory proportional to the cost parameter N. The algorithm also takes a block size parameter r (which determines the size of the internal mixing function) and a parallelization parameter p (which controls independent mixing lanes).</p><p>Source: <a href="https://github.com/ngkore/jostle-bc-crypto-benchmarking/blob/main/src/main/java/com/benchmark/KdfBenchmark.java">src/main/java/com/benchmark/KdfBenchmark.java</a></p><pre>public static class Scrypt extends KdfBenchmark {<br>// ... parameters ...<br>    @Benchmark<br>    public void deriveKey(Blackhole bh) throws Exception {<br>        SecretKeyFactory skf = SecretKeyFactory.getInstance(&quot;SCRYPT&quot;, provider);<br>        KeySpec spec;<br>        // Fixed parameters: r=8, p=1, keyLen=256<br>        int r = 8;<br>        int p = 1;<br>        int keyLen = 256;<br>        if (&quot;BC&quot;.equalsIgnoreCase(providerName)) {<br>            spec = new org.bouncycastle.jcajce.spec.ScryptKeySpec(password, salt, N, r, p, keyLen);<br>        } else {<br>             // OpenSSL Jostle provider<br>            spec = new org.openssl.jostle.jcajce.spec.ScryptKeySpec(password, salt, N, r, p, keyLen);<br>        }<br>        bh.consume(skf.generateSecret(spec));<br>    }<br>}</pre><p>The benchmark parameterizes the cost parameter N at two values: 16,384 (2^14) and 32,768 (2^15). The block size r = 8 and parallelization p = 1 are fixed at standard values. The derived key length is 256 bits.</p><p>Unlike PBKDF2, the Scrypt benchmark requires provider-specific conditional branching. Both providers require a custom ScryptKeySpec class to carry the Scrypt-specific parameters (N, r, p), and the standard JCA KeySpec hierarchy does not include a Scrypt-aware specification or atleast I am not aware of.</p><p>The two ScryptKeySpec classes reside in different packages (org.bouncycastle.jcajce.spec vs org.openssl.jostle.jcajce.spec) and cannot be used interchangeably, even though they are structurally identical.</p><p><strong>Bouncy Castle:</strong></p><p>Source: <a href="https://github.com/bcgit/bc-java/blob/main/prov/src/main/java/org/bouncycastle/jcajce/spec/ScryptKeySpec.java#L10">org/bouncycastle/jcajce/spec/ScryptKeySpec.java</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/0*o6m7_zwqmxQammds.png" /></figure><p><strong>Jostle:</strong></p><p>Source: <a href="https://github.com/openssl-projects/openssl-jostle/blob/main/jostle/src/main/java/org/openssl/jostle/jcajce/spec/ScryptKeySpec.java#L12">org/openssl/jostle/jcajce/spec/ScryptKeySpec.java</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/815/0*pJO2zUsJ6KMrGtGH.png" /></figure><h3>4. PqcBenchmark.java — PQ Operations</h3><p>The PQC benchmark subclass introduces KeyPair and raw byte[] data as shared state. Each PQC inner class benchmarks three operations: key generation, signing/encapsulation, and verification/decapsulation. The ML-DSA and SLH-DSA classes use the standard Signature API. The ML-KEM class requires provider-specific code.</p><h4>4.1. ML-DSA Benchmark</h4><p>ML-DSA (Module-Lattice-Based Digital Signature Algorithm, FIPS 204) is one of the three NIST-standardized post-quantum algorithms. Both providers implement it using the standard java.security.Signature API, which makes the benchmark code entirely provider-agnostic. The Signature API defines a contract where sign() returns a byte[] and verify() accepts a byte[]. These return types are part of the standard java.security.SignatureSpi interface. Since ML-DSA is a pure signature scheme that produces and verifies byte arrays, it maps perfectly onto this existing contract. No provider-specific types are needed.</p><p>Source: <a href="https://github.com/ngkore/jostle-bc-crypto-benchmarking/blob/main/src/main/java/com/benchmark/PqcBenchmark.java">src/main/java/com/benchmark/PqcBenchmark.java</a></p><pre>public static class MlDsa extends PqcBenchmark {<br>    @Param({<br>        &quot;ML-DSA-44&quot;,<br>        &quot;ML-DSA-65&quot;,<br>        &quot;ML-DSA-87&quot;<br>    })<br>    public String algorithm;<br>    private byte[] signature;<br>    @Setup(Level.Trial)<br>    public void setup() throws Exception {<br>        initProvider();<br>        KeyPairGenerator kpg = KeyPairGenerator.getInstance(algorithm, provider);<br>        keyPair = kpg.generateKeyPair();<br>        data = new byte[1024];<br>        new SecureRandom().nextBytes(data);<br>        Signature sig = Signature.getInstance(algorithm, provider);<br>        sig.initSign(keyPair.getPrivate());<br>        sig.update(data);<br>        signature = sig.sign();<br>    }<br>    @Benchmark<br>    public void sign(Blackhole bh) throws Exception {<br>        Signature sig = Signature.getInstance(algorithm, provider);<br>        sig.initSign(keyPair.getPrivate());<br>        sig.update(data);<br>        bh.consume(sig.sign());<br>    }<br>    @Benchmark<br>    public void verify(Blackhole bh) throws Exception {<br>        Signature sig = Signature.getInstance(algorithm, provider);<br>        sig.initVerify(keyPair.getPublic());<br>        sig.update(data);<br>        bh.consume(sig.verify(signature));<br>    }<br>}</pre><p>This code works identically for both providers. The only difference is the internal execution path: Jostle’s MLDSASignatureSpi calls through JNI to OpenSSL&#39;s ML-DSA implementation, while Bouncy Castle&#39;s SignatureSpi$MLDSA executes a pure-Java implementation.</p><p><strong>Jostle</strong> registers ML-DSA signatures by directly mapping algorithm names to an SPI class backed by native OpenSSL.</p><p>Source: <a href="https://github.com/openssl-projects/openssl-jostle/blob/main/jostle/src/main/java/org/openssl/jostle/jcajce/provider/ProvMLDSA.java#L48">org/openssl/jostle/jcajce/provider/ProvMLDSA.java</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0w8NQUom-LY9TSAA.png" /></figure><p>The MLDSASignatureSpi class extends java.security.SignatureSpi and implements engineSign() and engineVerify() by calling native methods through the NISelector.MLDSAServiceNI interface.</p><p><strong>Bouncy Castle</strong> uses its $Mappings pattern to register variant-specific signature classes.</p><p>Source: <a href="https://github.com/bcgit/bc-java/blob/main/prov/src/main/java/org/bouncycastle/jcajce/provider/asymmetric/MLDSA.java#L46">org/bouncycastle/jcajce/provider/asymmetric/MLDSA.java</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1018/0*eWIOAElny3XtzM7h.png" /></figure><p>Because both providers produce and consume standard byte[] signatures through the standard SignatureSpi contract, the benchmark code requires no conditional branching or provider-specific imports for ML-DSA.</p><h4>4.2 ML-KEM Benchmark</h4><p>ML-KEM (Module-Lattice-Based Key-Encapsulation Mechanism, FIPS 203) presents a fundamentally different challenge from ML-DSA. Unlike signature schemes, a KEM produces two outputs: a shared secret and an encapsulation (ciphertext). The standard JCA KeyGenerator.generateKey() method returns a single SecretKey object and has no mechanism to return the second output (the encapsulation byte array alongside the key). This section explains how each provider works around this limitation and why the benchmark code requires provider-specific branches.</p><p>Source: <a href="https://github.com/ngkore/jostle-bc-crypto-benchmarking/blob/main/src/main/java/com/benchmark/PqcBenchmark.java">src/main/java/com/benchmark/PqcBenchmark.java</a></p><pre>// encapsulation benchmark<br>@Benchmark<br>public void encaps(Blackhole bh) throws Exception {<br>    if (&quot;Jostle&quot;.equalsIgnoreCase(providerName)) {<br>        KeyGenerator kg = KeyGenerator.getInstance(&quot;ML-KEM&quot;, provider);<br>        kg.init(KEMGenerateSpec.builder()<br>                .withPublicKey(keyPair.getPublic())<br>                .withKeySizeInBits(256)<br>                .withAlgorithmName(&quot;AES&quot;)<br>                .build());<br>        bh.consume(kg.generateKey());<br>    } else {<br>        // Bouncy Castle provider<br>        KeyGenerator kg = KeyGenerator.getInstance(&quot;ML-KEM&quot;, provider);<br>        kg.init(new org.bouncycastle.jcajce.spec.KEMGenerateSpec(keyPair.getPublic(), &quot;AES&quot;),<br>                new SecureRandom());<br>        bh.consume(kg.generateKey());<br>    }<br>}</pre><p>Both providers work around this by returning a composite object: a custom subclass of SecretKey that bundles the shared secret and the encapsulation together. The caller must cast the returned SecretKey to the provider-specific subclass to access the encapsulation.</p><p>Both providers define nearly identical classes for this purpose:</p><p><strong>Bouncy Castle:</strong></p><p>Source: <a href="https://github.com/bcgit/bc-java/blob/main/prov/src/main/java/org/bouncycastle/jcajce/SecretKeyWithEncapsulation.java#L10">org/bouncycastle/jcajce/SecretKeyWithEncapsulation.java</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/732/0*gSl7xQxU5MRhoLzT.png" /></figure><p><strong>Jostle:</strong></p><p>Source: <a href="https://github.com/openssl-projects/openssl-jostle/blob/main/jostle/src/main/java/org/openssl/jostle/jcajce/SecretKeyWithEncapsulation.java#L17">org/openssl/jostle/jcajce/SecretKeyWithEncapsulation.java</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/684/0*1J8RMiQASmmlTMkn.png" /></figure><h4>4.3 Provider-Specific Encaps/Decaps</h4><p>Beyond the return type issue, each provider also requires its own AlgorithmParameterSpec to initialize the KeyGenerator. Jostle defines KEMGenerateSpec and KEMExtractSpec with a builder pattern. Bouncy Castle defines its own KEMGenerateSpec and KEMExtractSpec classes in its jcajce.spec package.</p><p><strong>Bouncy Castle’s encapsulation:</strong> <a href="https://github.com/bcgit/bc-java/blob/main/prov/src/main/java/org/bouncycastle/jcajce/spec/KEMGenerateSpec.java#L11">org/bouncycastle/jcajce/spec/KEMGenerateSpec.java</a></p><p><strong>Jostle’s encapsulation:</strong> <a href="https://github.com/openssl-projects/openssl-jostle/blob/main/jostle/src/main/java/org/openssl/jostle/jcajce/spec/KEMGenerateSpec.java#L16">org/openssl/jostle/jcajce/spec/KEMGenerateSpec.java</a></p><p><strong>Bouncy Castle’s decapsulation:</strong> <a href="https://github.com/bcgit/bc-java/blob/main/prov/src/main/java/org/bouncycastle/jcajce/spec/KEMExtractSpec.java#L11">org/bouncycastle/jcajce/spec/KEMExtractSpec.java</a></p><p><strong>Jostle’s decapsulation:</strong> <a href="https://github.com/openssl-projects/openssl-jostle/blob/main/jostle/src/main/java/org/openssl/jostle/jcajce/spec/KEMExtractSpec.java#L18">org/openssl/jostle/jcajce/spec/KEMExtractSpec.java</a></p><p>Under the hood, Jostle’s MLKEMKeyGenerator.engineGenerateKey() calls native OpenSSL functions for the actual KEM operation.</p><h4>4.4 Bouncy Castle’s Alternative Approaches to ML-KEM</h4><p>4.4.1 Cipher-Based Key Wrapping</p><p>In addition to the KeyGenerator workaround, Bouncy Castle also registers ML-KEM as a Cipher implementation that supports key wrapping. This allows provider-agnostic code to use the standard Cipher.wrap()/Cipher.unwrap() API.</p><p>Source: <a href="https://github.com/bcgit/bc-java/blob/main/prov/src/main/java/org/bouncycastle/jcajce/provider/asymmetric/MLKEM.java#L44">org/bouncycastle/jcajce/provider/asymmetric/MLKEM.java</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/723/0*4afxuQkw2Tf4PUc3.png" /></figure><p>The MLKEMCipherSpi.engineWrap() method performs KEM encapsulation internally and concatenates the encapsulation with the wrapped key into a single byte[].</p><p>Source: <a href="https://github.com/bcgit/bc-java/blob/main/prov/src/main/java/org/bouncycastle/jcajce/provider/asymmetric/mlkem/MLKEMCipherSpi.java#L238">org/bouncycastle/jcajce/provider/asymmetric/mlkem/MLKEMCipherSpi.java</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/718/0*qHxeb_sNTolh9t4e.png" /></figure><p>This approach hides the two-output problem inside the Cipher byte array protocol. However, Jostle does not provide a Cipher-based ML-KEM implementation, so this approach cannot be used for cross-provider benchmarking. Besides, the Cipher path introduces additional key wrapping overhead that would conflate the KEM measurement with symmetric encryption cost.</p><p>4.4.2 Standard KEM API (JEP 452)</p><p>Java 21 introduced javax.crypto.KEM (JEP 452), a standard API designed specifically for key encapsulation mechanisms. This API resolves the two-output problem cleanly:</p><pre>KEM kem = KEM.getInstance(&quot;ML-KEM&quot;, provider);<br>KEM.Encapsulator encapsulator = kem.newEncapsulator(publicKey);<br>KEM.Encapsulated encapsulated = encapsulator.encapsulate();<br>SecretKey sharedSecret = encapsulated.key();<br>byte[] encapsulation = encapsulated.encapsulation();</pre><p>The KEM.Encapsulated return type carries both the shared secret and the encapsulation. The KEM.Decapsulator provides a symmetric decapsulate(byte[]) method that recovers the shared secret from an encapsulation.</p><p>Bouncy Castle implements this standard API through MLKEMSpi, a class that implements javax.crypto.KEMSpi. It is registered in the JDK17+ multi-release overlay of the Bouncy Castle JAR.</p><p>Source: <a href="https://github.com/bcgit/bc-java/blob/main/prov/src/main/jdk17/org/bouncycastle/jcajce/provider/asymmetric/mlkem/MLKEMSpi.java#L15">prov/src/main/jdk17/org/bouncycastle/jcajce/provider/asymmetric/mlkem/MLKEMSpi.java</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/929/0*D1DBrnd_B6LL6_aE.png" /></figure><p>The KEM service registration appears only in the JDK17+ overlay of MLKEM.java:</p><p>Source: <a href="https://github.com/bcgit/bc-java/blob/main/prov/src/main/jdk17/org/bouncycastle/jcajce/provider/asymmetric/MLKEM.java#L56">prov/src/main/jdk17/org/bouncycastle/jcajce/provider/asymmetric/MLKEM.java</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/861/0*BsL_cTw9oLlGD54A.png" /></figure><p>This registration is absent from the base version of MLKEM.java (in prov/src/main/java/), which only registers KeyFactory, KeyPairGenerator, KeyGenerator, and Cipher services.</p><p><strong>Jostle</strong> does not implement javax.crypto.KEMSpi at all. The src/main/java21/ source directory in the Jostle project is empty. ML-KEM is only accessible through the KeyGenerator + KEMGenerateSpec/KEMExtractSpec pattern.</p><p>The benchmark uses the KeyGenerator path because it is the only API supported by both providers, enabling a direct side-by-side comparison of the raw KEM primitive.</p><h2>Build Configuration</h2><h3>Gradle Setup</h3><p>The project uses the me.champeau.jmh Gradle plugin (version 0.7.3) to integrate JMH into the build lifecycle.</p><p>Source: <a href="https://github.com/ngkore/jostle-bc-crypto-benchmarking/blob/main/build.gradle">build.gradle</a></p><pre>plugins {<br>    id &#39;java&#39;<br>    id &#39;me.champeau.jmh&#39; version &#39;0.7.3&#39;<br>}<br>java {<br>    toolchain {<br>        languageVersion = JavaLanguageVersion.of(25)<br>    }<br>}<br>dependencies {<br>    implementation fileTree(dir: &#39;libs&#39;, include: [&#39;*.jar&#39;])<br>    implementation &#39;org.openjdk.jmh:jmh-core:1.37&#39;<br>    annotationProcessor &#39;org.openjdk.jmh:jmh-generator-annprocess:1.37&#39;<br>}</pre><p>The provider JARs (bcprov-jdk18on-1.84-SNAPSHOT.jar and openssl-jostle-1.0-SNAPSHOT.jar) are loaded from the libs/ directory. JMH 1.37 is used for benchmark annotation processing and runtime.</p><h3>JVM Arguments</h3><p>The JMH block configures JVM arguments that are passed to the forked benchmark process.</p><pre>jvmArgs = [<br>    &#39;--enable-native-access=ALL-UNNAMED&#39;,<br>    &#39;-Dorg.openssl.jostle.loader.load_name_0=interface_jni&#39;,<br>    &#39;-XX:+UseG1GC&#39;,<br>    &#39;-XX:MaxGCPauseMillis=200&#39;,<br>    &#39;-XX:+IgnoreUnrecognizedVMOptions&#39;,<br>    &#39;--add-opens=java.base/java.lang=ALL-UNNAMED&#39;,<br>    &#39;--add-opens=java.base/sun.misc=ALL-UNNAMED&#39;,<br>    &#39;-Djmh.separateClasspathJAR=true&#39;,<br>    &#39;-Djava.io.tmpdir=/tmp&#39;<br>]</pre><p>--enable-native-access=ALL-UNNAMED permits the Jostle provider to call native methods without module access warnings. The loader.load_name_0 property tells the Jostle native loader which shared library to load. --add-opens flags are required because JMH internally accesses non-exported JDK internals for its benchmarking infrastructure. The G1 garbage collector with a 200ms pause target provides consistent GC behavior across benchmark runs.</p><h3>Result Output</h3><p>Benchmark results are written in JSON format to results/results.json. This file is consumed by the project&#39;s web-based visualizer:</p><pre>resultFormat = &#39;JSON&#39;<br>resultsFile = project.file(&quot;${project.projectDir}/results/results.json&quot;)</pre><p><a href="https://ngkore.github.io/jostle-bc-crypto-benchmarking/">JMH Benchmark Visualizer - Jostle vs BC</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6c8bc5def05c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Jostle Bouncy Castle Crypto Benchmarking Tool]]></title>
            <link>https://medium.com/@chmodshubham/jostle-bouncy-castle-crypto-benchmarking-tool-d1d9a0b24d0d?source=rss-a79607172f9d------2</link>
            <guid isPermaLink="false">https://medium.com/p/d1d9a0b24d0d</guid>
            <category><![CDATA[openssl]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[bouncy-castles]]></category>
            <category><![CDATA[cryptography]]></category>
            <category><![CDATA[jostle]]></category>
            <dc:creator><![CDATA[Shubham Kumar]]></dc:creator>
            <pubDate>Tue, 03 Feb 2026 04:36:01 GMT</pubDate>
            <atom:updated>2026-02-03T04:36:01.958Z</atom:updated>
            <content:encoded><![CDATA[<p>JMH benchmarking suite comparing cryptographic performance between <a href="https://github.com/bcgit/bc-java">Bouncy Castle (BC)</a> and <a href="https://github.com/openssl-projects/openssl-jostle">OpenSSL Jostle</a> providers.</p><blockquote><strong>Note:</strong> This documentation is a replica of the README available at the <a href="https://github.com/ngkore/jostle-bc-crypto-benchmarking">github/ngkore/jostle-bc-crypto-benchmarking</a>. Please refer to the original repository for the most up-to-date information.</blockquote><h2>Supported Algorithms</h2><ul><li><strong>Symmetric</strong>: AES, ARIA, Camellia, SM4 (AEAD, Block, Stream modes)</li><li><strong>KDF</strong>: PBKDF2 (SHA2, SHA3, SM3) and Scrypt</li><li><strong>Post-Quantum</strong>: ML-DSA, ML-KEM, SLH-DSA (NIST variants)</li></ul><h2>Prerequisites</h2><h3>Java 25+</h3><p>Download from the OpenJDK <a href="https://jdk.java.net/25/">download page</a>.</p><pre>wget https://download.java.net/java/GA/jdk25.0.1/2fbf10d8c78e40bd87641c434705079d/8/GPL/openjdk-25.0.1_linux-x64_bin.tar.gz<br><br># Create directory for Java installation<br>sudo mkdir -p /opt/java<br># Extract the tar.gz file to /opt/java<br>sudo tar -xzf openjdk-25.0.1_linux-x64_bin.tar.gz -C /opt/java<br># Rename for easier access (optional)<br>sudo mv /opt/java/jdk-25.0.1 /opt/java/jdk-25</pre><p>Configure JAVA_HOME and PATH variables:</p><pre># Add to ~/.bashrc<br>export JAVA_HOME=/opt/java/jdk-25<br>export PATH=$PATH:$JAVA_HOME/bin<br><br># Apply changes<br>source ~/.bashrc</pre><h3>Node.js 20+ (for Visualizer)</h3><p>Required only if you want to run the visualizer locally.</p><pre># Using nvm (recommended)<br>curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash<br>source ~/.bashrc<br>nvm install 20<br>nvm use 20</pre><h3>Setup</h3><h3>1. Provider JARs</h3><p>Place the following provider JARs in the libs/ directory:</p><ul><li>bcprov-jdk18on-*.jar (from Bouncy Castle)</li><li>openssl-jostle-*.jar (from Jostle provider)</li></ul><blockquote><strong>Note:</strong> Follow <a href="https://github.com/ngkore/jostle">ngkore/jostle</a> and <a href="https://github.com/ngkore/bouncy-castle-java">ngkore/bouncy-castle-java</a> for instructions on how to build the Jostle and Bouncy Castle provider.</blockquote><h3>2. Native Library Paths</h3><p>The Jostle provider requires OpenSSL and its own JNI libraries. Edit scripts/run_benchmarks.sh and update the DEFAULT_NATIVE_LIB_PATH variable to match your environment:</p><pre># Example in scripts/run_benchmarks.sh<br>DEFAULT_NATIVE_LIB_PATH=&quot;/path/to/openssl/libssl.so:/path/to/jostle/libinterface_jni.so&quot;</pre><p>If you don’t know the paths, use the find command:</p><p><strong>OpenSSL (look for libssl.so):</strong></p><pre>find /usr -name &quot;libssl.so*&quot; 2&gt;/dev/null<br># Or typical local install:<br>find /home -name &quot;libssl.so*&quot; 2&gt;/dev/null</pre><p>Output:</p><pre>ubuntu@vm01:~$ find /home -name &quot;libssl.so*&quot; 2&gt;/dev/null<br>/home/ubuntu/openssl-3.6.0/libssl.so.3<br>/home/ubuntu/openssl-3.6.0/libssl.so<br>/home/ubuntu/openssl_3_6/lib64/libssl.so.3<br>/home/ubuntu/openssl_3_6/lib64/libssl.so</pre><p><strong>Jostle (look for libinterface_jni.so):</strong></p><pre>find / -name &quot;libinterface_jni.so&quot; 2&gt;/dev/null</pre><p>Output:</p><pre>ubuntu@vm01:~$ find / -name &quot;libinterface_jni.so&quot; 2&gt;/dev/null<br>/home/ubuntu/bouncy-jostle/openssl-jostle/jostle/src/main/resources/native/linux/x86_64/libinterface_jni.so<br>/home/ubuntu/bouncy-jostle/openssl-jostle/jostle/bin/main/native/linux/x86_64/libinterface_jni.so<br>/home/ubuntu/bouncy-jostle/openssl-jostle/jostle/build/resources/main/native/linux/x86_64/libinterface_jni.so<br>/home/ubuntu/bouncy-jostle/openssl-jostle/interface/libinterface_jni.so</pre><p>Use /home/ubuntu/openssl_3_6/lib64:/home/ubuntu/bouncy-jostle/openssl-jostle/jostle/build/resources/main/native/linux/x86_64 for the DEFAULT_NATIVE_LIB_PATH.</p><h2>Running Benchmarks</h2><p>Use the provided script to execute benchmarks. It handles configuration, native paths, and logging.</p><pre>./scripts/run_benchmarks.sh</pre><h3>Outputs</h3><ul><li><strong>JSON Results</strong>: build/results/jmh/results.json (for analysis)</li><li><strong>Execution Log</strong>: build/results/jmh/benchmark_run.log (terminal output)</li></ul><h3>Configuration</h3><p>Configuration is centrally managed in scripts/run_benchmarks.sh.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/571/1*f5NtlfQoBEo1LPBOPcOwEw.png" /></figure><h2>Visualizer</h2><p>A React-based web application for visualizing benchmark results with interactive charts and tables.</p><h3>Local Development</h3><pre>cd visualizer<br>npm install<br>npm run dev</pre><p>The visualizer automatically loads results from results/results.json via symlink. After running benchmarks, start the visualizer to see the comparison between BC and Jostle performance.</p><h3>Production Build</h3><pre>npm run build</pre><p>The built files will be in visualizer/dist/.</p><h3>Live Demo</h3><p>The visualizer is automatically deployed to GitHub Pages when changes are pushed to visualizer/ or results/ on the main branch. Access the visualizer at:</p><p><a href="https://ngkore.github.io/jostle-bc-crypto-benchmarking/">JMH Benchmark Visualizer - Jostle vs BC</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d1d9a0b24d0d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Jostle Supported Algorithms]]></title>
            <link>https://medium.com/@chmodshubham/jostle-supported-algorithms-11da133cdade?source=rss-a79607172f9d------2</link>
            <guid isPermaLink="false">https://medium.com/p/11da133cdade</guid>
            <category><![CDATA[cryptography]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[openssl]]></category>
            <category><![CDATA[jostle]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Shubham Kumar]]></dc:creator>
            <pubDate>Mon, 02 Feb 2026 04:56:01 GMT</pubDate>
            <atom:updated>2026-02-02T04:56:01.374Z</atom:updated>
            <content:encoded><![CDATA[<p>This document provides a complete reference for all cryptographic operations supported in the <a href="https://github.com/openssl-projects/openssl-jostle">OpenSSL Jostle provider</a>.</p><blockquote><strong>Note:</strong> Some algorithms might be missed from the list below. Please refer to the source code for the most accurate and up-to-date information.</blockquote><h3>1. Symmetric Block Ciphers</h3><p><strong>Padding Pattern:</strong></p><ol><li>ECB/CBC modes support NoPadding, PKCS5Padding, PKCS7Padding.</li><li>Stream modes (CFB, OFB, CTR) and AEAD modes (GCM, CCM, OCB) support NoPadding only.</li><li>Special purpose modes (XTS, WRAP, WRAP_PAD) support NoPadding only.</li></ol><h3>AES (Advanced Encryption Standard)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/879/1*_g94QxExju4hv4bXEMptOQ.png" /></figure><h3>ARIA</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/661/1*Esi6Lt_La3Ew1eYk4sGIIg.png" /></figure><h3>CAMELLIA</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/581/1*BwslseZzXFqsrnC93QUEkQ.png" /></figure><h3>SM4</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/481/1*IGo4qBrbH5cPdN0zxH01oA.png" /></figure><h3>2. Post-Quantum Cryptography</h3><h3>ML-DSA (Module-Lattice-Based Digital Signature Algorithm)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/717/1*FPytwgvj4JahJLqbT0kt3A.png" /></figure><h3>SLH-DSA (Stateless Hash-Based Digital Signature Algorithm)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hwavzdk4fHixdAINmrnjlA.png" /></figure><h3>ML-KEM (Module-Lattice-Based Key Encapsulation Mechanism)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/725/1*kX-5Niky48QhFYMw06n4kw.png" /></figure><h3>3. Key Derivation Functions (KDF)</h3><h3>PBKDF2 (Password-Based Key Derivation Function 2)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B69BVyYY9HcMvKXVw7a1Tw.png" /></figure><h3>Scrypt</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/628/1*8FTWaW7ILlxGCZNaQpgKew.png" /></figure><h3>4. Algorithms Present But Not Exposed</h3><p>The following algorithms exist in the codebase but are NOT registered in the provider configuration.</p><h3>Symmetric Ciphers (Unexposed)</h3><p>You can find these algorithms defined in <a href="https://github.com/openssl-projects/openssl-jostle/blob/main/jostle/src/main/java/org/openssl/jostle/jcajce/provider/OSSLCipher.java">OSSLCipher.java</a> but they are not registered in the provider.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/489/1*SfAfbHF2bBARyNkglH6a7Q.png" /></figure><h3>Signature Algorithms (Unexposed)</h3><p>You can find these algorithms defined in <a href="https://github.com/openssl-projects/openssl-jostle/blob/main/jostle/src/main/java/org/openssl/jostle/jcajce/provider/SigAlgs.java">SigAlgs.java</a> but they are not registered in the provider.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/297/1*vxJsScZGwE4epyJxo2K5mw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=11da133cdade" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bouncy Castle Java Deployment]]></title>
            <link>https://medium.com/@chmodshubham/bouncy-castle-java-deployment-d36143f770df?source=rss-a79607172f9d------2</link>
            <guid isPermaLink="false">https://medium.com/p/d36143f770df</guid>
            <category><![CDATA[pqc]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[gradle]]></category>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[bouncy-castles]]></category>
            <dc:creator><![CDATA[Shubham Kumar]]></dc:creator>
            <pubDate>Sun, 01 Feb 2026 04:36:01 GMT</pubDate>
            <atom:updated>2026-02-01T04:36:01.226Z</atom:updated>
            <content:encoded><![CDATA[<p>This document provides a formal, technical procedure for deploying and building the Bouncy Castle Crypto APIs on Ubuntu 22.04 using OpenJDK 25.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bJsBUh5VQ1FC9qufp40E6w.jpeg" /></figure><blockquote><strong>Note:</strong> This documentation is a replica of the README available at the <a href="https://github.com/ngkore/bouncy-castle-java">github/ngkore/bouncy-castle-java</a>. Please refer to the original repository for the most up-to-date information.</blockquote><h3>1. Environment Setup</h3><h3>1.1. Install OpenJDK 25</h3><p>The build process requires a modern Java Development Kit. Follow these steps to manually install OpenJDK 25 and configure the system path.</p><pre># Download the OpenJDK Java 25 binary<br>wget https://download.java.net/java/GA/jdk25.0.1/2fbf10d8c78e40bd87641c434705079d/8/GPL/openjdk-25.0.1_linux-x64_bin.tar.gz<br># Create installation directory and extract<br>sudo mkdir -p /opt/java<br>sudo tar -xzf openjdk-25.0.1_linux-x64_bin.tar.gz -C /opt/java<br>sudo mv /opt/java/jdk-25.0.1 /opt/java/jdk-25</pre><h3>1.2. Configure Environment Variables</h3><p>To ensure the system recognizes the new Java version, update your shell profile (e.g., ~/.bashrc).</p><pre>export JAVA_HOME=/opt/java/jdk-25<br>export PATH=$PATH:$JAVA_HOME/bin<br># (Optional) Multi-JDK Testing: Define paths for older JVMs to test compatibility<br># export BC_JDK8=/path/to/java8<br># export BC_JDK11=/path/to/java11<br># export BC_JDK17=/path/to/java17<br># export BC_JDK25=/path/to/java25</pre><p>Apply changes: source ~/.bashrc</p><h3>2. Repository Acquisition</h3><p>Bouncy Castle relies on a separate repository for regression test data. Both must be cloned into the same parent directory.</p><pre>mkdir bc-workspace &amp;&amp; cd bc-workspace<br>git clone https://github.com/bcgit/bc-java.git<br>git clone https://github.com/bcgit/bc-test-data.git</pre><h3>3. Build Process</h3><p>Navigate to the project root and use the Gradle wrapper. The build supports skipping tests for rapid deployment.</p><pre>cd bc-java<br>chmod +x gradlew<br>./gradlew clean build<br># to skip tests<br>./gradlew clean build -x test</pre><h3>4. Artifact Management</h3><h3>4.1. Locate Generated Files</h3><p>Upon a successful build, each module generates artifacts in its respective build/libs directory. Use the following command to list all binaries:</p><pre>find . -name &quot;*.jar&quot; | grep &quot;build/libs&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*aafdz6cNK-ufPQ0S.png" /></figure><h3>4.2. Understanding Artifact Types</h3><p>Each module produces three distinct JAR types:</p><ol><li>*.jar: The primary compiled binary required for production use.</li><li>*-sources.jar: Contains the source code for IDE debugging and reference.</li><li>*-javadoc.jar: Contains the API documentation.</li></ol><h3>4.3. Module Reference Table</h3><p>Module Purpose Artifact Path Output JAR (v1.84)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/876/1*3o7dGCDIiX-ODmwajHqMqg.png" /></figure><h3>5. Verification</h3><h3>5.1. Artifact Integrity (Optional)</h3><p>If utilizing pre-compiled artifacts from <a href="https://www.bouncycastle.org/download/bouncy-castle-java/#latest">Maven Central</a>, verify them against the Bouncy Castle public key using GnuPG.</p><pre># Dearmor the public key<br>gpg -o bc_maven_public_key.gpg - dearmor bc_maven_public_key.asc<br># Verify the JAR signature<br>gpg - no-default-keyring - keyring ./bc_maven_public_key.gpg - verify &lt;file_name&gt;.jar.asc &lt;file_name&gt;.jar</pre><h3>5.2. Functional Deployment Test</h3><p>To verify the installation on OpenJDK 25, compile and run the following Java snippet.</p><p>Save this code as VerifyDeployment.java:</p><pre>import java.security.Security;<br>import org.bouncycastle.jce.provider.BouncyCastleProvider;<br><br>public class VerifyDeployment {<br>    public static void main(String[] args) {<br>        BouncyCastleProvider bc = new BouncyCastleProvider();<br>        Security.addProvider(bc);<br>        System.out.println(&quot;Bouncy Castle Provider Version: &quot; + bc.getVersionStr());<br>        System.out.println(&quot;Registration Status: &quot; + (Security.getProvider(&quot;BC&quot;) != null ? &quot;Success&quot; : &quot;Failed&quot;));<br>    }<br>}</pre><p>Execute the following commands to link the provider JAR and verify the build:</p><pre>export BC_JAR=&quot;./prov/build/libs/bcprov-jdk18on-1.84-SNAPSHOT.jar&quot;<br>javac -cp &quot;$BC_JAR&quot; VerifyDeployment.java<br>java -cp &quot;$BC_JAR:.&quot; VerifyDeployment</pre><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FoE9qP96lSYs%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DoE9qP96lSYs&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FoE9qP96lSYs%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/766e07e2b9b8fcf8a67e8baa193ea954/href">https://medium.com/media/766e07e2b9b8fcf8a67e8baa193ea954/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d36143f770df" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[OpenSSL Jostle]]></title>
            <link>https://medium.com/@chmodshubham/openssl-jostle-a21da656b84a?source=rss-a79607172f9d------2</link>
            <guid isPermaLink="false">https://medium.com/p/a21da656b84a</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[jostle]]></category>
            <category><![CDATA[openssl]]></category>
            <category><![CDATA[cryptography]]></category>
            <category><![CDATA[pqc]]></category>
            <dc:creator><![CDATA[Shubham Kumar]]></dc:creator>
            <pubDate>Fri, 30 Jan 2026 14:12:36 GMT</pubDate>
            <atom:updated>2026-01-30T14:29:21.703Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://github.com/openssl-projects/openssl-jostle">OpenSSL Jostle</a> is a Java provider that wraps OpenSSL native library features into a standard Java JCA/JCE Provider. This guide covers the deployment process on a Linux system.</p><blockquote><strong>Note:</strong> This documentation is a replica of the README available at the <a href="https://github.com/ngkore/jostle">github/ngkore/jostle</a>. Please refer to the original repository for the most up-to-date information.</blockquote><h3>Prerequisites</h3><p>The deployment requires Java 25 to build, though the final jar supports Java 1.8 to Java 25. You will also need CMake version 3.31 or higher.</p><h3>Deployment Steps</h3><h3>1. System Preparation</h3><p>Update system packages and install build dependencies:</p><pre>sudo apt update &amp;&amp; sudo apt upgrade<br>sudo apt install -y build-essential checkinstall zlib1g-dev libssl-dev<br>sudo apt install -y perl-modules perl-doc</pre><h3>2. Build OpenSSL Library 3.5+</h3><p>OpenSSL Library 3.5+ source bundle can be downloaded from <a href="https://openssl-library.org/source/">OpenSSL Downloads</a>.</p><pre>wget https://github.com/openssl/openssl/releases/download/openssl-3.6.0/openssl-3.6.0.tar.gz<br>tar -xzf openssl-3.6.0.tar.gz<br>cd openssl-3.6.0/<br>Configure and build OpenSSL with a local prefix:<br>## installing it to a local directory, openssl_3_6 instead of system-wide installation<br>./Configure - prefix=`pwd`/../openssl_3_6<br>make clean<br>make -j$(nproc)<br>make install_sw<br>Set the OPENSSL_PREFIX environment variable:<br>cd ../openssl_3_6/<br>export OPENSSL_PREFIX=`pwd`<br>echo &quot;${OPENSSL_PREFIX}&quot;<br>cd ..</pre><h3>3. Install OpenJDK Java 25</h3><p>Download the OpenJDK Java 25 <a href="https://jdk.java.net/25/">download page</a>.</p><pre>wget https://download.java.net/java/GA/jdk25.0.1/2fbf10d8c78e40bd87641c434705079d/8/GPL/openjdk-25.0.1_linux-x64_bin.tar.gz<br># Create directory for Java installation<br>sudo mkdir -p /opt/java<br># Extract the tar.gz file to /opt/java<br>sudo tar -xzf openjdk-25.0.1_linux-x64_bin.tar.gz -C /opt/java<br># Rename for easier access (optional)<br>sudo mv /opt/java/jdk-25.0.1 /opt/java/jdk-25</pre><p><strong>Set Environment Variables</strong></p><p>Configure JAVA_HOME and PATH variables for your system:</p><pre># Edit your bash profile<br>vim ~/.bashrc<br># Add these lines at the end of the file:<br>export JAVA_HOME=/opt/java/jdk-25<br>export PATH=$PATH:$JAVA_HOME/bin<br># Apply the changes<br>source ~/.bashrc</pre><p>Check that Java 25 is installed correctly:</p><pre>java - version<br>javac - version<br>echo $JAVA_HOME</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/666/0*FGShdC8MCag2u85O.png" /></figure><p>For system-wide installation (all users), edit /etc/environment:</p><pre>sudo vim /etc/environment<br># Add this line:<br>JAVA_HOME=&quot;/opt/java/jdk-25&quot;<br>PATH=&quot;/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/java/jdk-25/bin&quot;</pre><h3>4. Install CMake</h3><p>Download and install CMake 4.1.2 (or any version &gt;= 3.31 will work), see <a href="https://github.com/Kitware/CMake/releases/">https://github.com/Kitware/CMake/releases/</a>:</p><pre>wget https://github.com/Kitware/CMake/releases/download/v4.1.2/cmake-4.1.2-linux-x86_64.tar.gz<br>tar -xzf cmake-4.1.2-linux-x86_64.tar.gz<br>sudo cp -r cmake-4.1.2-linux-x86_64 /opt/cmake<br>sudo ln -s /opt/cmake/bin/cmake /usr/local/bin/cmake<br>cmake - version</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/701/0*A1hRZt9nzS5NO5gk.png" /></figure><h3>5. Build OpenSSL JOSTLE</h3><p>Clone the repository:</p><pre>git clone https://github.com/openssl-projects/openssl-jostle.git<br>cd openssl-jostle/</pre><p>Generate Java headers:</p><pre>./gradlew clean compileJava</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*al9Jpkv-jOizK7bb.png" /></figure><p>Enable operations testing support (optional):</p><pre>export JOSTLE_OPS_TEST=true<br># To unset<br>unset JOSTLE_OPS_TEST</pre><p>Build the interface libraries:</p><pre>./interface/build.sh</pre><p>The command will compile the C/C++ interface layer that bridges Java and OpenSSL. This script uses CMAKE and the previously set OPENSSL_PREFIX to find OpenSSL libraries. It generates both JNI (Java Native Interface) and FFI (Foreign Function Interface) bindings. The compiled libraries are automatically copied to jostle/src/main/resources/native/.</p><p>Build the final jar:</p><pre>./gradlew clean build<br>## To skip tests during build<br>./gradlew clean build -x test</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qjD7PU15lOSRh8GA.png" /></figure><p>Complete build output (without skipping tests) can be found in <a href="https://github.com/ngkore/jostle/blob/main/gradlew-build.log">gradle-build.log</a>.</p><h3>6. Verify Installation</h3><p>Run the DumpInfo utility to verify successful deployment:</p><pre>java - module-path jostle/build/libs/openssl-jostle-1.0-SNAPSHOT.jar \<br> - enable-native-access=org.openssl.jostle.prov \<br> - module org.openssl.jostle.prov/org.openssl.jostle.util.DumpInfo</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Y0686bNxyTulb16L.png" /></figure><h3>Build Output</h3><p>The compiled jar file will be located at:</p><pre>openssl-jostle/jostle/build/libs/openssl-jostle-1.0-SNAPSHOT.jar</pre><h3>Interface Selection</h3><p>JOSTLE defaults to FFI interface when available. To force JNI interface:</p><pre>java -Dorg.openssl.jostle.loader.interface=JNI \<br> - module-path jostle/build/libs/openssl-jostle-1.0-SNAPSHOT.jar \<br> - enable-native-access=org.openssl.jostle.prov \<br> - module org.openssl.jostle.prov/org.openssl.jostle.util.DumpInfo</pre><p>Interface Options:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/581/1*jaanKsLaPuhnjmDwVzZQBQ.png" /></figure><h3>Tutorial Video</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FVjXnHwPAvic%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DVjXnHwPAvic&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FVjXnHwPAvic%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/4cbdd33b078751f6f354a2d9d6ad2742/href">https://medium.com/media/4cbdd33b078751f6f354a2d9d6ad2742/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a21da656b84a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[O-RAN Software Community (OSC) SMO/OAM]]></title>
            <link>https://medium.com/@chmodshubham/o-ran-software-community-osc-smo-oam-007fab63b911?source=rss-a79607172f9d------2</link>
            <guid isPermaLink="false">https://medium.com/p/007fab63b911</guid>
            <category><![CDATA[rics]]></category>
            <category><![CDATA[ran]]></category>
            <category><![CDATA[oran]]></category>
            <category><![CDATA[oam]]></category>
            <category><![CDATA[smo]]></category>
            <dc:creator><![CDATA[Shubham Kumar]]></dc:creator>
            <pubDate>Tue, 27 Jan 2026 06:35:43 GMT</pubDate>
            <atom:updated>2026-01-27T06:35:43.903Z</atom:updated>
            <content:encoded><![CDATA[<p>The O-RAN architecture decomposes the RAN into three distinct functional entities: the Open Central Unit (O-CU), the Open Distributed Unit (O-DU), and the Open Radio Unit (O-RU). While this disaggregation fosters innovation and vendor diversity, it introduces significant complexity in management and orchestration. The Service Management and Orchestration (SMO) framework is designed to handle this complexity. It provides lifecycle management, configuration control, performance monitoring, fault handling, and automation for all RAN components deployed across the O-Cloud.</p><p>The<a href="https://o-ran-sc.org/"> O-RAN Software Community (OSC)</a> serves as the open-source implementation arm of the<a href="https://www.o-ran.org/"> O-RAN Alliance</a>. Within OSC, the OAM project plays a critical role. It provides the reference software for the administrative and operator functions of the O-RAN architecture. The project does not strictly build from scratch; rather, it integrates and extends mature open-source components from the ONAP (Open Network Automation Platform) ecosystem, specifically the SDN Controller (SDNC) and the Virtual Event Streaming (VES) collector, to create a compliant O1 interface termination point.</p><p>However, the OSC OAM goal is not just about connectivity between SMO and RAN elements. The real objective is to enable closed-loop automation, where network telemetry (Performance Management — PM, and Fault Management — FM) flows up to the SMO using VES/HTTP, and intelligent decisions flow down as configuration updates (Configuration Management — CM) via the NETCONF/YANG protocol. This bi-directional control loop is the foundation of the “Intelligent RAN”.</p><h3>ONAP Components in OSC OAM</h3><p>The OSC OAM architecture is a distributed system composed of loosely coupled microservices. It heavily utilizes specific ONAP components to create a compliant termination point for the O1 Interface.</p><p>The O1 interface represents the primary management component in the O-RAN architecture. It connects the SMO to the O-CU, O-DU, and Near-RT RIC. It operates in the management plane using standard Internet protocols:</p><ol><li>NETCONF/YANG for synchronous configuration (CM) and</li><li>HTTP/VES for asynchronous notifications (FM, PM) to ensure interoperability between SMO and RAN functions from diverse vendors.</li></ol><blockquote><strong>Note:</strong> Follow this repository (<a href="https://github.com/ngkore/OSC-OAM">github/ngkore/OSC-OAM</a>) to setup the OSC-OAM on your system.</blockquote><p>Below is a snapshot of the Kubernetes pods that together form a functional SMO/OAM in a simplified Kubernetes environment (with simpler authentication mechanisms that means no Keycloak and Traefik).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8sU5FUeepqoYZGaE.png" /></figure><pre>ubuntu@ubuntu:~/o1-adapter$ kubectl get pods -A<br>NAMESPACE          NAME                                                READY   STATUS      RESTARTS       AGE<br>cert-manager       cert-manager-5bd57786d4-vcdxb                       1/1     Running     0              3h32m<br>cert-manager       cert-manager-cainjector-57657d5754-94vl4            1/1     Running     0              3h32m<br>cert-manager       cert-manager-webhook-7d9f8748d4-j956r               1/1     Running     0              3h32m<br>ingress-nginx      ingress-nginx-admission-create-f8wnm                0/1     Completed   0              3h32m<br>ingress-nginx      ingress-nginx-admission-patch-crqqj                 0/1     Completed   3              3h32m<br>ingress-nginx      ingress-nginx-controller-65d6d978b-87kpg            1/1     Running     0              3h32m<br>kube-system        calico-kube-controllers-6b78c44475-v86sb            1/1     Running     0              3h32m<br>kube-system        canal-wvvb7                                         2/2     Running     0              3h32m<br>kube-system        coredns-5cd5577cc9-7gq6t                            1/1     Running     0              3h32m<br>kube-system        coredns-5cd5577cc9-tcr26                            1/1     Running     0              3h32m<br>kube-system        etcd-ubuntu                                         1/1     Running     0              3h33m<br>kube-system        kube-apiserver-ubuntu                               1/1     Running     0              3h33m<br>kube-system        kube-controller-manager-ubuntu                      1/1     Running     0              3h32m<br>kube-system        kube-proxy-x7brv                                    1/1     Running     0              3h32m<br>kube-system        kube-scheduler-ubuntu                               1/1     Running     0              3h33m<br>kube-system        metrics-server-74fbf9b9b4-xcd5j                     1/1     Running     0              3h32m<br>kube-system        node-local-dns-gf7t6                                1/1     Running     0              3h32m<br>mariadb-operator   mariadb-operator-844954c944-pnclh                   1/1     Running     0              3h25m<br>mariadb-operator   mariadb-operator-cert-controller-769886898b-fqxc2   1/1     Running     0              3h25m<br>mariadb-operator   mariadb-operator-webhook-6768b6799d-2sgxz           1/1     Running     0              3h25m<br>onap               mariadb-galera-0                                    1/1     Running     0              3h22m<br>onap               onap-chartmuseum-7bc565d46-jnt47                    1/1     Running     0              3h21m<br>onap               onap-dcae-datafile-collector-54fb56f757-ckfmf       1/1     Running     0              3h21m<br>onap               onap-dcae-ms-healthcheck-d7cf866bb-2ntqz            1/1     Running     0              3h21m<br>onap               onap-dcae-pm-mapper-9f5b6fc74-qggjd                 1/1     Running     0              3h21m<br>onap               onap-dcae-ves-collector-5f57dcb588-9f4d8            1/1     Running     0              3h21m<br>onap               onap-dcae-ves-mapper-5dcc6dd778-h2fr2               1/1     Running     0              3h21m<br>onap               onap-dmaap-dr-mariadb-init-config-job-vrrd7         0/1     Completed   0              3h21m<br>onap               onap-dmaap-dr-node-0                                1/1     Running     0              3h21m<br>onap               onap-dmaap-dr-prov-66bf788f8-8scnn                  1/1     Running     0              3h21m<br>onap               onap-message-router-0                               2/2     Running     0              111m<br>onap               onap-robot-5c748c57d9-5dp5m                         1/1     Running     0              3h21m<br>onap               onap-sdnc-0                                         1/1     Running     0              3h21m<br>onap               onap-sdnc-sdnrdb-init-job-p4bjt                     0/1     Completed   0              3h21m<br>onap               onap-sdnc-web-6cf9547dbd-hlqdd                      1/1     Running     0              3h21m<br>onap               onap-strimzi-entity-operator-5b46c475d4-ln8nb       2/2     Running     0              3h22m<br>onap               onap-strimzi-kafka-0                                1/1     Running     0              3h22m<br>onap               onap-strimzi-zookeeper-0                            1/1     Running     0              3h23m<br>strimzi-system     strimzi-cluster-operator-585f6fd995-dfts5           1/1     Running     2 (119m ago)   3h26m</pre><p>The pods described above can be logically grouped into functional layers:</p><ol><li><strong>Ingress Layer:</strong> ingress-nginx-controller, cert-manager.</li><li><strong>Control Layer:</strong> onap-sdnc (SDN Controller), onap-sdnc-web (ODLUX Dashboard), mariadb-galera (Database).</li><li><strong>DCAE Layer (Data Collection):</strong> onap-dcae-ves-collector, onap-dcae-ves-mapper, onap-dcae-datafile-collector, onap-dcae-pm-mapper, onap-dcae-ms-healthcheck.</li><li><strong>DMaaP / Messaging Layer:</strong> onap-strimzi-entity-operator, onap-strimzi-kafka, onap-strimzi-zookeeper, onap-dmaap-dr-node, onap-dmaap-dr-prov, onap-message-router.</li><li><strong>Support Layer:</strong> onap-robot (Testing), onap-chartmuseum (Helm Repo).</li></ol><h3>SDN Controller (SDNC)</h3><p>The heart of the configuration management capability in the SMO is the SDN Controller. In the OSC distribution, this is a specific instantiation of the ONAP SDNC, which is itself built upon the OpenDaylight (ODL) platform.</p><p><strong>1.</strong> The primary function of the SDNC in the O1 context is to act as the <strong>NETCONF Client</strong>. It maintains persistent Secure Shell (SSH) or TLS connections to the southbound managed elements (O-DUs, O-CUs). Through these connections, it performs the following critical operations:</p><ul><li><strong>Capability Discovery</strong>: During the NETCONF “Hello” exchange, the SDNC discovers which YANG modules are supported by the device.</li><li><strong>Configuration Push</strong>: It translates high-level network intents into edit-config RPC calls to modify the device’s (DU, CU) running configuration.</li><li><strong>Synchronization</strong>: It periodically issues get-config calls to ensure its internal view of the network matches the actual device state.</li></ul><p><strong>2.</strong> OpenDaylight utilizes the Model-Driven Service Abstraction Layer (MD-SAL) to maintain two logical data stores: the “Config” datastore representing the desired state and the “Operational” datastore representing the actual state reported by the device. Any divergence between these two MD-SAL stores often signals a synchronization failure or a device malfunction.</p><p><strong>3. </strong>To ensure survival across restarts, a MariaDB database container is deployed alongside the SDNC to provide persistent storage for topological data, device credentials, and historical configuration states.</p><h4><strong>ODLUX (SDNC Dashboard)</strong></h4><p>The onap-sdnc-web pod hosts <strong>ODLUX</strong>, the User Experience framework from the LFN OpenDaylight project, serving as the primary graphical dashboard for the SMO. It functions as the visual front-end for the SDN Controller, allowing operators to visualize and manage the network without relying solely on API calls.</p><p>Through this interface, operators can perform critical tasks such as managing mount points to connect or disconnect devices like O-DUs via NETCONF, inspecting the MD-SAL datastores to compare desired versus actual device states, and viewing the network topology to monitor health status. In standard deployments, external traffic is routed to this service via the Ingress controller using the /odlux path.</p><h3>Virtual Event Streaming (VES) Collector</h3><p>While the SDNC handles bidirectional configuration, the VES Collector is the ingress point for unidirectional, high-volume telemetry data. It is a high-performance Java application (typically Spring Boot based) designed to accept HTTP POST requests containing JSON payloads.</p><ol><li>It exposes a RESTful API, typically at endpoints like /eventListener/v7, supporting both HTTP and HTTPS, with HTTPS being mandatory for secure O-RAN deployments that utilize mutual TLS (mTLS) for device authentication.</li><li>A critical function of the collector is input validation, where it uses a repository of JSON Schemas (the VES Common Event Format) to validate every incoming event against mandatory headers and domain-specific fields. Invalid events are rejected at the edge to prevent data corruption downstream, ensuring that only valid data enters the system.</li><li>The collector does not process the events itself but focuses solely on ingestion and publishing to the message bus, allowing it to scale horizontally and handle thousands of events per second without bottlenecks.</li></ol><p>In essence, the VES Collector functions as a RESTful ingestion point for JSON messages, verifying the source and validating events against the VES schema before distributing them to the DMaaP MR topics.</p><h3>Message Bus and Data Movement (Kafka / DMaaP)</h3><p>The operational intelligence of the SMO relies on a robust message bus to decouple data producers from consumers. In ONAP, this layer is referred to as DMaaP (Data Movement as a Platform), which acts as an abstraction layer over Apache Kafka.</p><p>While the legacy DMaaP Message Router (MR) has been deprecated in the New Delhi release in favor of Strimzi and Kafka, the Data Router (DR) remains a critical component for transporting large bulk files, such as XML performance logs, across the cluster.</p><blockquote><strong>Note:</strong> The Data Router itself is scheduled for deprecation in the Oslo release.</blockquote><h4>Data Router (DR) Architecture</h4><p>The Data Router functions as an asynchronous buffer between producers (like the VES Collector) and consumers (like the PM Mapper). It uses an Eclipse Jetty server for its frontend and relies on a MariaDB instance for storage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*EraejMIn7OVmpYWO.jpg" /></figure><p>Its core components include:</p><ol><li><strong>Provisioning Node</strong> (dmaap-dr-prov): Handles all requests to create feeds and subscribers.</li><li><strong>Data Node</strong> (dmaap-dr-node): Manages the actual publication and delivery of data files to subscribers.</li><li><strong>Storage (MariaDB)</strong>: Stores provisioning data (feed and subscriber definitions) and historical logging data regarding feed activity (publish/delivery logs) for monitoring purposes.</li></ol><p>To ensure efficient data consumption, telemetry flows are segregated into specific Kafka topics. This allows components like the SDNC to subscribe only to relevant events:</p><ol><li>unauthenticated.VES_PNFREG_OUTPUT: Reserved for PNF Registration events. Triggers SDNC to mount new devices.</li><li>unauthenticated.SEC_FAULT_OUTPUT: Dedicated to alarm and fault notifications.</li><li>unauthenticated.SEC_MEASUREMENT_OUTPUT: Dedicated to high-volume Performance Measurement (PM) data.</li><li>unauthenticated.VES_NOTIFICATION_OUTPUT: General state change notifications.</li></ol><p>With the deprecation of the DMaaP Bus Controller, the logic for provisioning feeds has moved directly into the application layer using the<a href="https://gerrit.onap.org/r/gitweb?p=dmaap/datarouter.git;a=blob;f=datarouter-prov-client/README.md"> Data Router Provisioning Client</a> (drprov-client). This client runs as a Kubernetes initContainer for DCAE applications. It interacts directly with the DR Provisioning API. It queries to see if a required Feed or Subscription already exists (based on name, version, or credentials). If the resource is missing, the client creates it; if it exists, the client retrieves the info and configures the application.</p><h4>Bulk File Processing Pipeline</h4><p>The retrieval and processing of bulk telemetry files is handled by a coordinated pipeline involving the DataFile Collector and the PM Mapper.</p><p><strong>DataFile Collector (DFC)</strong></p><p>The process begins when the DFC receives a fileReady event via the Message Router (sent from xNF via VES) in the JSON format. Upon this trigger, the DFC connects to the network function (DU, CU) using secure protocols like SFTP, FTPES, or HTTP/HTTPS to retrieve the file. It utilizes a changeIdentifier parameter to map file types to the appropriate Data Router feeds and subsequently publishes the downloaded file to the Data Router. The DFC includes built-in retry logic that attempts to recover from failures with increasing delays before eventually logging an error and discarding the file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PcFiJPy5LePcn7sa.jpg" /></figure><p><strong>PM Mapper</strong></p><p>Once the files are in the Data Router, the<a href="https://docs.onap.org/projects/onap-dcaegen2/en/latest/sections/services/pm-mapper/architecture.html"> PM Mapper</a> consumes the 3GPP XML files to standardize them. It filters the telemetry data based on configuration to reduce volume, converting it into the VES format, and publishing the result back to the Message Router.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iJ7i1mtfwW0Cpb7w.png" /></figure><p>To handle high loads, the mapper supports parallel processing. One can use these environment variables to tune performance:</p><ol><li>PROCESSING_LIMIT_RATE (optional, default value: 1) allows limiting the rate of processing files through the channel.</li><li>THREADS_MULTIPLIER (optional, default value: 1) — allows specifying a multiplier to calculate the number of threads.</li><li>PROCESSING_THREADS_COUNT (optional, default value: number of threads available to JVM) allows specifying the number of threads that will be used for file processing.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*CqSIUhJcvl_Erfra.jpg" /></figure><p><strong>VES-Mapper</strong></p><p>Different VNF vendors generate event and telemetry data in different formats. All VNF vendors don&#39;t need to support the VES format.<a href="https://docs.onap.org/projects/onap-dcaegen2/en/latest/sections/services/mapper/index.html"> VES-mapper</a> acts as a generic adapter to convert non-standard formats (e.g., SNMP, RESTConf) of event and telemetry data into the VES structure and publishes converted data to DMaaP for consumption by DCAE analytics apps.</p><blockquote><strong>Note:</strong> Currently mapping files are available for SNMP collector and RESTConf collector only.</blockquote><p><strong>Healthcheck</strong></p><p>A service container that exposes a Web API to verify that all DCAE platform and service components are in a “ready” state within Kubernetes.</p><h3>Persistence and Visualization Stack (InfluxDB &amp; Grafana)</h3><p>To make the telemetry data human-readable and historically analyzable, the SMO includes a time-series storage and visualization stack.</p><ol><li><strong>InfluxDB Connector</strong>: This is a specialized microservice (often written in Python or Go) that acts as a Kafka consumer. It subscribes to the measurement topics, parses the VES JSON structures, and flattens the data into a format suitable for InfluxDB (Time, Measurement Name, Tags, Fields).</li><li><strong>InfluxDB</strong>: A high-performance time-series database optimized for write-heavy workloads. It stores the raw counter data (e.g., active_ues, throughput_dl) indexed by time.</li><li><strong>Grafana</strong>: The visualization layer connects to InfluxDB as a data source. The OSC OAM project often distributes pre-provisioned Grafana dashboards (via JSON import) that visualize standard O-RAN metrics, providing operators with an immediate view of network health upon deployment.</li></ol><h3>Identity Management (Keycloak)</h3><p>The entry point to the SMO’s administrative functions is guarded by an Identity Provider (IdP). The OSC implementation utilizes Keycloak, an open-source identity and access management solution.</p><ol><li>Keycloak manages the creation of realms, users, and roles (e.g., “admin,” “operator”). It issues OpenID Connect (OIDC) tokens that are required to access the SMO’s northbound APIs and its graphical user interface.</li><li>Upon deployment, a Python script (config.py) is typically executed to pre-provision the Keycloak realm with the necessary users and service accounts required by the SDNC and other components to authenticate against each other.</li><li>The SDN Controller and the web dashboard are configured as OIDC clients, delegating all authentication logic to Keycloak. This ensures a Single Sign-On (SSO) experience across the various tools in the SMO stack.</li></ol><h3>API Gateway (Traefik)</h3><p>To present a unified interface to the external world and manage SSL termination, a reverse proxy is employed. Traefik routes incoming traffic based on URL paths to the appropriate backend container. For example, traffic to /odlux is routed to the SDNC’s web interface, while traffic to /auth goes to Keycloak. This simplifies the network configuration for the operator, who only needs to expose a single port (usually 443) to the external network.</p><h3>Data Flows</h3><p>Some example operational and data workflows within the OSC OAM/SMO environment are described below.</p><h3>Telemetry Ingestion Pipeline</h3><ol><li>O-DU generates a performance measurement file, parses it, and creates a VES measurement event.</li><li>Then, O-DU sends an HTTP POST to the VES Collector’s URL.</li><li>The VES Collector verifies the JSON schema.</li><li>The event is published to the measurement Kafka topic.</li><li>The InfluxDB Connector consumes the event from Kafka and writes it to InfluxDB.</li><li>Grafana queries InfluxDB and updates the dashboard charts.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*EgTWCoik0enBdlTA.png" /></figure><h3>Alarm Correlation Pipeline</h3><ol><li>O-RU detects a loss of synchronization and sends a VES fault event.</li><li>The event flows through the VES Collector to the fault Kafka topic.</li><li>The SDNC subscribes to this topic.</li><li>The SDNC correlates this alarm with the specific “Mount Point” representing that O-RU. It updates the device’s operational status in MD-SAL (e.g., from Green to Red) and updates the active alarm table in MariaDB.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*EL9ZJrRGxtC-Pnvy.png" /></figure><h3>PNF Registration</h3><ol><li>The O1 Adapter (e.g. OAI) reads its local configuration to identify the SMO VES Collector URL.</li><li>The adapter constructs the pnfRegistration JSON payload, specifically populating the oamV4IpAddress field with its own container IP address.</li><li>The O1 Adapter sends the event via HTTP POST to the VES Collector.</li><li>The VES Collector validates the JSON schema and publishes the validated event to the Kafka topic unauthenticated.VES_PNFREG_OUTPUT.</li><li>The SDNC Controller consumes the registration event from Kafka and parses the JSON to extract the target PNF’s IP address and Port.</li><li>The SDNC initiates the connection by establishing a secure SSH handshake tunnel with the O1 Adapter.</li><li>Both sides exchange &lt;hello&gt; messages to declare their capabilities and supported YANG modules.</li><li>During this exchange, the O1 Adapter specifically advertises support for the _3gpp-nr-nrm-gnbdufunction module.</li><li>The SDNC completes the sequence by requesting the current configuration to synchronize the device state.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*sa0rYkAXiMd6u05M.png" /></figure><p>Example, pnfRegistration event payload sent by the OAI O1 Adapter:</p><pre>&quot;event&quot;: {<br>        &quot;commonEventHeader&quot;: {<br>            &quot;domain&quot;: &quot;pnfRegistration&quot;,<br>            &quot;eventId&quot;: &quot;ManagedElement=gNB-Eurecom-5GNRBox-00001_pnfRegistration&quot;,<br>            &quot;eventName&quot;: &quot;pnfRegistration_OAI_pnfRegistration&quot;,<br>            &quot;eventType&quot;: &quot;OAI_pnfRegistration&quot;,<br>            &quot;sequence&quot;: 0,<br>            &quot;priority&quot;: &quot;Low&quot;,<br>            &quot;reportingEntityId&quot;: &quot;&quot;,<br>            &quot;reportingEntityName&quot;: &quot;ManagedElement=gNB-Eurecom-5GNRBox-00001&quot;,<br>            &quot;sourceId&quot;: &quot;3584&quot;,<br>            &quot;sourceName&quot;: &quot;gNB-Eurecom-5GNRBox-00001&quot;,<br>            &quot;startEpochMicrosec&quot;: 1766518876484213,<br>            &quot;lastEpochMicrosec&quot;: 1766518876484213,<br>            &quot;nfNamingCode&quot;: &quot;001&quot;,<br>            &quot;nfVendorName&quot;: &quot;OpenAirInterface Software Alliance&quot;,<br>            &quot;timeZoneOffset&quot;: &quot;+00:00&quot;,<br>            &quot;version&quot;: &quot;4.1&quot;,<br>            &quot;vesEventListenerVersion&quot;: &quot;7.2.1&quot;<br>        },<br>        &quot;pnfRegistrationFields&quot;: {<br>            &quot;pnfRegistrationFieldsVersion&quot;: &quot;2.1&quot;,<br>            &quot;lastServiceDate&quot;: &quot;2021-03-26&quot;,<br>            &quot;macAddress&quot;: &quot;00:00:00:00:00:00&quot;,<br>            &quot;manufactureDate&quot;: &quot;2021-01-16&quot;,<br>            &quot;modelNumber&quot;: &quot;nr-softmodem&quot;,<br>            &quot;oamV4IpAddress&quot;: &quot;10.156.217.243&quot;,<br>            &quot;serialNumber&quot;: &quot;OpenAirInterface Software Alliance-gNB-10.156.217.243-nr-softmodem&quot;,<br>            &quot;softwareVersion&quot;: &quot;2.3.5&quot;,<br>            &quot;unitFamily&quot;: &quot;OpenAirInterface Software Alliance-gNB&quot;,<br>            &quot;unitType&quot;: &quot;gNB&quot;,<br>            &quot;vendorName&quot;: &quot;OpenAirInterface Software Alliance&quot;,<br>            &quot;additionalFields&quot;: {<br>                &quot;oamPort&quot;: &quot;1830&quot;,<br>                &quot;protocol&quot;: &quot;SSH&quot;,<br>                &quot;username&quot;: &quot;netconf&quot;,<br>                &quot;password&quot;: &quot;netconf!&quot;,<br>                &quot;reconnectOnChangedSchema&quot;: &quot;false&quot;,<br>                &quot;sleep-factor&quot;: &quot;1.5&quot;,<br>                &quot;tcpOnly&quot;: &quot;false&quot;,<br>                &quot;connectionTimeout&quot;: &quot;20000&quot;,<br>                &quot;maxConnectionAttempts&quot;: &quot;100&quot;,<br>                &quot;betweenAttemptsTimeout&quot;: &quot;2000&quot;,<br>                &quot;keepaliveDelay&quot;: &quot;120&quot;<br>            }<br>        }</pre><h3>Closed-Loop Automation</h3><ol><li>The OAI softmodem’s scheduler detects that Physical Resource Block (PRB) utilization has exceeded 90%, identifying a state of congestion.</li><li>The OAI Adapter polls the o1 stats via telnet, observes the high load, and triggers a threshold crossing logic.</li><li>The adapter generates and sends a VES fault event with specificProblem set to “Congestion” and severity set to “MAJOR”.</li><li>The SMO (or a Non-RT RIC rApp) consumes this fault event from Kafka, where the policy engine triggers the rule to increase bandwidth.</li><li>The SMO sends a RESTCONF request to the SDNC to update the bandwidth parameter.</li><li>The SDNC translates this request into a NETCONF edit-config RPC and transmits it to the OAI Adapter.</li><li>The OAI Adapter receives the RPC via Netopeer2, where the Sysrepo callback invokes the internal handler.</li><li>The handler executes the command o1 config bw 40 (MHz) via telnet to the softmodem.</li><li>The softmodem re-initializes the radio front-end to enforce the new bandwidth configuration.</li><li>Once the load decreases, the adapter sends a subsequent VES event with the severity set to “NORMAL” to clear the alarm on the SMO dashboard.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Vr-q6s4W_fXLweH-.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=007fab63b911" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How LibOQS Uses Valgrind to Hunt for Constant-Time Leaks?]]></title>
            <link>https://medium.com/@chmodshubham/how-liboqs-uses-valgrind-to-hunt-for-constant-time-leaks-ea55ed72d546?source=rss-a79607172f9d------2</link>
            <guid isPermaLink="false">https://medium.com/p/ea55ed72d546</guid>
            <category><![CDATA[sad]]></category>
            <category><![CDATA[time-constant]]></category>
            <category><![CDATA[valgrind]]></category>
            <category><![CDATA[kem]]></category>
            <category><![CDATA[liboqs]]></category>
            <dc:creator><![CDATA[Shubham Kumar]]></dc:creator>
            <pubDate>Thu, 06 Nov 2025 20:41:58 GMT</pubDate>
            <atom:updated>2025-11-06T20:41:58.085Z</atom:updated>
            <content:encoded><![CDATA[<p>In cryptography, ensuring constant-time execution is a critical defense against timing side-channel attacks. An implementation is considered constant-time if its execution time and memory access patterns are independent of secret-valued inputs. Failure to adhere to this principle can allow an attacker to infer secret data, such as a private key, simply by measuring the time an operation takes.</p><p>The <a href="https://github.com/open-quantum-safe/liboqs">liboqs</a> project has a specific goal: to ensure that every single instance of secret-dependent control flow is documented. While this process doesn’t guarantee all code is perfectly constant-time, it provides a powerful tool to aid auditors in their search for non-constant-time behavior.</p><p>This documentation explores how liboqs implements this check. The testing methodology itself is built on established techniques. The core observation that Valgrind can be used to identify non-constant-time behaviour is from Adam Langley <a href="https://github.com/agl/ctgrind">[1]</a>, &amp; <a href="https://boringssl.googlesource.com/boringssl/+/a6a049a6fb51a052347611d41583a0622bc89d60">[2]</a>. This idea was applied to the SUPERCOP benchmarking suite by Mortiz Neikes’ TIMECOP project <a href="https://post-apocalyptic-crypto.org/timecop/index.html">[3]</a>, which (starting in 20200816) specifically applied it to randombytes calls <a href="https://bench.cr.yp.to/tips.html#timecop">[4]</a>. The liboqs test suite borrows this concept of instrumenting randombytes calls.</p><h3>Core Detection Methodology</h3><p>The testing strategy, inspired by work from Adam Langley, uses a clever “trick” with Valgrind’s Memcheck tool. Normally, Memcheck is used to find memory errors, like reading uninitialized data. The liboqs test suite leverages this by telling Valgrind that all secret data <em>is</em> uninitialized data.</p><p>Here’s how it works:</p><ol><li>The test programs (<strong><em>test_kem</em></strong> and <strong><em>test_sig</em></strong>) are run through Valgrind.</li><li>The tests intercept all calls to <strong><em>OQS_randombytes</em></strong>, which is the function used to generate secret keys and other random values.</li><li>Instead of just getting random bytes, the interceptor “poisons” them. It gets the real random bytes (so the crypto works) but then tells Valgrind that this block of memory is “uninitialized.”</li><li>As the cryptographic algorithm runs, if it ever makes a decision based on that secret data (like an if (secret[0] &gt; 10)), Valgrind sees a “conditional jump… depends on uninitialised value” and reports an error.</li></ol><p>This immediately flags any code path that branches on secret data.</p><pre> Secret Key Generation<br> ↓<br> [Real Random Bytes: 0x4F, 0x2A, 0x91, …]<br> ↓<br> MARK AS &quot;UNINITIALIZED&quot; (Poison)<br> ↓<br> [Same Bytes, but Valgrind Tracking]<br> ↓<br> Use in Cryptography<br> ↓<br> if (secret[0] &gt; 128) ← VALGRIND: &quot;WARNING!&quot;</pre><h3>The Suppression File System</h3><p>Not all Valgrind errors are critical security flaws. The purpose of this system is to document all suspected non-constant-time behavior. The liboqs codebase includes a set of “suppression files.” Each file documents one or more of these Valgrind errors. When the test script runs, it passes these files to Valgrind to “silence” known errors.</p><ul><li>If the script runs without error, it means all suspected non-constant-time behavior is documented.</li><li>If the script fails, it means a <em>new</em>, undocumented instance has been found.</li></ul><p>These suppressions are organized into two categories:</p><ul><li><strong>passes/</strong>: For errors that are known not to be a security threat (e.g., branching on public data).</li><li><strong>issues/</strong>: For errors that are being tracked as potential issues.</li></ul><h3>Part 1: How to Run the Constant-Time Tests</h3><p>You can run these tests yourself by building liboqs with the correct flags.</p><h3>Prerequisites</h3><ul><li><strong>OS</strong>: Ubuntu 22.04</li><li><strong>Memory</strong>: At least 4–8 GB</li><li><strong>Disk Space</strong>: More than 5 GB</li></ul><p>Install required tools and libraries:</p><pre>sudo apt update<br> sudo apt install astyle cmake gcc ninja-build libssl-dev \<br> python3-pytest python3-pytest-xdist unzip xsltproc \<br> doxygen graphviz python3-yaml valgrind</pre><p>Quick Installation</p><pre># Get the source code<br> git clone https://github.com/open-quantum-safe/liboqs.git<br> cd liboqs<br> <br> # Create build directory<br> mkdir build &amp;&amp; cd build<br> <br> # Configure build with constant-time testing enabled<br> cmake -GNinja .. \<br> -DCMAKE_BUILD_TYPE=Debug \<br> -DOQS_ENABLE_TEST_CONSTANT_TIME=ON \<br> -DOQS_DIST_BUILD=ON<br> <br> # Optional extra flags you can add:<br> # -DCMAKE_INSTALL_PREFIX=/usr/local # Install location<br> # -DOQS_USE_OPENSSL=ON # Use OpenSSL primitives<br> # -DOQS_ENABLE_KEM_CLASSIC_MCELIECE=OFF # Skip slow algorithms<br> # -DBUILD_SHARED_LIBS=ON # Build shared libs<br> <br> # Build the library<br> ninja</pre><h3>Running Constant-Time Tests</h3><p><strong>Test All Algorithms</strong></p><pre># From the build/ directory<br> python3 ../tests/test_constant_time.py</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*SIeaTnaKamXZpKBc.png" /></figure><p><strong>Note:</strong> Ignore the extra line breaks — I pressed Enter multiple times to ensure the program hadn’t frozen.</p><p><strong>Test Specific Algorithms</strong></p><pre># Test only Kyber<br> python3 ../tests/test_constant_time.py -k Kyber<br> <br> # Test specific variant<br> python3 ../tests/test_constant_time.py -k ML-KEM-512<br> <br> # Test with verbose output<br> python3 ../tests/test_constant_time.py -v -k Dilithium</pre><p><strong>Skip Slow Algorithms</strong></p><pre># Set environment variable to skip certain algorithms<br> export SKIP_ALGS=&quot;Classic-McEliece,HQC&quot;<br> python3 ../tests/test_constant_time.py</pre><h3>Part 2: A Deeper Look at the Implementation</h3><p>This testing framework is a combination of a Python script, the C test binaries, and the Valgrind tool.</p><p>Code References:</p><ul><li><a href="https://github.com/open-quantum-safe/liboqs/blob/main/tests/test_constant_time.py">tests/test_constant_time.py</a></li><li><a href="https://github.com/open-quantum-safe/liboqs/blob/main/tests/test_kem.c">tests/test_kem.c</a></li><li><a href="https://github.com/open-quantum-safe/liboqs/blob/main/tests/test_sig.c">tests/test_sig.c</a></li></ul><h3>Implementation Architecture</h3><p>The file structure for managing suppressions is key:</p><pre>liboqs/<br> ├── tests/<br> │ ├── test_constant_time.py # Main orchestrator<br> │ ├── test_kem.c # KEM test binary<br> │ ├── test_sig.c # Signature test binary<br> │ └── constant_time/<br> │ ├── kem/<br> │ │ ├── passes.json # Acceptable timing variations<br> │ │ ├── issues.json # Problematic timing leaks<br> │ │ ├── passes/ # Suppression files (OK)<br> │ │ │ └── *<br> │ │ └── issues/ # Suppression files (problems)<br> │ │ └── *<br> │ └── sig/<br> │ └── (same structure)</pre><h3>Key Functions and Their Roles</h3><p>The magic happens in the C code, specifically in <strong><em>test_kem.c </em></strong>(and <strong><em>test_sig.c</em></strong>).</p><p><strong>1. <em>main()</em> in <em>test_kem.c</em> — The Setup</strong></p><p>This is where the interceptor is installed. When <strong><em>OQS_ENABLE_TEST_CONSTANT_TIME</em></strong> is set, it overrides the default random-bytes generator.</p><pre>// main function initialization<br> int main(int argc, char **argv) {<br> // … initialization code …<br> <br> #ifdef OQS_ENABLE_TEST_CONSTANT_TIME<br> // THIS IS THE KEY: Install our interceptor function<br> OQS_randombytes_custom_algorithm(&amp;TEST_KEM_randombytes);<br> #endif<br> <br> // … rest of main function …<br> // Now all calls to OQS_randombytes will go through TEST_KEM_randombytes<br> }</pre><p><strong>2. <em>TEST_KEM_randombytes</em> — The Interceptor</strong></p><p>This function intercepts all requests for random bytes. It performs a “switching dance” to get real bytes and then “poisons” them.</p><pre>#ifdef OQS_ENABLE_TEST_CONSTANT_TIME<br> static void TEST_KEM_randombytes(uint8_t *random_array, size_t bytes_to_read) {<br> // Step 1: Temporarily switch to the real system RNG<br> // (to avoid infinite recursion)<br> OQS_randombytes_switch_algorithm(&quot;system&quot;);<br> <br> // Step 2: Get REAL random bytes (so crypto works correctly)<br> OQS_randombytes(random_array, bytes_to_read);<br> <br> // Step 3: Switch back to ourselves for future calls<br> OQS_randombytes_custom_algorithm(&amp;TEST_KEM_randombytes);<br> <br> // Step 4: THE MAGIC - Tell Valgrind these bytes are &quot;uninitialized&quot;<br> // Even though they contain real random data!<br> OQS_TEST_CT_CLASSIFY(random_array, bytes_to_read);<br> }<br> #endif</pre><p><strong>3. <em>OQS_randombytes</em> and its Helpers</strong></p><p>These functions manage a global function pointer (oqs_randombytes_algorithm) to determine which RNG to use.</p><pre>// This is what all cryptographic code calls to get random bytes.<br> void OQS_randombytes(uint8_t *random_array, size_t bytes_to_read) {<br> // Calls whatever function oqs_randombytes_algorithm points to<br> oqs_randombytes_algorithm(random_array, bytes_to_read);<br> }<br> <br> // This function changes which random number generator is active.<br> OQS_STATUS OQS_randombytes_switch_algorithm(const char *algorithm) {<br> if (strcasecmp(&quot;system&quot;, algorithm) == 0) {<br> // Switch to system RNG<br> oqs_randombytes_algorithm = &amp;OQS_randombytes_system;<br> return OQS_SUCCESS;<br> }<br> // … other options like &quot;openssl&quot; …<br> return OQS_ERROR;<br> }<br> <br> // This sets a custom random number generator (like our interceptor).<br> void OQS_randombytes_custom_algorithm(void (*algorithm_ptr)(uint8_t *, size_t)) {<br> // Change the global function pointer<br> oqs_randombytes_algorithm = algorithm_ptr;<br> }</pre><p><strong>4. <em>OQS_TEST_CT_CLASSIFY</em> — The Poison Macro</strong></p><p>This is the macro that actually tells Valgrind to mark the memory as uninitialized.</p><pre>#define OQS_TEST_CT_CLASSIFY(addr, len) \<br> VALGRIND_MAKE_MEM_UNDEFINED(addr, len)</pre><h3>Complete Call Flow</h3><p>This diagram shows the full process, from the Python script to the Valgrind warning.</p><p><strong>Phase 1: Initialization</strong></p><pre> 1. test_constant_time.py starts<br> ↓<br> 2. Loads suppression files from JSON<br> ↓<br> 3. Builds Valgrind command:<br> valgrind - tool=memcheck \<br> - suppressions=passes/file1 \<br> - suppressions=issues/file2 \<br> ./test_kem ML-KEM-512<br> ↓<br> 4. Launches test_kem under Valgrind</pre><p><strong>Phase 2: Setup</strong></p><pre> 5. test_kem main() starts<br> ↓<br> 6. Installs interceptor:<br> OQS_randombytes_custom_algorithm(&amp;TEST_KEM_randombytes)<br> ↓<br> [Now: oqs_randombytes_algorithm = TEST_KEM_randombytes]</pre><p><strong>Phase 3: Runtime</strong></p><pre> 7. Test function runs:<br> kem_test_correctness()<br> ↓<br> 8. Crypto needs random bytes:<br> OQS_KEM_keypair() calls OQS_randombytes(secret_key, 32)<br> ↓<br> 9. OQS_randombytes routes to TEST_KEM_randombytes:<br> TEST_KEM_randombytes(secret_key, 32)<br> ├── Switch to system RNG<br> ├── Get real random bytes [0x4F, 0x2A, …]<br> ├── Switch back to interceptor<br> └── POISON the bytes (mark as uninitialized)<br> ↓<br> 10. secret_key now contains real data BUT Valgrind thinks it&#39;s uninitialized<br> ↓<br> 11. Crypto uses the secret key:<br> if (secret_key[0] == 0) // Valgrind: &quot;WARNING! Branch on uninitialized!&quot;</pre><p><strong>Phase 4: Detection</strong></p><pre> 12. Valgrind reports error and exits with code 1<br> ↓<br> 13. Python checks exit code:<br> - Error + NOT in suppressions = TEST FAILS (new leak!)<br> - Error + IN suppressions = TEST PASSES (known issue)<br> - No error = TEST PASSES (no leaks detected)</pre><h3>Why The Switching Dance?</h3><p>The temporary switch inside <strong><em>TEST_KEM_randombytes</em></strong> is critical. It prevents infinite recursion:</p><pre>// WITHOUT switching (would crash!):<br> TEST_KEM_randombytes() {<br> OQS_randombytes(); // Calls TEST_KEM_randombytes<br> // Which calls OQS_randombytes<br> // Which calls TEST_KEM_randombytes<br> // INFINITE LOOP!<br> }<br> <br> // WITH switching (works!):<br> TEST_KEM_randombytes() {<br> switch_to_system(); // Now points to system RNG<br> OQS_randombytes(); // Calls system RNG (not ourselves!)<br> switch_back_to_us(); // Ready for next interception<br> }</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ea55ed72d546" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>