diff options
author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2003-10-03 09:42:48 +0000 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2003-10-03 09:42:48 +0000 |
commit | 8b99a69401e62d6e8721875fc9900bc887e4099f (patch) | |
tree | 8b023539206d5319a471556747d0747f1c1c7d0d | |
parent | b0a4ea9f5b29c8e04d5c22ff53f9c529419aaa65 (diff) | |
download | gnutls-8b99a69401e62d6e8721875fc9900bc887e4099f.tar.gz |
*** empty log message ***
-rw-r--r-- | includes/gnutls/extra.h | 27 | ||||
-rw-r--r-- | includes/gnutls/openpgp.h | 106 | ||||
-rw-r--r-- | libextra/openpgp/gnutls_openpgp.c | 39 |
3 files changed, 106 insertions, 66 deletions
diff --git a/includes/gnutls/extra.h b/includes/gnutls/extra.h index 709e164788..30976eb441 100644 --- a/includes/gnutls/extra.h +++ b/includes/gnutls/extra.h @@ -62,39 +62,12 @@ void gnutls_srp_set_server_credentials_function( gnutls_srp_server_credentials_function *); /* Openpgp certificate stuff */ -int gnutls_openpgp_fingerprint( const gnutls_datum* data, char* result, size_t* result_size); - -int gnutls_openpgp_key_to_xml( const gnutls_datum *cert, gnutls_datum *xmlkey, - int ext); - -int gnutls_openpgp_extract_key_name( const gnutls_datum *cert, - int idx, - gnutls_openpgp_name *dn ); - -int -gnutls_openpgp_extract_key_name_string( const gnutls_datum *cert, - int idx, - char *buf, unsigned int sizeof_buf); - -int gnutls_openpgp_extract_key_pk_algorithm(const gnutls_datum *cert, - int *r_bits); - -int gnutls_openpgp_extract_key_version( const gnutls_datum *cert ); - -time_t gnutls_openpgp_extract_key_creation_time( const gnutls_datum *cert ); -time_t gnutls_openpgp_extract_key_expiration_time( const gnutls_datum *cert ); - -int gnutls_openpgp_extract_key_id( const gnutls_datum *cert, unsigned char keyid[8]); typedef int (*gnutls_openpgp_recv_key_func)(gnutls_session, const unsigned char *keyfpr, unsigned int keyfpr_length, gnutls_datum *key); void gnutls_openpgp_set_recv_key_function( gnutls_session, gnutls_openpgp_recv_key_func); -int gnutls_openpgp_verify_key( const char *trustdb, const gnutls_datum* keyring, - const gnutls_datum* key_list, - int key_list_length); - int gnutls_certificate_set_openpgp_key_file( gnutls_certificate_credentials res, char *CERTFILE, char* KEYFILE); int gnutls_certificate_set_openpgp_key_mem( gnutls_certificate_credentials res, const gnutls_datum* CERT, const gnutls_datum* KEY); diff --git a/includes/gnutls/openpgp.h b/includes/gnutls/openpgp.h new file mode 100644 index 0000000000..6767796a75 --- /dev/null +++ b/includes/gnutls/openpgp.h @@ -0,0 +1,106 @@ +/* + * Copyright (C) 2003 Nikos Mavroyanopoulos + * + * This file is part of GNUTLS. + * + * The GNUTLS library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +/* This file contains the types and prototypes for the OpenPGP + * key and private key parsing functions. + */ + +#ifndef GNUTLS_OPENPGP_H +# define GNUTLS_OPENPGP_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <gnutls/gnutls.h> + +struct gnutls_openpgp_key; /* object to hold (parsed) openpgp keys */ + +typedef enum gnutls_openpgp_key_fmt { GNUTLS_X509_FMT_RAW, + GNUTLS_X509_FMT_BASE64 } gnutls_openpgp_key_fmt; + +int gnutls_openpgp_key_init( gnutls_openpgp_key* key); /* initializes the memory for gnutls_openpgp_key struct */ +void gnutls_openpgp_key_deinit(gnutls_openpgp_key key); /* frees all memory */ + +int gnutls_openpgp_key_import(gnutls_openpgp_key key, + const gnutls_datum* data, gnutls_openpgp_key_fmt format); + +int gnutls_openpgp_key_get_fingerprint( gnutls_openpgp_key key, + char* result, size_t* result_size); + +int gnutls_openpgp_key_get_name( gnutls_openpgp_key key, + int idx, + char *buf, size_t *sizeof_buf); + +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_check_hostname( gnutls_openpgp_key key, const char *hostname); + +int gnutls_openpgp_key_to_xml( gnutls_openpgp_key key key, gnutls_datum *xmlkey, + int ext); + +/* Keyring stuff. + */ +struct gnutls_openpgp_keyring; + +int gnutls_openpgp_keyring_init( gnutls_openpgp_keyring* ring); +void gnutls_openpgp_keyring_deinit(gnutls_openpgp_keyring ring); + +int gnutls_openpgp_keyring_import(gnutls_openpgp_keyring ring, + const gnutls_datum* data, gnutls_openpgp_key_fmt format); + +/* Trustdb functions. + */ +struct gnutls_openpgp_trustdb; + +int gnutls_openpgp_trustdb_init( gnutls_openpgp_trustdb* ring); +void gnutls_openpgp_trustdb_deinit(gnutls_openpgp_trustdb ring); + +int gnutls_openpgp_trustdb_import(gnutls_openpgp_trustdb ring, + const gnutls_datum* data, gnutls_openpgp_key_fmt format); + + +int gnutls_openpgp_key_verify_ring( + gnutls_openpgp_key key, + gnutls_openpgp_keyring ring, + unsigned int flags /* if not used reserved for future use, + unsigned int * verify /* the output of the verification */); + +int gnutls_openpgp_key_verify_db( + gnutls_openpgp_key key, + gnutls_openpgp_trustdb db, + unsigned int flags /* if not used reserved for future use, + unsigned int * verify /* the output of the verification */); + + +#ifdef __cplusplus +} +#endif +#endif /* GNUTLS_OPENPGP_H */ + diff --git a/libextra/openpgp/gnutls_openpgp.c b/libextra/openpgp/gnutls_openpgp.c index 28d4555641..b10364dfb4 100644 --- a/libextra/openpgp/gnutls_openpgp.c +++ b/libextra/openpgp/gnutls_openpgp.c @@ -915,45 +915,6 @@ leave: } -/** - * gnutls_openpgp_fingerprint - Gets the fingerprint - * @cert: the raw data that contains the OpenPGP public key. - * @fpr: the buffer to save the fingerprint. - * @fprlen: the integer to save the length of the fingerprint. - * - * Returns the fingerprint of the OpenPGP key. Depence on the algorithm, - * the fingerprint can be 16 or 20 bytes. - **/ -int -gnutls_openpgp_fingerprint( const gnutls_datum *cert, - unsigned char *fpr, size_t *fprlen ) -{ - CDK_PACKET *pkt; - cdk_pkt_pubkey_t pk = NULL; - - if( !cert || !fpr || !fprlen ) { - gnutls_assert( ); - return GNUTLS_E_INVALID_REQUEST; - } - - *fprlen = 0; - - pkt = search_packet( cert, CDK_PKT_PUBLIC_KEY ); - if( !pkt ) - return GNUTLS_E_OPENPGP_GETKEY_FAILED; - - pk = pkt->pkt.public_key; - *fprlen = 20; - if ( is_RSA(pk->pubkey_algo) && pk->version < 4 ) - *fprlen = 16; - cdk_pk_get_fingerprint( pk, fpr ); - search_packet( NULL, 0 ); - - return 0; -} - - - /*- * gnutls_openpgp_add_keyring_file - Adds a keyring file for OpenPGP * @keyring: data buffer to store the file. |