[PATCH] scd: Support AES decryption for OpenPGPcard v3.0.
NIIBE Yutaka
gniibe at fsij.org
Tue Jun 30 10:04:42 CEST 2015
On 06/26/2015 09:29 PM, NIIBE Yutaka wrote:
> The change is adding data object handling for the operation of
> PSO:DECIPHER with symmetric key. This feature is added in v2.1.
>
> With the change of today, a user (or manufacturer) can put AES key
> onto the data object of 0xD5.
Here is concrete example (I've tested with Gnuk modified).
====================================
$ gpg-connect-agent
> /hex
> scd setattr aeskey %f3%2e%34%fe%dc%ab%df%e3%47%ac%b3%4b%a5%10%d8%c6
OK
> scd setdata 025D6C89682D07CCFC034AF508420BF227
OK
> scd pkdecrypt OPENPGP.2
S PADDING 0
D[0000] E3 46 4A 4F FE C3 B0 67 EB DB 04 35 3E 88 98 49 .FJO...g...5>..I
OK
> scd setdata 026842488E4ECB02C7DEA372E78B320D16
OK
> scd pkdecrypt OPENPGP.2
S PADDING 0
D[0000] CE 1C A0 39 6A 14 C2 C2 80 BC F2 80 F2 3B 67 A5 ...9j........;g.
OK
> scd setdata 026A5751041E3A319A4D8213F46B36A7D3
OK
> scd pkdecrypt OPENPGP.2
S PADDING 0
D[0000] 20 33 EE D7 3F 62 F6 56 87 5A 3A 44 F1 90 1A A0 3..?b.V.Z:D....
OK
> /bye
====================================
Note that setting aeskey data object requires admin privilege.
In the current implementation of scdaemon, this feature can be only
used when a user registered a private key for encryption (== the key
OPENPGP.2 is valid).
Here is a patch for GnuPG development version.
For myself, I don't know if this feature is useful, but it seems that
there are some demand...
diff --git a/scd/app-openpgp.c b/scd/app-openpgp.c
index 467389d..f5911f3 100644
--- a/scd/app-openpgp.c
+++ b/scd/app-openpgp.c
@@ -4101,7 +4101,10 @@ do_decipher (app_t app, const char *keyidstr,
if (rc)
return rc;
- if (app->app_local->keyattr[1].key_type == KEY_TYPE_RSA)
+ if (indatalen == 16 + 1 || indatalen == 32 + 1)
+ /* PSO:DECIPHER with symmetric key. */
+ padind = -1;
+ else if (app->app_local->keyattr[1].key_type == KEY_TYPE_RSA)
{
/* We might encounter a couple of leading zeroes in the
cryptogram. Due to internal use of MPIs these leading zeroes
--
More information about the Gnupg-devel
mailing list