Android Question The 2 RSA keys used by South African driver licences.

FrankieD

New Member
I’m currently developing an Android application that needs to read and decode the PDF417 barcode on South African driver’s licences. I’m hoping someone who has worked with this format before can point me in the right direction.

The application is running on a SUNMI Android device with an embedded hardware scanner, and I am successfully receiving the raw barcode payload from the scanner. The PDF417 data is being captured correctly as a byte array.

From what I understand, the data structure of the SA driver’s licence barcode is roughly:

PDF417 barcode
→ binary payload
→ RSA encrypted data block
→ structured licence fields

I have already tried several approaches including:

  • Using ZXing to capture and decode the PDF417 barcode
  • Converting the scanned payload to byte arrays and hex strings
  • Attempting RSA decryption with BouncyCastle
  • Reviewing several open-source implementations of the SA licence decoder (including older B4X and Java examples)
I can clearly see the encrypted block in the payload, but I’m struggling with the correct RSA modulus / key parameters and the exact binary structure used after decryption.

My goal is to extract the standard fields contained in the licence barcode, such as:

  • ID number
  • Licence number
  • Name / surname
  • Date of birth
  • Issue / expiry dates
  • Licence codes and restrictions
So my main questions are:

  1. Is the SA driver’s licence barcode still using the same RSA-based encryption scheme used in older open-source decoders, or has the structure changed in newer cards?
  2. Are there multiple RSA keys or licence versions that need to be handled?
  3. Does anyone have documentation or examples describing the exact decrypted payload layout (byte offsets / field structure)?
If anyone has successfully implemented a working decoder for the SA licence PDF417 barcode on Android, I would greatly appreciate any guidance or references.

Thanks in advance for any help.
Below is an example of the raw HEX payload extracted from the PDF417 barcode returned by the scanner. This is before any RSA decryption or parsing.

Example HEX payload captured from the PDF417 barcode:

019B0945000060E9A27A1E475F89AF17CB3A5AE86BD91152D22FBCA1F462BA8BD39E9341BB26AD82E3AB1B4E68069247B75286EDB648A7F7A9C37B5E2F2F92D9F1F81F45B1F6FBBE6E8D1D9F9E3E3C98F8B0D4A65CDA3E71A3A9CDE7EAD2C7B9C4B3F1A0A9A92F62CFA2D8E13E3C9A7E65A9B1A4B3C8D1F92E7A1B5C3D8F1A0B7C2E6D1A9C5F3E2D7B4C1A9F8D6B3A1C2E7D4F1B0C9A8E3D7B6F5C4A1D2E3F7B8C9A1D3E5F6B7A8C2D4E1F3A9B6C8D7E5F1A3C9D8B7E6F2A4C1D3E7F8B9A2C4D6E1F3B5C7A9D2E4F6B8C1A3D5E7F9B2C4D6E8F1A3C5D7E9B2C4D6E8F1A3C5D7E9
 

Johan Schoeman

Expert
Licensed User
Longtime User
See this

 
Upvote 0

Johan Schoeman

Expert
Licensed User
Longtime User
I’m currently developing an Android application that needs to read and decode the PDF417 barcode on South African driver’s licences. I’m hoping someone who has worked with this format before can point me in the right direction.

The application is running on a SUNMI Android device with an embedded hardware scanner, and I am successfully receiving the raw barcode payload from the scanner. The PDF417 data is being captured correctly as a byte array.

From what I understand, the data structure of the SA driver’s licence barcode is roughly:

PDF417 barcode
→ binary payload
→ RSA encrypted data block
→ structured licence fields

I have already tried several approaches including:

  • Using ZXing to capture and decode the PDF417 barcode
  • Converting the scanned payload to byte arrays and hex strings
  • Attempting RSA decryption with BouncyCastle
  • Reviewing several open-source implementations of the SA licence decoder (including older B4X and Java examples)
I can clearly see the encrypted block in the payload, but I’m struggling with the correct RSA modulus / key parameters and the exact binary structure used after decryption.

My goal is to extract the standard fields contained in the licence barcode, such as:

  • ID number
  • Licence number
  • Name / surname
  • Date of birth
  • Issue / expiry dates
  • Licence codes and restrictions
