APDU to do decipher in OpenPGP card?
Achim Pietig
achim at pietig.com
Tue Jul 17 13:52:54 CEST 2012
Hello Quân,
the error 6A88 occurs if no decrypt key is present in the card.
You should import a key first with PUT DATA.
The plain text of the cryptogram shall be formatted in compliance with PKCS#1, as decribed on page 40 of the OpenPGP card specification.
Then the plain text is encrypted with the DEC key and the result has the same length than the modulus of the DEC key.
The cryptogram is sent with a leading 00 byte (padding indicator), so the complete length of the command data is modulus + 1.
For key length > 1024 you have to use extended length format for the APDU.
Regards,
Achim
Am 17.07.2012 04:13, schrieb Nguyễn Hồng Quân:
> Hello,
>
> I'm implementing the OpenPGP card support for OpenSC. I'm trying to do decipher on OpenPGP card but have difficulty building the APDU.
> For example, this is an APDU used for decrypting one my email:
>
> 00 2A 80 86 00 01 01 00 19 90 86 A0 62 D2 60 B1 .*..........b.`.
> 76 C9 61 90 5D AB 57 6C 3D CD 6C F1 08 07 FA AB v.a.].Wl=.l.....
> 64 C9 66 9E 05 63 4D 22 EA 8B 0D 34 59 56 25 62 d.f..cM"...4YV%b
> 5F DA 77 52 95 21 4E 12 73 98 4A 14 17 F7 B0 E9 _.wR.!N.s.J.....
> 14 32 9C A6 33 6C 83 C4 2D 67 BC B0 3B DD FA 2F .2..3l..-g..;../
> 8A 17 08 3B 4A F6 2D 21 BA AA CA 8F 35 29 81 A7 ...;J.-!....5)..
> 1F 96 4F 52 55 07 09 AF 75 F1 AE 62 C1 3D CA 5A ..ORU...u..b.=.Z
> 4E 29 FC A4 7F E7 23 BB 8B B5 D8 AA DC F7 D3 3E N)....#........>
> 6B 62 1E CE 06 D6 20 3D E2 A5 16 D5 B2 EE D8 F0 kb.... =........
> 7E E8 5B AB B5 3D 37 55 F8 64 00 78 80 02 35 74 ~.[..=7U.d.x..5t
> 00 8E 7C 67 A0 2B 4B A5 19 A2 F1 E5 00 56 91 07 ..|g.+K......V..
> BF 89 2C 9F B7 F9 94 73 98 58 18 38 97 F1 29 1C ..,....s.X.8..).
> 1C 49 78 BD 99 39 10 E2 0E 82 92 59 CE 71 26 D9 .Ix..9.....Y.q&.
> 1E AD FF DC 74 43 D7 09 7F 14 9A 8B 43 10 EC 19 ....tC......C...
> 2D 30 F9 EC 95 69 57 39 45 F7 C3 12 06 C1 2B 9C -0...iW9E.....+.
> 94 E1 2F 75 46 5F 37 86 50 D6 23 E0 53 AE 91 DF ../uF_7.P.#.S...
> 2B 4F BC 2C D7 38 2B BE 01 00
>
> But the card responds "6A 88" (Reference data not found).
> Could you please point out what is wrong in my above APDU? Is there any note about the input data for the Decipher APDU?
>
> --
> Regards,
> Quân
>
> Y!IM: ng_hquan_vn
>
>
>
> _______________________________________________
> Gnupg-devel mailing list
> Gnupg-devel at gnupg.org
> http://lists.gnupg.org/mailman/listinfo/gnupg-devel
>
More information about the Gnupg-devel
mailing list