Cryptographic Ops
Advanced Functionality
Collaboration diagram for Cryptographic Ops:

## Enumerations

enum | jwt_crypto_provider_t { JWT_CRYPTO_OPS_NONE = 0 , JWT_CRYPTO_OPS_OPENSSL , JWT_CRYPTO_OPS_GNUTLS , JWT_CRYPTO_OPS_MBEDTLS , JWT_CRYPTO_OPS_ANY }
| Different providers for crypto operations. More...

## Functions

const char * | jwt_get_crypto_ops (void)
jwt_crypto_provider_t | jwt_get_crypto_ops_t (void)
int | jwt_set_crypto_ops (const char *opname)
int | jwt_set_crypto_ops_t (jwt_crypto_provider_t opname)
int | jwt_crypto_ops_supports_jwk (void)

## Detailed Description

Functions used to set and get which crypto operations are used

LibJWT supports several crypto libraries, mainly "openssl", "gnutls", and "mbedtls". By default, "openssl" is used.

Warning
  Changing the crypto operations is not thread safe. You must protect changing them with some sort of lock, including locking around usage of the operations themselves. Ideally, you should only perform this at the start of your application before using any of LibJWTs functions. Failing to follow this guide can lead to crashes in certain situations.

Remarks
  ENVIRONMENT: You can set JWT_CRYPTO to the default operations you wish to use. If JWT_CRYPTO is invalid, an error message will be printed to the console when LibJWT is loaded by the application.

## Enumeration Type Documentation

## jwt_crypto_provider_t

enum jwt_crypto_provider_t

Different providers for crypto operations.

Used to set or test the underlying cryptographic library provider.

Remarks
  These being present are not a guarantee that the JWT library has been compiled to support it. Also, certain functions of the library may not be supported by each. For example, not all of them support JWKS operations.

Enumerator
JWT_CRYPTO_OPS_NONE | Used for error handling
JWT_CRYPTO_OPS_OPENSSL | OpenSSL Library
JWT_CRYPTO_OPS_GNUTLS | GnuTLS Library
JWT_CRYPTO_OPS_MBEDTLS | MBedTLS embedded library
JWT_CRYPTO_OPS_ANY | Used internally for hmac keys

## Function Documentation

## jwt_crypto_ops_supports_jwk()

int jwt_crypto_ops_supports_jwk | ( | void |  | ) |

Check if the current crypto operations support JWK usage

Returns
  1 if it does, 0 if not

## jwt_get_crypto_ops()

const char * jwt_get_crypto_ops | ( | void |  | ) |

Retrieve the name of the current crypto operations being used.

Returns
  name of the crypto operation set

## jwt_get_crypto_ops_t()

jwt_crypto_provider_t jwt_get_crypto_ops_t | ( | void |  | ) |

Retrieve the type of the current crypto operations being used.

Returns
  jwt_crypto_provider_t of the crypto operation set

## jwt_set_crypto_ops()

int jwt_set_crypto_ops | ( | const char * | opname | ) |

Set the crypto operations to the named set.

The opname is one of the available operators in the compiled version of LibJWT. Most times, this is either "openssl" or "gnutls".

Parameters

  opname | the name of the crypto operation to set

Returns
  0 on success, 1 for error

## jwt_set_crypto_ops_t()

int jwt_set_crypto_ops_t | ( | jwt_crypto_provider_t | opname | ) |

Set the crypto operations to a jwt_crypto_provider_t type

The same as jwt_set_crypto_ops(), but uses the type as opname

Parameters

  opname | A valid jwt_crypto_provider_t type

Returns
  0 on success, 1 for error