crypto

## crypto crypto |

## Synopsis

    typedef             gnutls_cipher_hd_t;
    int                 gnutls_cipher_init                  (gnutls_cipher_hd_t *handle,
                                                             gnutls_cipher_algorithm_t cipher,
                                                             const gnutls_datum_t *key,
                                                             const gnutls_datum_t *iv);
    int                 gnutls_cipher_encrypt               (const gnutls_cipher_hd_t handle,
                                                             void *text,
                                                             size_t textlen);
    int                 gnutls_cipher_decrypt               (const gnutls_cipher_hd_t handle,
                                                             void *ciphertext,
                                                             size_t ciphertextlen);
    int                 gnutls_cipher_decrypt2              (gnutls_cipher_hd_t handle,
                                                             const void *ciphertext,
                                                             size_t ciphertextlen,
                                                             void *text,
                                                             size_t textlen);
    int                 gnutls_cipher_encrypt2              (gnutls_cipher_hd_t handle,
                                                             void *text,
                                                             size_t textlen,
                                                             void *ciphertext,
                                                             size_t ciphertextlen);
    void                gnutls_cipher_deinit                (gnutls_cipher_hd_t handle);
    int                 gnutls_cipher_get_block_size        (gnutls_cipher_algorithm_t algorithm);
    typedef             gnutls_hash_hd_t;
    typedef             gnutls_hmac_hd_t;
    int                 gnutls_hmac_init                    (gnutls_hmac_hd_t *dig,
                                                             gnutls_digest_algorithm_t algorithm,
                                                             const void *key,
                                                             size_t keylen);
    int                 gnutls_hmac                         (gnutls_hmac_hd_t handle,
                                                             const void *text,
                                                             size_t textlen);
    void                gnutls_hmac_output                  (gnutls_hmac_hd_t handle,
                                                             void *digest);
    void                gnutls_hmac_deinit                  (gnutls_hmac_hd_t handle,
                                                             void *digest);
    int                 gnutls_hmac_get_len                 (gnutls_mac_algorithm_t algorithm);
    int                 gnutls_hmac_fast                    (gnutls_mac_algorithm_t algorithm,
                                                             const void *key,
                                                             size_t keylen,
                                                             const void *text,
                                                             size_t textlen,
                                                             void *digest);
    int                 gnutls_hash_init                    (gnutls_hash_hd_t *dig,
                                                             gnutls_digest_algorithm_t algorithm);
    int                 gnutls_hash                         (gnutls_hash_hd_t handle,
                                                             const void *text,
                                                             size_t textlen);
    void                gnutls_hash_output                  (gnutls_hash_hd_t handle,
                                                             void *digest);
    void                gnutls_hash_deinit                  (gnutls_hash_hd_t handle,
                                                             void *digest);
    int                 gnutls_hash_get_len                 (gnutls_digest_algorithm_t algorithm);
    int                 gnutls_hash_fast                    (gnutls_digest_algorithm_t algorithm,
                                                             const void *text,
                                                             size_t textlen,
                                                             void *digest);
    #define             GNUTLS_CRYPTO_API_VERSION
    #define             gnutls_crypto_single_cipher_st
    #define             gnutls_crypto_single_mac_st
    #define             gnutls_crypto_single_digest_st
    int                 (*init)                             (gnutls_cipher_algorithm_t Param1,
                                                             void **ctx);
    int                 (*setkey)                           (void *ctx,
                                                             const void *key,
                                                             size_t keysize);
    int                 (*setiv)                            (void *ctx,
                                                             const void *iv,
                                                             size_t ivsize);
    int                 (*encrypt)                          (void *ctx,
                                                             const void *plain,
                                                             size_t plainsize,
                                                             void *encr,
                                                             size_t encrsize);
    int                 (*decrypt)                          (void *ctx,
                                                             const void *encr,
                                                             size_t encrsize,
                                                             void *plain,
                                                             size_t plainsize);
    void                (*deinit)                           (void *ctx);
    int                 (*hash)                             (void *ctx,
                                                             const void *text,
                                                             size_t textsize);
    int                 (*output)                           (void *src_ctx,
                                                             void *digest,
                                                             size_t digestsize);
    int                 (*copy)                             (void **dst_ctx,
                                                             void *src_ctx);
    enum                gnutls_rnd_level_t;
    int                 gnutls_rnd                          (gnutls_rnd_level_t level,
                                                             void *data,
                                                             size_t len);
    enum                gnutls_pk_flag_t;
    int                 (*rnd)                              (void *ctx,
                                                             int level,
                                                             void *data,
                                                             size_t datasize);
    typedef             bigint_t;
    enum                gnutls_bigint_format_t;
    bigint_t            (*bigint_new)                       (int nbits);
    void                (*bigint_release)                   (bigint_t n);
    int                 (*bigint_cmp)                       (const bigint_t m1,
                                                             const bigint_t m2);
    int                 (*bigint_cmp_ui)                    (const bigint_t m1,
                                                             unsigned long  m2);
    bigint_t            (*bigint_mod)                       (const bigint_t a,
                                                             const bigint_t b);
    bigint_t            (*bigint_set)                       (bigint_t a,
                                                             const bigint_t b);
    bigint_t            (*bigint_set_ui)                    (bigint_t a,
                                                             unsigned long  b);
    unsigned            int                                 ();
    bigint_t            (*bigint_powm)                      (bigint_t w,
                                                             const bigint_t b,
                                                             const bigint_t e,
                                                             const bigint_t m);
    bigint_t            (*bigint_addm)                      (bigint_t w,
                                                             const bigint_t a,
                                                             const bigint_t b,
                                                             const bigint_t m);
    bigint_t            (*bigint_subm)                      (bigint_t w,
                                                             const bigint_t a,
                                                             const bigint_t b,
                                                             const bigint_t m);
    bigint_t            (*bigint_mulm)                      (bigint_t w,
                                                             const bigint_t a,
                                                             const bigint_t b,
                                                             const bigint_t m);
    bigint_t            (*bigint_mul)                       (bigint_t w,
                                                             const bigint_t a,
                                                             const bigint_t b);
    bigint_t            (*bigint_add_ui)                    (bigint_t w,
                                                             const bigint_t a,
                                                             unsigned long  b);
    bigint_t            (*bigint_sub_ui)                    (bigint_t w,
                                                             const bigint_t a,
                                                             unsigned long  b);
    bigint_t            (*bigint_mul_ui)                    (bigint_t w,
                                                             const bigint_t a,
                                                             unsigned long  b);
    bigint_t            (*bigint_div)                       (bigint_t q,
                                                             const bigint_t a,
                                                             const bigint_t b);
    int                 (*bigint_prime_check)               (const bigint_t pp);
    int                 (*bigint_generate_group)            (gnutls_group_st *gg,
                                                             unsigned int bits);
    bigint_t            (*bigint_scan)                      (const void *buf,
                                                             size_t buf_size,
                                                             gnutls_bigint_format_t format);
    int                 (*bigint_print)                     (const bigint_t a,
                                                             void *buf,
                                                             size_t *buf_size,
                                                             gnutls_bigint_format_t format);
    #define             GNUTLS_MAX_PK_PARAMS
    void                gnutls_pk_params_release            (gnutls_pk_params_st *p);
    void                gnutls_pk_params_init               (gnutls_pk_params_st *p);
    enum                gnutls_direction_t;
    int                 (*sign)                             (gnutls_pk_algorithm_t Param1,
                                                             gnutls_datum_t *signature,
                                                             const gnutls_datum_t *data,
                                                             const gnutls_pk_params_st *priv);
    int                 (*verify)                           (gnutls_pk_algorithm_t Param1,
                                                             const gnutls_datum_t *data,
                                                             const gnutls_datum_t *signature,
                                                             const gnutls_pk_params_st *pub);
    int                 (*generate)                         (gnutls_pk_algorithm_t Param1,
                                                             unsigned int nbits,
                                                             gnutls_pk_params_st *Param3);
    int                 (*pk_fixup_private_params)          (gnutls_pk_algorithm_t Param1,
                                                             gnutls_direction_t Param2,
                                                             gnutls_pk_params_st *Param3);
    #define             gnutls_crypto_single_cipher_register(algo,
                                                             prio,
                                                             st)
    #define             gnutls_crypto_single_mac_register   (algo,
                                                             prio,
                                                             st)
    #define             gnutls_crypto_single_digest_register(algo,
                                                             prio,
                                                             st)
    int                 gnutls_crypto_single_cipher_register2
                                                            (gnutls_cipher_algorithm_t algorithm,
                                                             int priority,
                                                             int version,
                                                             const gnutls_crypto_single_cipher_st *s);
    int                 gnutls_crypto_single_mac_register2  (gnutls_mac_algorithm_t algorithm,
                                                             int priority,
                                                             int version,
                                                             const gnutls_crypto_single_mac_st *s);
    int                 gnutls_crypto_single_digest_register2
                                                            (gnutls_digest_algorithm_t algorithm,
                                                             int priority,
                                                             int version,
                                                             const gnutls_crypto_single_digest_st *s);
    #define             gnutls_crypto_cipher_register       (prio,
                                                             st)
    #define             gnutls_crypto_mac_register          (prio,
                                                             st)
    #define             gnutls_crypto_digest_register       (prio,
                                                             st)
    int                 gnutls_crypto_cipher_register2      (int priority,
                                                             int version,
                                                             const gnutls_crypto_cipher_st *s);
    int                 gnutls_crypto_mac_register2         (int priority,
                                                             int version,
                                                             const gnutls_crypto_mac_st *s);
    int                 gnutls_crypto_digest_register2      (int priority,
                                                             int version,
                                                             const gnutls_crypto_digest_st *s);
    #define             gnutls_crypto_rnd_register          (prio,
                                                             st)
    #define             gnutls_crypto_pk_register           (prio,
                                                             st)
    #define             gnutls_crypto_bigint_register       (prio,
                                                             st)
    int                 gnutls_crypto_rnd_register2         (int priority,
                                                             int version,
                                                             const gnutls_crypto_rnd_st *s);
    int                 gnutls_crypto_pk_register2          (int priority,
                                                             int version,
                                                             const gnutls_crypto_pk_st *s);
    int                 gnutls_crypto_bigint_register2      (int priority,
                                                             int version,
                                                             const gnutls_crypto_bigint_st *s);

