diff options
Diffstat (limited to 'lib/gnutls_priority.c')
-rw-r--r-- | lib/gnutls_priority.c | 213 |
1 files changed, 110 insertions, 103 deletions
diff --git a/lib/gnutls_priority.c b/lib/gnutls_priority.c index 7a39b827a1..e3fa10e409 100644 --- a/lib/gnutls_priority.c +++ b/lib/gnutls_priority.c @@ -42,18 +42,19 @@ **/ int gnutls_cipher_set_priority(gnutls_session session, const int *list) { - int num = 0, i; + int num = 0, i; - while (list[num] != 0) num++; - if (num > MAX_ALGOS) num = MAX_ALGOS; - session->internals.cipher_algorithm_priority.algorithms = num; + while (list[num] != 0) + num++; + if (num > MAX_ALGOS) + num = MAX_ALGOS; + session->internals.cipher_algorithm_priority.algorithms = num; - for (i = 0; i < num; i++) { - session->internals.cipher_algorithm_priority.priority[i] = - list[i]; - } + for (i = 0; i < num; i++) { + session->internals.cipher_algorithm_priority.priority[i] = list[i]; + } - return 0; + return 0; } /** @@ -70,18 +71,19 @@ int gnutls_cipher_set_priority(gnutls_session session, const int *list) **/ int gnutls_kx_set_priority(gnutls_session session, const int *list) { - int num = 0, i; + int num = 0, i; - while (list[num] != 0) num++; - if (num > MAX_ALGOS) num = MAX_ALGOS; - session->internals.kx_algorithm_priority.algorithms = num; + while (list[num] != 0) + num++; + if (num > MAX_ALGOS) + num = MAX_ALGOS; + session->internals.kx_algorithm_priority.algorithms = num; - for (i = 0; i < num; i++) { - session->internals.kx_algorithm_priority.priority[i] = - list[i]; - } + for (i = 0; i < num; i++) { + session->internals.kx_algorithm_priority.priority[i] = list[i]; + } - return 0; + return 0; } /** @@ -98,18 +100,19 @@ int gnutls_kx_set_priority(gnutls_session session, const int *list) **/ int gnutls_mac_set_priority(gnutls_session session, const int *list) { - int num = 0, i; + int num = 0, i; - while (list[num] != 0) num++; - if (num > MAX_ALGOS) num = MAX_ALGOS; - session->internals.mac_algorithm_priority.algorithms = num; + while (list[num] != 0) + num++; + if (num > MAX_ALGOS) + num = MAX_ALGOS; + session->internals.mac_algorithm_priority.algorithms = num; - for (i = 0; i < num; i++) { - session->internals.mac_algorithm_priority.priority[i] = - list[i]; - } + for (i = 0; i < num; i++) { + session->internals.mac_algorithm_priority.priority[i] = list[i]; + } - return 0; + return 0; } /** @@ -132,17 +135,19 @@ int gnutls_mac_set_priority(gnutls_session session, const int *list) int gnutls_compression_set_priority(gnutls_session session, const int *list) { - int num = 0, i; - - while (list[num] != 0) num++; - if (num > MAX_ALGOS) num = MAX_ALGOS; - session->internals.compression_method_priority.algorithms = num; - - for (i = 0; i < num; i++) { - session->internals.compression_method_priority. - priority[i] = list[i]; - } - return 0; + int num = 0, i; + + while (list[num] != 0) + num++; + if (num > MAX_ALGOS) + num = MAX_ALGOS; + session->internals.compression_method_priority.algorithms = num; + + for (i = 0; i < num; i++) { + session->internals.compression_method_priority. + priority[i] = list[i]; + } + return 0; } /** @@ -157,23 +162,25 @@ int gnutls_compression_set_priority(gnutls_session session, **/ int gnutls_protocol_set_priority(gnutls_session session, const int *list) { - int num = 0, i; + int num = 0, i; - while (list[num] != 0) num++; - if (num > MAX_ALGOS) num = MAX_ALGOS; - session->internals.protocol_priority.algorithms = num; + while (list[num] != 0) + num++; + if (num > MAX_ALGOS) + num = MAX_ALGOS; + session->internals.protocol_priority.algorithms = num; - for (i = 0; i < num; i++) { - session->internals.protocol_priority.priority[i] = list[i]; - } + for (i = 0; i < num; i++) { + session->internals.protocol_priority.priority[i] = list[i]; + } - /* set the current version to the first in the chain. - * This will be overridden later. - */ - if (num > 0) - _gnutls_set_current_version(session, list[0]); + /* set the current version to the first in the chain. + * This will be overridden later. + */ + if (num > 0) + _gnutls_set_current_version(session, list[0]); - return 0; + return 0; } /** @@ -193,22 +200,23 @@ int gnutls_certificate_type_set_priority(gnutls_session session, { #ifdef USE_OPENPGP - int num = 0, i; + int num = 0, i; - while (list[num] != 0) num++; - if (num > MAX_ALGOS) num = MAX_ALGOS; - session->internals.cert_type_priority.algorithms = num; + while (list[num] != 0) + num++; + if (num > MAX_ALGOS) + num = MAX_ALGOS; + session->internals.cert_type_priority.algorithms = num; - for (i = 0; i < num; i++) { - session->internals.cert_type_priority.priority[i] = - list[i]; - } + for (i = 0; i < num; i++) { + session->internals.cert_type_priority.priority[i] = list[i]; + } - return 0; + return 0; #else - return GNUTLS_E_UNIMPLEMENTED_FEATURE; + return GNUTLS_E_UNIMPLEMENTED_FEATURE; #endif } @@ -231,25 +239,24 @@ int gnutls_certificate_type_set_priority(gnutls_session session, **/ int gnutls_set_default_priority(gnutls_session session) { - static const int protocol_priority[] = - { GNUTLS_TLS1, GNUTLS_SSL3, 0 }; - static const int kx_priority[] = - { GNUTLS_KX_RSA, GNUTLS_KX_DHE_DSS, GNUTLS_KX_DHE_RSA, 0 }; - static const int cipher_priority[] = { - GNUTLS_CIPHER_AES_256_CBC, GNUTLS_CIPHER_AES_128_CBC, - GNUTLS_CIPHER_3DES_CBC, GNUTLS_CIPHER_ARCFOUR_128, 0 - }; - static const int comp_priority[] = { GNUTLS_COMP_NULL, 0 }; - static const int mac_priority[] = - { GNUTLS_MAC_SHA, GNUTLS_MAC_MD5, GNUTLS_MAC_RMD160, 0 }; - - gnutls_cipher_set_priority(session, cipher_priority); - gnutls_compression_set_priority(session, comp_priority); - gnutls_kx_set_priority(session, kx_priority); - gnutls_protocol_set_priority(session, protocol_priority); - gnutls_mac_set_priority(session, mac_priority); - - return 0; + static const int protocol_priority[] = { GNUTLS_TLS1, GNUTLS_SSL3, 0 }; + static const int kx_priority[] = + { GNUTLS_KX_RSA, GNUTLS_KX_DHE_DSS, GNUTLS_KX_DHE_RSA, 0 }; + static const int cipher_priority[] = { + GNUTLS_CIPHER_AES_256_CBC, GNUTLS_CIPHER_AES_128_CBC, + GNUTLS_CIPHER_3DES_CBC, GNUTLS_CIPHER_ARCFOUR_128, 0 + }; + static const int comp_priority[] = { GNUTLS_COMP_NULL, 0 }; + static const int mac_priority[] = + { GNUTLS_MAC_SHA, GNUTLS_MAC_MD5, GNUTLS_MAC_RMD160, 0 }; + + gnutls_cipher_set_priority(session, cipher_priority); + gnutls_compression_set_priority(session, comp_priority); + gnutls_kx_set_priority(session, kx_priority); + gnutls_protocol_set_priority(session, protocol_priority); + gnutls_mac_set_priority(session, mac_priority); + + return 0; } /** @@ -268,27 +275,27 @@ int gnutls_set_default_priority(gnutls_session session) **/ int gnutls_set_default_export_priority(gnutls_session session) { - static const int protocol_priority[] = { - GNUTLS_TLS1, GNUTLS_SSL3, 0 - }; - static const int kx_priority[] = { - GNUTLS_KX_RSA, GNUTLS_KX_DHE_DSS, GNUTLS_KX_DHE_RSA, - GNUTLS_KX_RSA_EXPORT, 0 - }; - static const int cipher_priority[] = { - GNUTLS_CIPHER_AES_256_CBC, GNUTLS_CIPHER_AES_128_CBC, - GNUTLS_CIPHER_3DES_CBC, GNUTLS_CIPHER_ARCFOUR_128, - GNUTLS_CIPHER_ARCFOUR_40, 0 - }; - static const int comp_priority[] = { GNUTLS_COMP_NULL, 0 }; - static const int mac_priority[] = - { GNUTLS_MAC_SHA, GNUTLS_MAC_MD5, GNUTLS_MAC_RMD160, 0 }; - - gnutls_cipher_set_priority(session, cipher_priority); - gnutls_compression_set_priority(session, comp_priority); - gnutls_kx_set_priority(session, kx_priority); - gnutls_protocol_set_priority(session, protocol_priority); - gnutls_mac_set_priority(session, mac_priority); - - return 0; + static const int protocol_priority[] = { + GNUTLS_TLS1, GNUTLS_SSL3, 0 + }; + static const int kx_priority[] = { + GNUTLS_KX_RSA, GNUTLS_KX_DHE_DSS, GNUTLS_KX_DHE_RSA, + GNUTLS_KX_RSA_EXPORT, 0 + }; + static const int cipher_priority[] = { + GNUTLS_CIPHER_AES_256_CBC, GNUTLS_CIPHER_AES_128_CBC, + GNUTLS_CIPHER_3DES_CBC, GNUTLS_CIPHER_ARCFOUR_128, + GNUTLS_CIPHER_ARCFOUR_40, 0 + }; + static const int comp_priority[] = { GNUTLS_COMP_NULL, 0 }; + static const int mac_priority[] = + { GNUTLS_MAC_SHA, GNUTLS_MAC_MD5, GNUTLS_MAC_RMD160, 0 }; + + gnutls_cipher_set_priority(session, cipher_priority); + gnutls_compression_set_priority(session, comp_priority); + gnutls_kx_set_priority(session, kx_priority); + gnutls_protocol_set_priority(session, protocol_priority); + gnutls_mac_set_priority(session, mac_priority); + + return 0; } |