{0, 0, 0, 0, 0}
};
-/* Keep the contents of this struct the same as the previous one. */
-static const gnutls_protocol_t supported_protocols[] = {
- GNUTLS_SSL3,
- GNUTLS_TLS1,
- GNUTLS_TLS1_1,
- GNUTLS_TLS1_2,
- GNUTLS_DTLS1_0,
- 0
-};
-
#define GNUTLS_VERSION_LOOP(b) \
const gnutls_version_entry *p; \
for(p = sup_versions; p->name != NULL; p++) { b ; }
{0, 0, 0, 0, 0, 0, 0}
};
-/* Keep the contents of this struct the same as the previous one. */
-static const gnutls_cipher_algorithm_t supported_ciphers[] = {
- GNUTLS_CIPHER_AES_256_CBC,
- GNUTLS_CIPHER_AES_128_CBC,
- GNUTLS_CIPHER_3DES_CBC,
- GNUTLS_CIPHER_DES_CBC,
- GNUTLS_CIPHER_ARCFOUR_128,
- GNUTLS_CIPHER_ARCFOUR_40,
- GNUTLS_CIPHER_RC2_40_CBC,
-#ifdef ENABLE_CAMELLIA
- GNUTLS_CIPHER_CAMELLIA_256_CBC,
- GNUTLS_CIPHER_CAMELLIA_128_CBC,
-#endif
- GNUTLS_CIPHER_NULL,
- 0
-};
-
-#define GNUTLS_LOOP(b) \
+#define GNUTLS_CIPHER_LOOP(b) \
const gnutls_cipher_entry *p; \
for(p = algorithms; p->name != NULL; p++) { b ; }
#define GNUTLS_ALG_LOOP(a) \
- GNUTLS_LOOP( if(p->id == algorithm) { a; break; } )
+ GNUTLS_CIPHER_LOOP( if(p->id == algorithm) { a; break; } )
struct gnutls_hash_entry
{0, 0, 0, 0}
};
-/* Keep the contents of this struct the same as the previous one. */
-static const gnutls_mac_algorithm_t supported_macs[] = {
- GNUTLS_MAC_SHA1,
- GNUTLS_MAC_MD5,
- GNUTLS_MAC_SHA256,
- GNUTLS_MAC_SHA384,
- GNUTLS_MAC_SHA512,
- GNUTLS_MAC_MD2,
- GNUTLS_MAC_RMD160,
- GNUTLS_MAC_NULL,
- 0
-};
#define GNUTLS_HASH_LOOP(b) \
const gnutls_hash_entry *p; \
{0, 0, 0, 0, 0}
};
-/* Keep the contents of this struct the same as the previous one. */
-static const gnutls_kx_algorithm_t supported_kxs[] = {
-#ifdef ENABLE_ANON
- GNUTLS_KX_ANON_DH,
-#endif
- GNUTLS_KX_RSA,
- GNUTLS_KX_RSA_EXPORT,
- GNUTLS_KX_DHE_RSA,
- GNUTLS_KX_DHE_DSS,
-#ifdef ENABLE_SRP
- GNUTLS_KX_SRP_DSS,
- GNUTLS_KX_SRP_RSA,
- GNUTLS_KX_SRP,
-#endif
-#ifdef ENABLE_PSK
- GNUTLS_KX_PSK,
- GNUTLS_KX_DHE_PSK,
-#endif
- 0
-};
-
#define GNUTLS_KX_LOOP(b) \
const gnutls_kx_algo_entry *p; \
for(p = _gnutls_kx_algorithms; p->name != NULL; p++) { b ; }
* example, MD2 is not supported as a cipher suite, but is supported
* for other purposes (e.g., X.509 signature verification or similar).
*
+ * This function is not thread safe.
+ *
* Returns: Return a zero-terminated list of #gnutls_mac_algorithm_t
* integers indicating the available MACs.
**/
const gnutls_mac_algorithm_t *
gnutls_mac_list (void)
{
+static gnutls_mac_algorithm_t supported_macs[MAX_ALGOS] = { 0 };
+
+ if (supported_macs[0] == 0)
+ {
+ int i = 0;
+
+ GNUTLS_HASH_LOOP ( supported_macs[i++]=p->id);
+ supported_macs[i++]=0;
+ }
+
return supported_macs;
}
{
gnutls_cipher_algorithm_t ret = GNUTLS_CIPHER_UNKNOWN;
- GNUTLS_LOOP (if (strcasecmp (p->name, name) == 0) ret = p->id);
+ GNUTLS_CIPHER_LOOP (if (strcasecmp (p->name, name) == 0) ret = p->id);
return ret;
}
* example, DES is not supported as a cipher suite, but is supported
* for other purposes (e.g., PKCS#8 or similar).
*
+ * This function is not thread safe.
+ *
* Returns: a zero-terminated list of #gnutls_cipher_algorithm_t
* integers indicating the available ciphers.
*
const gnutls_cipher_algorithm_t *
gnutls_cipher_list (void)
{
+static gnutls_cipher_algorithm_t supported_ciphers[MAX_ALGOS] = {0};
+
+ if (supported_ciphers[0] == 0)
+ {
+ int i = 0;
+
+ GNUTLS_CIPHER_LOOP (supported_ciphers[i++]=p->id);
+ supported_ciphers[i++]=0;
+ }
+
return supported_ciphers;
}
*
* Get a list of supported key exchange algorithms.
*
+ * This function is not thread safe.
+ *
* Returns: a zero-terminated list of #gnutls_kx_algorithm_t integers
* indicating the available key exchange algorithms.
**/
const gnutls_kx_algorithm_t *
gnutls_kx_list (void)
{
+static gnutls_kx_algorithm_t supported_kxs[MAX_ALGOS] = {0};
+
+ if (supported_kxs[0] == 0)
+ {
+ int i = 0;
+
+ GNUTLS_KX_LOOP (supported_kxs[i++]=p->algorithm);
+ supported_kxs[i++]=0;
+ }
+
return supported_kxs;
}
*
* Get a list of supported protocols, e.g. SSL 3.0, TLS 1.0 etc.
*
+ * This function is not threat safe.
+ *
* Returns: a zero-terminated list of #gnutls_protocol_t integers
* indicating the available protocols.
*
const gnutls_protocol_t *
gnutls_protocol_list (void)
{
+static gnutls_protocol_t supported_protocols[MAX_ALGOS] = {0};
+
+ if (supported_protocols[0] == 0)
+ {
+ int i = 0;
+
+ GNUTLS_VERSION_LOOP (supported_protocols[i++]=p->id);
+ supported_protocols[i++]=0;
+ }
+
return supported_protocols;
}
{0, 0, 0, 0, 0, TLS_SIGN_AID_UNKNOWN}
};
-/* Keep the contents of this struct the same as the previous one. */
-static const gnutls_sign_algorithm_t supported_sign[] = {
- GNUTLS_SIGN_RSA_SHA1,
- GNUTLS_SIGN_RSA_SHA224,
- GNUTLS_SIGN_RSA_SHA256,
- GNUTLS_SIGN_RSA_SHA384,
- GNUTLS_SIGN_RSA_SHA512,
- GNUTLS_SIGN_RSA_RMD160,
- GNUTLS_SIGN_DSA_SHA1,
- GNUTLS_SIGN_DSA_SHA224,
- GNUTLS_SIGN_DSA_SHA256,
- GNUTLS_SIGN_RSA_MD5,
- GNUTLS_SIGN_RSA_MD2,
- 0
-};
-
#define GNUTLS_SIGN_LOOP(b) \
do { \
const gnutls_sign_entry *p; \
const gnutls_sign_algorithm_t *
gnutls_sign_list (void)
{
+static gnutls_sign_algorithm_t supported_sign[MAX_ALGOS] = {0};
+
+ if (supported_sign[0] == 0)
+ {
+ int i = 0;
+
+ GNUTLS_SIGN_LOOP (supported_sign[i++]=p->id);
+ supported_sign[i++]=0;
+ }
+
return supported_sign;
}
{0, 0, 0}
};
+#define GNUTLS_PK_LOOP(b) \
+ { const gnutls_pk_entry *p; \
+ for(p = pk_algorithms; p->name != NULL; p++) { b ; } }
+
+
/**
* gnutls_pk_algorithm_get_name:
* @algorithm: is a pk algorithm
gnutls_pk_algorithm_get_name (gnutls_pk_algorithm_t algorithm)
{
const char *ret = NULL;
- const gnutls_pk_entry *p;
- for (p = pk_algorithms; p->name != NULL; p++)
+ GNUTLS_PK_LOOP(
if (p->id == algorithm)
{
ret = p->name;
break;
}
+ );
return ret;
}
*
* Get a list of supported public key algorithms.
*
+ * This function is not thread safe.
+ *
* Returns: a zero-terminated list of #gnutls_pk_algorithm_t integers
* indicating the available ciphers.
*
const gnutls_pk_algorithm_t *
gnutls_pk_list (void)
{
- static const gnutls_pk_algorithm_t supported_pks[] = {
- GNUTLS_PK_RSA,
- GNUTLS_PK_DSA,
- /* GNUTLS_PK_DH is not returned because it is not
- * a real public key algorithm. I.e. cannot be used
- * as a public key algorithm of a certificate.
- */
- 0
- };
+static gnutls_pk_algorithm_t supported_pks[MAX_ALGOS] = {0};
+
+ if (supported_pks[0] == 0)
+ {
+ int i = 0;
+
+ GNUTLS_PK_LOOP (if (p->id != GNUTLS_PK_UNKNOWN && supported_pks[i>0?(i-1):0]!=p->id) supported_pks[i++]=p->id);
+ supported_pks[i++]=0;
+ }
return supported_pks;
}