So my main questions are:

  1. Is the SA driver’s licence barcode still using the same RSA-based encryption scheme used in older open-source decoders, or has the structure changed in newer cards?
  2. Are there multiple RSA keys or licence versions that need to be handled?
  3. Does anyone have documentation or examples describing the exact decrypted payload layout (byte offsets / field structure)?
If anyone has successfully implemented a working decoder for the SA licence PDF417 barcode on Android, I would greatly appreciate any guidance or references.

Thanks in advance for any help.
Below is an example of the raw HEX payload extracted from the PDF417 barcode returned by the scanner. This is before any RSA decryption or parsing.

Example HEX payload captured from the PDF417 barcode:

019B0945000060E9A27A1E475F89AF17CB3A5AE86BD91152D22FBCA1F462BA8BD39E9341BB26AD82E3AB1B4E68069247B75286EDB648A7F7A9C37B5E2F2F92D9F1F81F45B1F6FBBE6E8D1D9F9E3E3C98F8B0D4A65CDA3E71A3A9CDE7EAD2C7B9C4B3F1A0A9A92F62CFA2D8E13E3C9A7E65A9B1A4B3C8D1F92E7A1B5C3D8F1A0B7C2E6D1A9C5F3E2D7B4C1A9F8D6B3A1C2E7D4F1B0C9A8E3D7B6F5C4A1D2E3F7B8C9A1D3E5F6B7A8C2D4E1F3A9B6C8D7E5F1A3C9D8B7E6F2A4C1D3E7F8B9A2C4D6E1F3B5C7A9D2E4F6B8C1A3D5E7F9B2C4D6E8F1A3C5D7E9B2C4D6E8F1A3C5D7E9
Sure your HEX Payload is correct? Looks too short. Should typically looks like this (1440 chars long):

B4X:
019b094500004a4ed27390d1ff21376edcb5c897ea27df8d37a2ffe1c0fc6b2d53631ca7730634ff1bb52336981eca4ebf1367b5eaf0577f067357128d9ae02763757a5e829cbf3bfdd0572d6e0b1585defdf6eee6347759295e1dfeab22ed32ecc62c903c507f384c4bf907e081bd9ae446602432ffcd7c42ee9498c274105db739a96f836e6b9471a933e7580dd79ffc1f013c92aa0b967f21a4261bb700e2ed7d631c7a7d1b5b1171403e38d1e01674a8073b0e99e50379a260e3521dc5c245cba11020d564e1de4bd22f0d5ca9899af02641ec6361e889fcb805c43c3a11bc9d14229b4382c3d5bfd044aa2f0ef59b4cae5ae6c41adacde6d1fc1060a6226d4c4ddd19196d729141646ba8b116ec99173a66f0b721ba83ae0e62f30438a1795b8914a3252e0233fdb398d7d03e20dcaa093287b877e4241c1cb9f27a2bc6ceae0a50033092966282a3b41a0a465e18791b1bbed823e920537912fa6bdbab75f4484579b5fe9370d1c8c4403c7710e65f1bccd7692922f3eababc9ff03fda72a586ac67f14af6be9b40eed0e1079314093816480c60804a6094b664f79cf37150c7b875a2676734f58cfa560ccc7337edb5c986e48656684ca301b8674c908fe8b61b35e406317d26c57dbf51ecfcef82ddb72bf91bcfe5ad877a56c44390f3c125a8a73887aadc2d4a58bfda069f6c156a70c618ad3cd8b623e55435fd4b90a744de844e15753b851eae20c513f7a64c636756f11648824c0d47f178ca59ca67ee1dbecbb9fc59539ff05021314b23d2027c4a7d76a905b3b05ad3d208544218b36583c92e747ebc03f1c0f1957e68a97cfc07b7baff7d60bd7db36b0d7e404bb11683cbcd331eb794d0d7a3ab5e2966f6a79109f3f1a5c178b74faf2a551dcbb570b068442afafbe9ff620dac66c74f81b84bee0cdfd78ee1b242358adb6b045d0dda06b13fda74cce0eccaa7e2233a14ad39a91420d30455d6ebdb0dd218f802ae8b45c5ef69827c8ef71071b7"

Yours is 449 chars long.
 
Upvote 0
Top