<?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"><channel><title><![CDATA[Deciphering General-Ciphering (0xDB) and General-Signing (0xDF) APDUs]]></title><description><![CDATA[<h3>Dissecting Encrypted DLMS APDUs</h3>
<p dir="auto">When security is applied at the application layer, the plaintext COSEM APDU is encapsulated in a <code>General-Ciphering</code> (<code>0xDB</code>) structure.</p>
<h4>Wire Format (APDU Tag 0xDB)</h4>
<pre><code class="language-hex">DB 08 47 55 52 55 58 31 32 33 21 00 00 00 42 A1 12 ... 89 AB CD EF 01 23 45 67 89 AB CD EF
</code></pre>
<h4>Field Breakdown</h4>
<ol>
<li><strong>Tag</strong>: <code>DB</code> (<code>general-ciphering</code>)</li>
<li><strong>System Title Length &amp; Value</strong>: <code>08</code> followed by 8 bytes (<code>47 55 52 55 58 31 32 33</code> = <code>GURUX123</code>)</li>
<li><strong>Security Control Byte</strong>: <code>21</code>
<ul>
<li>Bit 4-5 (<code>10</code>b = 0x20): <strong>Authentication + Encryption</strong> (AES-GCM)</li>
<li>Bit 0-3 (<code>0001</code>b = 0x01): <strong>Security Suite 0 / Key Set 1</strong></li>
</ul>
</li>
<li><strong>Invocation Counter</strong>: <code>00 00 00 42</code> (4 bytes, decimal 66)</li>
<li><strong>Ciphertext</strong>: <code>A1 12 ...</code></li>
<li><strong>Authentication Tag (GMAC Tag)</strong>: Last 12 bytes (<code>96-bit</code> or <code>128-bit</code> ICV)</li>
</ol>
<h4>AES-GCM Initialization Vector (IV) Construction (12 bytes)</h4>
<ul>
<li><strong>Bytes 0-7</strong>: System Title (8 bytes)</li>
<li><strong>Bytes 8-11</strong>: Invocation Counter (4 bytes in Big-Endian)</li>
</ul>
]]></description><link>https://dlms.sharur.org/topic/34/deciphering-general-ciphering-0xdb-and-general-signing-0xdf-apdus</link><generator>RSS for Node</generator><lastBuildDate>Fri, 16 Oct 2026 19:49:50 GMT</lastBuildDate><atom:link href="https://dlms.sharur.org/topic/34.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 22 Aug 2026 12:36:33 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Deciphering General-Ciphering (0xDB) and General-Signing (0xDF) APDUs on Sat, 22 Aug 2026 12:36:41 GMT]]></title><description><![CDATA[<p dir="auto">The Additional Authenticated Data (AAD) for AES-GCM decryption consists of:</p>
<pre><code class="language-text">AAD = Security_Control_Byte (1 byte) || Authentication_Key (16 bytes, if AK is distinct from EK)
</code></pre>
<p dir="auto">If AAD is omitted or formatted with the wrong key during tag computation, the GCM tag validation fails with <code>deciphering-failed</code>.</p>
]]></description><link>https://dlms.sharur.org/post/79</link><guid isPermaLink="true">https://dlms.sharur.org/post/79</guid><dc:creator><![CDATA[elena_rostova]]></dc:creator><pubDate>Sat, 22 Aug 2026 12:36:41 GMT</pubDate></item></channel></rss>