## Description

## Details

### gnutls_cipher_hd_t

      typedef struct cipher_hd_st *gnutls_cipher_hd_t;

### gnutls_cipher_init ()

    int                 gnutls_cipher_init                  (gnutls_cipher_hd_t *handle,
                                                             gnutls_cipher_algorithm_t cipher,
                                                             const gnutls_datum_t *key,
                                                             const gnutls_datum_t *iv);

This function will initialize an context that can be used for encryption/decryption of data. This will effectively use the current crypto backend in use by gnutls or the cryptographic accelerator in use.

`handle` : | is a gnutls_cipher_hd_t structure.
`cipher` : | the encryption algorithm to use
`key` : | The key to be used for encryption
`iv` : | The IV to use (if not applicable set NULL)
Returns : | Zero or a negative value on error.

Since 2.10.0

### gnutls_cipher_encrypt ()

    int                 gnutls_cipher_encrypt               (const gnutls_cipher_hd_t handle,
                                                             void *text,
                                                             size_t textlen);

This function will encrypt the given data using the algorithm specified by the context.

`handle` : | is a gnutls_cipher_hd_t structure.
`text` : | the data to encrypt
`textlen` : | The length of data to encrypt
Returns : | Zero or a negative value on error.

Since 2.10.0

### gnutls_cipher_decrypt ()

    int                 gnutls_cipher_decrypt               (const gnutls_cipher_hd_t handle,
                                                             void *ciphertext,
                                                             size_t ciphertextlen);

