summaryrefslogtreecommitdiff
path: root/lib/x509/crl_write.c
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2004-06-07 10:05:43 +0000
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2004-06-07 10:05:43 +0000
commit802e1ede038010ddab31225f4b8a7e8d74f3b987 (patch)
treef9f07d2fb57da9843ac6b79e06e9266301b7e8b7 /lib/x509/crl_write.c
parente0781d87ea58ff1ac1b6439d60510a8a26ea9f54 (diff)
downloadgnutls-802e1ede038010ddab31225f4b8a7e8d74f3b987.tar.gz
changed indentation to 4 spaces instead of tabs.
Diffstat (limited to 'lib/x509/crl_write.c')
-rw-r--r--lib/x509/crl_write.c234
1 files changed, 125 insertions, 109 deletions
diff --git a/lib/x509/crl_write.c b/lib/x509/crl_write.c
index 7545f2c6a8..c68889cf52 100644
--- a/lib/x509/crl_write.c
+++ b/lib/x509/crl_write.c
@@ -41,7 +41,7 @@
#include <libtasn1.h>
#include <gnutls_ui.h>
-static void disable_optional_stuff( gnutls_x509_crl crl);
+static void disable_optional_stuff(gnutls_x509_crl crl);
/**
* gnutls_x509_crl_set_version - This function will set the CRL version
@@ -57,24 +57,25 @@ static void disable_optional_stuff( gnutls_x509_crl crl);
**/
int gnutls_x509_crl_set_version(gnutls_x509_crl crl, unsigned int version)
{
-int result;
-char null = version;
+ int result;
+ char null = version;
- if (crl==NULL) {
- gnutls_assert();
- return GNUTLS_E_INVALID_REQUEST;
- }
+ if (crl == NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
- null -= 1;
- if (null < 0) null = 0;
+ null -= 1;
+ if (null < 0)
+ null = 0;
- result = asn1_write_value( crl->crl, "tbsCertList.version", &null, 1);
- if (result != ASN1_SUCCESS) {
- gnutls_assert();
- return _gnutls_asn2err(result);
- }
+ result = asn1_write_value(crl->crl, "tbsCertList.version", &null, 1);
+ if (result != ASN1_SUCCESS) {
+ gnutls_assert();
+ return _gnutls_asn2err(result);
+ }
- return 0;
+ return 0;
}
/**
@@ -92,28 +93,28 @@ char null = version;
* Returns 0 on success.
*
**/
-int gnutls_x509_crl_sign(gnutls_x509_crl crl, gnutls_x509_crt issuer,
- gnutls_x509_privkey issuer_key)
+int gnutls_x509_crl_sign(gnutls_x509_crl crl, gnutls_x509_crt issuer,
+ gnutls_x509_privkey issuer_key)
{
-int result;
-
- if (crl==NULL || issuer == NULL) {
- gnutls_assert();
- return GNUTLS_E_INVALID_REQUEST;
- }
-
- /* disable all the unneeded OPTIONAL fields.
- */
- disable_optional_stuff( crl);
-
- result = _gnutls_x509_pkix_sign( crl->crl, "tbsCertList", issuer,
- issuer_key);
- if (result < 0) {
- gnutls_assert();
- return result;
- }
-
- return 0;
+ int result;
+
+ if (crl == NULL || issuer == NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
+
+ /* disable all the unneeded OPTIONAL fields.
+ */
+ disable_optional_stuff(crl);
+
+ result = _gnutls_x509_pkix_sign(crl->crl, "tbsCertList", issuer,
+ issuer_key);
+ if (result < 0) {
+ gnutls_assert();
+ return result;
+ }
+
+ return 0;
}
/**
@@ -128,12 +129,13 @@ int result;
**/
int gnutls_x509_crl_set_this_update(gnutls_x509_crl crl, time_t act_time)
{
- if (crl==NULL) {
- gnutls_assert();
- return GNUTLS_E_INVALID_REQUEST;
- }
+ if (crl == NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
- return _gnutls_x509_set_time( crl->crl, "tbsCertList.thisUpdate", act_time);
+ return _gnutls_x509_set_time(crl->crl, "tbsCertList.thisUpdate",
+ act_time);
}
/**
@@ -148,11 +150,12 @@ int gnutls_x509_crl_set_this_update(gnutls_x509_crl crl, time_t act_time)
**/
int gnutls_x509_crl_set_next_update(gnutls_x509_crl crl, time_t exp_time)
{
- if (crl==NULL) {
- gnutls_assert();
- return GNUTLS_E_INVALID_REQUEST;
- }
- return _gnutls_x509_set_time( crl->crl, "tbsCertList.nextUpdate", exp_time);
+ if (crl == NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
+ return _gnutls_x509_set_time(crl->crl, "tbsCertList.nextUpdate",
+ exp_time);
}
/**
@@ -167,42 +170,53 @@ int gnutls_x509_crl_set_next_update(gnutls_x509_crl crl, time_t exp_time)
* Returns 0 on success, or a negative value in case of an error.
*
**/
-int gnutls_x509_crl_set_crt_serial(gnutls_x509_crl crl, const void* serial,
- size_t serial_size, time_t revocation_time)
+int gnutls_x509_crl_set_crt_serial(gnutls_x509_crl crl, const void *serial,
+ size_t serial_size,
+ time_t revocation_time)
{
- int ret;
-
- if (crl==NULL) {
- gnutls_assert();
- return GNUTLS_E_INVALID_REQUEST;
- }
-
- ret = asn1_write_value(crl->crl, "tbsCertList.revokedCertificates", "NEW", 1);
- if (ret != ASN1_SUCCESS) {
- gnutls_assert();
- return _gnutls_asn2err(ret);
- }
-
- ret = asn1_write_value(crl->crl, "tbsCertList.revokedCertificates.?LAST.userCertificate", serial, serial_size);
- if (ret != ASN1_SUCCESS) {
- gnutls_assert();
- return _gnutls_asn2err(ret);
- }
-
- ret = _gnutls_x509_set_time( crl->crl, "tbsCertList.revokedCertificates.?LAST.revocationDate",
- revocation_time);
- if (ret < 0) {
- gnutls_assert();
- return ret;
- }
-
- ret = asn1_write_value(crl->crl, "tbsCertList.revokedCertificates.?LAST.crlEntryExtensions", NULL, 0);
- if (ret != ASN1_SUCCESS) {
- gnutls_assert();
- return _gnutls_asn2err(ret);
- }
-
- return 0;
+ int ret;
+
+ if (crl == NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
+
+ ret =
+ asn1_write_value(crl->crl, "tbsCertList.revokedCertificates",
+ "NEW", 1);
+ if (ret != ASN1_SUCCESS) {
+ gnutls_assert();
+ return _gnutls_asn2err(ret);
+ }
+
+ ret =
+ asn1_write_value(crl->crl,
+ "tbsCertList.revokedCertificates.?LAST.userCertificate",
+ serial, serial_size);
+ if (ret != ASN1_SUCCESS) {
+ gnutls_assert();
+ return _gnutls_asn2err(ret);
+ }
+
+ ret =
+ _gnutls_x509_set_time(crl->crl,
+ "tbsCertList.revokedCertificates.?LAST.revocationDate",
+ revocation_time);
+ if (ret < 0) {
+ gnutls_assert();
+ return ret;
+ }
+
+ ret =
+ asn1_write_value(crl->crl,
+ "tbsCertList.revokedCertificates.?LAST.crlEntryExtensions",
+ NULL, 0);
+ if (ret != ASN1_SUCCESS) {
+ gnutls_assert();
+ return _gnutls_asn2err(ret);
+ }
+
+ return 0;
}
/**
@@ -217,43 +231,45 @@ int gnutls_x509_crl_set_crt_serial(gnutls_x509_crl crl, const void* serial,
*
**/
int gnutls_x509_crl_set_crt(gnutls_x509_crl crl, gnutls_x509_crt crt,
- time_t revocation_time)
+ time_t revocation_time)
{
- int ret;
- opaque serial[128];
- size_t serial_size;
-
- if (crl==NULL || crt == NULL) {
- gnutls_assert();
- return GNUTLS_E_INVALID_REQUEST;
- }
-
- serial_size = sizeof(serial);
- ret = gnutls_x509_crt_get_serial(crt, serial, &serial_size);
- if (ret < 0) {
- gnutls_assert();
- return ret;
- }
-
- ret = gnutls_x509_crl_set_crt_serial( crl, serial, serial_size, revocation_time);
- if (ret < 0) {
- gnutls_assert();
- return _gnutls_asn2err(ret);
- }
-
- return 0;
+ int ret;
+ opaque serial[128];
+ size_t serial_size;
+
+ if (crl == NULL || crt == NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
+
+ serial_size = sizeof(serial);
+ ret = gnutls_x509_crt_get_serial(crt, serial, &serial_size);
+ if (ret < 0) {
+ gnutls_assert();
+ return ret;
+ }
+
+ ret =
+ gnutls_x509_crl_set_crt_serial(crl, serial, serial_size,
+ revocation_time);
+ if (ret < 0) {
+ gnutls_assert();
+ return _gnutls_asn2err(ret);
+ }
+
+ return 0;
}
/* If OPTIONAL fields have not been initialized then
* disable them.
*/
-static void disable_optional_stuff( gnutls_x509_crl crl)
+static void disable_optional_stuff(gnutls_x509_crl crl)
{
- asn1_write_value( crl->crl, "tbsCertList.crlExtensions", NULL, 0);
+ asn1_write_value(crl->crl, "tbsCertList.crlExtensions", NULL, 0);
- return;
+ return;
}
-#endif /* ENABLE_PKI */
+#endif /* ENABLE_PKI */