summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSimon Josefsson <simon@josefsson.org>2008-10-08 17:09:58 +0200
committerSimon Josefsson <simon@josefsson.org>2008-10-08 17:09:58 +0200
commit0d91e8fb205e94169687f44bb338d3812dae372a (patch)
tree59ed59f6c55a35eec707ebd77d0e0fab7264ee17 /lib
parentce23654ab3b8097241c1639ebe3e853c4f67b6d7 (diff)
downloadgnutls-0d91e8fb205e94169687f44bb338d3812dae372a.tar.gz
Indent.
Diffstat (limited to 'lib')
-rw-r--r--lib/auth_cert.c4
-rw-r--r--lib/gnutls_constate.c21
-rw-r--r--lib/gnutls_mpi.c26
-rw-r--r--lib/gnutls_pk.c10
-rw-r--r--lib/opencdk/armor.c78
-rw-r--r--lib/opencdk/hash.c14
-rw-r--r--lib/opencdk/kbnode.c26
-rw-r--r--lib/opencdk/keydb.c268
-rw-r--r--lib/opencdk/pubkey.c2
-rw-r--r--lib/opencdk/stream.c130
-rw-r--r--lib/openpgp/privkey.c8
-rw-r--r--lib/x509/common.c10
-rw-r--r--lib/x509/crl.c7
-rw-r--r--lib/x509/crl_write.c4
-rw-r--r--lib/x509/crq.c163
-rw-r--r--lib/x509/extensions.c141
-rw-r--r--lib/x509/mpi.c22
-rw-r--r--lib/x509/output.c791
-rw-r--r--lib/x509/privkey.c4
-rw-r--r--lib/x509/x509.c9
-rw-r--r--lib/x509/x509_write.c74
21 files changed, 940 insertions, 872 deletions
diff --git a/lib/auth_cert.c b/lib/auth_cert.c
index a1000f1fa5..7c42f43853 100644
--- a/lib/auth_cert.c
+++ b/lib/auth_cert.c
@@ -74,8 +74,8 @@ _gnutls_copy_certificate_auth_info (cert_auth_info_t info,
if (info->raw_certificate_list != NULL)
{
for (j = 0; j < info->ncerts; j++)
- _gnutls_free_datum (&info->raw_certificate_list[j]);
- gnutls_free( info->raw_certificate_list);
+ _gnutls_free_datum (&info->raw_certificate_list[j]);
+ gnutls_free (info->raw_certificate_list);
}
if (ncerts == 0)
diff --git a/lib/gnutls_constate.c b/lib/gnutls_constate.c
index bd24b45c12..fc9757e8c0 100644
--- a/lib/gnutls_constate.c
+++ b/lib/gnutls_constate.c
@@ -66,7 +66,8 @@ _gnutls_set_keys (gnutls_session_t session, int hash_size, int IV_size,
int block_size;
char buf[65];
/* avoid using malloc */
- opaque key_block[2 * MAX_HASH_SIZE + 2 * MAX_CIPHER_KEY_SIZE + 2 * MAX_CIPHER_BLOCK_SIZE];
+ opaque key_block[2 * MAX_HASH_SIZE + 2 * MAX_CIPHER_KEY_SIZE +
+ 2 * MAX_CIPHER_BLOCK_SIZE];
if (session->cipher_specs.generated_keys != 0)
{
@@ -126,12 +127,12 @@ _gnutls_set_keys (gnutls_session_t session, int hash_size, int IV_size,
pos = 0;
if (hash_size > 0)
{
-
+
if (_gnutls_sset_datum
(&session->cipher_specs.client_write_mac_secret,
&key_block[pos], hash_size) < 0)
{
- gnutls_assert();
+ gnutls_assert ();
return GNUTLS_E_MEMORY_ERROR;
}
pos += hash_size;
@@ -140,7 +141,7 @@ _gnutls_set_keys (gnutls_session_t session, int hash_size, int IV_size,
(&session->cipher_specs.server_write_mac_secret,
&key_block[pos], hash_size) < 0)
{
- gnutls_assert();
+ gnutls_assert ();
return GNUTLS_E_MEMORY_ERROR;
}
pos += hash_size;
@@ -233,7 +234,7 @@ _gnutls_set_keys (gnutls_session_t session, int hash_size, int IV_size,
(&session->cipher_specs.client_write_key,
client_write_key, client_write_key_size) < 0)
{
- gnutls_assert();
+ gnutls_assert ();
return GNUTLS_E_MEMORY_ERROR;
}
_gnutls_hard_log ("INT: CLIENT WRITE KEY [%d]: %s\n",
@@ -246,7 +247,7 @@ _gnutls_set_keys (gnutls_session_t session, int hash_size, int IV_size,
(&session->cipher_specs.server_write_key,
server_write_key, server_write_key_size) < 0)
{
- gnutls_assert();
+ gnutls_assert ();
return GNUTLS_E_MEMORY_ERROR;
}
@@ -267,7 +268,7 @@ _gnutls_set_keys (gnutls_session_t session, int hash_size, int IV_size,
(&session->cipher_specs.client_write_IV, &key_block[pos],
IV_size) < 0)
{
- gnutls_assert();
+ gnutls_assert ();
return GNUTLS_E_MEMORY_ERROR;
}
pos += IV_size;
@@ -276,7 +277,7 @@ _gnutls_set_keys (gnutls_session_t session, int hash_size, int IV_size,
(&session->cipher_specs.server_write_IV, &key_block[pos],
IV_size) < 0)
{
- gnutls_assert();
+ gnutls_assert ();
return GNUTLS_E_MEMORY_ERROR;
}
pos += IV_size;
@@ -319,7 +320,7 @@ _gnutls_set_keys (gnutls_session_t session, int hash_size, int IV_size,
if (_gnutls_sset_datum
(&session->cipher_specs.client_write_IV, iv_block, IV_size) < 0)
{
- gnutls_assert();
+ gnutls_assert ();
return GNUTLS_E_MEMORY_ERROR;
}
@@ -327,7 +328,7 @@ _gnutls_set_keys (gnutls_session_t session, int hash_size, int IV_size,
(&session->cipher_specs.server_write_IV,
&iv_block[IV_size], IV_size) < 0)
{
- gnutls_assert();
+ gnutls_assert ();
return GNUTLS_E_MEMORY_ERROR;
}
}
diff --git a/lib/gnutls_mpi.c b/lib/gnutls_mpi.c
index ad93ce642c..26d820e802 100644
--- a/lib/gnutls_mpi.c
+++ b/lib/gnutls_mpi.c
@@ -49,22 +49,22 @@ _gnutls_mpi_randomize (bigint_t r, unsigned int bits,
opaque *buf;
int buf_release;
- if ( size < sizeof(tmpbuf))
+ if (size < sizeof (tmpbuf))
{
buf = tmpbuf;
buf_release = 0;
- }
- else
+ }
+ else
{
- buf = gnutls_malloc(size);
- if (buf == NULL)
- {
- gnutls_assert();
- goto cleanup;
- }
+ buf = gnutls_malloc (size);
+ if (buf == NULL)
+ {
+ gnutls_assert ();
+ goto cleanup;
+ }
buf_release = 1;
- }
-
+ }
+
ret = _gnutls_rnd (level, buf, size);
if (ret < 0)
@@ -95,7 +95,7 @@ _gnutls_mpi_randomize (bigint_t r, unsigned int bits,
if (buf_release != 0)
{
- gnutls_free( buf);
+ gnutls_free (buf);
buf = NULL;
}
@@ -110,7 +110,7 @@ _gnutls_mpi_randomize (bigint_t r, unsigned int bits,
cleanup:
if (buf_release != 0)
- gnutls_free( buf);
+ gnutls_free (buf);
return NULL;
}
diff --git a/lib/gnutls_pk.c b/lib/gnutls_pk.c
index c6a27a503b..c71ada6f20 100644
--- a/lib/gnutls_pk.c
+++ b/lib/gnutls_pk.c
@@ -55,7 +55,7 @@ _gnutls_pkcs1_rsa_encrypt (gnutls_datum_t * ciphertext,
gnutls_pk_params_st pk_params;
gnutls_datum to_encrypt, encrypted;
- for (i=0;i<params_len;i++)
+ for (i = 0; i < params_len; i++)
pk_params.params[i] = params[i];
pk_params.params_nr = params_len;
@@ -215,7 +215,7 @@ _gnutls_pkcs1_rsa_decrypt (gnutls_datum_t * plaintext,
size_t esize, mod_bits;
gnutls_pk_params_st pk_params;
- for (i=0;i<params_len;i++)
+ for (i = 0; i < params_len; i++)
pk_params.params[i] = params[i];
pk_params.params_nr = params_len;
@@ -415,7 +415,7 @@ _gnutls_dsa_sign (gnutls_datum_t * signature,
size_t k;
gnutls_pk_params_st pk_params;
- for (i=0;i<params_len;i++)
+ for (i = 0; i < params_len; i++)
pk_params.params[i] = params[i];
pk_params.params_nr = params_len;
@@ -497,7 +497,7 @@ _gnutls_dsa_verify (const gnutls_datum_t * vdata,
int ret, i;
gnutls_pk_params_st pk_params;
- for (i=0;i<params_len;i++)
+ for (i = 0; i < params_len; i++)
pk_params.params[i] = params[i];
pk_params.params_nr = params_len;
@@ -535,7 +535,7 @@ _generate_params (int algo, bigint_t * resarr, unsigned int *resarr_len,
gnutls_assert ();
return ret;
}
-
+
if (resarr && resarr_len && *resarr_len >= params.params_nr)
{
*resarr_len = params.params_nr;
diff --git a/lib/opencdk/armor.c b/lib/opencdk/armor.c
index 59c0dfebef..37d0138f69 100644
--- a/lib/opencdk/armor.c
+++ b/lib/opencdk/armor.c
@@ -162,7 +162,7 @@ base64_encode (char *out, const byte * in, size_t len, size_t olen)
{
if (!out || !in)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Value;
}
@@ -204,7 +204,7 @@ base64_decode (byte * out, const char *in)
if (!out || !in)
{
- gnutls_assert();
+ gnutls_assert ();
return -1;
}
@@ -213,28 +213,28 @@ base64_decode (byte * out, const char *in)
{
digit1 = in[0];
if (digit1 > 127 || b64val (digit1) == BAD)
- {
- gnutls_assert();
- return -1;
- }
+ {
+ gnutls_assert ();
+ return -1;
+ }
digit2 = in[1];
if (digit2 > 127 || b64val (digit2) == BAD)
- {
- gnutls_assert();
+ {
+ gnutls_assert ();
return -1;
- }
+ }
digit3 = in[2];
if (digit3 > 127 || ((digit3 != '=') && (b64val (digit3) == BAD)))
- {
- gnutls_assert();
+ {
+ gnutls_assert ();
return -1;
- }
+ }
digit4 = in[3];
if (digit4 > 127 || ((digit4 != '=') && (b64val (digit4) == BAD)))
{
- gnutls_assert();
+ gnutls_assert ();
return -1;
- }
+ }
in += 4;
/* digits are already sanity-checked */
@@ -323,7 +323,7 @@ is_armored (int ctb)
if (!(ctb & 0x80))
{
- gnutls_assert();
+ gnutls_assert ();
return 1; /* invalid packet: assume it is armored */
}
pkttype = ctb & 0x40 ? (ctb & 0x3f) : ((ctb >> 2) & 0xf);
@@ -370,13 +370,13 @@ armor_encode (void *data, FILE * in, FILE * out)
if (!afx)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Value;
}
if (afx->idx < 0 || afx->idx > (int) DIM (armor_begin) ||
afx->idx2 < 0 || afx->idx2 > (int) DIM (armor_end))
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Value;
}
@@ -393,7 +393,7 @@ armor_encode (void *data, FILE * in, FILE * out)
if (fstat (fileno (in), &statbuf))
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_General_Error;
}
@@ -403,10 +403,10 @@ armor_encode (void *data, FILE * in, FILE * out)
if (!nread)
break;
if (ferror (in))
- {
- gnutls_assert();
- return CDK_File_Error;
- }
+ {
+ gnutls_assert ();
+ return CDK_File_Error;
+ }
afx->crc = update_crc (afx->crc, (byte *) raw, nread);
base64_encode (buf, (byte *) raw, nread, DIM (buf) - 1);
fprintf (out, "%s%s", buf, lf);
@@ -462,7 +462,7 @@ search_header (const char *buf, const char **array)
if (strlen (buf) < 5 || strncmp (buf, "-----", 5))
{
- gnutls_assert();
+ gnutls_assert ();
return -1;
}
for (i = 0; (s = array[i]); i++)
@@ -495,7 +495,7 @@ armor_decode (void *data, FILE * in, FILE * out)
if (!afx)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Value;
}
@@ -515,7 +515,7 @@ armor_decode (void *data, FILE * in, FILE * out)
if (feof (in) || !pgp_data)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Armor_Error; /* no data found */
}
@@ -534,10 +534,10 @@ armor_decode (void *data, FILE * in, FILE * out)
Headers to be corruption of the ASCII Armor. A colon and a single
space separate the key and value. */
if (!strstr (buf, ": "))
- {
- gnutls_assert();
- return CDK_Armor_Error;
- }
+ {
+ gnutls_assert ();
+ return CDK_Armor_Error;
+ }
rc = CDK_General_Error;
for (i = 0; (s = valid_headers[i]); i++)
{
@@ -625,7 +625,7 @@ cdk_file_armor (cdk_ctx_t hd, const char *file, const char *output)
rc = cdk_stream_open (file, &inp);
if (rc)
{
- gnutls_assert();
+ gnutls_assert ();
return rc;
}
@@ -633,7 +633,7 @@ cdk_file_armor (cdk_ctx_t hd, const char *file, const char *output)
if (rc)
{
cdk_stream_close (inp);
- gnutls_assert();
+ gnutls_assert ();
return rc;
}
@@ -671,14 +671,14 @@ cdk_file_dearmor (const char *file, const char *output)
rc = _cdk_check_args (1, file, output);
if (rc)
{
- gnutls_assert();
+ gnutls_assert ();
return rc;
}
rc = cdk_stream_open (file, &inp);
if (rc)
{
- gnutls_assert();
+ gnutls_assert ();
return rc;
}
@@ -686,7 +686,7 @@ cdk_file_dearmor (const char *file, const char *output)
if (rc)
{
cdk_stream_close (inp);
- gnutls_assert();
+ gnutls_assert ();
return rc;
}
@@ -706,7 +706,7 @@ cdk_file_dearmor (const char *file, const char *output)
cdk_stream_close (inp);
cdk_stream_close (out);
- gnutls_assert();
+ gnutls_assert ();
return rc;
}
@@ -730,7 +730,7 @@ _cdk_filter_armor (void *data, int ctl, FILE * in, FILE * out)
}
}
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Mode;
}
@@ -758,12 +758,12 @@ cdk_armor_encode_buffer (const byte * inbuf, size_t inlen,
if (!inbuf || !nwritten)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Value;
}
if (type > CDK_ARMOR_SIGNATURE)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Mode;
}
@@ -776,7 +776,7 @@ cdk_armor_encode_buffer (const byte * inbuf, size_t inlen,
if (outbuf && outlen < pos)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Too_Short;
}
diff --git a/lib/opencdk/hash.c b/lib/opencdk/hash.c
index 61fadd6dad..cddcbc216f 100644
--- a/lib/opencdk/hash.c
+++ b/lib/opencdk/hash.c
@@ -42,7 +42,7 @@ hash_encode (void *data, FILE * in, FILE * out)
if (!mfx)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Value;
}
@@ -52,10 +52,10 @@ hash_encode (void *data, FILE * in, FILE * out)
{
err = _gnutls_hash_init (&mfx->md, mfx->digest_algo);
if (err < 0)
- {
- gnutls_assert();
- return map_gnutls_error (err);
- }
+ {
+ gnutls_assert ();
+ return map_gnutls_error (err);
+ }
mfx->md_initialized = 1;
}
@@ -88,7 +88,7 @@ _cdk_filter_hash (void *data, int ctl, FILE * in, FILE * out)
return 0;
}
}
-
- gnutls_assert();
+
+ gnutls_assert ();
return CDK_Inv_Mode;
}
diff --git a/lib/opencdk/kbnode.c b/lib/opencdk/kbnode.c
index e9374c87eb..376f308582 100644
--- a/lib/opencdk/kbnode.c
+++ b/lib/opencdk/kbnode.c
@@ -448,7 +448,7 @@ cdk_kbnode_write_to_mem_alloc (cdk_kbnode_t node,
if (!node || !r_buf || !r_buflen)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Value;
}
@@ -458,7 +458,7 @@ cdk_kbnode_write_to_mem_alloc (cdk_kbnode_t node,
rc = cdk_stream_tmp_new (&s);
if (rc)
{
- gnutls_assert();
+ gnutls_assert ();
return rc;
}
@@ -477,7 +477,7 @@ cdk_kbnode_write_to_mem_alloc (cdk_kbnode_t node,
if (rc)
{
cdk_stream_close (s);
- gnutls_assert();
+ gnutls_assert ();
return rc;
}
}
@@ -512,14 +512,14 @@ cdk_kbnode_write_to_mem (cdk_kbnode_t node, byte * buf, size_t * r_nbytes)
if (!node || !r_nbytes)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Value;
}
rc = cdk_stream_tmp_new (&s);
if (rc)
{
- gnutls_assert();
+ gnutls_assert ();
return rc;
}
@@ -538,7 +538,7 @@ cdk_kbnode_write_to_mem (cdk_kbnode_t node, byte * buf, size_t * r_nbytes)
if (rc)
{
cdk_stream_close (s);
- gnutls_assert();
+ gnutls_assert ();
return rc;
}
}
@@ -559,7 +559,7 @@ cdk_kbnode_write_to_mem (cdk_kbnode_t node, byte * buf, size_t * r_nbytes)
if (!rc)
*r_nbytes = cdk_stream_read (s, buf, len);
else
- gnutls_assert();
+ gnutls_assert ();
cdk_stream_close (s);
return rc;
}
@@ -586,7 +586,7 @@ cdk_kbnode_hash (cdk_kbnode_t node, digest_hd_st * md, int is_v4,
if (!node || !md)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Value;
}
if (!pkttype)
@@ -598,10 +598,10 @@ cdk_kbnode_hash (cdk_kbnode_t node, digest_hd_st * md, int is_v4,
{
pkt = cdk_kbnode_find_packet (node, pkttype);
if (!pkt)
- {
- gnutls_assert();
- return CDK_Inv_Packet;
- }
+ {
+ gnutls_assert ();
+ return CDK_Inv_Packet;
+ }
}
switch (pkttype)
@@ -620,7 +620,7 @@ cdk_kbnode_hash (cdk_kbnode_t node, digest_hd_st * md, int is_v4,
break;
default:
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Mode;
}
return 0;
diff --git a/lib/opencdk/keydb.c b/lib/opencdk/keydb.c
index 484792d7f5..651a205bb0 100644
--- a/lib/opencdk/keydb.c
+++ b/lib/opencdk/keydb.c
@@ -82,14 +82,14 @@ keydb_idx_build (const char *file)
if (!file)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Value;
}
rc = cdk_stream_open (file, &inp);
if (rc)
{
- gnutls_assert();
+ gnutls_assert ();
return rc;
}
@@ -97,7 +97,7 @@ keydb_idx_build (const char *file)
if (!idx_name)
{
cdk_stream_close (inp);
- gnutls_assert();
+ gnutls_assert ();
return CDK_Out_Of_Core;
}
rc = cdk_stream_create (idx_name, &out);
@@ -105,7 +105,7 @@ keydb_idx_build (const char *file)
if (rc)
{
cdk_stream_close (inp);
- gnutls_assert();
+ gnutls_assert ();
return rc;
}
@@ -138,7 +138,7 @@ keydb_idx_build (const char *file)
cdk_stream_close (out);
cdk_stream_close (inp);
- gnutls_assert();
+ gnutls_assert ();
return rc;
}
@@ -159,7 +159,7 @@ cdk_keydb_idx_rebuild (cdk_keydb_hd_t db, cdk_keydb_search_t dbs)
if (!db || !db->name || !dbs)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Value;
}
if (db->secret)
@@ -168,7 +168,7 @@ cdk_keydb_idx_rebuild (cdk_keydb_hd_t db, cdk_keydb_search_t dbs)
tmp_idx_name = keydb_idx_mkname (db->name);
if (!tmp_idx_name)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Out_Of_Core;
}
err = stat (tmp_idx_name, &stbuf);
@@ -184,16 +184,16 @@ cdk_keydb_idx_rebuild (cdk_keydb_hd_t db, cdk_keydb_search_t dbs)
{
dbs->idx_name = keydb_idx_mkname (db->name);
if (!dbs->idx_name)
- {
- gnutls_assert();
- return CDK_Out_Of_Core;
- }
+ {
+ gnutls_assert ();
+ return CDK_Out_Of_Core;
+ }
}
rc = keydb_idx_build (db->name);
if (!rc)
rc = cdk_stream_open (dbs->idx_name, &dbs->idx);
else
- gnutls_assert();
+ gnutls_assert ();
return rc;
}
@@ -206,14 +206,14 @@ keydb_idx_parse (cdk_stream_t inp, key_idx_t * r_idx)
if (!inp || !r_idx)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Value;
}
idx = cdk_calloc (1, sizeof *idx);
if (!idx)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Out_Of_Core;
}
@@ -242,12 +242,12 @@ keydb_idx_search (cdk_stream_t inp, u32 * keyid, const byte * fpr,
if (!inp || !r_off)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Value;
}
if ((keyid && fpr) || (!keyid && !fpr))
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Mode;
}
@@ -293,7 +293,7 @@ cdk_keydb_new_from_mem (cdk_keydb_hd_t * r_db, int secret,
if (!r_db)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Value;
}
*r_db = NULL;
@@ -302,7 +302,7 @@ cdk_keydb_new_from_mem (cdk_keydb_hd_t * r_db, int secret,
if (!db->fp)
{
cdk_free (db);
- gnutls_assert();
+ gnutls_assert ();
return rc;
}
if (cdk_armor_filter_use (db->fp))
@@ -331,7 +331,7 @@ cdk_keydb_new_from_stream (cdk_keydb_hd_t * r_hd, int secret, cdk_stream_t in)
if (!r_hd)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Value;
}
*r_hd = NULL;
@@ -357,7 +357,7 @@ cdk_keydb_new_from_file (cdk_keydb_hd_t * r_hd, int secret, const char *fname)
if (!r_hd)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Value;
}
*r_hd = NULL;
@@ -366,7 +366,7 @@ cdk_keydb_new_from_file (cdk_keydb_hd_t * r_hd, int secret, const char *fname)
if (!hd->name)
{
cdk_free (hd);
- gnutls_assert();
+ gnutls_assert ();
return CDK_Out_Of_Core;
}
hd->type = secret ? CDK_DBTYPE_SK_KEYRING : CDK_DBTYPE_PK_KEYRING;
@@ -403,10 +403,10 @@ cdk_keydb_new (cdk_keydb_hd_t * r_hd, int type, void *data, size_t count)
return cdk_keydb_new_from_stream (r_hd, 0, (cdk_stream_t) data);
default:
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Mode;
}
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Mode;
}
@@ -450,7 +450,7 @@ _cdk_keydb_open (cdk_keydb_hd_t hd, cdk_stream_t * ret_kr)
if (!hd || !ret_kr)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Value;
}
@@ -474,7 +474,7 @@ _cdk_keydb_open (cdk_keydb_hd_t hd, cdk_stream_t * ret_kr)
}
else
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Mode;
}
@@ -652,7 +652,7 @@ keydb_cache_add (cdk_keydb_search_t dbs, off_t offset)
k = cdk_calloc (1, sizeof *k);
if (!k)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Out_Of_Core;
}
@@ -729,19 +729,19 @@ cdk_keydb_search_start (cdk_keydb_search_t * st, cdk_keydb_hd_t db, int type,
if (!db)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Value;
}
if (type != CDK_DBSEARCH_NEXT && !desc)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Mode;
}
*st = cdk_calloc (1, sizeof (cdk_keydb_search_s));
if (!(*st))
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Out_Of_Core;
}
@@ -749,7 +749,7 @@ cdk_keydb_search_start (cdk_keydb_search_t * st, cdk_keydb_hd_t db, int type,
if (rc != CDK_Success)
{
free (*st);
- gnutls_assert();
+ gnutls_assert ();
return rc;
}
@@ -763,7 +763,7 @@ cdk_keydb_search_start (cdk_keydb_search_t * st, cdk_keydb_hd_t db, int type,
if (!(*st)->u.pattern)
{
cdk_free (*st);
- gnutls_assert();
+ gnutls_assert ();
return CDK_Out_Of_Core;
}
break;
@@ -798,7 +798,7 @@ cdk_keydb_search_start (cdk_keydb_search_t * st, cdk_keydb_hd_t db, int type,
if (!p)
{
cdk_free (*st);
- gnutls_assert();
+ gnutls_assert ();
return CDK_Out_Of_Core;
}
break;
@@ -821,8 +821,8 @@ cdk_keydb_search_start (cdk_keydb_search_t * st, cdk_keydb_hd_t db, int type,
else
{ /* Invalid key ID object. */
cdk_free (*st);
- gnutls_assert();
- return CDK_Inv_Mode;
+ gnutls_assert ();
+ return CDK_Inv_Mode;
}
break;
@@ -831,7 +831,7 @@ cdk_keydb_search_start (cdk_keydb_search_t * st, cdk_keydb_hd_t db, int type,
if (strlen (p) != 2 * KEY_FPR_LEN)
{
cdk_free (*st);
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Mode;
}
for (i = 0; i < KEY_FPR_LEN; i++)
@@ -848,7 +848,7 @@ cdk_keydb_search_start (cdk_keydb_search_t * st, cdk_keydb_hd_t db, int type,
default:
cdk_free (*st);
_cdk_log_debug ("cdk_keydb_search_start: invalid mode = %d\n", type);
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Mode;
}
@@ -864,7 +864,7 @@ keydb_pos_from_cache (cdk_keydb_hd_t hd, cdk_keydb_search_t ks,
if (!hd || !r_cache_hit || !r_off)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Value;
}
@@ -891,9 +891,9 @@ keydb_pos_from_cache (cdk_keydb_hd_t hd, cdk_keydb_search_t ks,
{
if (keydb_idx_search (ks->idx, ks->u.keyid, NULL, r_off))
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Error_No_Key;
- }
+ }
_cdk_log_debug ("cache: found keyid entry in idx table.\n");
*r_cache_hit = 1;
}
@@ -901,9 +901,9 @@ keydb_pos_from_cache (cdk_keydb_hd_t hd, cdk_keydb_search_t ks,
{
if (keydb_idx_search (ks->idx, NULL, ks->u.fpr, r_off))
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Error_No_Key;
- }
+ }
_cdk_log_debug ("cache: found fpr entry in idx table.\n");
*r_cache_hit = 1;
}
@@ -949,7 +949,7 @@ cdk_keydb_search (cdk_keydb_search_t st, cdk_keydb_hd_t hd,
if (!hd || !ret_key || !st)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Value;
}
@@ -959,7 +959,7 @@ cdk_keydb_search (cdk_keydb_search_t st, cdk_keydb_hd_t hd,
rc = _cdk_keydb_open (hd, &kr);
if (rc)
{
- gnutls_assert();
+ gnutls_assert ();
return rc;
}
@@ -990,11 +990,11 @@ cdk_keydb_search (cdk_keydb_search_t st, cdk_keydb_hd_t hd,
{
if (rc == CDK_EOF)
break;
- else
+ else
{
- gnutls_assert();
+ gnutls_assert ();
return rc;
- }
+ }
}
switch (st->type)
@@ -1034,7 +1034,7 @@ cdk_keydb_search (cdk_keydb_search_t st, cdk_keydb_hd_t hd,
rc = 0;
else if (rc == CDK_EOF && !key_found)
{
- gnutls_assert();
+ gnutls_assert ();
rc = CDK_Error_No_Key;
}
*ret_key = key_found ? knode : NULL;
@@ -1049,7 +1049,7 @@ cdk_keydb_get_bykeyid (cdk_keydb_hd_t hd, u32 * keyid, cdk_kbnode_t * ret_key)
if (!hd || !keyid || !ret_key)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Value;
}
@@ -1071,7 +1071,7 @@ cdk_keydb_get_byfpr (cdk_keydb_hd_t hd, const byte * fpr,
if (!hd || !fpr || !r_key)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Value;
}
@@ -1093,7 +1093,7 @@ cdk_keydb_get_bypattern (cdk_keydb_hd_t hd, const char *patt,
if (!hd || !patt || !ret_key)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Value;
}
@@ -1102,7 +1102,7 @@ cdk_keydb_get_bypattern (cdk_keydb_hd_t hd, const char *patt,
rc = cdk_keydb_search (st, hd, ret_key);
if (rc)
- gnutls_assert();
+ gnutls_assert ();
cdk_keydb_search_release (st);
return rc;
@@ -1232,13 +1232,13 @@ _cdk_keydb_get_sk_byusage (cdk_keydb_hd_t hd, const char *name,
if (!ret_sk || !usage)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Value;
}
if (!hd)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Error_No_Keyring;
}
@@ -1246,16 +1246,16 @@ _cdk_keydb_get_sk_byusage (cdk_keydb_hd_t hd, const char *name,
rc = cdk_keydb_search_start (&st, hd, CDK_DBSEARCH_AUTO, (char *) name);
if (rc)
{
- gnutls_assert();
+ gnutls_assert ();
return rc;
}
rc = cdk_keydb_search (st, hd, &knode);
if (rc)
{
- gnutls_assert();
+ gnutls_assert ();
return rc;
- }
+ }
cdk_keydb_search_release (st);
@@ -1263,7 +1263,7 @@ _cdk_keydb_get_sk_byusage (cdk_keydb_hd_t hd, const char *name,
if (!sk_node)
{
cdk_kbnode_release (knode);
- gnutls_assert();
+ gnutls_assert ();
return CDK_Unusable_Key;
}
@@ -1291,7 +1291,7 @@ _cdk_keydb_get_sk_byusage (cdk_keydb_hd_t hd, const char *name,
if (!pk_node)
{
cdk_kbnode_release (knode);
- gnutls_assert();
+ gnutls_assert ();
return CDK_Unusable_Key;
}
node = find_selfsig_node (knode, pk_node->pkt->pkt.secret_key->pk);
@@ -1318,12 +1318,12 @@ _cdk_keydb_get_pk_byusage (cdk_keydb_hd_t hd, const char *name,
if (!ret_pk || !usage)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Value;
}
if (!hd)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Error_No_Keyring;
}
@@ -1333,7 +1333,7 @@ _cdk_keydb_get_pk_byusage (cdk_keydb_hd_t hd, const char *name,
rc = cdk_keydb_search (st, hd, &knode);
if (rc)
{
- gnutls_assert();
+ gnutls_assert ();
return rc;
}
@@ -1343,7 +1343,7 @@ _cdk_keydb_get_pk_byusage (cdk_keydb_hd_t hd, const char *name,
if (!node)
{
cdk_kbnode_release (knode);
- gnutls_assert();
+ gnutls_assert ();
return CDK_Unusable_Key;
}
@@ -1368,7 +1368,7 @@ _cdk_keydb_get_pk_byusage (cdk_keydb_hd_t hd, const char *name,
if (!pk_node)
{
cdk_kbnode_release (knode);
- gnutls_assert();
+ gnutls_assert ();
return CDK_Unusable_Key;
}
node = find_selfsig_node (knode, pk_node->pkt->pkt.public_key);
@@ -1402,12 +1402,12 @@ cdk_keydb_get_pk (cdk_keydb_hd_t hd, u32 * keyid, cdk_pubkey_t * r_pk)
if (!keyid || !r_pk)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Value;
}
if (!hd)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Error_No_Keyring;
}
@@ -1416,13 +1416,13 @@ cdk_keydb_get_pk (cdk_keydb_hd_t hd, u32 * keyid, cdk_pubkey_t * r_pk)
rc = cdk_keydb_search_start (&st, hd, s_type, keyid);
if (rc)
{
- gnutls_assert();
+ gnutls_assert ();
return rc;
}
rc = cdk_keydb_search (st, hd, &knode);
if (rc)
{
- gnutls_assert();
+ gnutls_assert ();
return rc;
}
@@ -1432,7 +1432,7 @@ cdk_keydb_get_pk (cdk_keydb_hd_t hd, u32 * keyid, cdk_pubkey_t * r_pk)
if (!node)
{
cdk_kbnode_release (knode);
- gnutls_assert();
+ gnutls_assert ();
return CDK_Error_No_Key;
}
@@ -1466,12 +1466,12 @@ cdk_keydb_get_sk (cdk_keydb_hd_t hd, u32 * keyid, cdk_seckey_t * ret_sk)
if (!keyid || !ret_sk)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Value;
}
if (!hd)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Error_No_Keyring;
}
@@ -1479,7 +1479,7 @@ cdk_keydb_get_sk (cdk_keydb_hd_t hd, u32 * keyid, cdk_seckey_t * ret_sk)
rc = cdk_keydb_get_bykeyid (hd, keyid, &snode);
if (rc)
{
- gnutls_assert();
+ gnutls_assert ();
return rc;
}
@@ -1487,7 +1487,7 @@ cdk_keydb_get_sk (cdk_keydb_hd_t hd, u32 * keyid, cdk_seckey_t * ret_sk)
if (!node)
{
cdk_kbnode_release (snode);
- gnutls_assert();
+ gnutls_assert ();
return CDK_Error_No_Key;
}
@@ -1578,7 +1578,7 @@ keydb_merge_selfsig (cdk_kbnode_t key, u32 * keyid)
if (!key)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Value;
}
@@ -1588,10 +1588,10 @@ keydb_merge_selfsig (cdk_kbnode_t key, u32 * keyid)
continue;
unode = cdk_kbnode_find_prev (key, node, CDK_PKT_USER_ID);
if (!unode)
- {
- gnutls_assert();
+ {
+ gnutls_assert ();
return CDK_Error_No_Key;
- }
+ }
uid = unode->pkt->pkt.user_id;
sig = node->pkt->pkt.signature;
s = cdk_subpkt_find (sig->hashed, CDK_SIGSUBPKT_PRIMARY_UID);
@@ -1633,9 +1633,9 @@ keydb_merge_selfsig (cdk_kbnode_t key, u32 * keyid)
uid->prefs = cdk_calloc (1, sizeof (*uid->prefs) * (n + 1));
if (!uid->prefs)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Out_Of_Core;
- }
+ }
n = 0;
for (; nsymalg; nsymalg--, n++)
{
@@ -1696,12 +1696,12 @@ keydb_parse_allsigs (cdk_kbnode_t knode, cdk_keydb_hd_t hd, int check)
if (!knode)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Value;
}
if (check && !hd)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Mode;
}
@@ -1722,7 +1722,7 @@ keydb_parse_allsigs (cdk_kbnode_t knode, cdk_keydb_hd_t hd, int check)
kb = cdk_kbnode_find (knode, CDK_PKT_PUBLIC_KEY);
if (!kb)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Wrong_Format;
}
cdk_pk_get_keyid (kb->pkt->pkt.public_key, keyid);
@@ -1743,10 +1743,10 @@ keydb_parse_allsigs (cdk_kbnode_t knode, cdk_keydb_hd_t hd, int check)
_cdk_pk_check_sig (hd, kb, node, NULL, NULL);
}
else
- {
- gnutls_assert();
+ {
+ gnutls_assert ();
return CDK_Error_No_Key;
- }
+ }
}
/* Revocation certificates for subkeys */
else if (sig->sig_class == 0x28)
@@ -1759,10 +1759,10 @@ keydb_parse_allsigs (cdk_kbnode_t knode, cdk_keydb_hd_t hd, int check)
_cdk_pk_check_sig (hd, kb, node, NULL, NULL);
}
else
- {
- gnutls_assert();
+ {
+ gnutls_assert ();
return CDK_Error_No_Key;
- }
+ }
}
/* Revocation certifcates for user ID's */
else if (sig->sig_class == 0x30)
@@ -1777,10 +1777,10 @@ keydb_parse_allsigs (cdk_kbnode_t knode, cdk_keydb_hd_t hd, int check)
_cdk_pk_check_sig (hd, kb, node, NULL, NULL);
}
else
- {
- gnutls_assert();
+ {
+ gnutls_assert ();
return CDK_Error_No_Key;
- }
+ }
}
/* Direct certificates for primary keys */
else if (sig->sig_class == 0x1F)
@@ -1802,10 +1802,10 @@ keydb_parse_allsigs (cdk_kbnode_t knode, cdk_keydb_hd_t hd, int check)
_cdk_pk_check_sig (hd, kb, node, NULL, NULL);
}
else
- {
- gnutls_assert();
+ {
+ gnutls_assert ();
return CDK_Error_No_Key;
- }
+ }
}
/* Direct certificates for subkeys */
else if (sig->sig_class == 0x18)
@@ -1827,10 +1827,10 @@ keydb_parse_allsigs (cdk_kbnode_t knode, cdk_keydb_hd_t hd, int check)
_cdk_pk_check_sig (hd, kb, node, NULL, NULL);
}
else
- {
- gnutls_assert();
+ {
+ gnutls_assert ();
return CDK_Error_No_Key;
- }
+ }
}
}
}
@@ -1899,7 +1899,7 @@ cdk_keydb_get_keyblock (cdk_stream_t inp, cdk_kbnode_t * r_knode)
if (!inp || !r_knode)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Value;
}
@@ -1926,7 +1926,7 @@ cdk_keydb_get_keyblock (cdk_stream_t inp, cdk_kbnode_t * r_knode)
{ /* Release all packets we reached so far. */
_cdk_log_debug ("keydb_get_keyblock: error %d\n", rc);
cdk_kbnode_release (knode);
- gnutls_assert();
+ gnutls_assert ();
return rc;
}
}
@@ -2089,25 +2089,25 @@ cdk_keydb_export (cdk_keydb_hd_t hd, cdk_stream_t out, cdk_strlist_t remusr)
{
rc = cdk_keydb_search_start (&st, hd, CDK_DBSEARCH_AUTO, r->d);
if (rc)
- {
- gnutls_assert();
- return rc;
- }
+ {
+ gnutls_assert ();
+ return rc;
+ }
rc = cdk_keydb_search (st, hd, &knode);
cdk_keydb_search_release (st);
if (rc)
- {
- gnutls_assert();
+ {
+ gnutls_assert ();
return rc;
- }
+ }
node = cdk_kbnode_find (knode, CDK_PKT_PUBLIC_KEY);
if (!node)
- {
- gnutls_assert();
+ {
+ gnutls_assert ();
return CDK_Error_No_Key;
- }
+ }
/* If the key is a version 3 key, use the old packet
format for the output. */
@@ -2136,7 +2136,7 @@ cdk_keydb_export (cdk_keydb_hd_t hd, cdk_stream_t out, cdk_strlist_t remusr)
if (rc)
{
cdk_kbnode_release (knode);
- gnutls_assert();
+ gnutls_assert ();
return rc;
}
}
@@ -2197,14 +2197,14 @@ cdk_keydb_import (cdk_keydb_hd_t hd, cdk_kbnode_t knode)
if (!hd || !knode)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Value;
}
pkt = find_key_packet (knode, NULL);
if (!pkt)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Packet;
}
@@ -2228,7 +2228,7 @@ cdk_keydb_import (cdk_keydb_hd_t hd, cdk_kbnode_t knode)
rc = _cdk_stream_append (hd->name, &out);
if (rc)
{
- gnutls_assert();
+ gnutls_assert ();
return rc;
}
@@ -2254,7 +2254,7 @@ cdk_keydb_import (cdk_keydb_hd_t hd, cdk_kbnode_t knode)
if (rc)
{
cdk_stream_close (out);
- gnutls_assert();
+ gnutls_assert ();
return rc;
}
}
@@ -2276,14 +2276,14 @@ _cdk_keydb_check_userid (cdk_keydb_hd_t hd, u32 * keyid, const char *id)
if (!hd)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Value;
}
rc = cdk_keydb_search_start (&st, hd, CDK_DBSEARCH_KEYID, keyid);
if (rc)
{
- gnutls_assert();
+ gnutls_assert ();
return rc;
}
rc = cdk_keydb_search (st, hd, &knode);
@@ -2291,7 +2291,7 @@ _cdk_keydb_check_userid (cdk_keydb_hd_t hd, u32 * keyid, const char *id)
if (rc)
{
- gnutls_assert();
+ gnutls_assert ();
return rc;
}
@@ -2304,7 +2304,7 @@ _cdk_keydb_check_userid (cdk_keydb_hd_t hd, u32 * keyid, const char *id)
if (rc)
{
cdk_kbnode_release (knode);
- gnutls_assert();
+ gnutls_assert ();
return rc;
}
@@ -2343,19 +2343,19 @@ cdk_keydb_check_sk (cdk_keydb_hd_t hd, u32 * keyid)
if (!hd || !keyid)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Value;
}
if (!hd->secret)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Mode;
}
rc = _cdk_keydb_open (hd, &db);
if (rc)
{
- gnutls_assert();
+ gnutls_assert ();
return rc;
}
cdk_pkt_new (&pkt);
@@ -2376,7 +2376,7 @@ cdk_keydb_check_sk (cdk_keydb_hd_t hd, u32 * keyid)
cdk_pkt_free (pkt);
}
cdk_pkt_release (pkt);
- gnutls_assert();
+ gnutls_assert ();
return CDK_Error_No_Key;
}
@@ -2403,24 +2403,24 @@ cdk_listkey_start (cdk_listkey_t * r_ctx, cdk_keydb_hd_t db,
if (!r_ctx || !db)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Value;
}
if ((patt && fpatt) || (!patt && !fpatt))
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Mode;
}
rc = _cdk_keydb_open (db, &inp);
if (rc)
{
- gnutls_assert();
+ gnutls_assert ();
return rc;
}
ctx = cdk_calloc (1, sizeof *ctx);
- if (!ctx)
+ if (!ctx)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Out_Of_Core;
}
ctx->db = db;
@@ -2429,10 +2429,10 @@ cdk_listkey_start (cdk_listkey_t * r_ctx, cdk_keydb_hd_t db,
{
ctx->u.patt = cdk_strdup (patt);
if (!ctx->u.patt)
- {
- gnutls_assert();
+ {
+ gnutls_assert ();
return CDK_Out_Of_Core;
- }
+ }
}
else if (fpatt)
{
@@ -2479,12 +2479,12 @@ cdk_listkey_next (cdk_listkey_t ctx, cdk_kbnode_t * ret_key)
{
if (!ctx || !ret_key)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Value;
}
if (!ctx->init)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Mode;
}
@@ -2501,9 +2501,9 @@ cdk_listkey_next (cdk_listkey_t ctx, cdk_kbnode_t * ret_key)
rc = cdk_keydb_get_keyblock (ctx->inp, &node);
if (rc)
{
- gnutls_assert();
+ gnutls_assert ();
return rc;
- }
+ }
memset (&ks, 0, sizeof (ks));
ks.type = CDK_DBSEARCH_SUBSTR;
ks.u.pattern = ctx->u.patt;
@@ -2526,7 +2526,7 @@ cdk_listkey_next (cdk_listkey_t ctx, cdk_kbnode_t * ret_key)
return CDK_EOF;
return cdk_keydb_get_bypattern (ctx->db, ctx->t->d, ret_key);
}
- gnutls_assert();
+ gnutls_assert ();
return CDK_General_Error;
}
diff --git a/lib/opencdk/pubkey.c b/lib/opencdk/pubkey.c
index d4ad65f83f..2e44bfcf03 100644
--- a/lib/opencdk/pubkey.c
+++ b/lib/opencdk/pubkey.c
@@ -116,7 +116,7 @@ cdk_pk_verify (cdk_pubkey_t pk, cdk_pkt_signature_t sig, const byte * md)
data.size = enclen;
params.params_nr = cdk_pk_get_npkey (pk->pubkey_algo);
- for (i=0;i<params.params_nr;i++)
+ for (i = 0; i < params.params_nr; i++)
params.params[i] = pk->mpi[i];
params.flags = 0;
ret = _gnutls_pk_verify (algo, &data, &s_sig, &params);
diff --git a/lib/opencdk/stream.c b/lib/opencdk/stream.c
index 6abc4dc043..d1061925b8 100644
--- a/lib/opencdk/stream.c
+++ b/lib/opencdk/stream.c
@@ -79,7 +79,7 @@ _cdk_stream_open_mode (const char *file, const char *mode,
if (!file || !ret_s)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Value;
}
@@ -88,14 +88,14 @@ _cdk_stream_open_mode (const char *file, const char *mode,
s = cdk_calloc (1, sizeof *s);
if (!s)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Out_Of_Core;
}
s->fname = cdk_strdup (file);
if (!s->fname)
{
cdk_free (s);
- gnutls_assert();
+ gnutls_assert ();
return CDK_Out_Of_Core;
}
s->fp = fopen (file, mode);
@@ -103,7 +103,7 @@ _cdk_stream_open_mode (const char *file, const char *mode,
{
cdk_free (s->fname);
cdk_free (s);
- gnutls_assert();
+ gnutls_assert ();
return CDK_File_Error;
}
_cdk_log_debug ("open stream fd=%d\n", fileno (s->fp));
@@ -130,7 +130,7 @@ cdk_stream_new_from_cbs (cdk_stream_cbs_t cbs, void *opa,
if (!cbs || !opa || !ret_s)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Value;
}
@@ -138,7 +138,7 @@ cdk_stream_new_from_cbs (cdk_stream_cbs_t cbs, void *opa,
s = cdk_calloc (1, sizeof *s);
if (!s)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Out_Of_Core;
}
@@ -172,7 +172,7 @@ cdk_stream_new (const char *file, cdk_stream_t * ret_s)
if (!ret_s)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Value;
}
@@ -181,7 +181,7 @@ cdk_stream_new (const char *file, cdk_stream_t * ret_s)
s = cdk_calloc (1, sizeof *s);
if (!s)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Out_Of_Core;
}
s->flags.write = 1;
@@ -193,7 +193,7 @@ cdk_stream_new (const char *file, cdk_stream_t * ret_s)
if (!s->fname)
{
cdk_free (s);
- gnutls_assert();
+ gnutls_assert ();
return CDK_Out_Of_Core;
}
}
@@ -202,7 +202,7 @@ cdk_stream_new (const char *file, cdk_stream_t * ret_s)
{
cdk_free (s->fname);
cdk_free (s);
- gnutls_assert();
+ gnutls_assert ();
return CDK_File_Error;
}
_cdk_log_debug ("new stream fd=%d\n", fileno (s->fp));
@@ -226,7 +226,7 @@ cdk_stream_create (const char *file, cdk_stream_t * ret_s)
if (!file || !ret_s)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Value;
}
@@ -235,7 +235,7 @@ cdk_stream_create (const char *file, cdk_stream_t * ret_s)
s = cdk_calloc (1, sizeof *s);
if (!s)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Out_Of_Core;
}
s->flags.write = 1;
@@ -244,7 +244,7 @@ cdk_stream_create (const char *file, cdk_stream_t * ret_s)
if (!s->fname)
{
cdk_free (s);
- gnutls_assert();
+ gnutls_assert ();
return CDK_Out_Of_Core;
}
s->fp = fopen (file, "w+b");
@@ -252,7 +252,7 @@ cdk_stream_create (const char *file, cdk_stream_t * ret_s)
{
cdk_free (s->fname);
cdk_free (s);
- gnutls_assert();
+ gnutls_assert ();
return CDK_File_Error;
}
_cdk_log_debug ("stream create fd=%d\n", fileno (s->fp));
@@ -294,7 +294,7 @@ cdk_stream_tmp_from_mem (const void *buf, size_t buflen, cdk_stream_t * r_out)
rc = cdk_stream_tmp_new (&s);
if (rc)
{
- gnutls_assert();
+ gnutls_assert ();
return rc;
}
@@ -302,7 +302,7 @@ cdk_stream_tmp_from_mem (const void *buf, size_t buflen, cdk_stream_t * r_out)
if (nwritten == EOF)
{
cdk_stream_close (s);
- gnutls_assert();
+ gnutls_assert ();
return s->error;
}
cdk_stream_seek (s, 0);
@@ -320,7 +320,7 @@ _cdk_stream_fpopen (FILE * fp, unsigned write_mode, cdk_stream_t * ret_out)
s = cdk_calloc (1, sizeof *s);
if (!s)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Out_Of_Core;
}
@@ -343,7 +343,7 @@ _cdk_stream_append (const char *file, cdk_stream_t * ret_s)
if (!ret_s)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Value;
}
*ret_s = NULL;
@@ -351,7 +351,7 @@ _cdk_stream_append (const char *file, cdk_stream_t * ret_s)
rc = _cdk_stream_open_mode (file, "a+b", &s);
if (rc)
{
- gnutls_assert();
+ gnutls_assert ();
return rc;
}
@@ -394,7 +394,7 @@ cdk_stream_flush (cdk_stream_t s)
if (!s)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Value;
}
@@ -419,7 +419,7 @@ cdk_stream_flush (cdk_stream_t s)
if (rc)
{
s->error = rc;
- gnutls_assert();
+ gnutls_assert ();
return rc;
}
}
@@ -453,7 +453,7 @@ cdk_stream_close (cdk_stream_t s)
if (!s)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Value;
}
@@ -469,7 +469,7 @@ cdk_stream_close (cdk_stream_t s)
else
rc = 0;
cdk_free (s);
- gnutls_assert();
+ gnutls_assert ();
return rc;
}
@@ -510,7 +510,7 @@ cdk_stream_close (cdk_stream_t s)
s->cache.alloced = 0;
cdk_free (s);
- gnutls_assert();
+ gnutls_assert ();
return rc;
}
@@ -570,7 +570,7 @@ cdk_stream_get_length (cdk_stream_t s)
if (!s)
{
- gnutls_assert();
+ gnutls_assert ();
return (off_t) - 1;
}
@@ -582,14 +582,14 @@ cdk_stream_get_length (cdk_stream_t s)
if (rc)
{
s->error = rc;
- gnutls_assert();
+ gnutls_assert ();
return (off_t) - 1;
}
if (fstat (fileno (s->fp), &statbuf))
{
s->error = CDK_File_Error;
- gnutls_assert();
+ gnutls_assert ();
return (off_t) - 1;
}
@@ -727,14 +727,14 @@ cdk_stream_filter_disable (cdk_stream_t s, int type)
if (!s)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Value;
}
fnc = stream_id_to_filter (type);
if (!fnc)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Value;
}
f = filter_search (s, fnc);
@@ -757,7 +757,7 @@ stream_fp_replace (cdk_stream_t s, FILE ** tmp)
rc = fclose (s->fp);
if (rc)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_File_Error;
}
s->fp = *tmp;
@@ -779,7 +779,7 @@ stream_filter_write (cdk_stream_t s)
if (s->flags.filtrated)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Value;
}
@@ -933,7 +933,7 @@ cdk_stream_read (cdk_stream_t s, void *buf, size_t buflen)
if (!s)
{
s->error = CDK_Inv_Value;
- gnutls_assert();
+ gnutls_assert ();
return EOF;
}
@@ -947,7 +947,7 @@ cdk_stream_read (cdk_stream_t s, void *buf, size_t buflen)
if (s->flags.write && !s->flags.temp)
{
s->error = CDK_Inv_Mode;
- gnutls_assert();
+ gnutls_assert ();
return EOF; /* This is a write stream */
}
@@ -959,7 +959,7 @@ cdk_stream_read (cdk_stream_t s, void *buf, size_t buflen)
s->error = rc;
if (feof (s->fp))
s->flags.eof = 1;
- gnutls_assert();
+ gnutls_assert ();
return EOF;
}
s->flags.filtrated = 1;
@@ -990,14 +990,14 @@ cdk_stream_getc (cdk_stream_t s)
if (!s)
{
s->error = CDK_Inv_Value;
- gnutls_assert();
+ gnutls_assert ();
return EOF;
}
nread = cdk_stream_read (s, buf, 1);
if (nread == EOF)
{
s->error = CDK_File_Error;
- gnutls_assert();
+ gnutls_assert ();
return EOF;
}
return buf[0];
@@ -1023,7 +1023,7 @@ cdk_stream_write (cdk_stream_t s, const void *buf, size_t count)
if (!s)
{
s->error = CDK_Inv_Value;
- gnutls_assert();
+ gnutls_assert ();
return EOF;
}
@@ -1037,7 +1037,7 @@ cdk_stream_write (cdk_stream_t s, const void *buf, size_t count)
if (!s->flags.write)
{
s->error = CDK_Inv_Mode; /* this is a read stream */
- gnutls_assert();
+ gnutls_assert ();
return EOF;
}
@@ -1082,7 +1082,7 @@ cdk_stream_putc (cdk_stream_t s, int c)
if (!s)
{
s->error = CDK_Inv_Value;
- gnutls_assert();
+ gnutls_assert ();
return EOF;
}
buf[0] = c;
@@ -1107,7 +1107,7 @@ cdk_stream_seek (cdk_stream_t s, off_t offset)
if (!s)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Value;
}
@@ -1127,7 +1127,7 @@ cdk_stream_seek (cdk_stream_t s, off_t offset)
if (fseek (s->fp, offset, SEEK_SET))
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_File_Error;
}
return 0;
@@ -1164,13 +1164,13 @@ cdk_stream_set_armor_flag (cdk_stream_t s, int armor_type)
if (!s)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Value;
}
f = filter_add (s, _cdk_filter_armor, fARMOR);
if (!f)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Out_Of_Core;
}
f->u.afx.idx = f->u.afx.idx2 = armor_type;
@@ -1201,7 +1201,7 @@ cdk_stream_set_literal_flag (cdk_stream_t s, cdk_lit_format_t mode,
if (!s)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Value;
}
@@ -1209,7 +1209,7 @@ cdk_stream_set_literal_flag (cdk_stream_t s, cdk_lit_format_t mode,
f = filter_add (s, _cdk_filter_literal, fLITERAL);
if (!f)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Out_Of_Core;
}
f->u.pfx.mode = mode;
@@ -1240,7 +1240,7 @@ cdk_error_t
cdk_stream_set_compress_flag (cdk_stream_t s, int algo, int level)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Not_Implemented;
#if 0
@@ -1273,13 +1273,13 @@ cdk_stream_set_text_flag (cdk_stream_t s, const char *lf)
if (!s)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Value;
}
f = filter_add (s, _cdk_filter_text, fTEXT);
if (!f)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Out_Of_Core;
}
f->ctl = stream_get_mode (s);
@@ -1303,18 +1303,18 @@ cdk_stream_set_hash_flag (cdk_stream_t s, int digest_algo)
if (!s)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Value;
}
if (stream_get_mode (s))
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Mode;
}
f = filter_add (s, _cdk_filter_hash, fHASH);
if (!f)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Out_Of_Core;
}
f->ctl = stream_get_mode (s);
@@ -1336,12 +1336,12 @@ cdk_stream_enable_cache (cdk_stream_t s, int val)
{
if (!s)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Value;
}
if (!s->flags.write)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Mode;
}
s->cache.on = val;
@@ -1368,10 +1368,10 @@ stream_cache_flush (cdk_stream_t s, FILE * fp)
{
nwritten = fwrite (s->cache.buf, 1, s->cache.size, fp);
if (!nwritten)
- {
- gnutls_assert();
+ {
+ gnutls_assert ();
return CDK_File_Error;
- }
+ }
s->cache.size = 0;
s->cache.on = 0;
wipemem (s->cache.buf, s->cache.alloced);
@@ -1397,7 +1397,7 @@ cdk_stream_kick_off (cdk_stream_t inp, cdk_stream_t out)
if (!inp || !out)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Value;
}
rc = CDK_Success;
@@ -1440,7 +1440,7 @@ cdk_stream_mmap_part (cdk_stream_t s, off_t off, size_t len,
if (!ret_buf || !ret_buflen)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Value;
}
*ret_buf = NULL;
@@ -1448,7 +1448,7 @@ cdk_stream_mmap_part (cdk_stream_t s, off_t off, size_t len,
if (!s)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Value;
}
@@ -1456,7 +1456,7 @@ cdk_stream_mmap_part (cdk_stream_t s, off_t off, size_t len,
if (s->cbs_hd)
{
_cdk_log_debug ("cdk_stream_mmap_part: not supported on callbacks\n");
- gnutls_assert();
+ gnutls_assert ();
return CDK_Inv_Mode;
}
@@ -1464,13 +1464,13 @@ cdk_stream_mmap_part (cdk_stream_t s, off_t off, size_t len,
rc = cdk_stream_flush (s);
if (rc)
{
- gnutls_assert();
+ gnutls_assert ();
return rc;
}
rc = cdk_stream_seek (s, off);
if (rc)
{
- gnutls_assert();
+ gnutls_assert ();
return rc;
}
if (!len)
@@ -1478,12 +1478,12 @@ cdk_stream_mmap_part (cdk_stream_t s, off_t off, size_t len,
if (!len)
{
_cdk_log_debug ("cdk_stream_mmap_part: invalid file size %lu\n", len);
- gnutls_assert();
+ gnutls_assert ();
return s->error;
}
if (len > MAX_MAP_SIZE)
{
- gnutls_assert();
+ gnutls_assert ();
return CDK_Too_Short;
}
@@ -1494,7 +1494,7 @@ cdk_stream_mmap_part (cdk_stream_t s, off_t off, size_t len,
*ret_buflen = n;
rc = cdk_stream_seek (s, oldpos);
if (rc)
- gnutls_assert();
+ gnutls_assert ();
return rc;
}
diff --git a/lib/openpgp/privkey.c b/lib/openpgp/privkey.c
index c7cb371c4d..2aff7dee3d 100644
--- a/lib/openpgp/privkey.c
+++ b/lib/openpgp/privkey.c
@@ -116,16 +116,16 @@ gnutls_openpgp_privkey_import (gnutls_openpgp_privkey_t key,
}
if (cdk_armor_filter_use (inp))
- {
+ {
rc = cdk_stream_set_armor_flag (inp, 0);
if (rc != 0)
{
rc = _gnutls_map_cdk_rc (rc);
- cdk_stream_close (inp);
+ cdk_stream_close (inp);
gnutls_assert ();
return rc;
- }
- }
+ }
+ }
rc = cdk_keydb_get_keyblock (inp, &key->knode);
cdk_stream_close (inp);
diff --git a/lib/x509/common.c b/lib/x509/common.c
index 917a5faf8b..c7cf5a90f5 100644
--- a/lib/x509/common.c
+++ b/lib/x509/common.c
@@ -1074,11 +1074,11 @@ _gnutls_x509_write_value (ASN1_TYPE c, const char *root,
*/
val.data = gnutls_malloc (asize);
if (val.data == NULL)
- {
- gnutls_assert ();
- result = GNUTLS_E_MEMORY_ERROR;
- goto cleanup;
- }
+ {
+ gnutls_assert ();
+ result = GNUTLS_E_MEMORY_ERROR;
+ goto cleanup;
+ }
if ((result = asn1_create_element
(_gnutls_get_pkix (), "PKIX1.pkcs-7-Data", &c2)) != ASN1_SUCCESS)
diff --git a/lib/x509/crl.c b/lib/x509/crl.c
index b97098a0f2..eea360476e 100644
--- a/lib/x509/crl.c
+++ b/lib/x509/crl.c
@@ -807,8 +807,7 @@ gnutls_x509_crl_get_authority_key_id (gnutls_x509_crl_t crl, void *ret,
**/
int
gnutls_x509_crl_get_number (gnutls_x509_crl_t crl, void *ret,
- size_t * ret_size,
- unsigned int *critical)
+ size_t * ret_size, unsigned int *critical)
{
int result;
gnutls_datum_t id;
@@ -839,8 +838,8 @@ gnutls_x509_crl_get_number (gnutls_x509_crl_t crl, void *ret,
}
result = _gnutls_x509_ext_extract_number (ret, ret_size, id.data, id.size);
-
- _gnutls_free_datum( &id);
+
+ _gnutls_free_datum (&id);
if (result < 0)
{
diff --git a/lib/x509/crl_write.c b/lib/x509/crl_write.c
index 0e07ed2bef..978dec1025 100644
--- a/lib/x509/crl_write.c
+++ b/lib/x509/crl_write.c
@@ -310,7 +310,7 @@ static void
disable_optional_stuff (gnutls_x509_crl_t crl)
{
- if (crl->use_extensions == 0)
+ if (crl->use_extensions == 0)
{
asn1_write_value (crl->crl, "tbsCertList.crlExtensions", NULL, 0);
}
@@ -394,7 +394,7 @@ gnutls_x509_crl_set_authority_key_id (gnutls_x509_crl_t crl,
**/
int
gnutls_x509_crl_set_number (gnutls_x509_crl_t crl,
- const void *nr, size_t nr_size)
+ const void *nr, size_t nr_size)
{
int result;
gnutls_datum_t old_id, der_data;
diff --git a/lib/x509/crq.c b/lib/x509/crq.c
index d239d0ce2d..3999f40190 100644
--- a/lib/x509/crq.c
+++ b/lib/x509/crq.c
@@ -451,7 +451,7 @@ gnutls_x509_crq_get_challenge_password (gnutls_x509_crq_t crq,
* Critical will be either 0 or 1.
*/
static int
-add_attribute (ASN1_TYPE asn, const char* root, const char *attribute_id,
+add_attribute (ASN1_TYPE asn, const char *root, const char *attribute_id,
const gnutls_datum_t * ext_data)
{
int result;
@@ -470,8 +470,7 @@ add_attribute (ASN1_TYPE asn, const char* root, const char *attribute_id,
snprintf (name, sizeof (name), "%s.?LAST.type", root);
- result =
- asn1_write_value (asn, name, attribute_id, 1);
+ result = asn1_write_value (asn, name, attribute_id, 1);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
@@ -489,8 +488,7 @@ add_attribute (ASN1_TYPE asn, const char* root, const char *attribute_id,
snprintf (name, sizeof (name), "%s.?LAST.values.?LAST", root);
- result =
- _gnutls_x509_write_value (asn, name, ext_data, 0);
+ result = _gnutls_x509_write_value (asn, name, ext_data, 0);
if (result < 0)
{
gnutls_assert ();
@@ -504,7 +502,7 @@ add_attribute (ASN1_TYPE asn, const char* root, const char *attribute_id,
* index here starts from one.
*/
static int
-overwrite_attribute (ASN1_TYPE asn, const char* root, unsigned int indx,
+overwrite_attribute (ASN1_TYPE asn, const char *root, unsigned int indx,
const gnutls_datum_t * ext_data)
{
char name[MAX_NAME_SIZE], name2[MAX_NAME_SIZE];
@@ -527,9 +525,8 @@ overwrite_attribute (ASN1_TYPE asn, const char* root, unsigned int indx,
}
static int
-set_attribute (ASN1_TYPE asn, const char* root,
- const char *ext_id,
- const gnutls_datum_t * ext_data)
+set_attribute (ASN1_TYPE asn, const char *root,
+ const char *ext_id, const gnutls_datum_t * ext_data)
{
int result;
int k, len;
@@ -633,7 +630,7 @@ gnutls_x509_crq_set_attribute_by_oid (gnutls_x509_crq_t crq,
}
return set_attribute (crq->crq, "certificationRequestInfo.attributes",
- oid, &data);
+ oid, &data);
}
/**
@@ -829,7 +826,7 @@ gnutls_x509_crq_set_key (gnutls_x509_crq_t crq, gnutls_x509_privkey_t key)
**/
int
gnutls_x509_crq_get_key_rsa_raw (gnutls_x509_crq_t crq,
- gnutls_datum_t * m, gnutls_datum_t * e)
+ gnutls_datum_t * m, gnutls_datum_t * e)
{
int ret;
bigint_t params[MAX_PUBLIC_PARAMS_SIZE];
@@ -1212,8 +1209,8 @@ gnutls_x509_crq_get_attribute_info (gnutls_x509_crq_t cert, int indx,
return GNUTLS_E_INVALID_REQUEST;
}
- snprintf (name, sizeof (name), "certificationRequestInfo.attributes.?%u.type",
- indx + 1);
+ snprintf (name, sizeof (name),
+ "certificationRequestInfo.attributes.?%u.type", indx + 1);
len = *sizeof_oid;
result = asn1_read_value (cert->crq, name, oid, &len);
@@ -1264,8 +1261,8 @@ gnutls_x509_crq_get_attribute_data (gnutls_x509_crq_t cert, int indx,
return GNUTLS_E_INVALID_REQUEST;
}
- snprintf (name, sizeof (name), "certificationRequestInfo.attributes.?%u.values.?1",
- indx + 1);
+ snprintf (name, sizeof (name),
+ "certificationRequestInfo.attributes.?%u.values.?1", indx + 1);
len = *sizeof_data;
result = asn1_read_value (cert->crq, name, data, &len);
@@ -1314,7 +1311,7 @@ gnutls_x509_crq_get_extension_info (gnutls_x509_crq_t cert, int indx,
char str_critical[10];
char name[MAX_NAME_SIZE];
unsigned char extensions[MAX_CRQ_EXTENSIONS_SIZE];
- size_t extensions_size = sizeof(extensions);
+ size_t extensions_size = sizeof (extensions);
ASN1_TYPE c2;
int len;
@@ -1325,16 +1322,16 @@ gnutls_x509_crq_get_extension_info (gnutls_x509_crq_t cert, int indx,
}
/* read extensionRequest */
- result = gnutls_x509_crq_get_attribute_by_oid (cert, "1.2.840.113549.1.9.14",
- 0, extensions, &extensions_size);
+ result =
+ gnutls_x509_crq_get_attribute_by_oid (cert, "1.2.840.113549.1.9.14", 0,
+ extensions, &extensions_size);
if (result < 0)
{
gnutls_assert ();
return result;
}
- result = asn1_create_element
- (_gnutls_get_pkix (), "PKIX1.Extensions", &c2);
+ result = asn1_create_element (_gnutls_get_pkix (), "PKIX1.Extensions", &c2);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
@@ -1418,7 +1415,7 @@ gnutls_x509_crq_get_extension_data (gnutls_x509_crq_t cert, int indx,
int result, len;
char name[MAX_NAME_SIZE];
unsigned char extensions[MAX_CRQ_EXTENSIONS_SIZE];
- size_t extensions_size = sizeof(extensions);
+ size_t extensions_size = sizeof (extensions);
ASN1_TYPE c2;
if (!cert)
@@ -1428,16 +1425,16 @@ gnutls_x509_crq_get_extension_data (gnutls_x509_crq_t cert, int indx,
}
/* read extensionRequest */
- result = gnutls_x509_crq_get_attribute_by_oid (cert, "1.2.840.113549.1.9.14",
- 0, extensions, &extensions_size);
+ result =
+ gnutls_x509_crq_get_attribute_by_oid (cert, "1.2.840.113549.1.9.14", 0,
+ extensions, &extensions_size);
if (result < 0)
{
gnutls_assert ();
return result;
}
- result = asn1_create_element
- (_gnutls_get_pkix (), "PKIX1.Extensions", &c2);
+ result = asn1_create_element (_gnutls_get_pkix (), "PKIX1.Extensions", &c2);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
@@ -1452,8 +1449,7 @@ gnutls_x509_crq_get_extension_data (gnutls_x509_crq_t cert, int indx,
return _gnutls_asn2err (result);
}
- snprintf (name, sizeof (name), "?%u.extnValue",
- indx + 1);
+ snprintf (name, sizeof (name), "?%u.extnValue", indx + 1);
len = *sizeof_data;
result = asn1_read_value (c2, name, data, &len);
@@ -1499,7 +1495,7 @@ gnutls_x509_crq_get_key_usage (gnutls_x509_crq_t cert,
int result;
uint16_t _usage;
opaque buf[128];
- size_t buf_size = sizeof(buf);
+ size_t buf_size = sizeof (buf);
if (cert == NULL)
{
@@ -1507,11 +1503,11 @@ gnutls_x509_crq_get_key_usage (gnutls_x509_crq_t cert,
return GNUTLS_E_INVALID_REQUEST;
}
- result = gnutls_x509_crq_get_extension_by_oid(cert, "2.5.29.15", 0,
- buf, &buf_size, critical);
+ result = gnutls_x509_crq_get_extension_by_oid (cert, "2.5.29.15", 0,
+ buf, &buf_size, critical);
if (result < 0)
{
- gnutls_assert();
+ gnutls_assert ();
return result;
}
@@ -1556,7 +1552,7 @@ gnutls_x509_crq_get_basic_constraints (gnutls_x509_crq_t cert,
int result;
int tmp_ca;
opaque buf[256];
- size_t buf_size = sizeof(buf);
+ size_t buf_size = sizeof (buf);
if (cert == NULL)
{
@@ -1564,18 +1560,17 @@ gnutls_x509_crq_get_basic_constraints (gnutls_x509_crq_t cert,
return GNUTLS_E_INVALID_REQUEST;
}
- result = gnutls_x509_crq_get_extension_by_oid(cert, "2.5.29.19", 0,
- buf, &buf_size, critical);
+ result = gnutls_x509_crq_get_extension_by_oid (cert, "2.5.29.19", 0,
+ buf, &buf_size, critical);
if (result < 0)
{
- gnutls_assert();
+ gnutls_assert ();
return result;
}
result =
_gnutls_x509_ext_extract_basicConstraints (&tmp_ca,
- pathlen,
- buf, buf_size);
+ pathlen, buf, buf_size);
if (ca)
*ca = tmp_ca;
@@ -1598,7 +1593,7 @@ get_subject_alt_name (gnutls_x509_crq_t cert,
ASN1_TYPE c2 = ASN1_TYPE_EMPTY;
gnutls_x509_subject_alt_name_t type;
opaque dnsname[2048];
- size_t dnsname_size = sizeof(dnsname);
+ size_t dnsname_size = sizeof (dnsname);
if (cert == NULL)
{
@@ -1612,10 +1607,11 @@ get_subject_alt_name (gnutls_x509_crq_t cert,
*ret_size = 0;
if ((result =
- gnutls_x509_crq_get_extension_by_oid (cert, "2.5.29.17", 0,
- dnsname, &dnsname_size, critical)) < 0)
+ gnutls_x509_crq_get_extension_by_oid (cert, "2.5.29.17", 0,
+ dnsname, &dnsname_size,
+ critical)) < 0)
{
- gnutls_assert();
+ gnutls_assert ();
return result;
}
@@ -1637,7 +1633,8 @@ get_subject_alt_name (gnutls_x509_crq_t cert,
}
result =
- _gnutls_parse_general_name (c2, "", seq, ret, ret_size, ret_type, othername_oid);
+ _gnutls_parse_general_name (c2, "", seq, ret, ret_size, ret_type,
+ othername_oid);
asn1_delete_structure (&c2);
@@ -1671,12 +1668,13 @@ get_subject_alt_name (gnutls_x509_crq_t cert,
**/
int
gnutls_x509_crq_get_subject_alt_name (gnutls_x509_crq_t cert,
- unsigned int seq, void *ret,
- size_t * ret_size,
- unsigned int *ret_type,
- unsigned int *critical)
+ unsigned int seq, void *ret,
+ size_t * ret_size,
+ unsigned int *ret_type,
+ unsigned int *critical)
{
- return get_subject_alt_name (cert ,seq, ret, ret_size, ret_type, critical, 0);
+ return get_subject_alt_name (cert, seq, ret, ret_size, ret_type, critical,
+ 0);
}
/**
@@ -1742,25 +1740,29 @@ gnutls_x509_crq_get_extension_by_oid (gnutls_x509_crq_t cert,
char _oid[MAX_OID_SIZE];
size_t oid_size;
- for (i=0;;i++)
+ for (i = 0;; i++)
{
- oid_size = sizeof(_oid);
- result = gnutls_x509_crq_get_extension_info ( cert, i, _oid, &oid_size, critical);
+ oid_size = sizeof (_oid);
+ result =
+ gnutls_x509_crq_get_extension_info (cert, i, _oid, &oid_size,
+ critical);
if (result < 0)
- {
- gnutls_assert();
- return result;
- }
-
- if (strcmp( oid, _oid)==0)
- { /* found */
- if (indx == 0)
- return gnutls_x509_crq_get_extension_data (cert, i, buf, sizeof_buf);
- else indx--;
- }
- }
-
-
+ {
+ gnutls_assert ();
+ return result;
+ }
+
+ if (strcmp (oid, _oid) == 0)
+ { /* found */
+ if (indx == 0)
+ return gnutls_x509_crq_get_extension_data (cert, i, buf,
+ sizeof_buf);
+ else
+ indx--;
+ }
+ }
+
+
return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
}
@@ -1816,9 +1818,10 @@ gnutls_x509_crq_set_subject_alt_name (gnutls_x509_crq_t crq,
if (flags == GNUTLS_FSAN_APPEND)
{
- tmp_size = sizeof(tmp);
+ tmp_size = sizeof (tmp);
result = gnutls_x509_crq_get_extension_by_oid (crq, "2.5.29.17", 0,
- tmp, &tmp_size, &critical);
+ tmp, &tmp_size,
+ &critical);
if (result < 0 && result != GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE)
{
gnutls_assert ();
@@ -1999,13 +2002,13 @@ gnutls_x509_crq_get_key_purpose_oid (gnutls_x509_crq_t cert,
else
*sizeof_oid = 0;
- tmp_size = sizeof(tmp);
+ tmp_size = sizeof (tmp);
result = gnutls_x509_crq_get_extension_by_oid (cert, "2.5.29.37", 0,
- tmp, &tmp_size, critical);
+ tmp, &tmp_size, critical);
if (result < 0 && result != GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE)
{
- gnutls_assert();
+ gnutls_assert ();
return result;
}
@@ -2029,15 +2032,15 @@ gnutls_x509_crq_get_key_purpose_oid (gnutls_x509_crq_t cert,
}
- if ( prev_data.size > 0)
+ if (prev_data.size > 0)
{
result = asn1_der_decoding (&c2, prev_data.data, prev_data.size, NULL);
if (result != ASN1_SUCCESS)
- {
- gnutls_assert ();
- asn1_delete_structure (&c2);
- return _gnutls_asn2err (result);
- }
+ {
+ gnutls_assert ();
+ asn1_delete_structure (&c2);
+ return _gnutls_asn2err (result);
+ }
}
indx++;
@@ -2059,7 +2062,7 @@ gnutls_x509_crq_get_key_purpose_oid (gnutls_x509_crq_t cert,
if (result != ASN1_SUCCESS)
{
if (result != ASN1_MEM_ERROR)
- gnutls_assert ();
+ gnutls_assert ();
return _gnutls_asn2err (result);
}
@@ -2099,13 +2102,13 @@ gnutls_x509_crq_set_key_purpose_oid (gnutls_x509_crq_t cert,
/* Check if the extension already exists.
*/
- tmp_size = sizeof(tmp);
+ tmp_size = sizeof (tmp);
result = gnutls_x509_crq_get_extension_by_oid (cert, "2.5.29.37", 0,
- tmp, &tmp_size, NULL);
+ tmp, &tmp_size, NULL);
if (result < 0 && result != GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE)
{
- gnutls_assert();
+ gnutls_assert ();
return result;
}
@@ -2185,7 +2188,7 @@ gnutls_x509_crq_set_key_purpose_oid (gnutls_x509_crq_t cert,
gnutls_assert ();
return result;
}
-
+
return 0;
}
diff --git a/lib/x509/extensions.c b/lib/x509/extensions.c
index aaee26faa7..d8826ec810 100644
--- a/lib/x509/extensions.c
+++ b/lib/x509/extensions.c
@@ -34,9 +34,9 @@
#include <gnutls_datum.h>
static int
-get_extension (ASN1_TYPE asn, const char* root,
- const char *extension_id, int indx,
- gnutls_datum_t * ret, unsigned int *_critical)
+get_extension (ASN1_TYPE asn, const char *root,
+ const char *extension_id, int indx,
+ gnutls_datum_t * ret, unsigned int *_critical)
{
int k, result, len;
char name[MAX_NAME_SIZE], name2[MAX_NAME_SIZE];
@@ -101,8 +101,7 @@ get_extension (ASN1_TYPE asn, const char* root,
_gnutls_str_cat (name2, sizeof (name2), ".critical");
len = sizeof (str_critical);
- result =
- asn1_read_value (asn, name2, str_critical, &len);
+ result = asn1_read_value (asn, name2, str_critical, &len);
if (result == ASN1_ELEMENT_NOT_FOUND)
{
@@ -172,7 +171,8 @@ _gnutls_x509_crt_get_extension (gnutls_x509_crt_t cert,
const char *extension_id, int indx,
gnutls_datum_t * ret, unsigned int *_critical)
{
- return get_extension( cert->cert, "tbsCertificate.extensions", extension_id, indx, ret, _critical);
+ return get_extension (cert->cert, "tbsCertificate.extensions", extension_id,
+ indx, ret, _critical);
}
int
@@ -180,7 +180,8 @@ _gnutls_x509_crl_get_extension (gnutls_x509_crl_t crl,
const char *extension_id, int indx,
gnutls_datum_t * ret, unsigned int *_critical)
{
- return get_extension( crl->crl, "tbsCertList.crlExtensions", extension_id, indx, ret, _critical);
+ return get_extension (crl->crl, "tbsCertList.crlExtensions", extension_id,
+ indx, ret, _critical);
}
@@ -191,8 +192,8 @@ _gnutls_x509_crl_get_extension (gnutls_x509_crl_t crl,
* be returned.
*/
static int
-get_extension_oid (ASN1_TYPE asn, const char* root,
- int indx, void *oid, size_t * sizeof_oid)
+get_extension_oid (ASN1_TYPE asn, const char *root,
+ int indx, void *oid, size_t * sizeof_oid)
{
int k, result, len;
char name[MAX_NAME_SIZE], name2[MAX_NAME_SIZE];
@@ -284,14 +285,16 @@ int
_gnutls_x509_crt_get_extension_oid (gnutls_x509_crt_t cert,
int indx, void *oid, size_t * sizeof_oid)
{
- return get_extension_oid( cert->cert, "tbsCertificate.extensions", indx, oid, sizeof_oid);
+ return get_extension_oid (cert->cert, "tbsCertificate.extensions", indx,
+ oid, sizeof_oid);
}
int
_gnutls_x509_crl_get_extension_oid (gnutls_x509_crl_t crl,
int indx, void *oid, size_t * sizeof_oid)
{
- return get_extension_oid( crl->crl, "tbsCertList.crlExtensions", indx, oid, sizeof_oid);
+ return get_extension_oid (crl->crl, "tbsCertList.crlExtensions", indx, oid,
+ sizeof_oid);
}
/* This function will attempt to set the requested extension in
@@ -300,7 +303,7 @@ _gnutls_x509_crl_get_extension_oid (gnutls_x509_crl_t crl,
* Critical will be either 0 or 1.
*/
static int
-add_extension (ASN1_TYPE asn, const char* root, const char *extension_id,
+add_extension (ASN1_TYPE asn, const char *root, const char *extension_id,
const gnutls_datum_t * ext_data, unsigned int critical)
{
int result;
@@ -323,8 +326,7 @@ add_extension (ASN1_TYPE asn, const char* root, const char *extension_id,
else
snprintf (name, sizeof (name), "?LAST.extnID");
- result =
- asn1_write_value (asn, name, extension_id, 1);
+ result = asn1_write_value (asn, name, extension_id, 1);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
@@ -341,8 +343,7 @@ add_extension (ASN1_TYPE asn, const char* root, const char *extension_id,
else
snprintf (name, sizeof (name), "?LAST.critical");
- result =
- asn1_write_value (asn, name, str, 1);
+ result = asn1_write_value (asn, name, str, 1);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
@@ -354,8 +355,7 @@ add_extension (ASN1_TYPE asn, const char* root, const char *extension_id,
else
snprintf (name, sizeof (name), "?LAST.extnValue");
- result =
- _gnutls_x509_write_value (asn, name, ext_data, 0);
+ result = _gnutls_x509_write_value (asn, name, ext_data, 0);
if (result < 0)
{
gnutls_assert ();
@@ -369,7 +369,7 @@ add_extension (ASN1_TYPE asn, const char* root, const char *extension_id,
* index here starts from one.
*/
static int
-overwrite_extension (ASN1_TYPE asn, const char* root, unsigned int indx,
+overwrite_extension (ASN1_TYPE asn, const char *root, unsigned int indx,
const gnutls_datum_t * ext_data, unsigned int critical)
{
char name[MAX_NAME_SIZE], name2[MAX_NAME_SIZE];
@@ -410,10 +410,9 @@ overwrite_extension (ASN1_TYPE asn, const char* root, unsigned int indx,
}
static int
-set_extension (ASN1_TYPE asn, const char* root,
- const char *ext_id,
- const gnutls_datum_t * ext_data,
- unsigned int critical)
+set_extension (ASN1_TYPE asn, const char *root,
+ const char *ext_id,
+ const gnutls_datum_t * ext_data, unsigned int critical)
{
int result;
int k, len;
@@ -428,9 +427,9 @@ set_extension (ASN1_TYPE asn, const char* root,
k++;
if (root[0] != 0)
- snprintf (name, sizeof (name), "%s.?%u", root, k);
+ snprintf (name, sizeof (name), "%s.?%u", root, k);
else
- snprintf (name, sizeof (name), "?%u", k);
+ snprintf (name, sizeof (name), "?%u", k);
len = sizeof (extnID) - 1;
result = asn1_read_value (asn, name, extnID, &len);
@@ -503,7 +502,8 @@ _gnutls_x509_crt_set_extension (gnutls_x509_crt_t cert,
const gnutls_datum_t * ext_data,
unsigned int critical)
{
- return set_extension( cert->cert, "tbsCertificate.extensions", ext_id, ext_data, critical);
+ return set_extension (cert->cert, "tbsCertificate.extensions", ext_id,
+ ext_data, critical);
}
int
@@ -512,7 +512,8 @@ _gnutls_x509_crl_set_extension (gnutls_x509_crl_t crl,
const gnutls_datum_t * ext_data,
unsigned int critical)
{
- return set_extension( crl->crl, "tbsCertList.crlExtensions", ext_id, ext_data, critical);
+ return set_extension (crl->crl, "tbsCertList.crlExtensions", ext_id,
+ ext_data, critical);
}
#ifdef ENABLE_PKI
@@ -523,28 +524,28 @@ _gnutls_x509_crq_set_extension (gnutls_x509_crq_t crq,
unsigned int critical)
{
unsigned char extensions[MAX_CRQ_EXTENSIONS_SIZE];
- size_t extensions_size = sizeof(extensions);
+ size_t extensions_size = sizeof (extensions);
gnutls_datum der;
ASN1_TYPE c2;
int result;
result = gnutls_x509_crq_get_attribute_by_oid (crq, "1.2.840.113549.1.9.14",
- 0, extensions, &extensions_size);
+ 0, extensions,
+ &extensions_size);
if (result < 0)
{
- if (result == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE)
- {
- extensions_size = 0;
- }
- else
- {
- gnutls_assert ();
- return result;
- }
+ if (result == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE)
+ {
+ extensions_size = 0;
+ }
+ else
+ {
+ gnutls_assert ();
+ return result;
+ }
}
- result = asn1_create_element
- (_gnutls_get_pkix (), "PKIX1.Extensions", &c2);
+ result = asn1_create_element (_gnutls_get_pkix (), "PKIX1.Extensions", &c2);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
@@ -555,14 +556,14 @@ _gnutls_x509_crq_set_extension (gnutls_x509_crq_t crq,
{
result = asn1_der_decoding (&c2, extensions, extensions_size, NULL);
if (result != ASN1_SUCCESS)
- {
- gnutls_assert ();
- asn1_delete_structure (&c2);
- return _gnutls_asn2err (result);
- }
+ {
+ gnutls_assert ();
+ asn1_delete_structure (&c2);
+ return _gnutls_asn2err (result);
+ }
}
- result = set_extension( c2, "", ext_id, ext_data, critical);
+ result = set_extension (c2, "", ext_id, ext_data, critical);
if (result < 0)
{
gnutls_assert ();
@@ -581,7 +582,7 @@ _gnutls_x509_crq_set_extension (gnutls_x509_crq_t crq,
}
result = gnutls_x509_crq_set_attribute_by_oid (crq, "1.2.840.113549.1.9.14",
- der.data, der.size);
+ der.data, der.size);
if (result < 0)
{
@@ -589,7 +590,7 @@ _gnutls_x509_crq_set_extension (gnutls_x509_crq_t crq,
return result;
}
-
+
return 0;
}
@@ -763,10 +764,9 @@ _gnutls_x509_ext_gen_basicConstraints (int CA,
/* extract an INTEGER from the DER encoded extension
*/
int
-_gnutls_x509_ext_extract_number (opaque *number,
- size_t* _nr_size,
- opaque * extnValue,
- int extnValueLen)
+_gnutls_x509_ext_extract_number (opaque * number,
+ size_t * _nr_size,
+ opaque * extnValue, int extnValueLen)
{
ASN1_TYPE ext = ASN1_TYPE_EMPTY;
int result;
@@ -776,7 +776,8 @@ _gnutls_x509_ext_extract_number (opaque *number,
* to using INTEGER.
*/
if ((result = asn1_create_element
- (_gnutls_get_pkix (), "PKIX1.CertificateSerialNumber", &ext)) != ASN1_SUCCESS)
+ (_gnutls_get_pkix (), "PKIX1.CertificateSerialNumber",
+ &ext)) != ASN1_SUCCESS)
{
gnutls_assert ();
return _gnutls_asn2err (result);
@@ -797,7 +798,7 @@ _gnutls_x509_ext_extract_number (opaque *number,
result = _gnutls_asn2err (result);
else
result = 0;
-
+
*_nr_size = nr_size;
asn1_delete_structure (&ext);
@@ -808,13 +809,15 @@ _gnutls_x509_ext_extract_number (opaque *number,
/* generate an INTEGER in a DER encoded extension
*/
int
-_gnutls_x509_ext_gen_number (const opaque* number, size_t nr_size, gnutls_datum_t * der_ext)
+_gnutls_x509_ext_gen_number (const opaque * number, size_t nr_size,
+ gnutls_datum_t * der_ext)
{
ASN1_TYPE ext = ASN1_TYPE_EMPTY;
int result;
result =
- asn1_create_element (_gnutls_get_pkix (), "PKIX1.CertificateSerialNumber", &ext);
+ asn1_create_element (_gnutls_get_pkix (), "PKIX1.CertificateSerialNumber",
+ &ext);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
@@ -954,8 +957,10 @@ write_new_general_name (ASN1_TYPE ext, const char *ext_name,
*/
int
_gnutls_x509_ext_gen_subject_alt_name (gnutls_x509_subject_alt_name_t
- type, const void* data, unsigned int data_size,
- gnutls_datum_t* prev_der_ext, gnutls_datum_t * der_ext)
+ type, const void *data,
+ unsigned int data_size,
+ gnutls_datum_t * prev_der_ext,
+ gnutls_datum_t * der_ext)
{
ASN1_TYPE ext = ASN1_TYPE_EMPTY;
int result;
@@ -968,16 +973,19 @@ _gnutls_x509_ext_gen_subject_alt_name (gnutls_x509_subject_alt_name_t
return _gnutls_asn2err (result);
}
- if (prev_der_ext != NULL && prev_der_ext->data != NULL && prev_der_ext->size != 0)
+ if (prev_der_ext != NULL && prev_der_ext->data != NULL
+ && prev_der_ext->size != 0)
{
- result = asn1_der_decoding (&ext, prev_der_ext->data, prev_der_ext->size, NULL);
+ result =
+ asn1_der_decoding (&ext, prev_der_ext->data, prev_der_ext->size,
+ NULL);
if (result != ASN1_SUCCESS)
- {
- gnutls_assert ();
- asn1_delete_structure (&ext);
- return _gnutls_asn2err (result);
- }
+ {
+ gnutls_assert ();
+ asn1_delete_structure (&ext);
+ return _gnutls_asn2err (result);
+ }
}
result = write_new_general_name (ext, "", type, data, data_size);
@@ -1090,7 +1098,8 @@ _gnutls_x509_ext_gen_auth_key_id (const void *id, size_t id_size,
*/
int
_gnutls_x509_ext_gen_crl_dist_points (gnutls_x509_subject_alt_name_t
- type, const void *data, unsigned int data_size,
+ type, const void *data,
+ unsigned int data_size,
unsigned int reason_flags,
gnutls_datum_t * der_ext)
{
diff --git a/lib/x509/mpi.c b/lib/x509/mpi.c
index e1106c20d8..c4d86504ec 100644
--- a/lib/x509/mpi.c
+++ b/lib/x509/mpi.c
@@ -206,8 +206,8 @@ _gnutls_x509_read_dsa_pubkey (opaque * der, int dersize, bigint_t * params)
/* Extracts DSA and RSA parameters from a certificate.
*/
static int
- get_mpis (int pk_algorithm, ASN1_TYPE asn, const char* root,
- bigint_t * params, int *params_size)
+get_mpis (int pk_algorithm, ASN1_TYPE asn, const char *root,
+ bigint_t * params, int *params_size)
{
int result;
char name[256];
@@ -215,13 +215,13 @@ static int
/* Read the algorithm's parameters
*/
- snprintf(name, sizeof(name), "%s.subjectPublicKey", root);
+ snprintf (name, sizeof (name), "%s.subjectPublicKey", root);
result = _gnutls_x509_read_value (asn, name, &tmp, 2);
if (result < 0)
{
gnutls_assert ();
- fprintf(stderr, "name: %s\n", name);
+ fprintf (stderr, "name: %s\n", name);
return result;
}
@@ -274,7 +274,7 @@ static int
*/
_gnutls_free_datum (&tmp);
- snprintf(name, sizeof(name), "%s.algorithm.parameters", root);
+ snprintf (name, sizeof (name), "%s.algorithm.parameters", root);
result = _gnutls_x509_read_value (asn, name, &tmp, 0);
/* FIXME: If the parameters are not included in the certificate
@@ -325,8 +325,10 @@ _gnutls_x509_crt_get_mpis (gnutls_x509_crt_t cert,
/* Read the algorithm's OID
*/
pk_algorithm = gnutls_x509_crt_get_pk_algorithm (cert, NULL);
-
- return get_mpis( pk_algorithm, cert->cert, "tbsCertificate.subjectPublicKeyInfo", params, params_size);
+
+ return get_mpis (pk_algorithm, cert->cert,
+ "tbsCertificate.subjectPublicKeyInfo", params,
+ params_size);
}
/* Extracts DSA and RSA parameters from a certificate.
@@ -340,8 +342,10 @@ _gnutls_x509_crq_get_mpis (gnutls_x509_crq_t cert,
/* Read the algorithm's OID
*/
pk_algorithm = gnutls_x509_crq_get_pk_algorithm (cert, NULL);
-
- return get_mpis( pk_algorithm, cert->crq, "certificationRequestInfo.subjectPKInfo", params, params_size);
+
+ return get_mpis (pk_algorithm, cert->crq,
+ "certificationRequestInfo.subjectPKInfo", params,
+ params_size);
}
/*
diff --git a/lib/x509/output.c b/lib/x509/output.c
index 7cd78e6e8a..4eec33a2b7 100644
--- a/lib/x509/output.c
+++ b/lib/x509/output.c
@@ -94,44 +94,45 @@ asciiprint (gnutls_string * str, const char *data, size_t len)
addf (str, ".");
}
-static char* ip_to_string( void* _ip, int ip_size, char* string, int string_size)
+static char *
+ip_to_string (void *_ip, int ip_size, char *string, int string_size)
{
-uint8_t* ip;
+ uint8_t *ip;
- if (ip_size != 4 && ip_size != 16)
- {
- gnutls_assert();
- return NULL;
- }
+ if (ip_size != 4 && ip_size != 16)
+ {
+ gnutls_assert ();
+ return NULL;
+ }
- if (ip_size == 4 && string_size < 16)
- {
- gnutls_assert();
- return NULL;
- }
+ if (ip_size == 4 && string_size < 16)
+ {
+ gnutls_assert ();
+ return NULL;
+ }
- if (ip_size == 16 && string_size < 48)
- {
- gnutls_assert();
- return NULL;
- }
-
- ip = _ip;
- switch(ip_size)
- {
- case 4:
- sprintf(string, "%u.%u.%u.%u", ip[0], ip[1], ip[2], ip[3]);
- break;
- case 16:
- sprintf(string, "%x:%x:%x:%x:%x:%x:%x:%x",
- (ip[0] << 8) | ip[1], (ip[2] << 8) | ip[3],
- (ip[4] << 8) | ip[5], (ip[6] <<8) | ip[7],
- (ip[8] << 8) | ip[9], (ip[10] << 8) | ip[11],
- (ip[12] << 8)| ip[13], (ip[14] << 8) | ip[15]);
- break;
- }
-
- return string;
+ if (ip_size == 16 && string_size < 48)
+ {
+ gnutls_assert ();
+ return NULL;
+ }
+
+ ip = _ip;
+ switch (ip_size)
+ {
+ case 4:
+ sprintf (string, "%u.%u.%u.%u", ip[0], ip[1], ip[2], ip[3]);
+ break;
+ case 16:
+ sprintf (string, "%x:%x:%x:%x:%x:%x:%x:%x",
+ (ip[0] << 8) | ip[1], (ip[2] << 8) | ip[3],
+ (ip[4] << 8) | ip[5], (ip[6] << 8) | ip[7],
+ (ip[8] << 8) | ip[9], (ip[10] << 8) | ip[11],
+ (ip[12] << 8) | ip[13], (ip[14] << 8) | ip[15]);
+ break;
+ }
+
+ return string;
}
static void
@@ -211,7 +212,8 @@ print_ski (gnutls_string * str, gnutls_x509_crt_t cert)
#define TYPE_CRT 2
#define TYPE_CRQ 3
-typedef union {
+typedef union
+{
gnutls_x509_crt_t crt;
gnutls_x509_crq_t crq;
gnutls_x509_crl_t crl;
@@ -225,13 +227,16 @@ print_aki (gnutls_string * str, int type, cert_type_t cert)
int err;
if (type == TYPE_CRT)
- err = gnutls_x509_crt_get_authority_key_id (cert.crt, buffer, &size, NULL);
+ err =
+ gnutls_x509_crt_get_authority_key_id (cert.crt, buffer, &size, NULL);
else if (type == TYPE_CRL)
- err = gnutls_x509_crl_get_authority_key_id (cert.crl, buffer, &size, NULL);
- else {
- gnutls_assert();
- return;
- }
+ err =
+ gnutls_x509_crl_get_authority_key_id (cert.crl, buffer, &size, NULL);
+ else
+ {
+ gnutls_assert ();
+ return;
+ }
if (err != GNUTLS_E_SHORT_MEMORY_BUFFER)
{
@@ -247,9 +252,11 @@ print_aki (gnutls_string * str, int type, cert_type_t cert)
}
if (type == TYPE_CRT)
- err = gnutls_x509_crt_get_authority_key_id (cert.crt, buffer, &size, NULL);
+ err =
+ gnutls_x509_crt_get_authority_key_id (cert.crt, buffer, &size, NULL);
else
- err = gnutls_x509_crl_get_authority_key_id (cert.crl, buffer, &size, NULL);
+ err =
+ gnutls_x509_crl_get_authority_key_id (cert.crl, buffer, &size, NULL);
if (err < 0)
{
@@ -266,7 +273,8 @@ print_aki (gnutls_string * str, int type, cert_type_t cert)
}
static void
-print_key_usage (gnutls_string * str, const char* prefix, int type, cert_type_t cert)
+print_key_usage (gnutls_string * str, const char *prefix, int type,
+ cert_type_t cert)
{
unsigned int key_usage;
int err;
@@ -312,7 +320,7 @@ print_crldist (gnutls_string * str, gnutls_x509_crt_t cert)
char *buffer = NULL;
size_t size;
char str_ip[64];
- char* p;
+ char *p;
int err;
int indx;
@@ -361,8 +369,9 @@ print_crldist (gnutls_string * str, gnutls_x509_crt_t cert)
addf (str, "\t\t\tURI: %.*s\n", size, buffer);
break;
case GNUTLS_SAN_IPADDRESS:
- p = ip_to_string(buffer, size, str_ip, sizeof(str_ip));
- if (p == NULL) p = ERROR_STR;
+ p = ip_to_string (buffer, size, str_ip, sizeof (str_ip));
+ if (p == NULL)
+ p = ERROR_STR;
addf (str, "\t\t\tIPAddress: %s\n", p);
break;
case GNUTLS_SAN_DN:
@@ -378,7 +387,8 @@ print_crldist (gnutls_string * str, gnutls_x509_crt_t cert)
}
static void
-print_key_purpose (gnutls_string * str, const char* prefix, int type, cert_type_t cert)
+print_key_purpose (gnutls_string * str, const char *prefix, int type,
+ cert_type_t cert)
{
int indx;
char *buffer = NULL;
@@ -389,12 +399,13 @@ print_key_purpose (gnutls_string * str, const char* prefix, int type, cert_type_
{
size = 0;
if (type == TYPE_CRT)
- err = gnutls_x509_crt_get_key_purpose_oid (cert.crt, indx, buffer,
- &size, NULL);
+ err = gnutls_x509_crt_get_key_purpose_oid (cert.crt, indx, buffer,
+ &size, NULL);
else if (type == TYPE_CRQ)
- err = gnutls_x509_crq_get_key_purpose_oid (cert.crq, indx, buffer,
- &size, NULL);
- else return;
+ err = gnutls_x509_crq_get_key_purpose_oid (cert.crq, indx, buffer,
+ &size, NULL);
+ else
+ return;
if (err == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE)
return;
@@ -413,11 +424,11 @@ print_key_purpose (gnutls_string * str, const char* prefix, int type, cert_type_
}
if (type == TYPE_CRT)
- err = gnutls_x509_crt_get_key_purpose_oid (cert.crt, indx, buffer,
- &size, NULL);
+ err = gnutls_x509_crt_get_key_purpose_oid (cert.crt, indx, buffer,
+ &size, NULL);
else
- err = gnutls_x509_crq_get_key_purpose_oid (cert.crq, indx, buffer,
- &size, NULL);
+ err = gnutls_x509_crq_get_key_purpose_oid (cert.crq, indx, buffer,
+ &size, NULL);
if (err < 0)
{
@@ -451,17 +462,21 @@ print_key_purpose (gnutls_string * str, const char* prefix, int type, cert_type_
#endif
static void
-print_basic (gnutls_string * str, const char* prefix, int type, cert_type_t cert)
+print_basic (gnutls_string * str, const char *prefix, int type,
+ cert_type_t cert)
{
int pathlen;
int err;
if (type == TYPE_CRT)
- err = gnutls_x509_crt_get_basic_constraints (cert.crt, NULL, NULL, &pathlen);
+ err =
+ gnutls_x509_crt_get_basic_constraints (cert.crt, NULL, NULL, &pathlen);
else if (type == TYPE_CRQ)
- err = gnutls_x509_crq_get_basic_constraints (cert.crq, NULL, NULL, &pathlen);
- else return;
-
+ err =
+ gnutls_x509_crq_get_basic_constraints (cert.crq, NULL, NULL, &pathlen);
+ else
+ return;
+
if (err < 0)
{
addf (str, "error: get_basic_constraints: %s\n", gnutls_strerror (err));
@@ -479,11 +494,12 @@ print_basic (gnutls_string * str, const char* prefix, int type, cert_type_t cert
static void
-print_san (gnutls_string * str, const char* prefix, int type, cert_type_t cert)
+print_san (gnutls_string * str, const char *prefix, int type,
+ cert_type_t cert)
{
unsigned int san_idx;
char str_ip[64];
- char* p;
+ char *p;
for (san_idx = 0;; san_idx++)
{
@@ -492,12 +508,15 @@ print_san (gnutls_string * str, const char* prefix, int type, cert_type_t cert)
int err;
if (type == TYPE_CRT)
- err = gnutls_x509_crt_get_subject_alt_name (cert.crt, san_idx, buffer, &size,
- NULL);
+ err =
+ gnutls_x509_crt_get_subject_alt_name (cert.crt, san_idx, buffer,
+ &size, NULL);
else if (type == TYPE_CRQ)
- err = gnutls_x509_crq_get_subject_alt_name (cert.crq, san_idx, buffer, &size,
- NULL, NULL);
- else return;
+ err =
+ gnutls_x509_crq_get_subject_alt_name (cert.crq, san_idx, buffer,
+ &size, NULL, NULL);
+ else
+ return;
if (err == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE)
break;
@@ -516,11 +535,13 @@ print_san (gnutls_string * str, const char* prefix, int type, cert_type_t cert)
}
if (type == TYPE_CRT)
- err = gnutls_x509_crt_get_subject_alt_name (cert.crt, san_idx, buffer, &size,
- NULL);
+ err =
+ gnutls_x509_crt_get_subject_alt_name (cert.crt, san_idx, buffer,
+ &size, NULL);
else if (type == TYPE_CRQ)
- err = gnutls_x509_crq_get_subject_alt_name (cert.crq, san_idx, buffer, &size,
- NULL, NULL);
+ err =
+ gnutls_x509_crq_get_subject_alt_name (cert.crq, san_idx, buffer,
+ &size, NULL, NULL);
if (err < 0)
{
@@ -544,8 +565,9 @@ print_san (gnutls_string * str, const char* prefix, int type, cert_type_t cert)
addf (str, "%s\t\t\tURI: %.*s\n", prefix, size, buffer);
break;
case GNUTLS_SAN_IPADDRESS:
- p = ip_to_string(buffer, size, str_ip, sizeof(str_ip));
- if (p == NULL) p = ERROR_STR;
+ p = ip_to_string (buffer, size, str_ip, sizeof (str_ip));
+ if (p == NULL)
+ p = ERROR_STR;
addf (str, "%s\t\t\tIPAddress: %s\n", prefix, p);
break;
case GNUTLS_SAN_DN:
@@ -558,13 +580,13 @@ print_san (gnutls_string * str, const char* prefix, int type, cert_type_t cert)
size_t oidsize;
oidsize = 0;
- if (type == TYPE_CRT)
- err = gnutls_x509_crt_get_subject_alt_othername_oid
- (cert.crt, san_idx, oid, &oidsize);
- else if (type == TYPE_CRQ)
- err = gnutls_x509_crq_get_subject_alt_othername_oid
- (cert.crq, san_idx, oid, &oidsize);
-
+ if (type == TYPE_CRT)
+ err = gnutls_x509_crt_get_subject_alt_othername_oid
+ (cert.crt, san_idx, oid, &oidsize);
+ else if (type == TYPE_CRQ)
+ err = gnutls_x509_crq_get_subject_alt_othername_oid
+ (cert.crq, san_idx, oid, &oidsize);
+
if (err != GNUTLS_E_SHORT_MEMORY_BUFFER)
{
gnutls_free (buffer);
@@ -581,12 +603,12 @@ print_san (gnutls_string * str, const char* prefix, int type, cert_type_t cert)
return;
}
- if (type == TYPE_CRT)
- err = gnutls_x509_crt_get_subject_alt_othername_oid
- (cert.crt, san_idx, oid, &oidsize);
- else if (type == TYPE_CRQ)
- err = gnutls_x509_crq_get_subject_alt_othername_oid
- (cert.crq, san_idx, oid, &oidsize);
+ if (type == TYPE_CRT)
+ err = gnutls_x509_crt_get_subject_alt_othername_oid
+ (cert.crt, san_idx, oid, &oidsize);
+ else if (type == TYPE_CRQ)
+ err = gnutls_x509_crq_get_subject_alt_othername_oid
+ (cert.crq, san_idx, oid, &oidsize);
if (err < 0)
{
gnutls_free (buffer);
@@ -597,10 +619,12 @@ print_san (gnutls_string * str, const char* prefix, int type, cert_type_t cert)
}
if (err == GNUTLS_SAN_OTHERNAME_XMPP)
- addf (str, _("%s\t\t\tXMPP Address: %.*s\n"), prefix, size, buffer);
+ addf (str, _("%s\t\t\tXMPP Address: %.*s\n"), prefix, size,
+ buffer);
else
{
- addf (str, _("%s\t\t\totherName OID: %.*s\n"), prefix, oidsize, oid);
+ addf (str, _("%s\t\t\totherName OID: %.*s\n"), prefix,
+ oidsize, oid);
addf (str, _("%s\t\t\totherName DER: "), prefix);
hexprint (str, buffer, size);
addf (str, _("\n%s\t\t\totherName ASCII: "), prefix);
@@ -620,230 +644,244 @@ print_san (gnutls_string * str, const char* prefix, int type, cert_type_t cert)
}
}
-static void print_extensions( gnutls_string * str, const char* prefix, int type, cert_type_t cert)
+static void
+print_extensions (gnutls_string * str, const char *prefix, int type,
+ cert_type_t cert)
{
-int i, err;
+ int i, err;
- for (i = 0;; i++)
+ for (i = 0;; i++)
+ {
+ char oid[MAX_OID_SIZE] = "";
+ size_t sizeof_oid = sizeof (oid);
+ int critical;
+ size_t san_idx = 0;
+ size_t proxy_idx = 0;
+ size_t basic_idx = 0;
+ size_t keyusage_idx = 0;
+ size_t keypurpose_idx = 0;
+ size_t ski_idx = 0;
+ size_t aki_idx = 0;
+ size_t crldist_idx = 0;
+
+ if (type == TYPE_CRT)
+ err = gnutls_x509_crt_get_extension_info (cert.crt, i,
+ oid, &sizeof_oid,
+ &critical);
+
+ else if (type == TYPE_CRQ)
+ err = gnutls_x509_crq_get_extension_info (cert.crq, i,
+ oid, &sizeof_oid,
+ &critical);
+ else
{
- char oid[MAX_OID_SIZE] = "";
- size_t sizeof_oid = sizeof (oid);
- int critical;
- size_t san_idx = 0;
- size_t proxy_idx = 0;
- size_t basic_idx = 0;
- size_t keyusage_idx = 0;
- size_t keypurpose_idx = 0;
- size_t ski_idx = 0;
- size_t aki_idx = 0;
- size_t crldist_idx = 0;
+ gnutls_assert ();
+ return;
+ }
- if (type == TYPE_CRT)
- err = gnutls_x509_crt_get_extension_info (cert.crt, i,
- oid, &sizeof_oid,
- &critical);
+ if (err < 0)
+ {
+ if (err == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE)
+ break;
+ addf (str, "error: get_extension_info: %s\n",
+ gnutls_strerror (err));
+ continue;
+ }
- else if (type == TYPE_CRQ)
- err = gnutls_x509_crq_get_extension_info (cert.crq, i,
- oid, &sizeof_oid,
- &critical);
- else {
- gnutls_assert();
- return;
- }
+ if (i == 0)
+ addf (str, _("%s\tExtensions:\n"), prefix);
- if (err < 0)
+ if (strcmp (oid, "2.5.29.19") == 0)
+ {
+ if (basic_idx)
{
- if (err == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE)
- break;
- addf (str, "error: get_extension_info: %s\n",
- gnutls_strerror (err));
+ addf (str, "error: more than one basic constraint\n");
continue;
}
- if (i == 0)
- addf (str, _("%s\tExtensions:\n"), prefix);
-
- if (strcmp (oid, "2.5.29.19") == 0)
- {
- if (basic_idx)
- {
- addf (str, "error: more than one basic constraint\n");
- continue;
- }
-
- addf (str, _("%s\t\tBasic Constraints (%s):\n"), prefix,
- critical ? _("critical") : _("not critical"));
+ addf (str, _("%s\t\tBasic Constraints (%s):\n"), prefix,
+ critical ? _("critical") : _("not critical"));
- print_basic (str, prefix, type, cert);
+ print_basic (str, prefix, type, cert);
- basic_idx++;
- }
- else if (strcmp (oid, "2.5.29.14") == 0)
+ basic_idx++;
+ }
+ else if (strcmp (oid, "2.5.29.14") == 0)
+ {
+ if (ski_idx)
{
- if (ski_idx)
- {
- addf (str, "error: more than one SKI extension\n");
- continue;
- }
+ addf (str, "error: more than one SKI extension\n");
+ continue;
+ }
- addf (str, _("%s\t\tSubject Key Identifier (%s):\n"), prefix,
- critical ? _("critical") : _("not critical"));
+ addf (str, _("%s\t\tSubject Key Identifier (%s):\n"), prefix,
+ critical ? _("critical") : _("not critical"));
- if (type == TYPE_CRT) print_ski (str, cert.crt);
+ if (type == TYPE_CRT)
+ print_ski (str, cert.crt);
- ski_idx++;
- }
- else if (strcmp (oid, "2.5.29.35") == 0)
- {
+ ski_idx++;
+ }
+ else if (strcmp (oid, "2.5.29.35") == 0)
+ {
- if (aki_idx)
- {
- addf (str, "error: more than one AKI extension\n");
- continue;
- }
+ if (aki_idx)
+ {
+ addf (str, "error: more than one AKI extension\n");
+ continue;
+ }
- addf (str, _("%s\t\tAuthority Key Identifier (%s):\n"), prefix,
- critical ? _("critical") : _("not critical"));
+ addf (str, _("%s\t\tAuthority Key Identifier (%s):\n"), prefix,
+ critical ? _("critical") : _("not critical"));
- if (type == TYPE_CRT) print_aki (str, TYPE_CRT, cert);
+ if (type == TYPE_CRT)
+ print_aki (str, TYPE_CRT, cert);
- aki_idx++;
- }
- else if (strcmp (oid, "2.5.29.15") == 0)
+ aki_idx++;
+ }
+ else if (strcmp (oid, "2.5.29.15") == 0)
+ {
+ if (keyusage_idx)
{
- if (keyusage_idx)
- {
- addf (str, "error: more than one key usage extension\n");
- continue;
- }
+ addf (str, "error: more than one key usage extension\n");
+ continue;
+ }
- addf (str, _("%s\t\tKey Usage (%s):\n"), prefix,
- critical ? _("critical") : _("not critical"));
+ addf (str, _("%s\t\tKey Usage (%s):\n"), prefix,
+ critical ? _("critical") : _("not critical"));
- print_key_usage (str, prefix, type, cert);
+ print_key_usage (str, prefix, type, cert);
- keyusage_idx++;
- }
- else if (strcmp (oid, "2.5.29.37") == 0)
+ keyusage_idx++;
+ }
+ else if (strcmp (oid, "2.5.29.37") == 0)
+ {
+ if (keypurpose_idx)
{
- if (keypurpose_idx)
- {
- addf (str, "error: more than one key purpose extension\n");
- continue;
- }
+ addf (str, "error: more than one key purpose extension\n");
+ continue;
+ }
- addf (str, _("%s\t\tKey Purpose (%s):\n"), prefix,
- critical ? _("critical") : _("not critical"));
+ addf (str, _("%s\t\tKey Purpose (%s):\n"), prefix,
+ critical ? _("critical") : _("not critical"));
#ifdef ENABLE_PKI
- print_key_purpose (str, prefix, type, cert);
+ print_key_purpose (str, prefix, type, cert);
#endif
- keypurpose_idx++;
- }
- else if (strcmp (oid, "2.5.29.17") == 0)
+ keypurpose_idx++;
+ }
+ else if (strcmp (oid, "2.5.29.17") == 0)
+ {
+ if (san_idx)
{
- if (san_idx)
- {
- addf (str, "error: more than one SKI extension\n");
- continue;
- }
+ addf (str, "error: more than one SKI extension\n");
+ continue;
+ }
- addf (str, _("%s\t\tSubject Alternative Name (%s):\n"), prefix,
- critical ? _("critical") : _("not critical"));
+ addf (str, _("%s\t\tSubject Alternative Name (%s):\n"), prefix,
+ critical ? _("critical") : _("not critical"));
- print_san (str, prefix, type, cert);
+ print_san (str, prefix, type, cert);
- san_idx++;
- }
- else if (strcmp (oid, "2.5.29.31") == 0)
+ san_idx++;
+ }
+ else if (strcmp (oid, "2.5.29.31") == 0)
+ {
+ if (crldist_idx)
{
- if (crldist_idx)
- {
- addf (str, "error: more than one CRL distribution point\n");
- continue;
- }
+ addf (str, "error: more than one CRL distribution point\n");
+ continue;
+ }
- addf (str, _("%s\t\tCRL Distribution points (%s):\n"), prefix,
- critical ? _("critical") : _("not critical"));
+ addf (str, _("%s\t\tCRL Distribution points (%s):\n"), prefix,
+ critical ? _("critical") : _("not critical"));
#ifdef ENABLE_PKI
- if (type == TYPE_CRT) print_crldist (str, cert.crt);
+ if (type == TYPE_CRT)
+ print_crldist (str, cert.crt);
#endif
- crldist_idx++;
- }
- else if (strcmp (oid, "1.3.6.1.5.5.7.1.14") == 0)
+ crldist_idx++;
+ }
+ else if (strcmp (oid, "1.3.6.1.5.5.7.1.14") == 0)
+ {
+ if (proxy_idx)
{
- if (proxy_idx)
- {
- addf (str, "error: more than one proxy extension\n");
- continue;
- }
+ addf (str, "error: more than one proxy extension\n");
+ continue;
+ }
- addf (str, _("%s\t\tProxy Certificate Information (%s):\n"), prefix,
- critical ? _("critical") : _("not critical"));
+ addf (str, _("%s\t\tProxy Certificate Information (%s):\n"), prefix,
+ critical ? _("critical") : _("not critical"));
- if (type == TYPE_CRT) print_proxy (str, cert.crt);
+ if (type == TYPE_CRT)
+ print_proxy (str, cert.crt);
- proxy_idx++;
- }
+ proxy_idx++;
+ }
+ else
+ {
+ char *buffer;
+ size_t extlen = 0;
+
+ addf (str, _("%s\t\tUnknown extension %s (%s):\n"), prefix, oid,
+ critical ? _("critical") : _("not critical"));
+
+ if (type == TYPE_CRT)
+ err =
+ gnutls_x509_crt_get_extension_data (cert.crt, i, NULL, &extlen);
+ else if (type == TYPE_CRQ)
+ err =
+ gnutls_x509_crq_get_extension_data (cert.crq, i, NULL, &extlen);
else
{
- char *buffer;
- size_t extlen = 0;
-
- addf (str, _("%s\t\tUnknown extension %s (%s):\n"), prefix, oid,
- critical ? _("critical") : _("not critical"));
+ gnutls_assert ();
+ return;
+ }
- if (type == TYPE_CRT)
- err = gnutls_x509_crt_get_extension_data (cert.crt, i, NULL, &extlen);
- else if (type == TYPE_CRQ)
- err = gnutls_x509_crq_get_extension_data (cert.crq, i, NULL, &extlen);
- else {
- gnutls_assert();
- return;
- }
-
- if (err < 0)
- {
- addf (str, "error: get_extension_data: %s\n",
- gnutls_strerror (err));
- continue;
- }
+ if (err < 0)
+ {
+ addf (str, "error: get_extension_data: %s\n",
+ gnutls_strerror (err));
+ continue;
+ }
- buffer = gnutls_malloc (extlen);
- if (!buffer)
- {
- addf (str, "error: malloc: %s\n", gnutls_strerror (err));
- continue;
- }
+ buffer = gnutls_malloc (extlen);
+ if (!buffer)
+ {
+ addf (str, "error: malloc: %s\n", gnutls_strerror (err));
+ continue;
+ }
- if (type == TYPE_CRT)
- err = gnutls_x509_crt_get_extension_data (cert.crt, i, buffer, &extlen);
- else if (type == TYPE_CRQ)
- err = gnutls_x509_crq_get_extension_data (cert.crq, i, buffer, &extlen);
+ if (type == TYPE_CRT)
+ err =
+ gnutls_x509_crt_get_extension_data (cert.crt, i, buffer,
+ &extlen);
+ else if (type == TYPE_CRQ)
+ err =
+ gnutls_x509_crq_get_extension_data (cert.crq, i, buffer,
+ &extlen);
- if (err < 0)
- {
- gnutls_free (buffer);
- addf (str, "error: get_extension_data2: %s\n",
- gnutls_strerror (err));
- continue;
- }
+ if (err < 0)
+ {
+ gnutls_free (buffer);
+ addf (str, "error: get_extension_data2: %s\n",
+ gnutls_strerror (err));
+ continue;
+ }
- addf (str, _("%s\t\t\tASCII: "), prefix);
- asciiprint (str, buffer, extlen);
- addf (str, "\n");
+ addf (str, _("%s\t\t\tASCII: "), prefix);
+ asciiprint (str, buffer, extlen);
+ addf (str, "\n");
- addf (str, _("%s\t\t\tHexdump: "), prefix);
- hexprint (str, buffer, extlen);
- adds (str, "\n");
+ addf (str, _("%s\t\t\tHexdump: "), prefix);
+ hexprint (str, buffer, extlen);
+ adds (str, "\n");
- gnutls_free (buffer);
- }
+ gnutls_free (buffer);
}
+ }
}
static void
@@ -1016,9 +1054,9 @@ print_cert (gnutls_string * str, gnutls_x509_crt_t cert, int notsigned)
if (gnutls_x509_crt_get_version (cert) >= 3)
{
cert_type_t ccert;
-
+
ccert.crt = cert;
- print_extensions( str, "", TYPE_CRT, ccert);
+ print_extensions (str, "", TYPE_CRT, ccert);
}
/* Signature. */
@@ -1423,33 +1461,33 @@ print_crl (gnutls_string * str, gnutls_x509_crl_t crl, int notsigned)
if (strcmp (oid, "2.5.29.20") == 0)
{
char nr[128];
- size_t nr_size = sizeof(nr);
-
+ size_t nr_size = sizeof (nr);
+
if (crl_nr)
{
addf (str, "error: more than one CRL number\n");
continue;
}
- err = gnutls_x509_crl_get_number (crl, nr, &nr_size, &critical);
+ err = gnutls_x509_crl_get_number (crl, nr, &nr_size, &critical);
addf (str, _("\t\tCRL Number (%s): "),
critical ? _("critical") : _("not critical"));
- if (err < 0)
- addf (str, "error: get_number: %s\n", gnutls_strerror (err));
- else
- {
- hexprint (str, nr, nr_size);
- addf (str, "\n");
- }
+ if (err < 0)
+ addf (str, "error: get_number: %s\n", gnutls_strerror (err));
+ else
+ {
+ hexprint (str, nr, nr_size);
+ addf (str, "\n");
+ }
crl_nr++;
}
else if (strcmp (oid, "2.5.29.35") == 0)
{
cert_type_t ccert;
-
+
if (aki_idx)
{
addf (str, "error: more than one AKI extension\n");
@@ -1459,7 +1497,7 @@ print_crl (gnutls_string * str, gnutls_x509_crl_t crl, int notsigned)
addf (str, _("\t\tAuthority Key Identifier (%s):\n"),
critical ? _("critical") : _("not critical"));
- ccert.crl = crl;
+ ccert.crl = crl;
print_aki (str, TYPE_CRL, ccert);
aki_idx++;
@@ -1655,17 +1693,17 @@ print_crq (gnutls_string * str, gnutls_x509_crq_t cert)
}
/* Subject */
- {
- char dn[1024];
- size_t dn_size = sizeof (dn);
- int err;
+ {
+ char dn[1024];
+ size_t dn_size = sizeof (dn);
+ int err;
- err = gnutls_x509_crq_get_dn (cert, dn, &dn_size);
- if (err < 0)
- addf (str, "error: get_dn: %s\n", gnutls_strerror (err));
- else
- addf (str, _("\tSubject: %s\n"), dn);
- }
+ err = gnutls_x509_crq_get_dn (cert, dn, &dn_size);
+ if (err < 0)
+ addf (str, "error: get_dn: %s\n", gnutls_strerror (err));
+ else
+ addf (str, _("\tSubject: %s\n"), dn);
+ }
/* SubjectPublicKeyInfo. */
{
@@ -1705,7 +1743,7 @@ print_crq (gnutls_string * str, gnutls_x509_crq_t cert)
}
break;
-#if 0 /* not implemented yet */
+#if 0 /* not implemented yet */
case GNUTLS_PK_DSA:
{
gnutls_datum_t p, q, g, y;
@@ -1741,110 +1779,111 @@ print_crq (gnutls_string * str, gnutls_x509_crq_t cert)
}
/* parse attributes */
- {
- size_t i;
- int err = 0;
+ {
+ size_t i;
+ int err = 0;
- for (i = 0;; i++)
- {
- char oid[MAX_OID_SIZE] = "";
- size_t sizeof_oid = sizeof (oid);
- int extensions = 0;
- int challenge = 0;
+ for (i = 0;; i++)
+ {
+ char oid[MAX_OID_SIZE] = "";
+ size_t sizeof_oid = sizeof (oid);
+ int extensions = 0;
+ int challenge = 0;
- err = gnutls_x509_crq_get_attribute_info (cert, i,
- oid, &sizeof_oid);
- if (err < 0)
- {
- if (err == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE)
- break;
- addf (str, "error: get_extension_info: %s\n",
- gnutls_strerror (err));
- continue;
- }
+ err = gnutls_x509_crq_get_attribute_info (cert, i, oid, &sizeof_oid);
+ if (err < 0)
+ {
+ if (err == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE)
+ break;
+ addf (str, "error: get_extension_info: %s\n",
+ gnutls_strerror (err));
+ continue;
+ }
- if (i == 0)
- addf (str, _("\tAttributes:\n"));
+ if (i == 0)
+ addf (str, _("\tAttributes:\n"));
- if (strcmp (oid, "1.2.840.113549.1.9.14") == 0)
- {
- cert_type_t ccert;
-
- if (extensions)
- {
- addf (str, "error: more than one extensionsRequest\n");
- continue;
- }
+ if (strcmp (oid, "1.2.840.113549.1.9.14") == 0)
+ {
+ cert_type_t ccert;
- ccert.crq = cert;
- print_extensions (str, "\t", TYPE_CRQ, ccert);
+ if (extensions)
+ {
+ addf (str, "error: more than one extensionsRequest\n");
+ continue;
+ }
- extensions++;
- }
- else if (strcmp (oid, "1.2.840.113549.1.9.7") == 0)
- {
- char pass[1024];
- size_t pass_size = sizeof (pass);
-
- if (challenge)
- {
- addf (str, "error: more than one Challenge password attribute\n");
- continue;
- }
+ ccert.crq = cert;
+ print_extensions (str, "\t", TYPE_CRQ, ccert);
- err = gnutls_x509_crq_get_challenge_password (cert, pass, &pass_size);
- if (err < 0)
- addf (str, "error: get_challenge_password: %s\n", gnutls_strerror (err));
- else
- addf (str, _("\t\tChallenge password: %s\n"), pass);
+ extensions++;
+ }
+ else if (strcmp (oid, "1.2.840.113549.1.9.7") == 0)
+ {
+ char pass[1024];
+ size_t pass_size = sizeof (pass);
- challenge++;
- }
- else
- {
- char *buffer;
- size_t extlen = 0;
+ if (challenge)
+ {
+ addf (str,
+ "error: more than one Challenge password attribute\n");
+ continue;
+ }
- addf (str, _("\t\tUnknown attribute %s:\n"), oid);
+ err =
+ gnutls_x509_crq_get_challenge_password (cert, pass, &pass_size);
+ if (err < 0)
+ addf (str, "error: get_challenge_password: %s\n",
+ gnutls_strerror (err));
+ else
+ addf (str, _("\t\tChallenge password: %s\n"), pass);
- err = gnutls_x509_crq_get_attribute_data (cert, i,
- NULL, &extlen);
- if (err < 0)
- {
- addf (str, "error: get_attribute_data: %s\n",
- gnutls_strerror (err));
- continue;
- }
+ challenge++;
+ }
+ else
+ {
+ char *buffer;
+ size_t extlen = 0;
- buffer = gnutls_malloc (extlen);
- if (!buffer)
- {
- addf (str, "error: malloc: %s\n", gnutls_strerror (err));
- continue;
- }
+ addf (str, _("\t\tUnknown attribute %s:\n"), oid);
- err = gnutls_x509_crq_get_attribute_data (cert, i,
- buffer, &extlen);
- if (err < 0)
- {
- gnutls_free (buffer);
- addf (str, "error: get_attribute_data2: %s\n",
- gnutls_strerror (err));
- continue;
- }
+ err = gnutls_x509_crq_get_attribute_data (cert, i, NULL, &extlen);
+ if (err < 0)
+ {
+ addf (str, "error: get_attribute_data: %s\n",
+ gnutls_strerror (err));
+ continue;
+ }
- addf (str, _("\t\t\tASCII: "));
- asciiprint (str, buffer, extlen);
- addf (str, "\n");
+ buffer = gnutls_malloc (extlen);
+ if (!buffer)
+ {
+ addf (str, "error: malloc: %s\n", gnutls_strerror (err));
+ continue;
+ }
- addf (str, _("\t\t\tHexdump: "));
- hexprint (str, buffer, extlen);
- adds (str, "\n");
+ err = gnutls_x509_crq_get_attribute_data (cert, i,
+ buffer, &extlen);
+ if (err < 0)
+ {
+ gnutls_free (buffer);
+ addf (str, "error: get_attribute_data2: %s\n",
+ gnutls_strerror (err));
+ continue;
+ }
- gnutls_free (buffer);
- }
- }
- }
+ addf (str, _("\t\t\tASCII: "));
+ asciiprint (str, buffer, extlen);
+ addf (str, "\n");
+
+ addf (str, _("\t\t\tHexdump: "));
+ hexprint (str, buffer, extlen);
+ adds (str, "\n");
+
+ gnutls_free (buffer);
+ }
+ }
+ }
}
/**
@@ -1870,7 +1909,9 @@ gnutls_x509_crq_print (gnutls_x509_crq_t crq,
_gnutls_string_init (&str, gnutls_malloc, gnutls_realloc, gnutls_free);
- _gnutls_string_append_str (&str, _("PKCS #10 Certificate Request Information:\n"));
+ _gnutls_string_append_str (&str,
+ _
+ ("PKCS #10 Certificate Request Information:\n"));
print_crq (&str, crq);
diff --git a/lib/x509/privkey.c b/lib/x509/privkey.c
index 6ff61147ad..53e2f28b7d 100644
--- a/lib/x509/privkey.c
+++ b/lib/x509/privkey.c
@@ -158,7 +158,7 @@ _gnutls_privkey_decode_pkcs1_rsa_key (const gnutls_datum_t * raw_key,
ASN1_TYPE pkey_asn;
gnutls_pk_params_st pk_params;
- memset( &pk_params, 0, sizeof(pk_params));
+ memset (&pk_params, 0, sizeof (pk_params));
pk_params.params_nr = RSA_PRIVATE_PARAMS;
if ((result =
@@ -1049,7 +1049,7 @@ _gnutls_asn1_encode_rsa (ASN1_TYPE * c2, bigint_t * params)
/* Ok. Now we have the data. Create the asn1 structures
*/
-
+
/* first make sure that no previously allocated data are leaked */
if (*c2 != ASN1_TYPE_EMPTY)
{
diff --git a/lib/x509/x509.c b/lib/x509/x509.c
index 34f5cb634c..76712740fe 100644
--- a/lib/x509/x509.c
+++ b/lib/x509/x509.c
@@ -906,8 +906,8 @@ is_type_printable (int type)
*/
int
_gnutls_parse_general_name (ASN1_TYPE src, const char *src_name,
- int seq, void *name, size_t * name_size,
- unsigned int *ret_type, int othername_oid)
+ int seq, void *name, size_t * name_size,
+ unsigned int *ret_type, int othername_oid)
{
unsigned int len;
char nptr[MAX_NAME_SIZE];
@@ -1132,13 +1132,14 @@ get_subject_alt_name (gnutls_x509_crt_t cert,
}
result =
- _gnutls_parse_general_name (c2, "", seq, ret, ret_size, ret_type, othername_oid);
+ _gnutls_parse_general_name (c2, "", seq, ret, ret_size, ret_type,
+ othername_oid);
asn1_delete_structure (&c2);
if (result < 0)
{
- gnutls_assert();
+ gnutls_assert ();
return result;
}
diff --git a/lib/x509/x509_write.c b/lib/x509/x509_write.c
index 773d6e46b2..858c86c6e0 100644
--- a/lib/x509/x509_write.c
+++ b/lib/x509/x509_write.c
@@ -298,13 +298,14 @@ gnutls_x509_crt_set_crq (gnutls_x509_crt_t crt, gnutls_x509_crq_t crq)
* negative error value.
**/
int
-gnutls_x509_crt_set_crq_extensions (gnutls_x509_crt_t crt, gnutls_x509_crq_t crq)
+gnutls_x509_crt_set_crq_extensions (gnutls_x509_crt_t crt,
+ gnutls_x509_crq_t crq)
{
int result, i;
char oid[MAX_OID_SIZE];
size_t oid_size;
opaque extensions[MAX_CRQ_EXTENSIONS_SIZE];
- size_t extensions_size = sizeof(extensions);
+ size_t extensions_size = sizeof (extensions);
unsigned int critical;
gnutls_datum ext;
@@ -314,41 +315,46 @@ gnutls_x509_crt_set_crq_extensions (gnutls_x509_crt_t crt, gnutls_x509_crq_t crq
return GNUTLS_E_INVALID_REQUEST;
}
- for (i=0;;i++)
+ for (i = 0;; i++)
{
- oid_size = sizeof(oid);
- result = gnutls_x509_crq_get_extension_info ( crq, i, oid, &oid_size, &critical);
+ oid_size = sizeof (oid);
+ result =
+ gnutls_x509_crq_get_extension_info (crq, i, oid, &oid_size,
+ &critical);
if (result < 0)
- {
- if (result == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE)
- break;
+ {
+ if (result == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE)
+ break;
- gnutls_assert();
- return result;
- }
+ gnutls_assert ();
+ return result;
+ }
- extensions_size = sizeof(extensions);
- result = gnutls_x509_crq_get_extension_data (crq, i, extensions, &extensions_size);
+ extensions_size = sizeof (extensions);
+ result =
+ gnutls_x509_crq_get_extension_data (crq, i, extensions,
+ &extensions_size);
if (result < 0)
- {
- gnutls_assert();
- return result;
- }
-
+ {
+ gnutls_assert ();
+ return result;
+ }
+
ext.data = extensions;
ext.size = extensions_size;
-
+
result = _gnutls_x509_crt_set_extension (crt, oid, &ext, critical);
if (result < 0)
- {
- gnutls_assert();
- return result;
- }
-
+ {
+ gnutls_assert ();
+ return result;
+ }
+
}
-
- if (i>0) crt->use_extensions = 1;
+
+ if (i > 0)
+ crt->use_extensions = 1;
return 0;
}
@@ -541,15 +547,17 @@ gnutls_x509_crt_set_subject_alternative_name (gnutls_x509_crt_t crt,
return GNUTLS_E_INVALID_REQUEST;
}
- /* only handle text extensions */
- if (type != GNUTLS_SAN_DNSNAME && type != GNUTLS_SAN_RFC822NAME &&
- type != GNUTLS_SAN_URI)
+ /* only handle text extensions */
+ if (type != GNUTLS_SAN_DNSNAME && type != GNUTLS_SAN_RFC822NAME &&
+ type != GNUTLS_SAN_URI)
{
- gnutls_assert();
+ gnutls_assert ();
return GNUTLS_E_INVALID_REQUEST;
}
- return gnutls_x509_crt_set_subject_alt_name( crt, type, data_string, strlen(data_string), GNUTLS_FSAN_SET);
+ return gnutls_x509_crt_set_subject_alt_name (crt, type, data_string,
+ strlen (data_string),
+ GNUTLS_FSAN_SET);
}
/**
@@ -890,7 +898,9 @@ gnutls_x509_crt_set_crl_dist_points (gnutls_x509_crt_t crt,
type, const void *data_string,
unsigned int reason_flags)
{
- return gnutls_x509_crt_set_crl_dist_points2( crt, type, data_string, strlen(data_string),reason_flags);
+ return gnutls_x509_crt_set_crl_dist_points2 (crt, type, data_string,
+ strlen (data_string),
+ reason_flags);
}
/**