This function will decrypt the given data using the algorithm specified by the context.

`handle` : | is a gnutls_cipher_hd_t structure.
`ciphertext` : | the data to encrypt
`ciphertextlen` : | The length of data to encrypt
Returns : | Zero or a negative value on error.

Since 2.10.0

### gnutls_cipher_decrypt2 ()

    int                 gnutls_cipher_decrypt2              (gnutls_cipher_hd_t handle,
                                                             const void *ciphertext,
                                                             size_t ciphertextlen,
                                                             void *text,
                                                             size_t textlen);

This function will decrypt the given data using the algorithm specified by the context.

`handle` : | is a gnutls_cipher_hd_t structure.
`ciphertext` : | the data to encrypt
`ciphertextlen` : | The length of data to encrypt
`text` : | the decrypted data
`textlen` : | The available length for decrypted data
Returns : | Zero or a negative value on error.

Since 2.10.0

### gnutls_cipher_encrypt2 ()

    int                 gnutls_cipher_encrypt2              (gnutls_cipher_hd_t handle,
                                                             void *text,
                                                             size_t textlen,
                                                             void *ciphertext,
                                                             size_t ciphertextlen);

This function will encrypt the given data using the algorithm specified by the context.

`handle` : | is a gnutls_cipher_hd_t structure.
`text` : | the data to encrypt
`textlen` : | The length of data to encrypt
`ciphertext` : | the encrypted data
`ciphertextlen` : | The available length for encrypted data
Returns : | Zero or a negative value on error.

Since 2.10.0

