diff options
author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2003-03-22 14:57:49 +0000 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2003-03-22 14:57:49 +0000 |
commit | 683827f6b98e43561baf3d88b21c3d586ec0a65c (patch) | |
tree | 392ea037704437348648e89ba9aa49432f93d376 /lib/gnutls_cert.c | |
parent | 2f035aae4b0eb01794fc730d4064836d190e471d (diff) | |
download | gnutls-683827f6b98e43561baf3d88b21c3d586ec0a65c.tar.gz |
*** empty log message ***
Diffstat (limited to 'lib/gnutls_cert.c')
-rw-r--r-- | lib/gnutls_cert.c | 99 |
1 files changed, 79 insertions, 20 deletions
diff --git a/lib/gnutls_cert.c b/lib/gnutls_cert.c index 24406fbbd4..5ee7c6fd2c 100644 --- a/lib/gnutls_cert.c +++ b/lib/gnutls_cert.c @@ -42,20 +42,16 @@ #include "x509/x509.h" #include "x509/mpi.h" - /** - * gnutls_certificate_free_credentials - Used to free an allocated gnutls_certificate_credentials structure + * gnutls_certificate_free_keys - Used to free all the keys from a gnutls_certificate_credentials structure * @sc: is an &gnutls_certificate_credentials structure. * - * This structure is complex enough to manipulate directly thus - * this helper function is provided in order to free (deallocate) - * the structure. + * This function will delete all the keys and the certificates associated + * with the given credentials. This function must not be called when a + * TLS negotiation that uses the credentials is in progress. * - * This function does not free any temporary parameters associated - * with this structure (ie RSA and DH parameters are not freed by - * this function). **/ -void gnutls_certificate_free_credentials(gnutls_certificate_credentials sc) +void gnutls_certificate_free_keys(gnutls_certificate_credentials sc) { uint i, j; @@ -67,25 +63,88 @@ void gnutls_certificate_free_credentials(gnutls_certificate_credentials sc) } gnutls_free(sc->cert_list_length); + sc->cert_list_length = NULL; + gnutls_free(sc->cert_list); + sc->cert_list = NULL; - for (j = 0; j < sc->x509_ncas; j++) { - gnutls_x509_crt_deinit( sc->x509_ca_list[j]); + for (i = 0; i < sc->ncerts; i++) { + _gnutls_privkey_deinit( &sc->pkey[i]); } - for (j = 0; j < sc->x509_ncrls; j++) { - gnutls_x509_crl_deinit( sc->x509_crl_list[j]); - } + gnutls_free( sc->pkey); + sc->pkey = NULL; + + sc->ncerts = 0; + +} + +/** + * gnutls_certificate_free_cas - Used to free all the CAs from a gnutls_certificate_credentials structure + * @sc: is an &gnutls_certificate_credentials structure. + * + * This function will delete all the CAs associated + * with the given credentials. + * + **/ +void gnutls_certificate_free_cas(gnutls_certificate_credentials sc) +{ + uint j; + + for (j = 0; j < sc->x509_ncas; j++) { + gnutls_x509_crt_deinit( sc->x509_ca_list[j]); + } + + sc->x509_ncas = 0; gnutls_free( sc->x509_ca_list); - _gnutls_free_datum( &sc->keyring); + sc->x509_ca_list = NULL; - for (i = 0; i < sc->ncerts; i++) { - _gnutls_privkey_deinit( &sc->pkey[i]); - } + _gnutls_free_datum( &sc->x509_rdn_sequence); - gnutls_free( sc->pkey); - gnutls_free( sc->x509_rdn_sequence.data); +} + +/** + * gnutls_certificate_free_crls - Used to free all the CRLs from a gnutls_certificate_credentials structure + * @sc: is an &gnutls_certificate_credentials structure. + * + * This function will delete all the CRLs associated + * with the given credentials. + * + **/ +void gnutls_certificate_free_crls(gnutls_certificate_credentials sc) +{ + uint j; + + for (j = 0; j < sc->x509_ncrls; j++) { + gnutls_x509_crl_deinit( sc->x509_crl_list[j]); + } + + sc->x509_ncrls = 0; + + gnutls_free( sc->x509_crl_list); + sc->x509_crl_list = NULL; +} + +/** + * gnutls_certificate_free_credentials - Used to free an allocated gnutls_certificate_credentials structure + * @sc: is an &gnutls_certificate_credentials structure. + * + * This structure is complex enough to manipulate directly thus + * this helper function is provided in order to free (deallocate) + * the structure. + * + * This function does not free any temporary parameters associated + * with this structure (ie RSA and DH parameters are not freed by + * this function). + **/ +void gnutls_certificate_free_credentials(gnutls_certificate_credentials sc) +{ + gnutls_certificate_free_keys( sc); + gnutls_certificate_free_cas( sc); + gnutls_certificate_free_crls( sc); + + _gnutls_free_datum( &sc->keyring); gnutls_free( sc); } |