<?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 Priyanka Chauhan on Medium]]></title>
        <description><![CDATA[Stories by Priyanka Chauhan on Medium]]></description>
        <link>https://medium.com/@priyankachouhan2808?source=rss-f2221a975faf------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Stories by Priyanka Chauhan on Medium</title>
            <link>https://medium.com/@priyankachouhan2808?source=rss-f2221a975faf------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 08:20:17 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@priyankachouhan2808/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[SCEP Enrollment end to end process.]]></title>
            <link>https://medium.com/@priyankachouhan2808/scep-enrollment-end-to-end-process-0fef2d692999?source=rss-f2221a975faf------2</link>
            <guid isPermaLink="false">https://medium.com/p/0fef2d692999</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[cryptography]]></category>
            <category><![CDATA[openssl]]></category>
            <category><![CDATA[ssl-certificate]]></category>
            <category><![CDATA[crypto]]></category>
            <dc:creator><![CDATA[Priyanka Chauhan]]></dc:creator>
            <pubDate>Fri, 26 Sep 2025 11:48:54 GMT</pubDate>
            <atom:updated>2025-09-26T11:48:54.388Z</atom:updated>
            <content:encoded><![CDATA[<p>The <strong>Simple Certificate Enrollment Protocol (SCEP)</strong> is a widely used protocol that automates the process of enrolling X.509 certificates between clients and Certificate Authority. Sharing the high level details of how the process works.</p><figure><img alt="Demonstrating SCEP end to end enrolment process" src="https://cdn-images-1.medium.com/max/1024/1*NT144J7LD3_FpLjsQpocvA.png" /><figcaption>Demonstrating high level end to end SCEP enrolment.</figcaption></figure><p>1️⃣ <strong><em>Step 1: Get the CA Certificate. </em></strong>🚀<strong><br></strong>The client retrieves the CA’s SCEP certificate(s) using <strong>GetCACert</strong>.<br>These include:<br> CA signing certificate (to verify CA signatures).<br> CA/RA encryption certificate (to encrypt CSR requests).</p><p>2️⃣<strong><em>Step 2: Get the Challenge (Optional)</em><br></strong>If the CA enforces an enrolment challenge, the client must obtain it.<br>Static challenge: Pre-shared password (configured in advance).<br>Dynamic challenge: Retrieved from a separate process (e.g., device management system).<br>This challenge password is included later in the CSR attributes.</p><p>3️⃣<strong><em>Step 3: Create CSR (PKCS#10)</em><br></strong>Client generates a Certificate Signing Request (CSR).📝<br>Content includes:<br>Client’s Public key, subject information, optional extensions.<br>Challenge password (if required).<br>The CSR is signed with the client’s private key.<br><strong>Purpose</strong>: <em>Prove ownership of the key pair.</em><br>When the CA receives the request, it verifies this signature using the public key embedded in the CSR.</p><p>4️⃣<strong><em>Step 4: Wrap CSR in PKCS#7 Envelope</em><br> </strong>✍️ <strong>Signing (PKCS#7 SignedData) <br></strong>The client signs the CSR + attributes again, this time wrapping it inside a b. CMS SignedData structure.<br>Signed attributes include: <br>transactionID → uniquely links request/response.<br>senderNonce → random anti-replay value.<br>messageType = PKCSReq.<br>This <strong>second signature</strong> is also created with the client’s private key.</p><blockquote><strong><em>Purpose:</em><br></strong><em>Authenticate the SCEP message: -</em><br>a. The CMS SignedData contains the client’s digital signature created with its private key.<br>b. The CA verifies this signature using the public key inside the CSR (or from an existing trust anchor if already known).<br>c. If the signature matches → proves the message came from the entity that controls the corresponding private key.</blockquote><p>🔒<strong> Encryption (PKCS#7 EnvelopedData)<br></strong>The SignedData is then encrypted for confidentiality.<br>Process:<br>Client generates a <strong>random symmetric key</strong> 🔑(session key) vis 3DES/ AES.<br>Encrypts CSR content with this symmetric key (fast).<br>Encrypts the symmetric key with the CA’s <strong>public encryption certificate</strong> (asymmetric).<br>Only the CA can decrypt using its private key.</p><blockquote>⚠️ <strong>Note on padding:<br></strong>RSA is used to wrap the symmetric key,<br>The CMS_Encrypt API applies an RSA padding scheme during the key encryption step to ensure the session key can be securely wrapped.<br>In <strong>FIPS mode</strong>, PKCS#1 v1.5 padding is not allowed.<br>Must use <strong>RSA-OAEP padding</strong> instead in FIPS mode (Details: <a href="https://medium.com/p/cae200eaf4a4">article here</a>).</blockquote><p>5️⃣<strong><em>Step 5: Send the Request <br></em></strong>The entire EnvelopedData is <strong>Base64/DER encoded</strong>.<br>Client sends it to the CA via <strong>PKIOperation (HTTP POST)</strong>. 📩</p><p>6️⃣<strong><em>Step 6: CA Receives Request<br></em></strong>🔒<strong>Decrypt EnvelopedData<br></strong>CA uses its private key to decrypt the encrypted session key.<br>Recovers the symmetric key → decrypts the SignedData.</p><p>✍️<strong>Verify SignedData<br></strong>Extracts signed attributes: transactionID, senderNonce, messageType.<br>Recomputes the hash of CSR + signed attributes.<br>Verifies the client’s signature using the public key inside the CSR.<br>Ensures authenticity and integrity of the request.</p><p>7️⃣<strong><em>Step 7: CA Validates CSR<br></em></strong>Validates CSR signature (proof of possession).<br>Checks challenge password (if provided).<br>Applies CA policy / profile checks (e.g., subject name rules, key usage).<br>If any check fails → reject.</p><p>8️⃣<strong><em>Step 8: CA Decision</em><br>SUCCESS</strong>: CA issues an X.509 certificate (ClientPublicKey signed with CA’s private key).<br><strong>FAILURE</strong>: Request rejected.<br><strong>PENDING</strong>: Manual approval required. (not covered in detail in above flow diagram).</p><blockquote>The CA packages result into a CMS SignedData (CertRep) containing:<br>Issued certificate (and optionally CA chain).<br>Signed attributes:<br>transactionID (copied from request).<br>recipientNonce (copy of client’s senderNonce).<br>messageType = CertRep.<br>pkiStatus = SUCCESS / FAILURE / PENDING.</blockquote><p>9️⃣<strong><em>Step 9: CA Builds Response (CertRep)</em><br></strong>To protect the response:<br>CA computes a hash of content + signed attributes.<br>Signs the hash with its <strong>private key</strong>.<br>Packages everything into a <strong>PKCS#7 SignedData object</strong>.<br>The CertRep is sent back to the client.</p><p>🔟<strong><em>Step 10: Client Validates Response</em></strong></p><ol><li><strong>Verify CA’s Signature </strong>🛡️<strong><br></strong>Extracts CA certificate (trusted from Step 1).<br>Recomputes hash of received content + signed attributes.<br>Verifies the signature using CA’s public key.<br>✅ If matches → response is authentic.<br>❌ If fails → reject.</li><li><strong>Check Nonces and IDs </strong>☑️<strong><br></strong>Confirms transactionID matches request.<br>Confirms recipientNonce = its own senderNonce.</li><li><strong>Extract Certificate </strong>📜<strong><br></strong>If pkiStatus = SUCCESS → Issued certificate.<br>If pkiStatus = FAILURE → Fails.</li></ol><p>You made it till the end.. thank you for having patience to read the long article, if you like do give some👏👏</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0fef2d692999" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[OpenSSL 3.x vs OpenSSL 1.0.2 PKCS12_Create API behavior without FIPS]]></title>
            <link>https://medium.com/@priyankachouhan2808/openssl-3-x-vs-openssl-1-0-2-pkcs12-create-api-behavior-without-fips-7ce177f590c8?source=rss-f2221a975faf------2</link>
            <guid isPermaLink="false">https://medium.com/p/7ce177f590c8</guid>
            <category><![CDATA[cipher]]></category>
            <category><![CDATA[openssl-certificate]]></category>
            <category><![CDATA[openssl-3]]></category>
            <category><![CDATA[openssl]]></category>
            <category><![CDATA[install-openssl]]></category>
            <dc:creator><![CDATA[Priyanka Chauhan]]></dc:creator>
            <pubDate>Mon, 16 Jun 2025 12:54:10 GMT</pubDate>
            <atom:updated>2025-06-16T12:54:10.286Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Recently I was migrating from OpenSSL 1.0.2 to OpenSSL 3.x and encountered the difference in behavior of PKCS12_create API. The default behavior matters as some of the older devices does not understand the algorithm in PKCS12 file generated by OpenSSL 3.x. In below article, I’m sharing my understanding.</blockquote><pre>//PKCS12_create API syntax<br>PKCS12 *PKCS12_create(char *pass, char *name, EVP_PKEY *pkey, X509 *cert, STACK_OF(X509) *ca, int nid_key, int nid_cert, int iter, int mac_iter, int keytype);</pre><p>Highlighting the difference below in pkcs12 schema returned by the above API. Use following command to parse the certificate:<em><br></em><strong><em>openssl pkcs12 -info -in test.p12</em></strong></p><figure><img alt="MAC —" src="https://cdn-images-1.medium.com/max/1024/1*jxUp6-ERdE-Nd9-D_i1Fmg.png" /><figcaption>PKCS12 certificate comparison in OpenSSL 1.0.2 vs OpenSSL 3.x</figcaption></figure><blockquote><strong>Key Differences Between OpenSSL 1.0.2 and OpenSSL 3.x in PKCS#12 Structure.<br>MAC Algorithm<br></strong>a. OpenSSL 1.0.2 uses <strong>SHA1</strong> as the default MAC algorithm.<br>b. OpenSSL 3.x, by default, uses <strong>SHA256</strong> along with <strong>PRF hmacWithSHA256</strong>.<br><strong>Default Encryption Algorithms (Ciphers)<br></strong>a.<strong> </strong>OpenSSL 1.0.2 uses legacy ciphers such as pbeWithSHA1And3-KeyTripleDES-CBC and pbeWithSHA1And40BitRC2-CBC.<br>b. OpenSSL 3.x adopts more modern standards like PBES2, PBKDF2, and AES-256-CBC</blockquote><p><strong>Java Compatibility Notes.<br></strong>1.<strong> </strong>PKCS#12 files generated using <strong>PBES2 encryption</strong> may not be compatible with <strong>Java versions prior to 8u301 or 11.0.1</strong>, as those versions lack complete support for PBES2 parameters.<br>2. Additionally, <strong>MAC construction using PRF hmacWithSHA256</strong> is not fully supported in older Java releases, which may result in errors when attempting to parse or load such PKCS#12 files.<br>📌 <strong>Reference: </strong><a href="https://bugs.openjdk.org/browse/JDK-8228481">JDK Bug Report — JDK-8228481</a></p><p><strong>Solution<em>: To address backward compatibility</em></strong><br>To ensure compatibility with older devices, you should explicitly set the input parameters in the PKCS12_create API based on your requirements. Additionally, you can configure the MAC construction algorithm accordingly.<em> For example, to maintain the same security parameters as OpenSSL 1.0.2 while using OpenSSL 3.x: <br></em>1.<em> </em>Set the encryption algorithm to NID_pbe_WithSHA1And40BitRC2_CBC. <br>2. Set the MAC algorithm to SHA1</p><pre>//OpenSSL 3.x code (maintaining same security standard as in OpenSSL 1.0.2)<br>//Set the NID_pbe_WithSHA1And40BitRC2_CBC &amp; MAC as SHA1<br>//The certificate will be generated same as OpenSSL 1.0.2<br>p12 = PKCS12_create((char*)pswd, (char*)szCertStorePath, pkey, cert, NULL, pbeWithSHA1And3-KeyTripleDES-CBC, NID_pbe_WithSHA1And40BitRC2_CBC, 0, 0, 0); <br>PKCS12_set_mac(p12, pswd, strlen(pswd), NULL, 0, 1, EVP_sha1());</pre><p><strong>✅ Takeaway<br></strong>1<strong>. </strong>When generating PKCS#12 files with OpenSSL 3.x, be cautious of default settings like <strong>PBES2 encryption</strong> and <strong>SHA256-based MAC (hmacWithSHA256)</strong>.<br>2. The default behavior in OpenSSL 3.x offers improved security but may lead to incompatibility with older Java versions (prior to <strong>8u301</strong> or <strong>11.0.1</strong>) that do not fully support these algorithms.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7ce177f590c8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[OpenSSL3.x PKCS7_encrypt API with FIPS provider error:1C8000A8:Provider routines::invalid padding…]]></title>
            <link>https://medium.com/@priyankachouhan2808/openssl3-x-pkcs7-encrypt-api-with-fips-provider-error-1c8000a8-provider-routines-invalid-padding-cae200eaf4a4?source=rss-f2221a975faf------2</link>
            <guid isPermaLink="false">https://medium.com/p/cae200eaf4a4</guid>
            <category><![CDATA[pkcs7]]></category>
            <category><![CDATA[openssl]]></category>
            <category><![CDATA[openssl-3]]></category>
            <category><![CDATA[scep]]></category>
            <category><![CDATA[c]]></category>
            <dc:creator><![CDATA[Priyanka Chauhan]]></dc:creator>
            <pubDate>Sat, 19 Apr 2025 11:58:48 GMT</pubDate>
            <atom:updated>2025-09-19T12:41:29.852Z</atom:updated>
            <content:encoded><![CDATA[<h4>OpenSSL3.x PKCS7_encrypt API with FIPS provider error:1C8000A8:Provider routines::invalid padding mode</h4><p>Migrating from PKCS7 API to CMS API</p><p>📌 <strong>Background</strong></p><p>Being a newbie to OpenSSL, encountered one issue while working on a <strong>SCEP (Simple Certificate Enrollment Protocol)</strong> implementation. Hence sharing the problem and solution for the same. I was using the PKCS7_encrypt() API to create <strong>PKCS7 enveloped data</strong>. SCEP supports <strong>RSA-based encryption</strong>, I was using <strong>AES-256-CBC</strong> as the symmetric cipher. After upgrading to <strong>OpenSSL 3.4</strong>, I started encountering the following error:</p><pre>error:1C8000A8:Provider routines::invalid padding mode</pre><p>⚠️ <strong>Root Cause</strong></p><p>The issue was tied to FIPS (Federal Information Processing Standards) compliance. In OpenSSL 3.x, <strong>RSA encryption using PKCS#1 v1.5 padding is no longer FIPS-approved (</strong>weak padding, read the details here — <a href="https://medium.com/asecuritysite-when-bob-met-alice/so-how-does-padding-work-in-rsa-6b34a123ca1f"><em>https://medium.com/asecuritysite-when-bob-met-alice/so-how-does-padding-work-in-rsa-6b34a123ca1f</em></a><em>)</em>. This became problematic because PKCS7_encrypt() uses <strong>RSA with PKCS#1 v1.5 padding by default</strong>, and there&#39;s no direct API to change the padding scheme within the PKCS7 interface.</p><h4>✅Solution</h4><p>To comply with FIPS mode, RSA encryption must use <strong>OAEP (Optimal Asymmetric Encryption Padding)</strong> instead. However, since PKCS7_encrypt() doesn&#39;t allow changing the RSA padding mode, I migrated the implementation to use <strong>CMS (Cryptographic Message Syntax)</strong> APIs, which offer more flexibility and are a modern alternative to the older PKCS7 APIs.</p><pre>// Step 1: Create the CMS structure (partial mode to allow customization)<br>CMS_ContentInfo* cmsenc = CMS_encrypt(<br>    NULL,               // No recipients added yet<br>    encbio,             // BIO containing the data to encrypt<br>    scepReq-&gt;scep-&gt;conf-&gt;enc_alg, // Encryption algorithm (e.g., AES-256-CBC FIPS approved)<br>    CMS_BINARY | CMS_PARTIAL      // Flags: binary data, partial init<br>);<br><br>if (cmsenc == NULL) {<br>    std::cout &lt;&lt; &quot;Failed to create CMS structure for encryption&quot; &lt;&lt; std::endl;<br>    return 0;<br>}<br><br>// Step 2: Add recipients with FIPS-compliant padding (RSA-OAEP)<br>for (int i = 0; i &lt; sk_X509_num(recipients); ++i) {<br>    X509* cert = sk_X509_value(recipients, i);<br>    CMS_RecipientInfo* ri = CMS_add1_recipient(cmsenc, cert, NULL, NULL, CMS_KEY_PARAM | CMS_BINARY);<br><br>    if (ri == NULL) {<br>        std::cout &lt;&lt; &quot;Unable to add recipient&quot; &lt;&lt; std::endl;<br>        return 0;<br>    }<br><br>    // Access the EVP_PKEY_CTX to modify the padding<br>    EVP_PKEY_CTX* pctx = CMS_RecipientInfo_get0_pkey_ctx(ri);<br>    if (pctx == NULL) {<br>        std::cout &lt;&lt; &quot;Error retrieving key context&quot; &lt;&lt; std::endl;<br>        return 0;<br>    }<br><br>    // Set RSA padding to OAEP (FIPS-approved)<br>    if (EVP_PKEY_CTX_set_rsa_padding(pctx, RSA_PKCS1_OAEP_PADDING) == 0) {<br>        std::cout &lt;&lt; &quot;Error setting RSA padding mode to OAEP&quot; &lt;&lt; std::endl;<br>        return 0;<br>    }<br>}<br><br>// Step 3: Finalize the CMS structure<br>if (CMS_final(cmsenc, encbio, NULL, CMS_BINARY) &lt;= 0) {<br>    std::cout &lt;&lt; &quot;Error finalizing CMS encrypted data&quot; &lt;&lt; std::endl;<br>    return 0;<br>}</pre><h4>🧩Final Notes</h4><ul><li>FIPS mode disallows legacy padding schemes like PKCS#1 v1.5, which breaks older APIs PKCS7_encrypt.</li><li>CMS APIs provide a more flexible alternative that allows setting parameters like padding.</li><li>RSA-OAEP is the FIPS-compliant replacement and works seamlessly when configured through the CMS API.</li><li>With the deprecation of certain features in PKCS7 and enhanced capabilities in CMS, migrating to CMS APIs is a strategic move for long-term maintainability and standards compliance.</li></ul><p>At the end CMS API can be used in NON FIPS mode, and works perfectly fine.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cae200eaf4a4" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>