### gnutls_cipher_deinit ()

    void                gnutls_cipher_deinit                (gnutls_cipher_hd_t handle);

This function will deinitialize all resources occupied by the given encryption context.

`handle` : | is a gnutls_cipher_hd_t structure.

Since 2.10.0

### gnutls_cipher_get_block_size ()

    int                 gnutls_cipher_get_block_size        (gnutls_cipher_algorithm_t algorithm);

Get block size for encryption algorithm.

`algorithm` : | is an encryption algorithm
Returns : | block size for encryption algorithm.

Since 2.10.0

### gnutls_hash_hd_t

      typedef struct hash_hd_st *gnutls_hash_hd_t;

### gnutls_hmac_hd_t

      typedef struct hmac_hd_st *gnutls_hmac_hd_t;

### gnutls_hmac_init ()

    int                 gnutls_hmac_init                    (gnutls_hmac_hd_t *dig,
                                                             gnutls_digest_algorithm_t algorithm,
                                                             const void *key,
                                                             size_t keylen);

This function will initialize an context that can be used to produce a Message Authentication Code (MAC) of data. This will effectively use the current crypto backend in use by gnutls or the cryptographic accelerator in use.

`dig` : | is a gnutls_hmac_hd_t structure.
`algorithm` : | the HMAC algorithm to use
`key` : | The key to be used for encryption
`keylen` : | The length of the key
Returns : | Zero or a negative value on error.

Since 2.10.0

### gnutls_hmac ()

    int                 gnutls_hmac                         (gnutls_hmac_hd_t handle,
                                                             const void *text,
                                                             size_t textlen);

This function will hash the given data using the algorithm specified by the context.

`handle` : | is a gnutls_cipher_hd_t structure.
`text` : | the data to hash
`textlen` : | The length of data to hash
Returns : | Zero or a negative value on error.

Since 2.10.0

### gnutls_hmac_output ()

    void                gnutls_hmac_output                  (gnutls_hmac_hd_t handle,
                                                             void *digest);

This function will output the current MAC value.

`handle` : | is a gnutls_hmac_hd_t structure.
`digest` : | is the output value of the MAC

Since 2.10.0

### gnutls_hmac_deinit ()

    void                gnutls_hmac_deinit                  (gnutls_hmac_hd_t handle,
                                                             void *digest);

This function will deinitialize all resources occupied by the given hmac context.

`handle` : | is a gnutls_hmac_hd_t structure.
`digest` : | is the output value of the MAC

Since 2.10.0

### gnutls_hmac_get_len ()

    int                 gnutls_hmac_get_len                 (gnutls_mac_algorithm_t algorithm);

This function will return the length of the output data of the given hmac algorithm.

`algorithm` : | the hmac algorithm to use
Returns : | The length or zero on error.

Since 2.10.0

### gnutls_hmac_fast ()

    int                 gnutls_hmac_fast                    (gnutls_mac_algorithm_t algorithm,
                                                             const void *key,
                                                             size_t keylen,
                                                             const void *text,
                                                             size_t textlen,
                                                             void *digest);

This convenience function will hash the given data and return output on a single call.

`algorithm` : | the hash algorithm to use
`key` : | the key to use
`keylen` : | The length of the key
`text` : | the data to hash
`textlen` : | The length of data to hash
`digest` : | is the output value of the hash
Returns : | Zero or a negative value on error.

Since 2.10.0

### gnutls_hash_init ()

    int                 gnutls_hash_init                    (gnutls_hash_hd_t *dig,
                                                             gnutls_digest_algorithm_t algorithm);

This function will initialize an context that can be used to produce a Message Digest of data. This will effectively use the current crypto backend in use by gnutls or the cryptographic accelerator in use.

`dig` : | is a gnutls_hash_hd_t structure.
`algorithm` : | the hash algorithm to use
Returns : | Zero or a negative value on error.

Since 2.10.0

### gnutls_hash ()

    int                 gnutls_hash                         (gnutls_hash_hd_t handle,
                                                             const void *text,
                                                             size_t textlen);

This function will hash the given data using the algorithm specified by the context.

`handle` : | is a gnutls_cipher_hd_t structure.
`text` : | the data to hash
`textlen` : | The length of data to hash
Returns : | Zero or a negative value on error.

Since 2.10.0

### gnutls_hash_output ()

    void                gnutls_hash_output                  (gnutls_hash_hd_t handle,
                                                             void *digest);

This function will output the current hash value.

`handle` : | is a gnutls_hash_hd_t structure.
`digest` : | is the output value of the hash

Since 2.10.0

