LibJWT: Algorithms

| LibJWT 3.3.2 The C JSON Web Token Library +JWK +JWKS

Algorithms
JSON Web Token
Collaboration diagram for Algorithms:

## Enumerations
enum | jwt_alg_t { JWT_ALG_NONE = 0 , JWT_ALG_HS256 , JWT_ALG_HS384 , JWT_ALG_HS512 , JWT_ALG_RS256 , JWT_ALG_RS384 , JWT_ALG_RS512 , JWT_ALG_ES256 , JWT_ALG_ES384 , JWT_ALG_ES512 , JWT_ALG_PS256 , JWT_ALG_PS384 , JWT_ALG_PS512 , JWT_ALG_ES256K , JWT_ALG_EDDSA , JWT_ALG_INVAL }
| JWT algorithm types. More...

## Functions
jwt_alg_t | jwt_get_alg (const jwt_t *jwt)
const char * | jwt_alg_str (jwt_alg_t alg)
jwt_alg_t | jwt_str_alg (const char *alg)

## Detailed Description

Utility functions to convert between string and type for alg

## Enumeration Type Documentation

## ◆ jwt_alg_t

enum jwt_alg_t

JWT algorithm types.

These are the supported algorithm types for LibJWT.

RFC-7518 Sec 3.1

Enumerator
JWT_ALG_NONE | No signature
JWT_ALG_HS256 | HMAC using SHA-256
JWT_ALG_HS384 | HMAC using SHA-384
JWT_ALG_HS512 | HMAC using SHA-512
JWT_ALG_RS256 | RSASSA-PKCS1-v1_5 using SHA-256
JWT_ALG_RS384 | RSASSA-PKCS1-v1_5 using SHA-384
JWT_ALG_RS512 | RSASSA-PKCS1-v1_5 using SHA-512
JWT_ALG_ES256 | ECDSA using P-256 and SHA-256
JWT_ALG_ES384 | ECDSA using P-384 and SHA-384
JWT_ALG_ES512 | ECDSA using P-521 and SHA-512
JWT_ALG_PS256 | RSASSA-PSS using SHA-256 and MGF1 with SHA-256
JWT_ALG_PS384 | RSASSA-PSS using SHA-384 and MGF1 with SHA-384
JWT_ALG_PS512 | RSASSA-PSS using SHA-512 and MGF1 with SHA-512
JWT_ALG_ES256K | ECDSA using secp256k1 and SHA-256
JWT_ALG_EDDSA | EdDSA using Ed25519
JWT_ALG_INVAL | An invalid algorithm from the caller or the token

## Function Documentation

## ◆ jwt_alg_str()

const char * jwt_alg_str | ( | jwt_alg_t | alg | ) |

Convert alg type to it's string representation.

Returns a string that matches the alg type provided.

Parameters

  alg | A valid jwt_alg_t specifier.

Returns
  Returns a string (e.g. "RS256") matching the alg or NULL for invalid alg.

## ◆ jwt_get_alg()

jwt_alg_t jwt_get_alg | ( | const jwt_t * | jwt | ) |

Get the jwt_alg_t set for this JWT object.

Returns the jwt_alg_t type for this JWT object.

Parameters

  jwt | Pointer to a JWT object.

Returns
  Returns a jwt_alg_t type for this object.

## ◆ jwt_str_alg()

jwt_alg_t jwt_str_alg | ( | const char * | alg | ) |

Convert alg string to type.

Returns an alg type based on the string representation.

RFC-7518 Sec 3.1

Parameters

  alg | A valid string for algorithm type (e.g. "RS256").

Returns
  Returns a jwt_alg_t matching the string or JWT_ALG_INVAL if no matches were found.

Note
  This only works for algorithms that LibJWT supports or knows about.