gnutls_cipher_get_id - Linux


gnutls_cipher_get_id retrieves a list of cipher suites supported by a GNUTLS context. Cipher suites determine the algorithms used to encrypt and authenticate network communications.


gnutls_cipher_get_id(gnutls_session_t session);


  • session: A GNUTLS session object.

Return Value

Returns a list of available cipher suites, each represented by a unique identifier.


Get cipher suite identifiers:

#include <gnutls/gnutls.h>

int main() {
    gnutls_session_t session;
    gnutls_init(&session, GNUTLS_CLIENT);
    unsigned int cipher_count;
    const int *cipher_ids = gnutls_cipher_get_id(session);
    cipher_count = gnutls_cipher_get_count(session);

    for (int i = 0; i < cipher_count; i++) {
        printf("%u\n", cipher_ids[i]);

    return 0;

Common Issues

  • Ensure that the GNUTLS context is initialized before calling this function.
  • Check for errors after calling this function to handle any issues that may occur.


This function can be used with other GNUTLS functions to configure and manage network connections. For example, you can use gnutls_cipher_set_priority to set the order of cipher suites to be used by the session.

Related Commands

  • gnutls_cipher_get_name
  • gnutls_cipher_set_priority
  • gnutls_init