aboutsummaryrefslogtreecommitdiffstats
path: root/gpgmeplug/gpgmeplug.c
diff options
context:
space:
mode:
authorSteffen Hansen <[email protected]>2002-07-31 12:37:34 +0000
committerSteffen Hansen <[email protected]>2002-07-31 12:37:34 +0000
commit6676c74b6afd6aece8988c19c7b67cda9031efa2 (patch)
treea420a0cb5ef353f5012781f6dce534fc71287952 /gpgmeplug/gpgmeplug.c
parent2002-07-29 Marcus Brinkmann <[email protected]> (diff)
downloadgpgme-6676c74b6afd6aece8988c19c7b67cda9031efa2.tar.gz
gpgme-6676c74b6afd6aece8988c19c7b67cda9031efa2.zip
new cryptplug function importCertificateFromMem()
Diffstat (limited to '')
-rw-r--r--gpgmeplug/gpgmeplug.c41
1 files changed, 39 insertions, 2 deletions
diff --git a/gpgmeplug/gpgmeplug.c b/gpgmeplug/gpgmeplug.c
index 4af5ffec..f6030083 100644
--- a/gpgmeplug/gpgmeplug.c
+++ b/gpgmeplug/gpgmeplug.c
@@ -2234,7 +2234,7 @@ endListCertificates( struct CertIterator* it )
}
int
-importCertificate( const char* fingerprint )
+importCertificateWithFPR( const char* fingerprint, char** additional_info )
{
GpgmeError err;
GpgmeCtx ctx;
@@ -2296,6 +2296,7 @@ importCertificate( const char* fingerprint )
if( err ) {
fprintf( stderr, "gpgme_op_export returned %d\n", err );
free (buf);
+ *additional_info = gpgme_get_op_info( ctx, 0 );
gpgme_recipients_release( recips );
gpgme_data_release( keydata );
gpgme_release( ctx );
@@ -2305,10 +2306,11 @@ importCertificate( const char* fingerprint )
buf = NULL;
err = gpgme_op_import( ctx, keydata );
+ *additional_info = gpgme_get_op_info( ctx, 0 );
if( err ) {
fprintf( stderr, "gpgme_op_import returned %d\n", err );
gpgme_recipients_release( recips );
- gpgme_data_release( keydata );
+ gpgme_data_release( keydata );
gpgme_release( ctx );
return err;
}
@@ -2318,6 +2320,41 @@ importCertificate( const char* fingerprint )
gpgme_release( ctx );
return 0;
}
+int
+importCertificateFromMem( const char* data, size_t length , char** additional_info )
+{
+ GpgmeError err;
+ GpgmeCtx ctx;
+ GpgmeData keydata;
+
+ err = gpgme_new( &ctx );
+ /*fprintf( stderr, "2: gpgme returned %d\n", err );*/
+ if( err != GPGME_No_Error ) {
+ return err;
+ }
+ gpgme_set_protocol( ctx, GPGME_PROTOCOL_CMS );
+ gpgme_set_keylist_mode( ctx, GPGME_KEYLIST_MODE_LOCAL );
+
+ err = gpgme_data_new_from_mem( &keydata, data, length, 0 );
+ if( err ) {
+ fprintf( stderr, "gpgme_data_new returned %d\n", err );
+ gpgme_release( ctx );
+ return err;
+ }
+
+ err = gpgme_op_import( ctx, keydata );
+ *additional_info = gpgme_get_op_info( ctx, 0 );
+ if( err ) {
+ fprintf( stderr, "gpgme_op_import returned %d\n", err );
+ gpgme_data_release( keydata );
+ gpgme_release( ctx );
+ return err;
+ }
+
+ gpgme_data_release( keydata );
+ gpgme_release( ctx );
+ return 0;
+}
/* == == == == == == == == == == == == == == == == == == == == == == == == ==
== ==