### gnutls_hash_deinit ()

    void                gnutls_hash_deinit                  (gnutls_hash_hd_t handle,
                                                             void *digest);

This function will deinitialize all resources occupied by the given hash context.

`handle` : | is a gnutls_hash_hd_t structure.
`digest` : | is the output value of the hash

Since 2.10.0

### gnutls_hash_get_len ()

    int                 gnutls_hash_get_len                 (gnutls_digest_algorithm_t algorithm);

This function will return the length of the output data of the given hash algorithm.

`algorithm` : | the hash algorithm to use
Returns : | The length or zero on error.

Since 2.10.0

### gnutls_hash_fast ()

    int                 gnutls_hash_fast                    (gnutls_digest_algorithm_t algorithm,
                                                             const void *text,
                                                             size_t textlen,
                                                             void *digest);

This convenience function will hash the given data and return output on a single call.

`algorithm` : | the hash algorithm to use
`text` : | the data to hash
`textlen` : | The length of data to hash
`digest` : | is the output value of the hash
Returns : | Zero or a negative value on error.

Since 2.10.0

### GNUTLS_CRYPTO_API_VERSION

    #define GNUTLS_CRYPTO_API_VERSION 0x03

### gnutls_crypto_single_cipher_st

    #define gnutls_crypto_single_cipher_st gnutls_crypto_cipher_st

### gnutls_crypto_single_mac_st

    #define gnutls_crypto_single_mac_st gnutls_crypto_mac_st

### gnutls_crypto_single_digest_st

    #define gnutls_crypto_single_digest_st gnutls_crypto_digest_st

### init ()

    int                 (*init)                             (gnutls_cipher_algorithm_t Param1,
                                                             void **ctx);

### setkey ()

    int                 (*setkey)                           (void *ctx,
                                                             const void *key,
                                                             size_t keysize);

### setiv ()

    int                 (*setiv)                            (void *ctx,
                                                             const void *iv,
                                                             size_t ivsize);

### encrypt ()

    int                 (*encrypt)                          (void *ctx,
                                                             const void *plain,
                                                             size_t plainsize,
                                                             void *encr,
                                                             size_t encrsize);

### decrypt ()

    int                 (*decrypt)                          (void *ctx,
                                                             const void *encr,
                                                             size_t encrsize,
                                                             void *plain,
                                                             size_t plainsize);

### deinit ()

    void                (*deinit)                           (void *ctx);

### hash ()

    int                 (*hash)                             (void *ctx,
                                                             const void *text,
                                                             size_t textsize);

### output ()

    int                 (*output)                           (void *src_ctx,
                                                             void *digest,
                                                             size_t digestsize);

### copy ()

    int                 (*copy)                             (void **dst_ctx,
                                                             void *src_ctx);

### enum gnutls_rnd_level_t

    typedef enum {
        GNUTLS_RND_NONCE = 0,
        GNUTLS_RND_RANDOM = 1,
        GNUTLS_RND_KEY = 2
    } gnutls_rnd_level_t;

Enumeration of random quality levels.

`GNUTLS_RND_NONCE` | Non-predictable random number. Fatal in parts of session if broken, i.e., vulnerable to statistical analysis.
`GNUTLS_RND_RANDOM` | Pseudo-random cryptographic random number. Fatal in session if broken.
`GNUTLS_RND_KEY` | Fatal in many sessions if broken.

### gnutls_rnd ()

    int                 gnutls_rnd                          (gnutls_rnd_level_t level,
                                                             void *data,
                                                             size_t len);

This function will generate random data and store it to output buffer.

`level` : | a security level
`data` : | place to store random bytes
`len` : | The requested size
Returns : | Zero or a negative value on error.

### enum gnutls_pk_flag_t

    typedef enum {
        GNUTLS_PK_FLAG_NONE = 0
    } gnutls_pk_flag_t;

Enumeration of public-key flag.

`GNUTLS_PK_FLAG_NONE` | No flag.

### rnd ()

    int                 (*rnd)                              (void *ctx,
                                                             int level,
                                                             void *data,
                                                             size_t datasize);

### bigint_t

      typedef void *bigint_t;

### enum gnutls_bigint_format_t

    typedef enum {
        /* raw unsigned integer format */
        GNUTLS_MPI_FORMAT_USG = 0,
        /* raw signed integer format - always a leading zero when positive */
        GNUTLS_MPI_FORMAT_STD = 1,
        /* the pgp integer format */
        GNUTLS_MPI_FORMAT_PGP = 2
    } gnutls_bigint_format_t;

