diff options
author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2002-10-01 12:19:29 +0000 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2002-10-01 12:19:29 +0000 |
commit | bcf27ce987194388baac81206f5b825750c13383 (patch) | |
tree | 27531f00924adf1a5bdb07dc47a058eecdb1c456 | |
parent | 53effc202555e76bf475b31da2530f10e553da35 (diff) | |
download | gnutls-bcf27ce987194388baac81206f5b825750c13383.tar.gz |
Added function to extract the public key algorithm of a DER encoded private key.
-rw-r--r-- | configure.in | 2 | ||||
-rw-r--r-- | doc/TODO | 1 | ||||
-rw-r--r-- | lib/gnutls.h.in.in | 1 | ||||
-rw-r--r-- | lib/gnutls_privkey.c | 32 | ||||
-rw-r--r-- | lib/gnutls_privkey.h | 1 | ||||
-rw-r--r-- | lib/gnutls_ui.h | 1 |
6 files changed, 37 insertions, 1 deletions
diff --git a/configure.in b/configure.in index 508935832f..c894ad603d 100644 --- a/configure.in +++ b/configure.in @@ -12,7 +12,7 @@ AC_DEFINE_UNQUOTED(T_OS, "$target_os", [OS name]) dnl Gnutls Version GNUTLS_MAJOR_VERSION=0 GNUTLS_MINOR_VERSION=5 -GNUTLS_MICRO_VERSION=8 +GNUTLS_MICRO_VERSION=9 GNUTLS_VERSION=$GNUTLS_MAJOR_VERSION.$GNUTLS_MINOR_VERSION.$GNUTLS_MICRO_VERSION AC_DEFINE_UNQUOTED(GNUTLS_VERSION, "$GNUTLS_VERSION", [version of gnutls]) @@ -4,6 +4,7 @@ in order to avoid having people working on the same thing. Current list: + Add ability to read PKCS-12 structures (certificate and private key) +* Add algorithms to parse DER encoded private keys * Add support for the certificate authenticated SRP cipher suites * Add option to read the SRP parameters using a callback (server side) * Add functions to generate SRP parameters and SRP verifiers diff --git a/lib/gnutls.h.in.in b/lib/gnutls.h.in.in index 8c5a9a844f..983b2bb238 100644 --- a/lib/gnutls.h.in.in +++ b/lib/gnutls.h.in.in @@ -206,6 +206,7 @@ const char *gnutls_protocol_get_name(gnutls_protocol_version version); int gnutls_session_set_data( gnutls_session session, const void* session_data, int session_data_size); int gnutls_session_get_data( gnutls_session session, void* session_data, int *session_data_size); /* returns the session ID */ +#define GNUTLS_MAX_SESSION_ID 32 int gnutls_session_get_id( gnutls_session session, void* session_id, int *session_id_size); /* checks if this session is a resumed one diff --git a/lib/gnutls_privkey.c b/lib/gnutls_privkey.c index dd9832764c..be7d0eef0b 100644 --- a/lib/gnutls_privkey.c +++ b/lib/gnutls_privkey.c @@ -32,6 +32,7 @@ #include <gnutls_datum.h> #include <gnutls_mpi.h> #include <gnutls_global.h> +#include <gnutls_privkey.h> /* Converts an RSA PKCS#1 key to * an internal structure (gnutls_private_key) @@ -274,3 +275,34 @@ void _gnutls_free_private_key(gnutls_private_key pkey) return; } + +/** + * gnutls_x509_extract_key_pk_algorithm - This function returns the keys's PublicKey algorithm + * @cert: is a DER encoded private key + * + * This function will return the public key algorithm of a DER encoded private + * key. + * + * Returns a member of the gnutls_pk_algorithm enumeration on success, + * or a negative value on error. + * + **/ +int gnutls_x509_extract_key_pk_algorithm( const gnutls_datum * key) +{ +int cv, pk; + + pk = GNUTLS_PK_UNKNOWN; + + /* The only way to distinguish the keys + * is to count the sequence of integers. + */ + cv = _gnutls_der_check_if_rsa_key( key); + if (cv==0) + pk = GNUTLS_PK_RSA; + else + pk = GNUTLS_PK_DSA; + + return pk; + +} + diff --git a/lib/gnutls_privkey.h b/lib/gnutls_privkey.h index 4e045a01b6..127c300897 100644 --- a/lib/gnutls_privkey.h +++ b/lib/gnutls_privkey.h @@ -1,3 +1,4 @@ int _gnutls_PKCS1key2gnutlsKey(gnutls_private_key * pkey, gnutls_datum raw_key); int _gnutls_DSAkey2gnutlsKey(gnutls_private_key * pkey, gnutls_datum raw_key); void _gnutls_free_private_key( gnutls_private_key pkey); +int _gnutls_der_check_if_rsa_key(const gnutls_datum * key_struct); diff --git a/lib/gnutls_ui.h b/lib/gnutls_ui.h index 81ca943989..f9ccf3c329 100644 --- a/lib/gnutls_ui.h +++ b/lib/gnutls_ui.h @@ -92,6 +92,7 @@ time_t gnutls_x509_extract_certificate_expiration_time( const gnutls_datum*); int gnutls_x509_extract_certificate_subject_alt_name( const gnutls_datum*, int seq, char*, int*); int gnutls_x509_pkcs7_extract_certificate(const gnutls_datum * pkcs7_struct, int indx, char* certificate, int* certificate_size); int gnutls_x509_extract_certificate_pk_algorithm( const gnutls_datum * cert, int* bits); +int gnutls_x509_extract_key_pk_algorithm( const gnutls_datum * key); int gnutls_x509_verify_certificate( const gnutls_datum* cert_list, int cert_list_length, const gnutls_datum * CA_list, int CA_list_length, const gnutls_datum* CRL_list, int CRL_list_length); |