core,cpp: New key flag 'is_de_vs'.

* src/gpgme.h.in (_gpgme_subkey): New flag is_de_vs.
* tests/run-keylist.c (main): Print that flag.
* src/keylist.c (parse_pub_field18): New.
(keylist_colon_handler): Parse compliance flags.
* lang/cpp/src/key.cpp (Key::isDeVs): New.
(Subkey::isDeVs): New.

* lang/cpp/src/key.h (class Key): New method isDeVs.
(class Subkey): New method isDeVs.

Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2017-03-20 19:56:10 +01:00
parent 392e51dd11
commit ea9686ec71
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
7 changed files with 57 additions and 6 deletions

3
NEWS
View File

@ -10,14 +10,17 @@ Noteworthy changes in version 1.8.1 (unreleased)
gpgme_op_createkey CHANGED: Meaning of 'expire' parameter. gpgme_op_createkey CHANGED: Meaning of 'expire' parameter.
gpgme_op_createsubkey CHANGED: Meaning of 'expire' parameter. gpgme_op_createsubkey CHANGED: Meaning of 'expire' parameter.
GPGME_CREATE_NOEXPIRE NEW. GPGME_CREATE_NOEXPIRE NEW.
gpgme_subkey_t EXTENDED: New field is_de_vs.
cpp: Context::revUid(const Key&, const char*) NEW. cpp: Context::revUid(const Key&, const char*) NEW.
cpp: Context::startRevUid(const Key&, const char*) NEW. cpp: Context::startRevUid(const Key&, const char*) NEW.
cpp: Context::addUid(const Key&, const char*) NEW. cpp: Context::addUid(const Key&, const char*) NEW.
cpp: Context::startAddUid(const Key&, const char*) NEW. cpp: Context::startAddUid(const Key&, const char*) NEW.
cpp: Key::UserID::revoke() NEW. cpp: Key::UserID::revoke() NEW.
cpp: Key::addUid() NEW. cpp: Key::addUid() NEW.
cpp: Key::isDeVs NEW.
cpp: GpgGenCardKeyInteractor NEW. cpp: GpgGenCardKeyInteractor NEW.
cpp: Subkey::keyGrip NEW. cpp: Subkey::keyGrip NEW.
cpp: Subkey::isDeVs NEW.
qt: CryptoConfig::stringValueList() NEW. qt: CryptoConfig::stringValueList() NEW.
gpgme_data_rewind UN-DEPRECATE. gpgme_data_rewind UN-DEPRECATE.
py: Context.__init__ EXTENDED: New keyword arg home_dir. py: Context.__init__ EXTENDED: New keyword arg home_dir.

View File

@ -3156,6 +3156,12 @@ This is true if the subkey can be used for authentication.
This is true if the subkey can be used for qualified signatures This is true if the subkey can be used for qualified signatures
according to local government regulations. according to local government regulations.
@item unsigned int is_de_vs : 1
This is true if the subkey complies with the rules for classified
information in Germany at the restricted level (VS-NfD). This are
currently RSA keys of at least 2048 bits or ECDH/ECDSA keys using a
Brainpool curve.
@item unsigned int secret : 1 @item unsigned int secret : 1
This is true if the subkey is a secret key. Note that it will be This is true if the subkey is a secret key. Note that it will be
false if the key is actually a stub key; i.e. a secret key operation false if the key is actually a stub key; i.e. a secret key operation

View File

