return error sooner for decryption
authorNIIBE Yutaka <gniibe@fsij.org>
Mon, 9 Jul 2012 00:29:00 +0000 (09:29 +0900)
committerNIIBE Yutaka <gniibe@fsij.org>
Mon, 9 Jul 2012 00:29:00 +0000 (09:29 +0900)
ChangeLog
src/openpgp.c

index a1ade4d..b6e8581 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2012-07-09  Niibe Yutaka  <gniibe@fsij.org>
 
+       * src/openpgp.c (cmd_pso): For decryption, return error sooner for
+       invalid data.
+
        * tool/stlinkv2.py (stlinkv2.setup_gpio): Fix GPIOB_CRL.
 
        * test/rsa_keys.py (integer_to_bytes_256): Rename from
index bc03b44..439db4e 100644 (file)
@@ -776,10 +776,15 @@ cmd_pso (void)
 
       /* Skip padding 0x00 */
       len--;
-      r = rsa_decrypt (apdu.cmd_apdu_data+1, res_APDU, len,
-                      &kd[GPG_KEY_FOR_DECRYPTION]);
-      if (r < 0)
-       GPG_ERROR ();
+      if (len != KEY_CONTENT_LEN)
+       GPG_CONDITION_NOT_SATISFIED ();
+      else
+       {
+         r = rsa_decrypt (apdu.cmd_apdu_data+1, res_APDU, len,
+                          &kd[GPG_KEY_FOR_DECRYPTION]);
+         if (r < 0)
+           GPG_ERROR ();
+       }
     }
   else
     {