summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Josefsson <simon@josefsson.org>2009-10-26 14:45:39 +0100
committerSimon Josefsson <simon@josefsson.org>2009-10-26 14:45:39 +0100
commit1b98628dfbecc2b6ad6f4c04181956176506cd1e (patch)
treeff92dfe234c15ce25ffa834530f787b8167554c6
parent05f02b46b6195f35d5bf48f55da7e1a027128906 (diff)
downloadgnutls-1b98628dfbecc2b6ad6f4c04181956176506cd1e.tar.gz
Fix code style so it compiles with gcc 4.4 with warnings.
-rw-r--r--lib/gnutls_cipher.c2
-rw-r--r--lib/gnutls_handshake.c101
-rw-r--r--src/certtool.c56
3 files changed, 84 insertions, 75 deletions
diff --git a/lib/gnutls_cipher.c b/lib/gnutls_cipher.c
index 5f2ed62060..7519821cf9 100644
--- a/lib/gnutls_cipher.c
+++ b/lib/gnutls_cipher.c
@@ -217,7 +217,7 @@ mac_init (digest_hd_st * td, gnutls_mac_algorithm_t mac, opaque * secret,
return ret;
}
-inline static void
+static void
mac_deinit (digest_hd_st * td, opaque * res, int ver)
{
if (ver == GNUTLS_SSL3)
diff --git a/lib/gnutls_handshake.c b/lib/gnutls_handshake.c
index 7d5a820165..4183122f9d 100644
--- a/lib/gnutls_handshake.c
+++ b/lib/gnutls_handshake.c
@@ -78,21 +78,26 @@ _gnutls_handshake_hash_add_recvd (gnutls_session_t session,
void
_gnutls_handshake_hash_buffers_clear (gnutls_session_t session)
{
- if (session->security_parameters.handshake_mac_handle_type == HANDSHAKE_MAC_TYPE_10)
+ if (session->security_parameters.
+ handshake_mac_handle_type == HANDSHAKE_MAC_TYPE_10)
{
- _gnutls_hash_deinit (&session->internals.handshake_mac_handle.tls10.md5, NULL);
- _gnutls_hash_deinit (&session->internals.handshake_mac_handle.tls10.sha, NULL);
+ _gnutls_hash_deinit (&session->internals.
+ handshake_mac_handle.tls10.md5, NULL);
+ _gnutls_hash_deinit (&session->internals.
+ handshake_mac_handle.tls10.sha, NULL);
}
- else if (session->security_parameters.handshake_mac_handle_type == HANDSHAKE_MAC_TYPE_12)
+ else if (session->security_parameters.
+ handshake_mac_handle_type == HANDSHAKE_MAC_TYPE_12)
{
- _gnutls_hash_deinit (&session->internals.handshake_mac_handle.tls12.mac, NULL);
+ _gnutls_hash_deinit (&session->internals.
+ handshake_mac_handle.tls12.mac, NULL);
}
session->security_parameters.handshake_mac_handle_type = 0;
session->internals.handshake_mac_handle_init = 0;
_gnutls_handshake_buffer_clear (session);
}
-/* this will copy the required values for resuming to
+/* this will copy the required values for resuming to
* internals, and to security_parameters.
* this will keep as less data to security_parameters.
*/
@@ -150,7 +155,7 @@ _gnutls_set_client_random (gnutls_session_t session, uint8_t * rnd)
GNUTLS_RANDOM_SIZE);
}
-/* Calculate The SSL3 Finished message
+/* Calculate The SSL3 Finished message
*/
#define SSL3_CLIENT_MSG "CLNT"
#define SSL3_SERVER_MSG "SRVR"
@@ -164,25 +169,25 @@ _gnutls_ssl3_finished (gnutls_session_t session, int type, opaque * ret)
const char *mesg;
int rc;
- if (session->security_parameters.handshake_mac_handle_type == HANDSHAKE_MAC_TYPE_10)
+ if (session->security_parameters.
+ handshake_mac_handle_type == HANDSHAKE_MAC_TYPE_10)
{
- rc =
- _gnutls_hash_copy (&td_md5, &session->internals.handshake_mac_handle.tls10.md5);
+ rc = _gnutls_hash_copy (&td_md5, &session->internals.
+ handshake_mac_handle.tls10.md5);
if (rc < 0)
- {
- gnutls_assert ();
- return rc;
- }
+ {
+ gnutls_assert ();
+ return rc;
+ }
- rc =
- _gnutls_hash_copy (&td_sha, &session->internals.handshake_mac_handle.tls10.sha);
+ rc = _gnutls_hash_copy (&td_sha, &session->internals.
+ handshake_mac_handle.tls10.sha);
if (rc < 0)
- {
- gnutls_assert ();
- _gnutls_hash_deinit (&td_md5, NULL);
- return rc;
- }
-
+ {
+ gnutls_assert ();
+ _gnutls_hash_deinit (&td_md5, NULL);
+ return rc;
+ }
}
else
{
@@ -190,7 +195,6 @@ _gnutls_ssl3_finished (gnutls_session_t session, int type, opaque * ret)
return GNUTLS_E_INTERNAL_ERROR;
}
-
if (type == GNUTLS_SERVER)
{
mesg = SSL3_SERVER_MSG;
@@ -213,7 +217,7 @@ _gnutls_ssl3_finished (gnutls_session_t session, int type, opaque * ret)
return 0;
}
-/* Hash the handshake messages as required by TLS 1.0
+/* Hash the handshake messages as required by TLS 1.0
*/
#define SERVER_MSG "server finished"
#define CLIENT_MSG "client finished"
@@ -223,52 +227,51 @@ _gnutls_finished (gnutls_session_t session, int type, void *ret)
{
const int siz = TLS_MSG_LEN;
opaque concat[MAX_HASH_SIZE+16/*MD5*/];
- size_t len;
+ size_t len = 20 + 16;
const char *mesg;
digest_hd_st td_md5;
digest_hd_st td_sha;
- gnutls_protocol_t ver = gnutls_protocol_get_version (session);
int rc;
- if (session->security_parameters.handshake_mac_handle_type == HANDSHAKE_MAC_TYPE_10)
+ if (session->security_parameters.
+ handshake_mac_handle_type == HANDSHAKE_MAC_TYPE_10)
{
rc =
- _gnutls_hash_copy (&td_md5,
- &session->internals.handshake_mac_handle.tls10.md5);
+ _gnutls_hash_copy (&td_md5, &session->internals.
+ handshake_mac_handle.tls10.md5);
if (rc < 0)
{
gnutls_assert ();
return rc;
}
- rc =
- _gnutls_hash_copy (&td_sha, &session->internals.handshake_mac_handle.tls10.sha);
+ rc = _gnutls_hash_copy (&td_sha, &session->internals.
+ handshake_mac_handle.tls10.sha);
if (rc < 0)
- {
- gnutls_assert ();
- _gnutls_hash_deinit (&td_md5, NULL);
- return rc;
- }
+ {
+ gnutls_assert ();
+ _gnutls_hash_deinit (&td_md5, NULL);
+ return rc;
+ }
- _gnutls_hash_deinit (&td_md5, concat);
- _gnutls_hash_deinit (&td_sha, &concat[16]);
- len = 20 + 16;
+ _gnutls_hash_deinit (&td_md5, concat);
+ _gnutls_hash_deinit (&td_sha, &concat[16]);
}
- else if (session->security_parameters.handshake_mac_handle_type == HANDSHAKE_MAC_TYPE_12)
+ else if (session->security_parameters.
+ handshake_mac_handle_type == HANDSHAKE_MAC_TYPE_12)
{
- rc =
- _gnutls_hash_copy (&td_sha, &session->internals.handshake_mac_handle.tls12.mac);
+ rc = _gnutls_hash_copy (&td_sha, &session->internals.
+ handshake_mac_handle.tls12.mac);
if (rc < 0)
- {
- gnutls_assert ();
- return rc;
- }
+ {
+ gnutls_assert ();
+ return rc;
+ }
- _gnutls_hash_deinit (&td_sha, concat);
- len = _gnutls_hash_get_algo_len (td_sha.algorithm);
+ _gnutls_hash_deinit (&td_sha, concat);
+ len = _gnutls_hash_get_algo_len (td_sha.algorithm);
}
-
if (type == GNUTLS_SERVER)
{
mesg = SERVER_MSG;
diff --git a/src/certtool.c b/src/certtool.c
index 97647eaf01..145bcebbab 100644
--- a/src/certtool.c
+++ b/src/certtool.c
@@ -301,7 +301,7 @@ generate_certificate (gnutls_x509_privkey_t * ret_key,
get_cn_crt_set (crt);
get_uid_crt_set (crt);
get_oid_crt_set (crt);
- get_key_purpose_set( crt);
+ get_key_purpose_set (crt);
if (!batch)
fprintf (stderr,
@@ -930,7 +930,8 @@ gaa_parser (int argc, char **argv)
gnutls_global_set_log_function (tls_log_func);
gnutls_global_set_log_level (info.debug);
- if (info.debug > 1) printf("Setting log level to %d\n", info.debug);
+ if (info.debug > 1)
+ printf ("Setting log level to %d\n", info.debug);
if ((ret = gnutls_global_init ()) < 0)
error (EXIT_FAILURE, 0, "global_init: %s", gnutls_strerror (ret));
@@ -2246,8 +2247,7 @@ print_verification_res (gnutls_x509_crt_t crt,
ret = gnutls_x509_crt_verify (crt, &issuer, 1, 0, &output);
if (ret < 0)
- error (EXIT_FAILURE, 0, "verification error: %s",
- gnutls_strerror (ret));
+ error (EXIT_FAILURE, 0, "verification error: %s", gnutls_strerror (ret));
if (output & GNUTLS_CERT_INVALID)
{
@@ -2416,26 +2416,32 @@ verify_crl (void)
fprintf (outfile, "\n");
}
-static int cipher_to_flags(const char* cipher)
+static int
+cipher_to_flags (const char *cipher)
{
-int flags;
-
- if (strcasecmp(cipher, "3des")==0) {
- flags = GNUTLS_PKCS_USE_PBES2_3DES;
- } else if (strcasecmp(cipher, "aes-128")==0) {
- flags = GNUTLS_PKCS_USE_PBES2_AES_128;
- } else if (strcasecmp(cipher, "aes-192")==0) {
- flags = GNUTLS_PKCS_USE_PBES2_AES_192;
- } else if (strcasecmp(cipher, "aes-256")==0) {
- flags = GNUTLS_PKCS_USE_PBES2_AES_256;
- } else if (strcasecmp(cipher, "rc2-40")==0) {
- flags = GNUTLS_PKCS_USE_PKCS12_RC2_40;
- } else {
- error(EXIT_FAILURE, 0, "Unknown cipher %s\n", cipher);
- }
-
- return flags;
+ if (strcasecmp (cipher, "3des") == 0)
+ {
+ return GNUTLS_PKCS_USE_PBES2_3DES;
+ }
+ else if (strcasecmp (cipher, "aes-128") == 0)
+ {
+ return GNUTLS_PKCS_USE_PBES2_AES_128;
+ }
+ else if (strcasecmp (cipher, "aes-192") == 0)
+ {
+ return GNUTLS_PKCS_USE_PBES2_AES_192;
+ }
+ else if (strcasecmp (cipher, "aes-256") == 0)
+ {
+ return GNUTLS_PKCS_USE_PBES2_AES_256;
+ }
+ else if (strcasecmp (cipher, "rc2-40") == 0)
+ {
+ return GNUTLS_PKCS_USE_PKCS12_RC2_40;
+ }
+ error (EXIT_FAILURE, 0, "Unknown cipher %s\n", cipher);
+ return -1;
}
void
@@ -2459,7 +2465,7 @@ generate_pkcs8 (void)
if (info.export)
flags = GNUTLS_PKCS_USE_PKCS12_RC2_40;
else
- flags = cipher_to_flags(info.pkcs_cipher);
+ flags = cipher_to_flags (info.pkcs_cipher);
if (password == NULL || password[0] == 0)
{
@@ -2552,7 +2558,7 @@ generate_pkcs12 (void)
if (info.export)
flags = GNUTLS_PKCS_USE_PKCS12_RC2_40;
else
- flags = cipher_to_flags(info.pkcs_cipher);
+ flags = cipher_to_flags (info.pkcs_cipher);
result = gnutls_pkcs12_bag_encrypt (bag, pass, flags);
if (result < 0)
@@ -2574,7 +2580,7 @@ generate_pkcs12 (void)
if (info.export)
flags = GNUTLS_PKCS_USE_PKCS12_RC2_40;
else
- flags = cipher_to_flags(info.pkcs_cipher);
+ flags = cipher_to_flags (info.pkcs_cipher);
size = sizeof (buffer);
result =