@ -234,6 +234,11 @@ bool Key::isQualified() const
return key && key->is_qualified; return key && key->is_qualified;
} }
bool Key::isDeVs() const
{
return key && key->subkeys && key->subkeys->is_de_vs;
}
const char *Key::issuerSerial() const const char *Key::issuerSerial() const
{ {
return key ? key->issuer_serial : 0 ; return key ? key->issuer_serial : 0 ;
@ -469,6 +474,11 @@ bool Subkey::isQualified() const
return subkey && subkey->is_qualified; return subkey && subkey->is_qualified;
} }
bool Subkey::isDeVs() const
{
return subkey && subkey->is_de_vs;
}
bool Subkey::isCardKey() const bool Subkey::isCardKey() const
{ {
return subkey && subkey->is_cardkey; return subkey && subkey->is_cardkey;

View File

@ -112,6 +112,7 @@ public:
bool canCertify() const; bool canCertify() const;
bool canAuthenticate() const; bool canAuthenticate() const;
bool isQualified() const; bool isQualified() const;
bool isDeVs() const;
bool hasSecret() const; bool hasSecret() const;
GPGMEPP_DEPRECATED bool isSecret() const GPGMEPP_DEPRECATED bool isSecret() const
@ -219,6 +220,7 @@ public:
bool canCertify() const; bool canCertify() const;
bool canAuthenticate() const; bool canAuthenticate() const;
bool isQualified() const; bool isQualified() const;
bool isDeVs() const;
bool isCardKey() const; bool isCardKey() const;
bool isSecret() const; bool isSecret() const;

View File

@ -538,8 +538,11 @@ struct _gpgme_subkey
/* True if the secret key is stored on a smart card. */ /* True if the secret key is stored on a smart card. */
unsigned int is_cardkey : 1; unsigned int is_cardkey : 1;
/* True if the key is compliant to the de-vs mode. */
unsigned int is_de_vs : 1;
/* Internal to GPGME, do not use. */ /* Internal to GPGME, do not use. */
unsigned int _unused : 21; unsigned int _unused : 20;
/* Public key algorithm supported by this subkey. */ /* Public key algorithm supported by this subkey. */
gpgme_pubkey_algo_t pubkey_algo; gpgme_pubkey_algo_t pubkey_algo;

View File

@ -416,6 +416,23 @@ parse_sec_field15 (gpgme_key_t key, gpgme_subkey_t subkey, char *field)
} }
/* Parse the compliance field. */
static void
parse_pub_field18 (gpgme_subkey_t subkey, char *field)
{
char *p, *endp;
unsigned long ul;
for (p = field; p && (ul = strtoul (p, &endp, 10)) && p != endp; p = endp)
{
switch (ul)
{
case 23: subkey->is_de_vs = 1; break;
}
}
}
/* Parse a tfs record. */ /* Parse a tfs record. */
static gpg_error_t static gpg_error_t
parse_tfs_record (gpgme_user_id_t uid, char **field, int nfield) parse_tfs_record (gpgme_user_id_t uid, char **field, int nfield)
@ -535,7 +552,7 @@ keylist_colon_handler (void *priv, char *line)
RT_SSB, RT_SEC, RT_CRT, RT_CRS, RT_REV, RT_SPK RT_SSB, RT_SEC, RT_CRT, RT_CRS, RT_REV, RT_SPK
} }
rectype = RT_NONE; rectype = RT_NONE;
#define NR_FIELDS 17 #define NR_FIELDS 18
char *field[NR_FIELDS]; char *field[NR_FIELDS];
int fields = 0; int fields = 0;
void *hook; void *hook;
@ -712,6 +729,10 @@ keylist_colon_handler (void *priv, char *line)
return gpg_error_from_syserror (); return gpg_error_from_syserror ();
} }
/* Field 18 has the compliance flags. */
if (fields >= 17 && *field[17])
parse_pub_field18 (subkey, field[17]);
break; break;
case RT_SUB: case RT_SUB:
@ -785,6 +806,10 @@ keylist_colon_handler (void *priv, char *line)
return gpg_error_from_syserror (); return gpg_error_from_syserror ();
} }
/* Field 18 has the compliance flags. */
if (fields >= 17 && *field[17])
parse_pub_field18 (subkey, field[17]);
break; break;
case RT_UID: case RT_UID:

View File

@ -223,13 +223,14 @@ main (int argc, char **argv)
key->can_sign? "s":"", key->can_sign? "s":"",
key->can_certify? "c":"", key->can_certify? "c":"",
key->can_authenticate? "a":""); key->can_authenticate? "a":"");
printf ("flags :%s%s%s%s%s%s%s\n", printf ("flags :%s%s%s%s%s%s%s%s\n",
key->secret? " secret":"", key->secret? " secret":"",
key->revoked? " revoked":"", key->revoked? " revoked":"",
key->expired? " expired":"", key->expired? " expired":"",
key->disabled? " disabled":"", key->disabled? " disabled":"",
key->invalid? " invalid":"", key->invalid? " invalid":"",
key->is_qualified? " qualifid":"", key->is_qualified? " qualified":"",
key->subkeys && key->subkeys->is_de_vs? " de-vs":"",
key->subkeys && key->subkeys->is_cardkey? " cardkey":""); key->subkeys && key->subkeys->is_cardkey? " cardkey":"");
subkey = key->subkeys; subkey = key->subkeys;
@ -248,14 +249,15 @@ main (int argc, char **argv)
subkey->can_sign? "s":"", subkey->can_sign? "s":"",
subkey->can_certify? "c":"", subkey->can_certify? "c":"",
subkey->can_authenticate? "a":""); subkey->can_authenticate? "a":"");
printf ("flags %2d:%s%s%s%s%s%s%s\n", printf ("flags %2d:%s%s%s%s%s%s%s%s\n",
nsub, nsub,
subkey->secret? " secret":"", subkey->secret? " secret":"",
subkey->revoked? " revoked":"", subkey->revoked? " revoked":"",
subkey->expired? " expired":"", subkey->expired? " expired":"",
subkey->disabled? " disabled":"", subkey->disabled? " disabled":"",
subkey->invalid? " invalid":"", subkey->invalid? " invalid":"",
subkey->is_qualified? " qualifid":"", subkey->is_qualified? " qualified":"",
subkey->is_de_vs? " de-vs":"",
subkey->is_cardkey? " cardkey":""); subkey->is_cardkey? " cardkey":"");
} }
for (nuids=0, uid=key->uids; uid; uid = uid->next, nuids++) for (nuids=0, uid=key->uids; uid; uid = uid->next, nuids++)