Enumeration of different bignum integer encoding formats.

`GNUTLS_MPI_FORMAT_USG` | Raw unsigned integer format.
`GNUTLS_MPI_FORMAT_STD` | Raw signed integer format, always a leading zero when positive.
`GNUTLS_MPI_FORMAT_PGP` | The pgp integer format.

### bigint_new ()

    bigint_t            (*bigint_new)                       (int nbits);

### bigint_release ()

    void                (*bigint_release)                   (bigint_t n);

### bigint_cmp ()

    int                 (*bigint_cmp)                       (const bigint_t m1,
                                                             const bigint_t m2);

### bigint_cmp_ui ()

    int                 (*bigint_cmp_ui)                    (const bigint_t m1,
                                                             unsigned long  m2);

### bigint_mod ()

    bigint_t            (*bigint_mod)                       (const bigint_t a,
                                                             const bigint_t b);

### bigint_set ()

    bigint_t            (*bigint_set)                       (bigint_t a,
                                                             const bigint_t b);

### bigint_set_ui ()

    bigint_t            (*bigint_set_ui)                    (bigint_t a,
                                                             unsigned long  b);

### int ()

    unsigned            int                                 ();

### bigint_powm ()

    bigint_t            (*bigint_powm)                      (bigint_t w,
                                                             const bigint_t b,
                                                             const bigint_t e,
                                                             const bigint_t m);

### bigint_addm ()

    bigint_t            (*bigint_addm)                      (bigint_t w,
                                                             const bigint_t a,
                                                             const bigint_t b,
                                                             const bigint_t m);

### bigint_subm ()

    bigint_t            (*bigint_subm)                      (bigint_t w,
                                                             const bigint_t a,
                                                             const bigint_t b,
                                                             const bigint_t m);

### bigint_mulm ()

    bigint_t            (*bigint_mulm)                      (bigint_t w,
                                                             const bigint_t a,
                                                             const bigint_t b,
                                                             const bigint_t m);

### bigint_mul ()

    bigint_t            (*bigint_mul)                       (bigint_t w,
                                                             const bigint_t a,
                                                             const bigint_t b);

### bigint_add_ui ()

    bigint_t            (*bigint_add_ui)                    (bigint_t w,
                                                             const bigint_t a,
                                                             unsigned long  b);

### bigint_sub_ui ()

    bigint_t            (*bigint_sub_ui)                    (bigint_t w,
                                                             const bigint_t a,
                                                             unsigned long  b);

### bigint_mul_ui ()

    bigint_t            (*bigint_mul_ui)                    (bigint_t w,
                                                             const bigint_t a,
                                                             unsigned long  b);

### bigint_div ()

    bigint_t            (*bigint_div)                       (bigint_t q,
                                                             const bigint_t a,
                                                             const bigint_t b);

### bigint_prime_check ()

    int                 (*bigint_prime_check)               (const bigint_t pp);

### bigint_generate_group ()

    int                 (*bigint_generate_group)            (gnutls_group_st *gg,
                                                             unsigned int bits);

### bigint_scan ()

    bigint_t            (*bigint_scan)                      (const void *buf,
                                                             size_t buf_size,
                                                             gnutls_bigint_format_t format);

### bigint_print ()

    int                 (*bigint_print)                     (const bigint_t a,
                                                             void *buf,
                                                             size_t *buf_size,
                                                             gnutls_bigint_format_t format);

### GNUTLS_MAX_PK_PARAMS

    #define GNUTLS_MAX_PK_PARAMS 16

### gnutls_pk_params_release ()

    void                gnutls_pk_params_release            (gnutls_pk_params_st *p);

### gnutls_pk_params_init ()

    void                gnutls_pk_params_init               (gnutls_pk_params_st *p);

### enum gnutls_direction_t

    typedef enum {
        GNUTLS_IMPORT = 0,
        GNUTLS_EXPORT = 1
    } gnutls_direction_t;

Enumeration of different directions.

`GNUTLS_IMPORT` | Import direction.
`GNUTLS_EXPORT` | Export direction.

### sign ()

    int                 (*sign)                             (gnutls_pk_algorithm_t Param1,
                                                             gnutls_datum_t *signature,
                                                             const gnutls_datum_t *data,
                                                             const gnutls_pk_params_st *priv);

### verify ()

    int                 (*verify)                           (gnutls_pk_algorithm_t Param1,
                                                             const gnutls_datum_t *data,
                                                             const gnutls_datum_t *signature,
                                                             const gnutls_pk_params_st *pub);

