summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2003-03-22 14:57:49 +0000
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2003-03-22 14:57:49 +0000
commit683827f6b98e43561baf3d88b21c3d586ec0a65c (patch)
tree392ea037704437348648e89ba9aa49432f93d376
parent2f035aae4b0eb01794fc730d4064836d190e471d (diff)
downloadgnutls-683827f6b98e43561baf3d88b21c3d586ec0a65c.tar.gz
*** empty log message ***
-rw-r--r--lib/gnutls_cert.c99
-rw-r--r--lib/gnutls_x509.c81
2 files changed, 79 insertions, 101 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);
}
diff --git a/lib/gnutls_x509.c b/lib/gnutls_x509.c
index b476b0e656..e85e7adedc 100644
--- a/lib/gnutls_x509.c
+++ b/lib/gnutls_x509.c
@@ -700,87 +700,6 @@ static int read_key_file(gnutls_certificate_credentials res, const char *keyfile
}
/**
- * gnutls_certificate_free_keys - Used to free all the keys from a gnutls_certificate_credentials structure
- * @sc: is an &gnutls_certificate_credentials 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.
- *
- **/
-void gnutls_certificate_free_keys(gnutls_certificate_credentials sc)
-{
- uint i, j;
-
- for (i = 0; i < sc->ncerts; i++) {
- for (j = 0; j < sc->cert_list_length[i]; j++) {
- _gnutls_free_cert( &sc->cert_list[i][j]);
- }
- gnutls_free( sc->cert_list[i]);
- }
-
- gnutls_free(sc->cert_list_length);
- sc->cert_list_length = NULL;
-
- gnutls_free(sc->cert_list);
- sc->cert_list = NULL;
-
- for (i = 0; i < sc->ncerts; i++) {
- _gnutls_privkey_deinit( &sc->pkey[i]);
- }
-
- 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);
- sc->x509_ca_list = NULL;
-}
-
-/**
- * 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_set_x509_key_mem - Used to set keys in a gnutls_certificate_credentials structure
* @res: is an &gnutls_certificate_credentials structure.
* @CERT: contains a certificate list (path) for the specified private key