diff options
author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2003-12-10 13:58:56 +0000 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2003-12-10 13:58:56 +0000 |
commit | 43e359e19a8aaa2c27bf3268d21ccffa50838665 (patch) | |
tree | 0f57741673f0226c846479502f2168934ccf33e4 | |
parent | 7740b8649816375d05741a2df67b07a27dc601b0 (diff) | |
download | gnutls-43e359e19a8aaa2c27bf3268d21ccffa50838665.tar.gz |
Added gnutls_rsa_params_export_pkcs1() and gnutls_rsa_params_import_pkcs1().
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | configure.in | 2 | ||||
-rw-r--r-- | lib/gnutls.h.in.in | 10 | ||||
-rw-r--r-- | lib/gnutls_dh_primes.c | 2 | ||||
-rw-r--r-- | lib/gnutls_rsa_export.c | 51 | ||||
-rw-r--r-- | lib/gnutls_state.c | 2 |
6 files changed, 62 insertions, 6 deletions
@@ -2,6 +2,7 @@ Version 1.0.1 - Some minor fixes in the makefiles. They now include CFLAGS from libgcrypt or opencdk if installed in a non standard directory. - Fixed the SRP detection test in gnutls-cli-debug. +- Added gnutls_rsa_params_export_pkcs1() and gnutls_rsa_params_import_pkcs1(). Version 1.0.0 (04/12/2003) - Exported the static SRP group parameters. diff --git a/configure.in b/configure.in index 42c267683e..21230de5c7 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=1 GNUTLS_MINOR_VERSION=0 -GNUTLS_MICRO_VERSION=0 +GNUTLS_MICRO_VERSION=1 GNUTLS_VERSION=$GNUTLS_MAJOR_VERSION.$GNUTLS_MINOR_VERSION.$GNUTLS_MICRO_VERSION AC_DEFINE_UNQUOTED(GNUTLS_VERSION, "$GNUTLS_VERSION", [version of gnutls]) diff --git a/lib/gnutls.h.in.in b/lib/gnutls.h.in.in index d57263d18b..1d89595bd1 100644 --- a/lib/gnutls.h.in.in +++ b/lib/gnutls.h.in.in @@ -319,6 +319,7 @@ int gnutls_credentials_clear( gnutls_session session); /* cred is a structure defined by the kx algorithm */ int gnutls_credentials_set( gnutls_session, gnutls_credentials_type type, void* cred); +#define gnutls_cred_set gnutls_credentials_set /* Credential structures for SRP - used in gnutls_credentials_set(); */ @@ -420,12 +421,12 @@ void gnutls_global_set_log_level( int level); int gnutls_dh_params_init( gnutls_dh_params*); void gnutls_dh_params_deinit( gnutls_dh_params); int gnutls_dh_params_import_raw(gnutls_dh_params dh_params, const gnutls_datum *prime, - const gnutls_datum* generator); + const gnutls_datum* generator); int gnutls_dh_params_import_pkcs3(gnutls_dh_params params, const gnutls_datum * pkcs3_params, gnutls_x509_crt_fmt format); int gnutls_dh_params_generate2(gnutls_dh_params params, int bits); int gnutls_dh_params_export_pkcs3( gnutls_dh_params params, - gnutls_x509_crt_fmt format, unsigned char* params_data, size_t* params_data_size); + gnutls_x509_crt_fmt format, unsigned char* params_data, size_t* params_data_size); int gnutls_dh_params_export_raw(gnutls_dh_params params, gnutls_datum * prime, gnutls_datum * generator, unsigned int *bits); @@ -443,6 +444,11 @@ int gnutls_rsa_params_export_raw(gnutls_rsa_params params, gnutls_datum * m, gnutls_datum *e, gnutls_datum *d, gnutls_datum *p, gnutls_datum* q, gnutls_datum* u, unsigned int *bits); +int gnutls_rsa_params_export_pkcs1( gnutls_rsa_params params, + gnutls_x509_crt_fmt format, unsigned char* params_data, + size_t* params_data_size); +int gnutls_rsa_params_import_pkcs1(gnutls_rsa_params params, + const gnutls_datum * pkcs1_params, gnutls_x509_crt_fmt format); /* Session stuff */ diff --git a/lib/gnutls_dh_primes.c b/lib/gnutls_dh_primes.c index 58d5c9bc1f..d3dbde8b5c 100644 --- a/lib/gnutls_dh_primes.c +++ b/lib/gnutls_dh_primes.c @@ -268,8 +268,6 @@ int ret; * * This function will extract the DHParams found in a PKCS3 formatted * structure. This is the format generated by "openssl dhparam" tool. - * The output will be allocated using gnutls_malloc() and will be put - * in prime and generator structures. * * If the structure is PEM encoded, it should have a header * of "BEGIN DH PARAMETERS". diff --git a/lib/gnutls_rsa_export.c b/lib/gnutls_rsa_export.c index bc9bbeb990..bc7104fb92 100644 --- a/lib/gnutls_rsa_export.c +++ b/lib/gnutls_rsa_export.c @@ -220,6 +220,57 @@ int gnutls_rsa_params_generate2(gnutls_rsa_params params, unsigned int bits) } /** + * gnutls_rsa_params_import_pkcs1 - This function will import RSA params from a pkcs1 structure + * @params: A structure where the parameters will be copied to + * @pkcs1_params: should contain a PKCS1 RSAPublicKey structure PEM or DER encoded + * @format: the format of params. PEM or DER. + * + * This function will extract the RSAPublicKey found in a PKCS1 formatted + * structure. + * + * If the structure is PEM encoded, it should have a header + * of "BEGIN RSA PRIVATE KEY". + * + * In case of failure a negative value will be returned, and + * 0 on success. + * + **/ +int gnutls_rsa_params_import_pkcs1(gnutls_rsa_params params, + const gnutls_datum * pkcs1_params, gnutls_x509_crt_fmt format) +{ + return gnutls_x509_privkey_import( params, pkcs1_params, + format); +} + + +/** + * gnutls_rsa_params_export_pkcs1 - This function will export RSA params to a pkcs1 structure + * @params: Holds the RSA parameters + * @format: the format of output params. One of PEM or DER. + * @params_data: will contain a PKCS1 RSAPublicKey structure PEM or DER encoded + * @params_data_size: holds the size of params_data (and will be replaced by the actual size of parameters) + * + * This function will export the given RSA parameters to a PKCS1 + * RSAPublicKey structure. If the buffer provided is not long enough to + * hold the output, then GNUTLS_E_SHORT_MEMORY_BUFFER will be returned. + * + * If the structure is PEM encoded, it will have a header + * of "BEGIN RSA PRIVATE KEY". + * + * In case of failure a negative value will be returned, and + * 0 on success. + * + **/ +int gnutls_rsa_params_export_pkcs1( gnutls_rsa_params params, + gnutls_x509_crt_fmt format, unsigned char* params_data, + size_t* params_data_size) +{ + return gnutls_x509_privkey_export( params, format, + params_data, params_data_size); +} + + +/** * gnutls_rsa_params_export_raw - This function will export the RSA parameters * @params: a structure that holds the rsa parameters * @m: will hold the modulus diff --git a/lib/gnutls_state.c b/lib/gnutls_state.c index a56a668077..310f159ccb 100644 --- a/lib/gnutls_state.c +++ b/lib/gnutls_state.c @@ -783,7 +783,7 @@ void gnutls_session_set_ptr(gnutls_session session, void* ptr) * protocol and is only useful if a prior gnutls function call (e.g. * gnutls_handshake()) was interrupted for some reason, that is, if a function * returned GNUTLS_E_INTERRUPTED or GNUTLS_E_AGAIN. In such a case, you might - * want to call select() (or poll()) before calling the interrupted gnutls + * want to call select() or poll() before calling the interrupted gnutls * function again. To tell you whether a file descriptor should be selected * for either reading or writing, gnutls_record_get_direction() returns 0 if * the interrupted function was trying to read data, and 1 if it was trying to |