Attempting to load keys onto the card with gpg keytocard fails with error "gpg: KEYTOCARD failed: Invalid value".
With some debugging, I can see that cmd_import_data is being called, but the data in the apdu includes multi-byte length fields not accounted for in the parsing function.
I'm using http://g10code.com/docs/openpgp-card-3.0.pdf for reference. Section 4.4.4 states DO length fields can be variable byte length:
single byte for values from 0-127 (x00 to x7F), and for 128-255 two bytes are used (x81 followed by single byte length), and for values > 255 three bytes are used (x82 followed by two byte length).
I can work on adding support for variable byte length fields, or if you prefer to keep the development I'll respect that.
APDU (with test signature priv key)
00 // CLA
DB // INS
3F FF //P1P2
00 01 1A //LC = 282
4D /DO, start of *data
82 01 16 //DO len = 278
B6 00 //key select = sign key
7F 48 // key template marker
08 // len of tags
91 04 // e len = 4
92 81 80 // p len = 128
93 81 80 // q len = 128
5F 48 // key concat marker
82 01 04 // concat len = 260
00 01 00 01 // e
D1 A9 69 C6 43 E4 5B CE 34 D6 B7 7D C9 4F 3C 9D 2C 9E B7 8D C7 5D C8 A3 49 9F A8 6F A7 55 E9 34 FD 5B CD 5D E6 36 A7 02 72 9D C2 3A 62 DC E4 E5 68 FB 9A 6F 25 4D 4B 69 4A BA 02 E8 F7 32 1B 1A 0A 94 AA 67 A3 19 E3 47 6B 4C 68 A8 32 86 26 96 24 34 95 1E 28 02 8D 97 95 6D 50 68 FA 3F D1 D2 37 DA 8D 89 E1 36 8F 27 4D 88 94 CB 79 62 9D 4A 8B C5 CD DD 50 D0 99 3F 59 60 31 CF 74 91 88 63 // p
F5 C5 5A FC 2F 6C E6 B3 41 5A 7A 1F 31 B2 72 5B 1E EE 5F E1 72 39 A1 F1 C1 04 83 EC A1 27 5F F0 0E 31 23 DE BE 47 9A 3C D0 2B 01 F4 92 C1 8B FB A8 86 1A 57 2F 73 0B A6 E0 90 CB E4 DB 33 1E 02 A0 60 86 4D 48 89 AB 97 21 7D 28 DE C7 EA B8 F4 42 3B D1 8A 85 BA A3 FE 85 46 CD CC DD C7 00 27 D9 6A A1 EC FA 52 67 9C 5A 0D 12 E1 5C 3D FE 42 B7 E4 D4 55 E2 C5 C4 A9 D0 E6 54 3A E0 04 72 FD // q
Attempting to load keys onto the card with gpg keytocard fails with error "gpg: KEYTOCARD failed: Invalid value". With some debugging, I can see that cmd_import_data is being called, but the data in the apdu includes multi-byte length fields not accounted for in the parsing function.
I'm using http://g10code.com/docs/openpgp-card-3.0.pdf for reference. Section 4.4.4 states DO length fields can be variable byte length: single byte for values from 0-127 (x00 to x7F), and for 128-255 two bytes are used (x81 followed by single byte length), and for values > 255 three bytes are used (x82 followed by two byte length).
I can work on adding support for variable byte length fields, or if you prefer to keep the development I'll respect that.
APDU (with test signature priv key) 00 // CLA DB // INS 3F FF //P1P2 00 01 1A //LC = 282 4D /DO, start of *data 82 01 16 //DO len = 278 B6 00 //key select = sign key 7F 48 // key template marker 08 // len of tags 91 04 // e len = 4 92 81 80 // p len = 128 93 81 80 // q len = 128 5F 48 // key concat marker 82 01 04 // concat len = 260 00 01 00 01 // e D1 A9 69 C6 43 E4 5B CE 34 D6 B7 7D C9 4F 3C 9D 2C 9E B7 8D C7 5D C8 A3 49 9F A8 6F A7 55 E9 34 FD 5B CD 5D E6 36 A7 02 72 9D C2 3A 62 DC E4 E5 68 FB 9A 6F 25 4D 4B 69 4A BA 02 E8 F7 32 1B 1A 0A 94 AA 67 A3 19 E3 47 6B 4C 68 A8 32 86 26 96 24 34 95 1E 28 02 8D 97 95 6D 50 68 FA 3F D1 D2 37 DA 8D 89 E1 36 8F 27 4D 88 94 CB 79 62 9D 4A 8B C5 CD DD 50 D0 99 3F 59 60 31 CF 74 91 88 63 // p F5 C5 5A FC 2F 6C E6 B3 41 5A 7A 1F 31 B2 72 5B 1E EE 5F E1 72 39 A1 F1 C1 04 83 EC A1 27 5F F0 0E 31 23 DE BE 47 9A 3C D0 2B 01 F4 92 C1 8B FB A8 86 1A 57 2F 73 0B A6 E0 90 CB E4 DB 33 1E 02 A0 60 86 4D 48 89 AB 97 21 7D 28 DE C7 EA B8 F4 42 3B D1 8A 85 BA A3 FE 85 46 CD CC DD C7 00 27 D9 6A A1 EC FA 52 67 9C 5A 0D 12 E1 5C 3D FE 42 B7 E4 D4 55 E2 C5 C4 A9 D0 E6 54 3A E0 04 72 FD // q