diff options
author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2010-07-23 23:48:45 +0200 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2010-07-23 23:50:38 +0200 |
commit | b12d2b7d3f741e2049dfbb6668503a007c10f543 (patch) | |
tree | b5c8b3972c391cefb8f5fabb402b30924c18d895 /lib/x509/privkey.c | |
parent | 08edf1b4f10d6b5d2a265d7210944f044f607729 (diff) | |
download | gnutls-b12d2b7d3f741e2049dfbb6668503a007c10f543.tar.gz |
Better handling of security parameters to key sizes matching (via a single table). Added
functions to return the security parameter of a private key.
Diffstat (limited to 'lib/x509/privkey.c')
-rw-r--r-- | lib/x509/privkey.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/x509/privkey.c b/lib/x509/privkey.c index 2b8e213829..964ccb3d9e 100644 --- a/lib/x509/privkey.c +++ b/lib/x509/privkey.c @@ -830,6 +830,36 @@ gnutls_x509_privkey_export (gnutls_x509_privkey_t key, } /** + * gnutls_x509_privkey_sec_param: + * @key: a key structure + * + * This function will return the security parameter appropriate with + * this private key. + * + * Returns: On success, a valid security parameter is returned otherwise + * %GNUTLS_SEC_PARAM_UNKNOWN is returned. + **/ +gnutls_sec_param_t +gnutls_x509_privkey_sec_param (gnutls_x509_privkey_t key) +{ +int ret; + + switch (key->pk_algorithm) + { + case GNUTLS_PK_RSA: + ret = gnutls_pk_bits_to_sec_param (GNUTLS_PK_RSA, _gnutls_mpi_get_nbits(key->params[0]/*m*/)); + break; + case GNUTLS_PK_DSA: + ret = gnutls_pk_bits_to_sec_param (GNUTLS_PK_DSA, _gnutls_mpi_get_nbits(key->params[0] /*p*/)); + break; + default: + ret = GNUTLS_SEC_PARAM_UNKNOWN; + } + + return ret; +} + +/** * gnutls_x509_privkey_export_rsa_raw: * @key: a structure that holds the rsa parameters * @m: will hold the modulus |