### generate ()

    int                 (*generate)                         (gnutls_pk_algorithm_t Param1,
                                                             unsigned int nbits,
                                                             gnutls_pk_params_st *Param3);

### pk_fixup_private_params ()

    int                 (*pk_fixup_private_params)          (gnutls_pk_algorithm_t Param1,
                                                             gnutls_direction_t Param2,
                                                             gnutls_pk_params_st *Param3);

### gnutls_crypto_single_cipher_register()

    #define             gnutls_crypto_single_cipher_register(algo, prio, st)

### gnutls_crypto_single_mac_register()

    #define             gnutls_crypto_single_mac_register(algo, prio, st)

### gnutls_crypto_single_digest_register()

    #define             gnutls_crypto_single_digest_register(algo, prio, st)

### gnutls_crypto_single_cipher_register2 ()

    int                 gnutls_crypto_single_cipher_register2
                                                            (gnutls_cipher_algorithm_t algorithm,
                                                             int priority,
                                                             int version,
                                                             const gnutls_crypto_single_cipher_st *s);

This function will register a cipher algorithm to be used by gnutls. Any algorithm registered will override the included algorithms and by convention kernel implemented algorithms have priority of 90. The algorithm with the lowest priority will be used by gnutls.

This function should be called before `gnutls_global_init()`.

For simplicity you can use the convenience `gnutls_crypto_single_cipher_register()` macro.

`algorithm` : | is the gnutls algorithm identifier
`priority` : | is the priority of the algorithm
`version` : | should be set to `GNUTLS_CRYPTO_API_VERSION`
`s` : | is a structure holding new cipher's data
Returns : | `GNUTLS_E_SUCCESS` on success, otherwise an error.

Since 2.6.0

### gnutls_crypto_single_mac_register2 ()

    int                 gnutls_crypto_single_mac_register2  (gnutls_mac_algorithm_t algorithm,
                                                             int priority,
                                                             int version,
                                                             const gnutls_crypto_single_mac_st *s);

This function will register a MAC algorithm to be used by gnutls. Any algorithm registered will override the included algorithms and by convention kernel implemented algorithms have priority of 90. The algorithm with the lowest priority will be used by gnutls.

This function should be called before `gnutls_global_init()`.

For simplicity you can use the convenience `gnutls_crypto_single_mac_register()` macro.

`algorithm` : | is the gnutls algorithm identifier
`priority` : | is the priority of the algorithm
`version` : | should be set to `GNUTLS_CRYPTO_API_VERSION`
`s` : | is a structure holding new algorithms's data
Returns : | `GNUTLS_E_SUCCESS` on success, otherwise an error.

Since 2.6.0

### gnutls_crypto_single_digest_register2 ()

    int                 gnutls_crypto_single_digest_register2
                                                            (gnutls_digest_algorithm_t algorithm,
                                                             int priority,
                                                             int version,
                                                             const gnutls_crypto_single_digest_st *s);

This function will register a digest (hash) algorithm to be used by gnutls. Any algorithm registered will override the included algorithms and by convention kernel implemented algorithms have priority of 90. The algorithm with the lowest priority will be used by gnutls.

This function should be called before `gnutls_global_init()`.

For simplicity you can use the convenience `gnutls_crypto_single_digest_register()` macro.

`algorithm` : | is the gnutls algorithm identifier
`priority` : | is the priority of the algorithm
`version` : | should be set to `GNUTLS_CRYPTO_API_VERSION`
`s` : | is a structure holding new algorithms's data
Returns : | `GNUTLS_E_SUCCESS` on success, otherwise an error.

Since 2.6.0

### gnutls_crypto_cipher_register()

    #define             gnutls_crypto_cipher_register(prio, st)

### gnutls_crypto_mac_register()

    #define             gnutls_crypto_mac_register(prio, st)

### gnutls_crypto_digest_register()

    #define             gnutls_crypto_digest_register(prio, st)

### gnutls_crypto_cipher_register2 ()

    int                 gnutls_crypto_cipher_register2      (int priority,
                                                             int version,
                                                             const gnutls_crypto_cipher_st *s);

This function will register a cipher interface to be used by gnutls. Any interface registered will override the included engine and by convention kernel implemented interfaces should have priority of 90. The interface with the lowest priority will be used by gnutls.

This function should be called before `gnutls_global_init()`.

For simplicity you can use the convenience `gnutls_crypto_cipher_register()` macro.

