diff options
author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2003-10-03 12:16:39 +0000 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2003-10-03 12:16:39 +0000 |
commit | e01342e2cdc7e52469716fc2c246f44100fa5068 (patch) | |
tree | b66f07b5b7e3c82baaa177d3defbe6a30d7b05a2 /libextra | |
parent | 1dc257e520537614992b4adb25fa8bc8b5591324 (diff) | |
download | gnutls-e01342e2cdc7e52469716fc2c246f44100fa5068.tar.gz |
Updated the openpgp key API.
Diffstat (limited to 'libextra')
-rw-r--r-- | libextra/Makefile.am | 2 | ||||
-rw-r--r-- | libextra/gnutls_extra.c | 4 | ||||
-rw-r--r-- | libextra/openpgp/Makefile.am | 2 | ||||
-rw-r--r-- | libextra/openpgp/gnutls_openpgp.h | 9 | ||||
-rw-r--r-- | libextra/openpgp/openpgp.c | 6 | ||||
-rw-r--r-- | libextra/openpgp/openpgp.h | 32 |
6 files changed, 50 insertions, 5 deletions
diff --git a/libextra/Makefile.am b/libextra/Makefile.am index a0279ac02a..175313cc09 100644 --- a/libextra/Makefile.am +++ b/libextra/Makefile.am @@ -33,7 +33,7 @@ libgnutls_extra_la_SOURCES = $(COBJECTS_EXTRA) libgnutls_extra_la_LIBADD = $(LZO_OBJECTS) ../lib/libgnutls.la \ openpgp/openpgp.lo openpgp/xml.lo openpgp/gnutls_openpgp.lo \ - openpgp/extras.lo openpgp/verify.lo + openpgp/extras.lo openpgp/verify.lo openpgp/compat.lo EXTRA_libgnutls_extra_la_SOURCES = minilzo.c diff --git a/libextra/gnutls_extra.c b/libextra/gnutls_extra.c index 5938e9ff92..2e2c27c3a8 100644 --- a/libextra/gnutls_extra.c +++ b/libextra/gnutls_extra.c @@ -22,7 +22,7 @@ #include <gnutls_errors.h> #include <gnutls_extensions.h> #include <ext_srp.h> -#include <gnutls_openpgp.h> +#include <openpgp/gnutls_openpgp.h> #include <gnutls_extra.h> #include <gnutls_algorithms.h> #include <minilzo.h> @@ -151,12 +151,14 @@ extern OPENPGP_FINGERPRINT _E_gnutls_openpgp_fingerprint; extern OPENPGP_KEY_REQUEST _E_gnutls_openpgp_request_key; static void _gnutls_add_openpgp_functions(void) { +#ifdef HAVE_LIBOPENCDK _E_gnutls_openpgp_verify_key = gnutls_openpgp_verify_key; _E_gnutls_openpgp_extract_key_expiration_time = gnutls_openpgp_extract_key_expiration_time; _E_gnutls_openpgp_extract_key_creation_time = gnutls_openpgp_extract_key_creation_time; _E_gnutls_openpgp_fingerprint = gnutls_openpgp_fingerprint; _E_gnutls_openpgp_request_key = _gnutls_openpgp_request_key; _E_gnutls_openpgp_cert2gnutls_cert = _gnutls_openpgp_cert2gnutls_cert; +#endif } extern const char* gnutls_check_version( const char*); diff --git a/libextra/openpgp/Makefile.am b/libextra/openpgp/Makefile.am index 787a84ae54..6c47b1835a 100644 --- a/libextra/openpgp/Makefile.am +++ b/libextra/openpgp/Makefile.am @@ -3,7 +3,7 @@ EXTRA_DIST = openpgp.h gnutls_openpgp.h noinst_LTLIBRARIES = libpgp.la -COBJECTS = openpgp.c xml.c gnutls_openpgp.c verify.c extras.c +COBJECTS = openpgp.c xml.c gnutls_openpgp.c verify.c extras.c compat.c libpgp_la_SOURCES = $(COBJECTS) diff --git a/libextra/openpgp/gnutls_openpgp.h b/libextra/openpgp/gnutls_openpgp.h index e89708d10e..7a60dfa1c4 100644 --- a/libextra/openpgp/gnutls_openpgp.h +++ b/libextra/openpgp/gnutls_openpgp.h @@ -80,5 +80,14 @@ keybox_blob* kbx_read_blob( const gnutls_datum* keyring, size_t pos ); cdk_keydb_hd_t kbx_to_keydb( keybox_blob *blob ); void kbx_blob_release( keybox_blob *ctx ); +int gnutls_openpgp_verify_key(const char *trustdb, + const gnutls_datum * keyring, + const gnutls_datum * cert_list, + int cert_list_length); +int gnutls_openpgp_fingerprint(const gnutls_datum * cert, + unsigned char *fpr, size_t * fprlen); +time_t gnutls_openpgp_extract_key_creation_time(const gnutls_datum * cert); +time_t gnutls_openpgp_extract_key_expiration_time(const gnutls_datum * cert); + #endif /*GNUTLS_OPENPGP_H*/ diff --git a/libextra/openpgp/openpgp.c b/libextra/openpgp/openpgp.c index c24c8a14f9..c30a3a1062 100644 --- a/libextra/openpgp/openpgp.c +++ b/libextra/openpgp/openpgp.c @@ -62,6 +62,8 @@ int gnutls_openpgp_key_init(gnutls_openpgp_key * key) **/ void gnutls_openpgp_key_deinit(gnutls_openpgp_key key) { + if (!key) return; + if (key->knode) { cdk_kbnode_release( key->knode); key->knode = NULL; @@ -275,7 +277,7 @@ gnutls_openpgp_key_get_pk_algorithm( gnutls_openpgp_key key, int *r_bits) * Extract the version of the OpenPGP key. **/ int -gnutls_openpgp_extract_key_version( gnutls_openpgp_key key) +gnutls_openpgp_key_get_version( gnutls_openpgp_key key) { CDK_PACKET *pkt; int version = 0; @@ -298,7 +300,7 @@ gnutls_openpgp_extract_key_version( gnutls_openpgp_key key) * Returns the timestamp when the OpenPGP key was created. **/ time_t -gnutls_openpgp_extract_key_creation_time( gnutls_openpgp_key key) +gnutls_openpgp_key_get_creation_time( gnutls_openpgp_key key) { CDK_PACKET *pkt; time_t timestamp = 0; diff --git a/libextra/openpgp/openpgp.h b/libextra/openpgp/openpgp.h index b559522da7..e98ad18de8 100644 --- a/libextra/openpgp/openpgp.h +++ b/libextra/openpgp/openpgp.h @@ -28,6 +28,38 @@ int gnutls_openpgp_key_get_name( gnutls_openpgp_key key, int idx, char *buf, size_t *sizeof_buf); +int gnutls_openpgp_key_get_fingerprint( gnutls_openpgp_key key, + unsigned char *fpr, size_t *fprlen); +int gnutls_openpgp_key_get_pk_algorithm( gnutls_openpgp_key key, int *r_bits); +int gnutls_openpgp_key_get_version( gnutls_openpgp_key key); +time_t gnutls_openpgp_key_get_creation_time( gnutls_openpgp_key key); +time_t gnutls_openpgp_key_get_expiration_time( gnutls_openpgp_key key); +int gnutls_openpgp_key_get_id( gnutls_openpgp_key key, + unsigned char keyid[8]); +int gnutls_openpgp_key_init(gnutls_openpgp_key * key); +void gnutls_openpgp_key_deinit(gnutls_openpgp_key key); +int gnutls_openpgp_key_import(gnutls_openpgp_key key, + const gnutls_datum * data, gnutls_openpgp_key_fmt format); + + +void gnutls_openpgp_keyring_deinit(gnutls_openpgp_keyring keyring); +int gnutls_openpgp_keyring_init(gnutls_openpgp_keyring * keyring); +int gnutls_openpgp_keyring_import(gnutls_openpgp_keyring keyring, + const gnutls_datum * data, + gnutls_openpgp_key_fmt format); + +void gnutls_openpgp_trustdb_deinit(gnutls_openpgp_trustdb trustdb); +int gnutls_openpgp_trustdb_init(gnutls_openpgp_trustdb * trustdb); +int gnutls_openpgp_trustdb_import_file(gnutls_openpgp_trustdb trustdb, + const char * file); + +int gnutls_openpgp_key_verify_ring( gnutls_openpgp_key key, + gnutls_openpgp_keyring keyring, + unsigned int flags, unsigned int *verify); + +int gnutls_openpgp_key_verify_trustdb( gnutls_openpgp_key key, + gnutls_openpgp_trustdb trustdb, + unsigned int flags, unsigned int *verify); #endif |