Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Dark

Collapse
SHARUR
Community Wiki DLMS/COSEM Tools
Search Sign in

Deciphering General-Ciphering (0xDB) and General-Signing (0xDF) APDUs

Scheduled Pinned Locked Moved General Discussion
general-cipheriapdusecuritygmacdecryption
2 Posts 2 Posters 10 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
  • A Offline
    A Offline
    alex_turner
    wrote on last edited by
    #1

    Dissecting Encrypted DLMS APDUs

    When security is applied at the application layer, the plaintext COSEM APDU is encapsulated in a General-Ciphering (0xDB) structure.

    Wire Format (APDU Tag 0xDB)

    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
    

    Field Breakdown

    1. Tag: DB (general-ciphering)
    2. System Title Length & Value: 08 followed by 8 bytes (47 55 52 55 58 31 32 33 = GURUX123)
    3. Security Control Byte: 21
      • Bit 4-5 (10b = 0x20): Authentication + Encryption (AES-GCM)
      • Bit 0-3 (0001b = 0x01): Security Suite 0 / Key Set 1
    4. Invocation Counter: 00 00 00 42 (4 bytes, decimal 66)
    5. Ciphertext: A1 12 ...
    6. Authentication Tag (GMAC Tag): Last 12 bytes (96-bit or 128-bit ICV)

    AES-GCM Initialization Vector (IV) Construction (12 bytes)

    • Bytes 0-7: System Title (8 bytes)
    • Bytes 8-11: Invocation Counter (4 bytes in Big-Endian)
    1 Reply Last reply
    0
    • E Offline
      E Offline
      elena_rostova
      wrote on last edited by
      #2

      The Additional Authenticated Data (AAD) for AES-GCM decryption consists of:

      AAD = Security_Control_Byte (1 byte) || Authentication_Key (16 bytes, if AK is distinct from EK)
      

      If AAD is omitted or formatted with the wrong key during tag computation, the GCM tag validation fails with deciphering-failed.

      1 Reply Last reply
      0

      Hello! It looks like you're interested in this conversation, but you don't have an account yet.

      Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

      With your input, this post could be even better 💗

      Register Login
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      Powered by NodeBB Contributors
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups