summaryrefslogtreecommitdiff
path: root/lib/x509/crq.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/x509/crq.c')
-rw-r--r--lib/x509/crq.c321
1 files changed, 145 insertions, 176 deletions
diff --git a/lib/x509/crq.c b/lib/x509/crq.c
index 162f16a638..b43214af69 100644
--- a/lib/x509/crq.c
+++ b/lib/x509/crq.c
@@ -157,7 +157,7 @@ gnutls_x509_crq_import(gnutls_x509_crq_t crq,
result = 0;
- cleanup:
+ cleanup:
if (need_free)
_gnutls_free_datum(&_data);
return result;
@@ -182,7 +182,7 @@ gnutls_x509_crq_import(gnutls_x509_crq_t crq,
int gnutls_x509_crq_get_signature_algorithm(gnutls_x509_crq_t crq)
{
return map_errs_to_zero(_gnutls_x509_get_signature_algorithm(crq->crq,
- "signatureAlgorithm"));
+ "signatureAlgorithm"));
}
/**
@@ -215,8 +215,7 @@ gnutls_x509_crq_get_private_key_usage_period(gnutls_x509_crq_t crq,
}
ret = gnutls_x509_crq_get_extension_by_oid(crq, "2.5.29.16", 0,
- buf, &buf_size,
- critical);
+ buf, &buf_size, critical);
if (ret < 0)
return gnutls_assert_val(ret);
@@ -243,13 +242,12 @@ gnutls_x509_crq_get_private_key_usage_period(gnutls_x509_crq_t crq,
ret = 0;
- cleanup:
+ cleanup:
asn1_delete_structure(&c2);
return ret;
}
-
/**
* gnutls_x509_crq_get_dn:
* @crq: should contain a #gnutls_x509_crq_t type
@@ -269,8 +267,7 @@ gnutls_x509_crq_get_private_key_usage_period(gnutls_x509_crq_t crq,
* long enough, and in that case the *@buf_size will be updated with
* the required size. On success 0 is returned.
**/
-int
-gnutls_x509_crq_get_dn(gnutls_x509_crq_t crq, char *buf, size_t * buf_size)
+int gnutls_x509_crq_get_dn(gnutls_x509_crq_t crq, char *buf, size_t *buf_size)
{
if (crq == NULL) {
gnutls_assert();
@@ -332,7 +329,8 @@ int gnutls_x509_crq_get_dn2(gnutls_x509_crq_t crq, gnutls_datum_t * dn)
*
* Since: 3.5.7
**/
-int gnutls_x509_crq_get_dn3(gnutls_x509_crq_t crq, gnutls_datum_t * dn, unsigned flags)
+int gnutls_x509_crq_get_dn3(gnutls_x509_crq_t crq, gnutls_datum_t * dn,
+ unsigned flags)
{
if (crq == NULL) {
gnutls_assert();
@@ -372,7 +370,7 @@ int gnutls_x509_crq_get_dn3(gnutls_x509_crq_t crq, gnutls_datum_t * dn, unsigned
int
gnutls_x509_crq_get_dn_by_oid(gnutls_x509_crq_t crq, const char *oid,
unsigned indx, unsigned int raw_flag,
- void *buf, size_t * buf_size)
+ void *buf, size_t *buf_size)
{
gnutls_datum_t td;
int ret;
@@ -408,7 +406,7 @@ gnutls_x509_crq_get_dn_by_oid(gnutls_x509_crq_t crq, const char *oid,
**/
int
gnutls_x509_crq_get_dn_oid(gnutls_x509_crq_t crq,
- unsigned indx, void *oid, size_t * sizeof_oid)
+ unsigned indx, void *oid, size_t *sizeof_oid)
{
if (crq == NULL) {
gnutls_assert();
@@ -435,7 +433,7 @@ gnutls_x509_crq_get_dn_oid(gnutls_x509_crq_t crq,
**/
int
gnutls_x509_crq_get_challenge_password(gnutls_x509_crq_t crq,
- char *pass, size_t * pass_size)
+ char *pass, size_t *pass_size)
{
gnutls_datum_t td;
int ret;
@@ -447,8 +445,8 @@ gnutls_x509_crq_get_challenge_password(gnutls_x509_crq_t crq,
ret =
_x509_parse_attribute(crq->crq,
- "certificationRequestInfo.attributes",
- "1.2.840.113549.1.9.7", 0, 0, &td);
+ "certificationRequestInfo.attributes",
+ "1.2.840.113549.1.9.7", 0, 0, &td);
if (ret < 0)
return gnutls_assert_val(ret);
@@ -488,8 +486,8 @@ gnutls_x509_crq_set_attribute_by_oid(gnutls_x509_crq_t crq,
}
return _x509_set_attribute(crq->crq,
- "certificationRequestInfo.attributes", oid,
- &data);
+ "certificationRequestInfo.attributes", oid,
+ &data);
}
/**
@@ -514,7 +512,7 @@ gnutls_x509_crq_set_attribute_by_oid(gnutls_x509_crq_t crq,
int
gnutls_x509_crq_get_attribute_by_oid(gnutls_x509_crq_t crq,
const char *oid, unsigned indx, void *buf,
- size_t * buf_size)
+ size_t *buf_size)
{
int ret;
gnutls_datum_t td;
@@ -526,8 +524,8 @@ gnutls_x509_crq_get_attribute_by_oid(gnutls_x509_crq_t crq,
ret =
_x509_parse_attribute(crq->crq,
- "certificationRequestInfo.attributes", oid,
- indx, 1, &td);
+ "certificationRequestInfo.attributes", oid,
+ indx, 1, &td);
if (ret < 0)
return gnutls_assert_val(ret);
@@ -580,8 +578,7 @@ gnutls_x509_crq_set_dn_by_oid(gnutls_x509_crq_t crq, const char *oid,
* Returns: On success, %GNUTLS_E_SUCCESS (0) is returned, otherwise a
* negative error value.
**/
-int
-gnutls_x509_crq_set_version(gnutls_x509_crq_t crq, unsigned int version)
+int gnutls_x509_crq_set_version(gnutls_x509_crq_t crq, unsigned int version)
{
int result;
unsigned char null = version;
@@ -636,7 +633,7 @@ int gnutls_x509_crq_get_version(gnutls_x509_crq_t crq)
return _gnutls_asn2err(result);
}
- return (int) version[0] + 1;
+ return (int)version[0] + 1;
}
/**
@@ -650,8 +647,7 @@ int gnutls_x509_crq_get_version(gnutls_x509_crq_t crq)
* Returns: On success, %GNUTLS_E_SUCCESS (0) is returned, otherwise a
* negative error value.
**/
-int
-gnutls_x509_crq_set_key(gnutls_x509_crq_t crq, gnutls_x509_privkey_t key)
+int gnutls_x509_crq_set_key(gnutls_x509_crq_t crq, gnutls_x509_privkey_t key)
{
int result;
@@ -661,9 +657,7 @@ gnutls_x509_crq_set_key(gnutls_x509_crq_t crq, gnutls_x509_privkey_t key)
}
result = _gnutls_x509_encode_and_copy_PKI_params
- (crq->crq,
- "certificationRequestInfo.subjectPKInfo",
- &key->params);
+ (crq->crq, "certificationRequestInfo.subjectPKInfo", &key->params);
if (result < 0) {
gnutls_assert();
@@ -729,7 +723,7 @@ gnutls_x509_crq_get_key_rsa_raw(gnutls_x509_crq_t crq,
ret = 0;
- cleanup:
+ cleanup:
gnutls_pk_params_release(&params);
return ret;
}
@@ -784,9 +778,7 @@ gnutls_x509_crq_set_key_rsa_raw(gnutls_x509_crq_t crq,
temp_params.algo = GNUTLS_PK_RSA;
result = _gnutls_x509_encode_and_copy_PKI_params
- (crq->crq,
- "certificationRequestInfo.subjectPKInfo",
- &temp_params);
+ (crq->crq, "certificationRequestInfo.subjectPKInfo", &temp_params);
if (result < 0) {
gnutls_assert();
@@ -796,7 +788,7 @@ gnutls_x509_crq_set_key_rsa_raw(gnutls_x509_crq_t crq,
ret = 0;
- error:
+ error:
gnutls_pk_params_release(&temp_params);
return ret;
}
@@ -813,8 +805,7 @@ gnutls_x509_crq_set_key_rsa_raw(gnutls_x509_crq_t crq,
* negative error value.
**/
int
-gnutls_x509_crq_set_challenge_password(gnutls_x509_crq_t crq,
- const char *pass)
+gnutls_x509_crq_set_challenge_password(gnutls_x509_crq_t crq, const char *pass)
{
int result;
char *password = NULL;
@@ -828,8 +819,7 @@ gnutls_x509_crq_set_challenge_password(gnutls_x509_crq_t crq,
*/
result =
asn1_write_value(crq->crq,
- "certificationRequestInfo.attributes", "NEW",
- 1);
+ "certificationRequestInfo.attributes", "NEW", 1);
if (result != ASN1_SUCCESS) {
gnutls_assert();
return _gnutls_asn2err(result);
@@ -837,11 +827,13 @@ gnutls_x509_crq_set_challenge_password(gnutls_x509_crq_t crq,
if (pass) {
gnutls_datum_t out;
- result = _gnutls_utf8_password_normalize(pass, strlen(pass), &out, 0);
+ result =
+ _gnutls_utf8_password_normalize(pass, strlen(pass), &out,
+ 0);
if (result < 0)
return gnutls_assert_val(result);
- password = (char*)out.data;
+ password = (char *)out.data;
}
assert(password != NULL);
@@ -922,7 +914,7 @@ gnutls_x509_crq_sign2(gnutls_x509_crq_t crq, gnutls_x509_privkey_t key,
result = 0;
- fail:
+ fail:
gnutls_privkey_deinit(privkey);
return result;
@@ -974,7 +966,7 @@ int gnutls_x509_crq_sign(gnutls_x509_crq_t crq, gnutls_x509_privkey_t key)
int
gnutls_x509_crq_export(gnutls_x509_crq_t crq,
gnutls_x509_crt_fmt_t format, void *output_data,
- size_t * output_data_size)
+ size_t *output_data_size)
{
if (crq == NULL) {
gnutls_assert();
@@ -1031,8 +1023,7 @@ gnutls_x509_crq_export2(gnutls_x509_crq_t crq,
* Returns: a member of the #gnutls_pk_algorithm_t enumeration on
* success, or a negative error code on error.
**/
-int
-gnutls_x509_crq_get_pk_algorithm(gnutls_x509_crq_t crq, unsigned int *bits)
+int gnutls_x509_crq_get_pk_algorithm(gnutls_x509_crq_t crq, unsigned int *bits)
{
int result;
@@ -1064,8 +1055,7 @@ gnutls_x509_crq_get_pk_algorithm(gnutls_x509_crq_t crq, unsigned int *bits)
**/
int
gnutls_x509_crq_get_spki(gnutls_x509_crq_t crq,
- gnutls_x509_spki_t spki,
- unsigned int flags)
+ gnutls_x509_spki_t spki, unsigned int flags)
{
int result;
gnutls_x509_spki_st params;
@@ -1109,23 +1099,26 @@ gnutls_x509_crq_get_spki(gnutls_x509_crq_t crq,
*
* Since: 3.5.0
**/
-int gnutls_x509_crq_get_signature_oid(gnutls_x509_crq_t crq, char *oid, size_t *oid_size)
+int gnutls_x509_crq_get_signature_oid(gnutls_x509_crq_t crq, char *oid,
+ size_t *oid_size)
{
char str[MAX_OID_SIZE];
int len, result, ret;
gnutls_datum_t out;
len = sizeof(str);
- result = asn1_read_value(crq->crq, "signatureAlgorithm.algorithm", str, &len);
+ result =
+ asn1_read_value(crq->crq, "signatureAlgorithm.algorithm", str,
+ &len);
if (result != ASN1_SUCCESS) {
gnutls_assert();
return _gnutls_asn2err(result);
}
- out.data = (void*)str;
+ out.data = (void *)str;
out.size = len;
- ret = _gnutls_copy_string(&out, (void*)oid, oid_size);
+ ret = _gnutls_copy_string(&out, (void *)oid, oid_size);
if (ret < 0) {
gnutls_assert();
return ret;
@@ -1149,23 +1142,27 @@ int gnutls_x509_crq_get_signature_oid(gnutls_x509_crq_t crq, char *oid, size_t *
*
* Since: 3.5.0
**/
-int gnutls_x509_crq_get_pk_oid(gnutls_x509_crq_t crq, char *oid, size_t *oid_size)
+int gnutls_x509_crq_get_pk_oid(gnutls_x509_crq_t crq, char *oid,
+ size_t *oid_size)
{
char str[MAX_OID_SIZE];
int len, result, ret;
gnutls_datum_t out;
len = sizeof(str);
- result = asn1_read_value(crq->crq, "certificationRequestInfo.subjectPKInfo.algorithm.algorithm", str, &len);
+ result =
+ asn1_read_value(crq->crq,
+ "certificationRequestInfo.subjectPKInfo.algorithm.algorithm",
+ str, &len);
if (result != ASN1_SUCCESS) {
gnutls_assert();
return _gnutls_asn2err(result);
}
- out.data = (void*)str;
+ out.data = (void *)str;
out.size = len;
- ret = _gnutls_copy_string(&out, (void*)oid, oid_size);
+ ret = _gnutls_copy_string(&out, (void *)oid, oid_size);
if (ret < 0) {
gnutls_assert();
return ret;
@@ -1200,7 +1197,7 @@ int gnutls_x509_crq_get_pk_oid(gnutls_x509_crq_t crq, char *oid, size_t *oid_siz
**/
int
gnutls_x509_crq_get_attribute_info(gnutls_x509_crq_t crq, unsigned indx,
- void *oid, size_t * sizeof_oid)
+ void *oid, size_t *sizeof_oid)
{
int result;
char name[MAX_NAME_SIZE];
@@ -1254,7 +1251,7 @@ gnutls_x509_crq_get_attribute_info(gnutls_x509_crq_t crq, unsigned indx,
**/
int
gnutls_x509_crq_get_attribute_data(gnutls_x509_crq_t crq, unsigned indx,
- void *data, size_t * sizeof_data)
+ void *data, size_t *sizeof_data)
{
int result, len;
char name[MAX_NAME_SIZE];
@@ -1265,8 +1262,7 @@ gnutls_x509_crq_get_attribute_data(gnutls_x509_crq_t crq, unsigned indx,
}
snprintf(name, sizeof(name),
- "certificationRequestInfo.attributes.?%u.values.?1",
- indx + 1);
+ "certificationRequestInfo.attributes.?%u.values.?1", indx + 1);
len = *sizeof_data;
result = asn1_read_value(crq->crq, name, data, &len);
@@ -1309,7 +1305,7 @@ gnutls_x509_crq_get_attribute_data(gnutls_x509_crq_t crq, unsigned indx,
**/
int
gnutls_x509_crq_get_extension_info(gnutls_x509_crq_t crq, unsigned indx,
- void *oid, size_t * sizeof_oid,
+ void *oid, size_t *sizeof_oid,
unsigned int *critical)
{
int result;
@@ -1329,8 +1325,7 @@ gnutls_x509_crq_get_extension_info(gnutls_x509_crq_t crq, unsigned indx,
result =
gnutls_x509_crq_get_attribute_by_oid(crq,
"1.2.840.113549.1.9.14",
- 0, NULL,
- &extensions_size);
+ 0, NULL, &extensions_size);
if (result == GNUTLS_E_SHORT_MEMORY_BUFFER) {
extensions = gnutls_malloc(extensions_size);
if (extensions == NULL) {
@@ -1350,15 +1345,15 @@ gnutls_x509_crq_get_extension_info(gnutls_x509_crq_t crq, unsigned indx,
}
result =
- asn1_create_element(_gnutls_get_pkix(), "PKIX1.Extensions",
- &c2);
+ asn1_create_element(_gnutls_get_pkix(), "PKIX1.Extensions", &c2);
if (result != ASN1_SUCCESS) {
gnutls_assert();
result = _gnutls_asn2err(result);
goto out;
}
- result = _asn1_strict_der_decode(&c2, extensions, extensions_size, NULL);
+ result =
+ _asn1_strict_der_decode(&c2, extensions, extensions_size, NULL);
if (result != ASN1_SUCCESS) {
gnutls_assert();
asn1_delete_structure(&c2);
@@ -1404,7 +1399,7 @@ gnutls_x509_crq_get_extension_info(gnutls_x509_crq_t crq, unsigned indx,
result = 0;
- out:
+ out:
gnutls_free(extensions);
return result;
}
@@ -1434,7 +1429,7 @@ gnutls_x509_crq_get_extension_info(gnutls_x509_crq_t crq, unsigned indx,
**/
int
gnutls_x509_crq_get_extension_data(gnutls_x509_crq_t crq, unsigned indx,
- void *data, size_t * sizeof_data)
+ void *data, size_t *sizeof_data)
{
int ret;
gnutls_datum_t raw;
@@ -1472,7 +1467,7 @@ gnutls_x509_crq_get_extension_data(gnutls_x509_crq_t crq, unsigned indx,
**/
int
gnutls_x509_crq_get_extension_data2(gnutls_x509_crq_t crq,
- unsigned indx, gnutls_datum_t * data)
+ unsigned indx, gnutls_datum_t * data)
{
int ret, result;
char name[MAX_NAME_SIZE];
@@ -1489,8 +1484,7 @@ gnutls_x509_crq_get_extension_data2(gnutls_x509_crq_t crq,
ret =
gnutls_x509_crq_get_attribute_by_oid(crq,
"1.2.840.113549.1.9.14",
- 0, NULL,
- &extensions_size);
+ 0, NULL, &extensions_size);
if (ret != GNUTLS_E_SHORT_MEMORY_BUFFER) {
gnutls_assert();
if (ret == 0)
@@ -1515,15 +1509,15 @@ gnutls_x509_crq_get_extension_data2(gnutls_x509_crq_t crq,
}
result =
- asn1_create_element(_gnutls_get_pkix(), "PKIX1.Extensions",
- &c2);
+ asn1_create_element(_gnutls_get_pkix(), "PKIX1.Extensions", &c2);
if (result != ASN1_SUCCESS) {
gnutls_assert();
ret = _gnutls_asn2err(result);
goto cleanup;
}
- result = _asn1_strict_der_decode(&c2, extensions, extensions_size, NULL);
+ result =
+ _asn1_strict_der_decode(&c2, extensions, extensions_size, NULL);
if (result != ASN1_SUCCESS) {
gnutls_assert();
ret = _gnutls_asn2err(result);
@@ -1571,8 +1565,7 @@ gnutls_x509_crq_get_extension_data2(gnutls_x509_crq_t crq,
**/
int
gnutls_x509_crq_get_key_usage(gnutls_x509_crq_t crq,
- unsigned int *key_usage,
- unsigned int *critical)
+ unsigned int *key_usage, unsigned int *critical)
{
int result;
uint8_t buf[128];
@@ -1585,8 +1578,7 @@ gnutls_x509_crq_get_key_usage(gnutls_x509_crq_t crq,
}
result = gnutls_x509_crq_get_extension_by_oid(crq, "2.5.29.15", 0,
- buf, &buf_size,
- critical);
+ buf, &buf_size, critical);
if (result < 0) {
gnutls_assert();
return result;
@@ -1642,8 +1634,7 @@ gnutls_x509_crq_get_basic_constraints(gnutls_x509_crq_t crq,
}
result = gnutls_x509_crq_get_extension_by_oid(crq, "2.5.29.19", 0,
- buf, &buf_size,
- critical);
+ buf, &buf_size, critical);
if (result < 0) {
gnutls_assert();
return result;
@@ -1651,7 +1642,8 @@ gnutls_x509_crq_get_basic_constraints(gnutls_x509_crq_t crq,
bd.data = buf;
bd.size = buf_size;
- result = gnutls_x509_ext_import_basic_constraints(&bd, &tmp_ca, pathlen);
+ result =
+ gnutls_x509_ext_import_basic_constraints(&bd, &tmp_ca, pathlen);
if (ca)
*ca = tmp_ca;
@@ -1666,7 +1658,7 @@ gnutls_x509_crq_get_basic_constraints(gnutls_x509_crq_t crq,
static int
get_subject_alt_name(gnutls_x509_crq_t crq,
unsigned int seq, void *ret,
- size_t * ret_size, unsigned int *ret_type,
+ size_t *ret_size, unsigned int *ret_type,
unsigned int *critical, int othername_oid)
{
int result;
@@ -1770,7 +1762,7 @@ get_subject_alt_name(gnutls_x509_crq_t crq,
int
gnutls_x509_crq_get_subject_alt_name(gnutls_x509_crq_t crq,
unsigned int seq, void *ret,
- size_t * ret_size,
+ size_t *ret_size,
unsigned int *ret_type,
unsigned int *critical)
{
@@ -1809,10 +1801,9 @@ gnutls_x509_crq_get_subject_alt_name(gnutls_x509_crq_t crq,
int
gnutls_x509_crq_get_subject_alt_othername_oid(gnutls_x509_crq_t crq,
unsigned int seq,
- void *ret, size_t * ret_size)
+ void *ret, size_t *ret_size)
{
- return get_subject_alt_name(crq, seq, ret, ret_size, NULL, NULL,
- 1);
+ return get_subject_alt_name(crq, seq, ret, ret_size, NULL, NULL, 1);
}
/**
@@ -1839,7 +1830,7 @@ gnutls_x509_crq_get_subject_alt_othername_oid(gnutls_x509_crq_t crq,
int
gnutls_x509_crq_get_extension_by_oid(gnutls_x509_crq_t crq,
const char *oid, unsigned indx,
- void *buf, size_t * buf_size,
+ void *buf, size_t *buf_size,
unsigned int *critical)
{
int result;
@@ -1851,8 +1842,7 @@ gnutls_x509_crq_get_extension_by_oid(gnutls_x509_crq_t crq,
oid_size = sizeof(_oid);
result =
gnutls_x509_crq_get_extension_info(crq, i, _oid,
- &oid_size,
- critical);
+ &oid_size, critical);
if (result < 0) {
gnutls_assert();
return result;
@@ -1870,7 +1860,6 @@ gnutls_x509_crq_get_extension_by_oid(gnutls_x509_crq_t crq,
}
}
-
return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
}
@@ -1897,9 +1886,9 @@ gnutls_x509_crq_get_extension_by_oid(gnutls_x509_crq_t crq,
**/
int
gnutls_x509_crq_get_extension_by_oid2(gnutls_x509_crq_t crq,
- const char *oid, unsigned indx,
- gnutls_datum_t *output,
- unsigned int *critical)
+ const char *oid, unsigned indx,
+ gnutls_datum_t * output,
+ unsigned int *critical)
{
int result;
unsigned int i;
@@ -1910,8 +1899,7 @@ gnutls_x509_crq_get_extension_by_oid2(gnutls_x509_crq_t crq,
oid_size = sizeof(_oid);
result =
gnutls_x509_crq_get_extension_info(crq, i, _oid,
- &oid_size,
- critical);
+ &oid_size, critical);
if (result < 0) {
gnutls_assert();
return result;
@@ -1921,8 +1909,8 @@ gnutls_x509_crq_get_extension_by_oid2(gnutls_x509_crq_t crq,
if (indx == 0)
return
gnutls_x509_crq_get_extension_data2(crq,
- i,
- output);
+ i,
+ output);
else
indx--;
}
@@ -1966,8 +1954,7 @@ int
gnutls_x509_crq_set_subject_alt_name(gnutls_x509_crq_t crq,
gnutls_x509_subject_alt_name_t nt,
const void *data,
- unsigned int data_size,
- unsigned int flags)
+ unsigned int data_size, unsigned int flags)
{
int result = 0;
gnutls_datum_t der_data = { NULL, 0 };
@@ -1996,8 +1983,7 @@ gnutls_x509_crq_set_subject_alt_name(gnutls_x509_crq_t crq,
break;
case GNUTLS_E_SUCCESS:
- prev_der_data.data =
- gnutls_malloc(prev_der_data.size);
+ prev_der_data.data = gnutls_malloc(prev_der_data.size);
if (prev_der_data.data == NULL) {
gnutls_assert();
return GNUTLS_E_MEMORY_ERROR;
@@ -2026,9 +2012,9 @@ gnutls_x509_crq_set_subject_alt_name(gnutls_x509_crq_t crq,
/* generate the extension.
*/
- result = _gnutls_x509_ext_gen_subject_alt_name(nt, NULL, data, data_size,
- &prev_der_data,
- &der_data);
+ result =
+ _gnutls_x509_ext_gen_subject_alt_name(nt, NULL, data, data_size,
+ &prev_der_data, &der_data);
gnutls_free(prev_der_data.data);
if (result < 0) {
gnutls_assert();
@@ -2048,7 +2034,7 @@ gnutls_x509_crq_set_subject_alt_name(gnutls_x509_crq_t crq,
return 0;
- finish:
+ finish:
return result;
}
@@ -2073,10 +2059,10 @@ gnutls_x509_crq_set_subject_alt_name(gnutls_x509_crq_t crq,
**/
int
gnutls_x509_crq_set_subject_alt_othername(gnutls_x509_crq_t crq,
- const char *oid,
- const void *data,
- unsigned int data_size,
- unsigned int flags)
+ const char *oid,
+ const void *data,
+ unsigned int data_size,
+ unsigned int flags)
{
int result = 0;
gnutls_datum_t der_data = { NULL, 0 };
@@ -2106,8 +2092,7 @@ gnutls_x509_crq_set_subject_alt_othername(gnutls_x509_crq_t crq,
break;
case GNUTLS_E_SUCCESS:
- prev_der_data.data =
- gnutls_malloc(prev_der_data.size);
+ prev_der_data.data = gnutls_malloc(prev_der_data.size);
if (prev_der_data.data == NULL) {
gnutls_assert();
return GNUTLS_E_MEMORY_ERROR;
@@ -2133,7 +2118,9 @@ gnutls_x509_crq_set_subject_alt_othername(gnutls_x509_crq_t crq,
}
}
- result = _gnutls_encode_othername_data(flags, data, data_size, &encoded_data);
+ result =
+ _gnutls_encode_othername_data(flags, data, data_size,
+ &encoded_data);
if (result < 0) {
gnutls_assert();
goto finish;
@@ -2141,10 +2128,11 @@ gnutls_x509_crq_set_subject_alt_othername(gnutls_x509_crq_t crq,
/* generate the extension.
*/
- result = _gnutls_x509_ext_gen_subject_alt_name(GNUTLS_SAN_OTHERNAME, oid,
- encoded_data.data, encoded_data.size,
- &prev_der_data,
- &der_data);
+ result =
+ _gnutls_x509_ext_gen_subject_alt_name(GNUTLS_SAN_OTHERNAME, oid,
+ encoded_data.data,
+ encoded_data.size,
+ &prev_der_data, &der_data);
if (result < 0) {
gnutls_assert();
goto finish;
@@ -2161,7 +2149,7 @@ gnutls_x509_crq_set_subject_alt_othername(gnutls_x509_crq_t crq,
result = 0;
- finish:
+ finish:
_gnutls_free_datum(&prev_der_data);
_gnutls_free_datum(&der_data);
_gnutls_free_datum(&encoded_data);
@@ -2185,8 +2173,7 @@ gnutls_x509_crq_set_subject_alt_othername(gnutls_x509_crq_t crq,
**/
int
gnutls_x509_crq_set_basic_constraints(gnutls_x509_crq_t crq,
- unsigned int ca,
- int pathLenConstraint)
+ unsigned int ca, int pathLenConstraint)
{
int result;
gnutls_datum_t der_data;
@@ -2198,14 +2185,15 @@ gnutls_x509_crq_set_basic_constraints(gnutls_x509_crq_t crq,
/* generate the extension.
*/
- result = gnutls_x509_ext_export_basic_constraints(ca, pathLenConstraint, &der_data);
+ result =
+ gnutls_x509_ext_export_basic_constraints(ca, pathLenConstraint,
+ &der_data);
if (result < 0) {
gnutls_assert();
return result;
}
- result =
- _gnutls_x509_crq_set_extension(crq, "2.5.29.19", &der_data, 1);
+ result = _gnutls_x509_crq_set_extension(crq, "2.5.29.19", &der_data, 1);
_gnutls_free_datum(&der_data);
@@ -2229,8 +2217,7 @@ gnutls_x509_crq_set_basic_constraints(gnutls_x509_crq_t crq,
*
* Since: 2.8.0
**/
-int
-gnutls_x509_crq_set_key_usage(gnutls_x509_crq_t crq, unsigned int usage)
+int gnutls_x509_crq_set_key_usage(gnutls_x509_crq_t crq, unsigned int usage)
{
int result;
gnutls_datum_t der_data;
@@ -2242,15 +2229,13 @@ gnutls_x509_crq_set_key_usage(gnutls_x509_crq_t crq, unsigned int usage)
/* generate the extension.
*/
- result =
- gnutls_x509_ext_export_key_usage(usage, &der_data);
+ result = gnutls_x509_ext_export_key_usage(usage, &der_data);
if (result < 0) {
gnutls_assert();
return result;
}
- result =
- _gnutls_x509_crq_set_extension(crq, "2.5.29.15", &der_data, 1);
+ result = _gnutls_x509_crq_set_extension(crq, "2.5.29.15", &der_data, 1);
_gnutls_free_datum(&der_data);
@@ -2284,8 +2269,7 @@ gnutls_x509_crq_set_key_usage(gnutls_x509_crq_t crq, unsigned int usage)
int
gnutls_x509_crq_get_key_purpose_oid(gnutls_x509_crq_t crq,
unsigned indx, void *oid,
- size_t * sizeof_oid,
- unsigned int *critical)
+ size_t *sizeof_oid, unsigned int *critical)
{
char tmpstr[MAX_NAME_SIZE];
int result, len;
@@ -2318,8 +2302,7 @@ gnutls_x509_crq_get_key_purpose_oid(gnutls_x509_crq_t crq,
result = gnutls_x509_crq_get_extension_by_oid(crq, "2.5.29.37", 0,
prev.data,
- &prev_size,
- critical);
+ &prev_size, critical);
if (result < 0) {
gnutls_assert();
gnutls_free(prev.data);
@@ -2353,8 +2336,7 @@ gnutls_x509_crq_get_key_purpose_oid(gnutls_x509_crq_t crq,
*sizeof_oid = len;
asn1_delete_structure(&c2);
- if (result == ASN1_VALUE_NOT_FOUND
- || result == ASN1_ELEMENT_NOT_FOUND) {
+ if (result == ASN1_VALUE_NOT_FOUND || result == ASN1_ELEMENT_NOT_FOUND) {
return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
}
@@ -2415,8 +2397,7 @@ gnutls_x509_crq_set_key_purpose_oid(gnutls_x509_crq_t crq,
result =
gnutls_x509_crq_get_extension_by_oid(crq, "2.5.29.37",
0, prev.data,
- &prev_size,
- &critical);
+ &prev_size, &critical);
if (result < 0) {
gnutls_assert();
gnutls_free(prev.data);
@@ -2513,8 +2494,7 @@ gnutls_x509_crq_set_key_purpose_oid(gnutls_x509_crq_t crq,
**/
int
gnutls_x509_crq_get_key_id(gnutls_x509_crq_t crq, unsigned int flags,
- unsigned char *output_data,
- size_t * output_data_size)
+ unsigned char *output_data, size_t *output_data_size)
{
int ret = 0;
gnutls_pk_params_st params;
@@ -2530,8 +2510,7 @@ gnutls_x509_crq_get_key_id(gnutls_x509_crq_t crq, unsigned int flags,
return ret;
}
- ret =
- _gnutls_get_key_id(&params, output_data, output_data_size, flags);
+ ret = _gnutls_get_key_id(&params, output_data, output_data_size, flags);
gnutls_pk_params_release(&params);
@@ -2569,8 +2548,7 @@ gnutls_x509_crq_get_key_id(gnutls_x509_crq_t crq, unsigned int flags,
**/
int
gnutls_x509_crq_privkey_sign(gnutls_x509_crq_t crq, gnutls_privkey_t key,
- gnutls_digest_algorithm_t dig,
- unsigned int flags)
+ gnutls_digest_algorithm_t dig, unsigned int flags)
{
int result;
gnutls_datum_t signature;
@@ -2585,8 +2563,7 @@ gnutls_x509_crq_privkey_sign(gnutls_x509_crq_t crq, gnutls_privkey_t key,
}
/* Make sure version field is set. */
- if (gnutls_x509_crq_get_version(crq) ==
- GNUTLS_E_ASN1_VALUE_NOT_FOUND) {
+ if (gnutls_x509_crq_get_version(crq) == GNUTLS_E_ASN1_VALUE_NOT_FOUND) {
result = gnutls_x509_crq_set_version(crq, 1);
if (result < 0) {
gnutls_assert();
@@ -2608,7 +2585,9 @@ gnutls_x509_crq_privkey_sign(gnutls_x509_crq_t crq, gnutls_privkey_t key,
gnutls_pubkey_deinit(pubkey);
return gnutls_assert_val(ret);
}
- ret = gnutls_pubkey_get_preferred_hash_algorithm(pubkey, &dig, NULL);
+ ret =
+ gnutls_pubkey_get_preferred_hash_algorithm(pubkey, &dig,
+ NULL);
gnutls_pubkey_deinit(pubkey);
if (ret < 0)
@@ -2631,8 +2610,7 @@ gnutls_x509_crq_privkey_sign(gnutls_x509_crq_t crq, gnutls_privkey_t key,
/* Step 1. Self sign the request.
*/
result =
- _gnutls_x509_get_tbs(crq->crq, "certificationRequestInfo",
- &tbs);
+ _gnutls_x509_get_tbs(crq->crq, "certificationRequestInfo", &tbs);
if (result < 0) {
gnutls_assert();
@@ -2645,8 +2623,7 @@ gnutls_x509_crq_privkey_sign(gnutls_x509_crq_t crq, gnutls_privkey_t key,
FIX_SIGN_PARAMS(params, flags, dig);
- result = privkey_sign_and_hash_data(key, se,
- &tbs, &signature, &params);
+ result = privkey_sign_and_hash_data(key, se, &tbs, &signature, &params);
gnutls_free(tbs.data);
if (result < 0) {
@@ -2680,7 +2657,6 @@ gnutls_x509_crq_privkey_sign(gnutls_x509_crq_t crq, gnutls_privkey_t key,
return 0;
}
-
/**
* gnutls_x509_crq_verify:
* @crq: is the crq to be verified
@@ -2707,8 +2683,7 @@ int gnutls_x509_crq_verify(gnutls_x509_crq_t crq, unsigned int flags)
ret =
_gnutls_x509_get_signed_data(crq->crq, NULL,
- "certificationRequestInfo",
- &data);
+ "certificationRequestInfo", &data);
if (ret < 0) {
gnutls_assert();
return ret;
@@ -2729,8 +2704,7 @@ int gnutls_x509_crq_verify(gnutls_x509_crq_t crq, unsigned int flags)
goto cleanup;
}
- ret =
- _gnutls_x509_get_signature(crq->crq, "signature", &signature);
+ ret = _gnutls_x509_get_signature(crq->crq, "signature", &signature);
if (ret < 0) {
gnutls_assert();
goto cleanup;
@@ -2743,8 +2717,7 @@ int gnutls_x509_crq_verify(gnutls_x509_crq_t crq, unsigned int flags)
}
ret = _gnutls_x509_read_sign_params(crq->crq,
- "signatureAlgorithm",
- &sign_params);
+ "signatureAlgorithm", &sign_params);
if (ret < 0) {
gnutls_assert();
goto cleanup;
@@ -2760,7 +2733,7 @@ int gnutls_x509_crq_verify(gnutls_x509_crq_t crq, unsigned int flags)
ret = 0;
- cleanup:
+ cleanup:
_gnutls_free_datum(&data);
_gnutls_free_datum(&signature);
gnutls_pk_params_release(&params);
@@ -2819,12 +2792,11 @@ gnutls_x509_crq_set_private_key_usage_period(gnutls_x509_crq_t crq,
goto cleanup;
}
- result = _gnutls_x509_crq_set_extension(crq, "2.5.29.16",
- &der_data, 0);
+ result = _gnutls_x509_crq_set_extension(crq, "2.5.29.16", &der_data, 0);
_gnutls_free_datum(&der_data);
- cleanup:
+ cleanup:
asn1_delete_structure(&c2);
return result;
@@ -2857,11 +2829,10 @@ gnutls_x509_crq_set_private_key_usage_period(gnutls_x509_crq_t crq,
**/
int gnutls_x509_crq_get_tlsfeatures(gnutls_x509_crq_t crq,
gnutls_x509_tlsfeatures_t features,
- unsigned int flags,
- unsigned int *critical)
+ unsigned int flags, unsigned int *critical)
{
int ret;
- gnutls_datum_t der = {NULL, 0};
+ gnutls_datum_t der = { NULL, 0 };
if (crq == NULL) {
gnutls_assert();
@@ -2869,9 +2840,9 @@ int gnutls_x509_crq_get_tlsfeatures(gnutls_x509_crq_t crq,
}
if ((ret =
- gnutls_x509_crq_get_extension_by_oid2(crq, GNUTLS_X509EXT_OID_TLSFEATURES, 0,
- &der, critical)) < 0)
- {
+ gnutls_x509_crq_get_extension_by_oid2(crq,
+ GNUTLS_X509EXT_OID_TLSFEATURES,
+ 0, &der, critical)) < 0) {
return ret;
}
@@ -2924,7 +2895,9 @@ int gnutls_x509_crq_set_tlsfeatures(gnutls_x509_crq_t crq,
return ret;
}
- ret = _gnutls_x509_crq_set_extension(crq, GNUTLS_X509EXT_OID_TLSFEATURES, &der, 0);
+ ret =
+ _gnutls_x509_crq_set_extension(crq, GNUTLS_X509EXT_OID_TLSFEATURES,
+ &der, 0);
_gnutls_free_datum(&der);
@@ -2953,13 +2926,12 @@ int gnutls_x509_crq_set_tlsfeatures(gnutls_x509_crq_t crq,
int
gnutls_x509_crq_set_extension_by_oid(gnutls_x509_crq_t crq,
const char *oid, const void *buf,
- size_t sizeof_buf,
- unsigned int critical)
+ size_t sizeof_buf, unsigned int critical)
{
int result;
gnutls_datum_t der_data;
- der_data.data = (void *) buf;
+ der_data.data = (void *)buf;
der_data.size = sizeof_buf;
if (crq == NULL) {
@@ -2967,8 +2939,7 @@ gnutls_x509_crq_set_extension_by_oid(gnutls_x509_crq_t crq,
return GNUTLS_E_INVALID_REQUEST;
}
- result =
- _gnutls_x509_crq_set_extension(crq, oid, &der_data, critical);
+ result = _gnutls_x509_crq_set_extension(crq, oid, &der_data, critical);
if (result < 0) {
gnutls_assert();
return result;
@@ -2999,8 +2970,7 @@ gnutls_x509_crq_set_extension_by_oid(gnutls_x509_crq_t crq,
**/
int
gnutls_x509_crq_set_spki(gnutls_x509_crq_t crq,
- const gnutls_x509_spki_t spki,
- unsigned int flags)
+ const gnutls_x509_spki_t spki, unsigned int flags)
{
int ret;
gnutls_pk_algorithm_t crq_pk;
@@ -3023,8 +2993,8 @@ gnutls_x509_crq_set_spki(gnutls_x509_crq_t crq,
crq_pk = params.algo;
if (!_gnutls_pk_are_compat(crq_pk, spki->pk)) {
- ret = gnutls_assert_val(GNUTLS_E_INVALID_REQUEST);
- goto cleanup;
+ ret = gnutls_assert_val(GNUTLS_E_INVALID_REQUEST);
+ goto cleanup;
}
if (spki->pk != GNUTLS_PK_RSA_PSS) {
@@ -3084,10 +3054,9 @@ gnutls_x509_crq_set_spki(gnutls_x509_crq_t crq,
}
ret = _gnutls_x509_write_spki_params(crq->crq,
- "certificationRequestInfo."
- "subjectPKInfo."
- "algorithm",
- &tpki);
+ "certificationRequestInfo."
+ "subjectPKInfo."
+ "algorithm", &tpki);
if (ret < 0) {
gnutls_assert();
goto cleanup;