This makes a more consistent API at the cost of requiring gnutls_get_cipher_suite_info().
An advantage however is that more information can now be accessed.
** libgnutls: Added the SECP192R1 curve.
-** libgnutls: Added gnutls_priority_get_cipher_suite() to
+** libgnutls: Added gnutls_priority_get_cipher_suite_index() to
allow listing the ciphersuites enabled in a priority structure.
+It outputs and index to be used in gnutls_get_cipher_suite_info().
** libgnutls: Optimizations in the elliptic curve code (timing
attacks resistant code is only used in ECDSA private key operations).
now added again in the distribution.
** API and ABI modifications:
-gnutls_priority_get_cipher_suite: Added
+gnutls_priority_get_cipher_suite_index: Added
* Version 3.0.8 (released 2011-11-12)
APIMANS += gnutls_key_generate.3
APIMANS += gnutls_priority_init.3
APIMANS += gnutls_priority_deinit.3
+APIMANS += gnutls_priority_get_cipher_suite.3
APIMANS += gnutls_priority_set.3
APIMANS += gnutls_priority_set_direct.3
APIMANS += gnutls_set_default_priority.3
/**
* gnutls_priority_get_cipher_suite:
* @pcache: is a #gnutls_prioritity_t structure.
- * @idx: is an index number
- * @name: Will point to the ciphersuite name
- * @cs_id: output buffer with room for 2 bytes, indicating cipher suite value
+ * @idx: is an index number.
+ * @sidx: internal index of cipher suite to get information about.
*
- * Provides ciphersuite information. The index provided is an internal
- * index kept at the priorities structure. It might be that a valid index
- * does not correspond to a ciphersuite and in that case %GNUTLS_E_UNKNOWN_CIPHER_SUITE
- * will be returned. Once the last available index is crossed then
+ * Provides the internal ciphersuite index to be used with
+ * gnutls_cipher_suite_info(). The index @idx provided is an
+ * index kept at the priorities structure. It might be that a valid
+ * priorities index does not correspond to a ciphersuite and in
+ * that case %GNUTLS_E_UNKNOWN_CIPHER_SUITE will be returned.
+ * Once the last available index is crossed then
* %GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE will be returned.
*
* Returns: On success it returns %GNUTLS_E_SUCCESS (0), or a negative error value otherwise.
**/
int
-gnutls_priority_get_cipher_suite (gnutls_priority_t pcache, int idx, const char** name, unsigned char cs_id[2])
+gnutls_priority_get_cipher_suite_index (gnutls_priority_t pcache, unsigned int idx, unsigned int *sidx)
{
-int mac_idx, cipher_idx, kx_idx;
+int mac_idx, cipher_idx, kx_idx, i;
int total = pcache->mac.algorithms * pcache->cipher.algorithms * pcache->kx.algorithms;
-const gnutls_cipher_suite_entry * ce;
if (idx >= total)
return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
idx /= pcache->cipher.algorithms;
kx_idx = idx % pcache->kx.algorithms;
- ce = cipher_suite_get(pcache->kx.priority[kx_idx], pcache->cipher.priority[cipher_idx],
- pcache->mac.priority[mac_idx]);
-
- if (ce == NULL)
- {
- *name = NULL;
- memset(cs_id, 0, 2);
- }
- else
- {
- *name = ce->name;
- memcpy(cs_id, ce->id.suite, 2);
- }
-
- if (*name == NULL)
+ for (i=0;i<CIPHER_SUITES_COUNT;i++)
{
- *name = "(no corresponding ciphersuite)";
- return GNUTLS_E_UNKNOWN_CIPHER_SUITE;
+ if (cs_algorithms[i].kx_algorithm == pcache->kx.priority[kx_idx] &&
+ cs_algorithms[i].block_algorithm == pcache->cipher.priority[cipher_idx] &&
+ cs_algorithms[i].mac_algorithm == pcache->mac.priority[mac_idx])
+ {
+ *sidx = i;
+ return 0;
+ }
}
-
- return 0;
+ return GNUTLS_E_UNKNOWN_CIPHER_SUITE;
}
-
int gnutls_priority_init (gnutls_priority_t * priority_cache,
const char *priorities, const char **err_pos);
void gnutls_priority_deinit (gnutls_priority_t priority_cache);
- int gnutls_priority_get_cipher_suite (gnutls_priority_t pcache, int idx, const char** name, unsigned char cs_id[2]);
+ int gnutls_priority_get_cipher_suite_index (gnutls_priority_t pcache, unsigned int idx, unsigned int *sidx);
int gnutls_priority_set (gnutls_session_t session,
gnutls_priority_t priority);
gnutls_srp_4096_group_generator;
gnutls_srp_4096_group_prime;
gnutls_x509_privkey_verify_params;
- gnutls_priority_get_cipher_suite;
+ gnutls_priority_get_cipher_suite_index;
} GNUTLS_2_12;
GNUTLS_PRIVATE {
{
size_t i;
int ret;
+ unsigned int idx;
const char *name;
const char *err;
unsigned char id[2];
for (i=0;;i++)
{
- ret = gnutls_priority_get_cipher_suite(pcache, i, &name, id);
+ ret = gnutls_priority_get_cipher_suite_index(pcache, i, &idx);
if (ret == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE) break;
if (ret == GNUTLS_E_UNKNOWN_CIPHER_SUITE) continue;
- printf ("%-50s\t0x%02x, 0x%02x\n", name, id[0], id[1]);
+ name = gnutls_cipher_suite_info(idx, id, NULL, NULL, NULL, &version);
+
+ if (name != NULL)
+ printf ("%-50s\t0x%02x, 0x%02x\t%s\n",
+ name, (unsigned char) id[0], (unsigned char) id[1],
+ gnutls_protocol_get_name (version));
}
return;