Deciphering General-Ciphering (0xDB) and General-Signing (0xDF) APDUs
-
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 EFField Breakdown
- Tag:
DB(general-ciphering) - System Title Length & Value:
08followed by 8 bytes (47 55 52 55 58 31 32 33=GURUX123) - Security Control Byte:
21- Bit 4-5 (
10b = 0x20): Authentication + Encryption (AES-GCM) - Bit 0-3 (
0001b = 0x01): Security Suite 0 / Key Set 1
- Bit 4-5 (
- Invocation Counter:
00 00 00 42(4 bytes, decimal 66) - Ciphertext:
A1 12 ... - Authentication Tag (GMAC Tag): Last 12 bytes (
96-bitor128-bitICV)
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)
- Tag:
-
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.
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