`priority` : | is the priority of the cipher interface
`version` : | should be set to `GNUTLS_CRYPTO_API_VERSION`
`s` : | is a structure holding new interface's data
Returns : | `GNUTLS_E_SUCCESS` on success, otherwise an error.

Since 2.6.0

### gnutls_crypto_mac_register2 ()

    int                 gnutls_crypto_mac_register2         (int priority,
                                                             int version,
                                                             const gnutls_crypto_mac_st *s);

This function will register a mac interface to be used by gnutls. Any interface registered will override the included engine and by convention kernel implemented interfaces should have priority of 90. The interface with the lowest priority will be used by gnutls.

This function should be called before `gnutls_global_init()`.

For simplicity you can use the convenience `gnutls_crypto_digest_register()` macro.

`priority` : | is the priority of the mac interface
`version` : | should be set to `GNUTLS_CRYPTO_API_VERSION`
`s` : | is a structure holding new interface's data
Returns : | `GNUTLS_E_SUCCESS` on success, otherwise an error.

Since 2.6.0

### gnutls_crypto_digest_register2 ()

    int                 gnutls_crypto_digest_register2      (int priority,
                                                             int version,
                                                             const gnutls_crypto_digest_st *s);

This function will register a digest interface to be used by gnutls. Any interface registered will override the included engine and by convention kernel implemented interfaces should have priority of 90. The interface with the lowest priority will be used by gnutls.

This function should be called before `gnutls_global_init()`.

For simplicity you can use the convenience `gnutls_crypto_digest_register()` macro.

`priority` : | is the priority of the digest interface
`version` : | should be set to `GNUTLS_CRYPTO_API_VERSION`
`s` : | is a structure holding new interface's data
Returns : | `GNUTLS_E_SUCCESS` on success, otherwise an error.

Since 2.6.0

### gnutls_crypto_rnd_register()

    #define             gnutls_crypto_rnd_register(prio, st)

### gnutls_crypto_pk_register()

    #define             gnutls_crypto_pk_register(prio, st)

### gnutls_crypto_bigint_register()

    #define             gnutls_crypto_bigint_register(prio, st)

### gnutls_crypto_rnd_register2 ()

    int                 gnutls_crypto_rnd_register2         (int priority,
                                                             int version,
                                                             const gnutls_crypto_rnd_st *s);

This function will register a random generator to be used by gnutls. Any generator registered will override the included generator and by convention kernel implemented generators have priority of 90. The generator with the lowest priority will be used by gnutls.

This function should be called before `gnutls_global_init()`.

For simplicity you can use the convenience `gnutls_crypto_rnd_register()` macro.

`priority` : | is the priority of the generator
`version` : | should be set to `GNUTLS_CRYPTO_API_VERSION`
`s` : | is a structure holding new generator's data
Returns : | `GNUTLS_E_SUCCESS` on success, otherwise an error.

Since 2.6.0

### gnutls_crypto_pk_register2 ()

    int                 gnutls_crypto_pk_register2          (int priority,
                                                             int version,
                                                             const gnutls_crypto_pk_st *s);

This function will register an interface for gnutls to operate on public key operations. Any interface registered will override the included interface. The interface with the lowest priority will be used by gnutls.

Note that the bigint interface must interoperate with the bigint interface. Thus if this interface is updated the `gnutls_crypto_bigint_register()` should also be used.

This function should be called before `gnutls_global_init()`.

For simplicity you can use the convenience `gnutls_crypto_pk_register()` macro.

`priority` : | is the priority of the interface
`version` : | should be set to `GNUTLS_CRYPTO_API_VERSION`
`s` : | is a structure holding new interface's data
Returns : | `GNUTLS_E_SUCCESS` on success, otherwise an error.

Since 2.6.0

### gnutls_crypto_bigint_register2 ()

    int                 gnutls_crypto_bigint_register2      (int priority,
                                                             int version,
                                                             const gnutls_crypto_bigint_st *s);

This function will register an interface for gnutls to operate on big integers. Any interface registered will override the included interface. The interface with the lowest priority will be used by gnutls.

Note that the bigint interface must interoperate with the public key interface. Thus if this interface is updated the `gnutls_crypto_pk_register()` should also be used.

This function should be called before `gnutls_global_init()`.

For simplicity you can use the convenience `gnutls_crypto_bigint_register()` macro.

`priority` : | is the priority of the interface
`version` : | should be set to `GNUTLS_CRYPTO_API_VERSION`
`s` : | is a structure holding new interface's data
Returns : | `GNUTLS_E_SUCCESS` on success, otherwise an error.

Since 2.6.0