LibJWT Dev
The C JSON Web Token Library +JWK +JWKS
Cryptographic Operations

Functions used to set and get which crypto operations are used More...

Collaboration diagram for Cryptographic Operations:

Enumerations

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

Functions

const char * jwt_get_crypto_ops (void)
 Retrieve the name of the current crypto operations being used.
 
jwt_crypto_provider_t jwt_get_crypto_ops_t (void)
 Retrieve the type of the current crypto operations being used.
 
int jwt_set_crypto_ops (const char *opname)
 Set the crypto operations to the named set.
 
int jwt_set_crypto_ops_t (jwt_crypto_provider_t opname)
 Set the crypto operations to a jwt_crypto_provider_t type.
 
int jwt_crypto_ops_supports_jwk (void)
 Check if the current crypto operations support JWK usage.
 

Detailed Description

Functions used to set and get which crypto operations are used

LibJWT supports several crypto libaries, mainly "openssl" and "gnutls". By default, if enabled, "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

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.

Definition at line 129 of file jwt.h.

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
opnamethe name of the crypto operation to set
Returns
0 on success, valid errno otherwise.

◆ 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
opnameA valid jwt_crypto_provider_t type
Returns
0 on success, valid errno otherwise.