From 421469b2209b0599e9a1db1ea70129581fda8bb6 Mon Sep 17 00:00:00 2001 From: Stacey Sheldon Date: Tue, 1 Jan 2019 01:23:55 -0500 Subject: [PATCH 1/2] FASC-N: correct encoding of the packed 4-bit decimal format with odd parity The BCD digits in the FASC-N credential are sent lsb first followed by an odd parity. Since this perl script is simply packing the bits in their expected order, the encodings should exactly match figure 7 in "Technical Implementation Guidance: Smart Card Enabled Physical Access Control Systems Version 2.2". --- tools/fasc.pl | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tools/fasc.pl b/tools/fasc.pl index 9ba75dd..205b65a 100644 --- a/tools/fasc.pl +++ b/tools/fasc.pl @@ -31,24 +31,24 @@ # S9999F9999F999999F0F1F0000000000300001E # and outputs that in hex, encoded in the 5-bit form described in # "Technical Implementation Guidance: Smart Card Enabled Physical Access -# Control Systems" +# Control Systems Version 2.2", Section 6.2, Figure 7. use strict; use Bit::Vector; my %encoding = ( 0 => "00001", - 1 => "00010", - 2 => "00100", - 3 => "00111", - 4 => "01000", - 5 => "01011", + 1 => "10000", + 2 => "01000", + 3 => "11001", + 4 => "00100", + 5 => "10101", 6 => "01101", - 7 => "01110", - 8 => "10000", + 7 => "11100", + 8 => "00010", 9 => "10011", - S => "11010", # the examples and definitions of S and F differ - F => "10110", # but we'll go with the examples here.. + S => "11010", + F => "10110", E => "11111", ); From 811ddbb22d293aea6508d69bb7b98d8386fc8071 Mon Sep 17 00:00:00 2001 From: Stacey Sheldon Date: Tue, 1 Jan 2019 01:43:51 -0500 Subject: [PATCH 2/2] CHUID: fix the encoding of the FASC-N data element in the CHUID This is the hard-coded FASC-N field being used by yubico-piv-tool [9999-9999-999999-0-1-0000000000300001] S9999F9999F999999F0F1F0000000000300001E It should be encoded as this sequence of 5-bit values 11010 (SS) 10011 10011 10011 10011 (9999) 10110 (FS) 10011 10011 10011 10011 (9999) 10110 (FS) 10011 10011 10011 10011 10011 10011 (999999) 10110 (FS) 00001 (0) 10110 (FS) 10000 (1) 10110 (FS) 00001 00001 00001 00001 00001 00001 00001 00001 00001 00001 (0000000000) 11001 (3) 00001 00001 00001 00001 (0000) 10000 (1) 11111 (ES) 01011 (LRC) This packs into this 25-byte (200-bit) sequence of hex bytes: d4 e7 39 da 73 9c ed 39 ce 73 9d 83 68 58 21 08 42 10 84 21 c8 42 10 c3 eb --- lib/util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/util.c b/lib/util.c index 626eab3..4133187 100644 --- a/lib/util.c +++ b/lib/util.c @@ -57,8 +57,8 @@ */ const uint8_t CHUID_TMPL[] = { 0x30, 0x19, 0xd4, 0xe7, 0x39, 0xda, 0x73, 0x9c, 0xed, 0x39, 0xce, 0x73, 0x9d, - 0x83, 0x68, 0x58, 0x21, 0x08, 0x42, 0x10, 0x84, 0x21, 0x38, 0x42, 0x10, 0xc3, - 0xf5, 0x34, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x83, 0x68, 0x58, 0x21, 0x08, 0x42, 0x10, 0x84, 0x21, 0xc8, 0x42, 0x10, 0xc3, + 0xeb, 0x34, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x35, 0x08, 0x32, 0x30, 0x33, 0x30, 0x30, 0x31, 0x30, 0x31, 0x3e, 0x00, 0xfe, 0x00, };