pubkey: Add forward compatibility feature.
authorWerner Koch <wk@gnupg.org>
Wed, 6 Nov 2013 07:56:02 +0000 (08:56 +0100)
committerWerner Koch <wk@gnupg.org>
Wed, 6 Nov 2013 07:56:15 +0000 (08:56 +0100)
* cipher/pubkey-util.c (_gcry_pk_util_parse_flaglist): Add
"igninvflag".
--

If future versions of Libgcrypt want to add optional flags to a pubkey
s-expression, they may use the "igninvflag" flag to make the flag
parser ignore flags it does not know about.

Signed-off-by: Werner Koch <wk@gnupg.org>
cipher/pubkey-util.c

index a91e66f..a591c0d 100644 (file)
@@ -60,6 +60,7 @@ _gcry_pk_util_parse_flaglist (gcry_sexp_t list,
   int i;
   int encoding = PUBKEY_ENC_UNKNOWN;
   int flags = 0;
+  int igninvflag = 0;
 
   for (i=list?gcry_sexp_length (list)-1:0; i > 0; i--)
     {
@@ -80,7 +81,7 @@ _gcry_pk_util_parse_flaglist (gcry_sexp_t list,
               encoding = PUBKEY_ENC_RAW;
               flags |= PUBKEY_FLAG_RAW_FLAG; /* Explicitly given.  */
             }
-          else
+          else if (!igninvflag)
             rc = GPG_ERR_INV_FLAG;
           break;
 
@@ -97,7 +98,7 @@ _gcry_pk_util_parse_flaglist (gcry_sexp_t list,
               encoding = PUBKEY_ENC_RAW;
               flags |= PUBKEY_FLAG_GOST;
             }
-          else
+          else if (!igninvflag)
             rc = GPG_ERR_INV_FLAG;
           break;
 
@@ -112,7 +113,7 @@ _gcry_pk_util_parse_flaglist (gcry_sexp_t list,
               encoding = PUBKEY_ENC_PKCS1;
               flags |= PUBKEY_FLAG_FIXEDLEN;
             }
-          else
+          else if (!igninvflag)
             rc = GPG_ERR_INV_FLAG;
           break;
 
@@ -121,23 +122,28 @@ _gcry_pk_util_parse_flaglist (gcry_sexp_t list,
             flags |= PUBKEY_FLAG_RFC6979;
           else if (!memcmp (s, "noparam", 7))
             flags |= PUBKEY_FLAG_NOPARAM;
-          else
+          else if (!igninvflag)
             rc = GPG_ERR_INV_FLAG;
           break;
 
         case 8:
           if (!memcmp (s, "use-x931", 8))
             flags |= PUBKEY_FLAG_USE_X931;
-          else
+          else if (!igninvflag)
             rc = GPG_ERR_INV_FLAG;
           break;
 
+        case 10:
+          if (!memcmp (s, "igninvflag", 10))
+            igninvflag = 1;
+          break;
+
         case 11:
           if (!memcmp (s, "no-blinding", 11))
             flags |= PUBKEY_FLAG_NO_BLINDING;
           else if (!memcmp (s, "use-fips186", 11))
             flags |= PUBKEY_FLAG_USE_FIPS186;
-          else
+          else if (!igninvflag)
             rc = GPG_ERR_INV_FLAG;
           break;
 
@@ -146,12 +152,13 @@ _gcry_pk_util_parse_flaglist (gcry_sexp_t list,
             flags |= PUBKEY_FLAG_USE_FIPS186_2;
           else if (!memcmp (s, "transient-key", 13))
             flags |= PUBKEY_FLAG_TRANSIENT_KEY;
-          else
+          else if (!igninvflag)
             rc = GPG_ERR_INV_FLAG;
           break;
 
         default:
-          rc = GPG_ERR_INV_FLAG;
+          if (!igninvflag)
+            rc = GPG_ERR_INV_FLAG;
           break;
         }
     }