Rhonabwy Javascript Object Signing and Encryption (JOSE) library - JWK, JWKS, JWS, JWE and JWT

Loading...
Searching...
No Matches
Validate a JWK and generate a key pair

## Functions
int | r_jwk_key_type (jwk_t *jwk, unsigned int *bits, int x5u_flags)
int | r_jwk_is_valid (jwk_t *jwk)
int | r_jwk_is_valid_x5u (jwk_t *jwk, int x5u_flags)
int | r_jwk_generate_key_pair (jwk_t *jwk_privkey, jwk_t *jwk_pubkey, int type, unsigned int bits, const char *kid)

## Detailed Description

## Function Documentation

## ◆ r_jwk_generate_key_pair()

int r_jwk_generate_key_pair | ( | jwk_t * | jwk_privkey,
|  | jwk_t * | jwk_pubkey,
|  | int | type,
|  | unsigned int | bits,
|  | const char * | kid )

Generates a pair of private and public key using given parameters

Parameters

  jwk_privkey | the private key to set, must be initialized
  jwk_pubkey | the public key to set, must be initialized
  JWK, JWKS, JWS, JWE type | the type of key, values available are R_KEY_TYPE_RSA or R_KEY_TYPE_EC
  bits | the key size to generate, if the key type is R_KEY_TYPE_EC, the key size is the curve length: 256, 384 or 512
  kid | the key ID to set to the JWKs, if NULL or empty, will be set automatically

Returns
  RHN_OK on success, an error value on error

## ◆ r_jwk_is_valid()

int r_jwk_is_valid | ( | jwk_t * | jwk | ) |

Check if the jwk is valid

Parameters

  jwk | the jwk_t * to test

Returns
  RHN_OK on success, an error value on error Logs error message with yder on error

## ◆ r_jwk_is_valid_x5u()

int r_jwk_is_valid_x5u | ( | jwk_t * | jwk,
|  | int | x5u_flags )

Check if the x5u property is valid

Parameters

  jwk | the jwk_t * to test
  x5u_flags | Flags to retrieve x5u certificates pointed by x5u if necessary, could be 0 if not needed Flags available are R_FLAG_IGNORE_SERVER_CERTIFICATE: ignrore if web server certificate is invalid R_FLAG_FOLLOW_REDIRECT: follow redirections if necessary R_FLAG_IGNORE_REMOTE: do not download remote key, but the function may return an error

Returns
  RHN_OK on success, an error value on error Logs error message with yder on error

## ◆ r_jwk_key_type()

int r_jwk_key_type | ( | jwk_t * | jwk,
|  | unsigned int * | bits,
|  | int | x5u_flags )

Get the type and algorithm of a jwk_t

Parameters

  jwk | the jwk_t * to test
  bits | set the key size in bits (may be NULL)
  x5u_flags | Flags to retrieve x5u certificates pointed by x5u if necessary, could be 0 if not needed Flags available are R_FLAG_IGNORE_SERVER_CERTIFICATE: ignrore if web server certificate is invalid R_FLAG_FOLLOW_REDIRECT: follow redirections if necessary R_FLAG_IGNORE_REMOTE: do not download remote key, but the function may return an error

Returns
  an integer containing
  - R_KEY_TYPE_NONE if the jwk is invalid
  - the type:
  - R_KEY_TYPE_PUBLIC: for a public key
  - R_KEY_TYPE_PRIVATE: for a private key
  - R_KEY_TYPE_SYMMETRIC: for a symmetrick key
  - the algorithm used
  - R_KEY_TYPE_RSA: for a RSA key
  - R_KEY_TYPE_EC: for a EC key
  - R_KEY_TYPE_HMAC: for a HMAC key You must test the result value with bitwise operator Ex: if (r_jwk_key_type(jwk) & R_KEY_TYPE_PUBLIC) { if (r_jwk_key_type(jwk) & R_KEY_TYPE_RSA) { You can combine type and algorithm values in the bitwise operator Ex: if (r_jwk_key_type(jwk) & (R_KEY_TYPE_RSA|R_KEY_TYPE_PRIVATE)) {