aboutsummaryrefslogtreecommitdiffstats
path: root/gpgmeplug/gpgmeplug.c
diff options
context:
space:
mode:
authorKarl-Heinz Zimmer <[email protected]>2002-10-31 13:59:38 +0000
committerKarl-Heinz Zimmer <[email protected]>2002-10-31 13:59:38 +0000
commit05f1c81b601e9897a2c8577103f9f433abc2d92c (patch)
treee3cfc1935c66c49e8f936bb0e4083c247ad7fe8a /gpgmeplug/gpgmeplug.c
parentImplementing the 1st of missing features reported by Ingo: isEmailInCertifica... (diff)
downloadgpgme-05f1c81b601e9897a2c8577103f9f433abc2d92c.tar.gz
gpgme-05f1c81b601e9897a2c8577103f9f433abc2d92c.zip
Add support for certificates having the e-mail address stored in GPGME_ATTR_USERID instead of GPGME_ATTR_EMAIL.
Diffstat (limited to '')
-rw-r--r--gpgmeplug/gpgmeplug.c76
1 files changed, 14 insertions, 62 deletions
diff --git a/gpgmeplug/gpgmeplug.c b/gpgmeplug/gpgmeplug.c
index b9dba9db..6461a556 100644
--- a/gpgmeplug/gpgmeplug.c
+++ b/gpgmeplug/gpgmeplug.c
@@ -456,67 +456,6 @@ bool warnNoCertificate()
bool isEmailInCertificate( const char* email, const char* fingerprint )
{
-/*
- GpgmeError err;
- GpgmeCtx ctx;
- GpgmeData keydata;
- GpgmeRecipients recips;
- char* buf;
- const char* tmp1;
- char* tmp2;
- bool bOk = false;
-
- err = gpgme_new( &ctx );
- if( err != GPGME_No_Error ) {
- return false;
- }
- gpgme_set_protocol( ctx, GPGME_PROTOCOL_CMS );
- gpgme_set_keylist_mode( ctx, GPGME_KEYLIST_MODE_LOCAL );
-
- err = gpgme_data_new( &keydata );
- if( err ) {
- fprintf( stderr, "gpgme_data_new returned %d\n", err );
- gpgme_release( ctx );
- return false;
- }
-
- err = gpgme_recipients_new( &recips );
- if( err ) {
- fprintf( stderr, "gpgme_recipients_new returned %d\n", err );
- gpgme_data_release( keydata );
- gpgme_release( ctx );
- return false;
- }
-
- buf = malloc( sizeof(char)*( strlen( fingerprint ) + 1 ) );
- if( !buf ) {
- gpgme_recipients_release( recips );
- gpgme_data_release( keydata );
- gpgme_release( ctx );
- fprintf( stderr, "GPGME OUT OF CORE: malloc returned error!\n" );
- return false;
- }
- tmp1 = fingerprint;
- tmp2 = buf;
- while( *tmp1 ) {
- if( *tmp1 != ':' ) *tmp2++ = *tmp1;
- tmp1++;
- }
- *tmp2 = 0;
- // fprintf( stderr, "calling gpgme_recipients_add_name( %s )\n", buf );
- err = gpgme_recipients_add_name( recips, buf );
- if( err ) {
- fprintf( stderr, "gpgme_recipients_add_name returned %d\n", err );
- free (buf);
- gpgme_recipients_release( recips );
- gpgme_data_release( keydata );
- gpgme_release( ctx );
- return err;
- }
-*/
-
-
-
GpgmeCtx ctx;
GpgmeError err;
GpgmeKey rKey;
@@ -524,7 +463,10 @@ bool isEmailInCertificate( const char* email, const char* fingerprint )
const char* attr_string;
int emailCount = 0;
bool bOk = false;
+ int fprLen = strlen( fingerprint );
+ fprintf( stderr, "gpgmeplug isEmailInCertificate looking for fingerprint %s\n", fingerprint );
+
gpgme_new( &ctx );
gpgme_set_protocol( ctx, GPGMEPLUG_PROTOCOL );
@@ -538,12 +480,22 @@ bool isEmailInCertificate( const char* email, const char* fingerprint )
(attr_string = gpgme_key_get_string_attr(
rKey, GPGME_ATTR_EMAIL, 0, UID_idx ) );
++UID_idx ){
- if (*attr_string) {
+ if (attr_string && *attr_string) {
++emailCount;
fprintf( stderr, "gpgmeplug isEmailInCertificate found email: %s\n", attr_string );
if( 0 == strcasecmp(attr_string, email) ){
bOk = true;
break;
+ }else{
+ attr_string = gpgme_key_get_string_attr(
+ rKey, GPGME_ATTR_USERID, 0, UID_idx );
+ if (attr_string && *attr_string == '<'){
+ ++attr_string;
+ if( 0 == strncasecmp(attr_string, email, fprLen) ){
+ bOk = true;
+ break;
+ }
+ }
}
}
}