Rhonabwy: JWK Import functions

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

Functions
JWK Import functions

## Functions
int | r_jwk_import_from_json_str (jwk_t *jwk, const char *input)
int | r_jwk_import_from_json_t (jwk_t *jwk, json_t *j_input)
int | r_jwk_import_from_pem_der (jwk_t *jwk, int type, int format, const unsigned char *input, size_t input_len)
int | r_jwk_import_from_gnutls_privkey (jwk_t *jwk, gnutls_privkey_t key)
int | r_jwk_import_from_gnutls_pubkey (jwk_t *jwk, gnutls_pubkey_t pub)
int | r_jwk_import_from_gnutls_x509_crt (jwk_t *jwk, gnutls_x509_crt_t crt)
int | r_jwk_import_from_x5u (jwk_t *jwk, int x5u_flags, const char *x5u)
int | r_jwk_import_from_x5c (jwk_t *jwk, const char *x5c)
int | r_jwk_import_from_symmetric_key (jwk_t *jwk, const unsigned char *key, size_t key_len)
int | r_jwk_import_from_password (jwk_t *jwk, const char *password)
int | r_jwk_extract_pubkey (jwk_t *jwk_privkey, jwk_t *jwk_pubkey, int x5u_flags)
jwk_t * | r_jwk_quick_import (rhn_import type,...)
jwk_t * | r_jwk_copy (jwk_t *jwk)
int | r_jwk_equal (jwk_t *jwk1, jwk_t *jwk2)

## Detailed Description

Import a jwk from JSON data, gnutls inner types or PEM/DER

## Function Documentation

## ◆ r_jwk_import_from_json_str()

int r_jwk_import_from_json_str | ( | jwk_t * | jwk,
|  | const char * | input
| ) |  |

Import a JSON in string format into a jwk_t

Parameters

  jwk | the jwk_t * to import to
  input | a JWK in JSON stringified format If jwk is set, values will be overwritten

Returns
  RHN_OK on success, an error value on error

## ◆ r_jwk_import_from_json_t()

int r_jwk_import_from_json_t | ( | jwk_t * | jwk,
|  | json_t * | j_input
| ) |  |

Import a JSON in json_t format into a jwk_t

Parameters

  jwk | the jwk_t * to import to
  j_input | a JWK in json_t * format If jwk is set, values will be overwritten

Returns
  RHN_OK on success, an error value on error

## ◆ r_jwk_import_from_pem_der()

int r_jwk_import_from_pem_der | ( | jwk_t * | jwk,
|  | int | type,
|  | int | format,
|  | const unsigned char * | input,
|  | size_t | input_len
| ) |  |

Import a public or private key or a X509 certificate in PEM or DER format into a jwk_t

Parameters

  jwk | the jwk_t * to import to
  type | the type of the input, values available are R_X509_TYPE_PUBKEY, R_X509_TYPE_PRIVKEY or R_X509_TYPE_CERTIFICATE
  format | the format of the input, values available are R_FORMAT_PEM or R_FORMAT_DER
  input | the input value, must contain the key or the certificate in PEM or DER format
  input_len | the length of the data contained in input If jwk is set, values will be overwritten

Returns
  RHN_OK on success, an error value on error

## ◆ r_jwk_import_from_gnutls_privkey()

int r_jwk_import_from_gnutls_privkey | ( | jwk_t * | jwk,
|  | gnutls_privkey_t | key
| ) |  |

Import a GnuTLS private key in gnutls_privkey_t format into a jwk_t

Parameters

  jwk | the jwk_t * to import to
  key | the private key to be imported to jwk If jwk is set, values will be overwritten

Returns
  RHN_OK on success, an error value on error

## ◆ r_jwk_import_from_gnutls_pubkey()

int r_jwk_import_from_gnutls_pubkey | ( | jwk_t * | jwk,
|  | gnutls_pubkey_t | pub
| ) |  |

Import a GnuTLS public key in gnutls_pubkey_t format into a jwk_t

Parameters

  jwk | the jwk_t * to import to
  pub | the public key to be imported to jwk If jwk is set, values will be overwritten

Returns
  RHN_OK on success, an error value on error

## ◆ r_jwk_import_from_gnutls_x509_crt()

int r_jwk_import_from_gnutls_x509_crt | ( | jwk_t * | jwk,
|  | gnutls_x509_crt_t | crt
| ) |  |

Import a GnuTLS X509 certificate in gnutls_x509_crt_t format into a jwk_t

Parameters

  jwk | the jwk_t * to import to
  crt | the X509 certificate whose public key will be imported to jwk If jwk is set, values will be overwritten

Returns
  RHN_OK on success, an error value on error

## ◆ r_jwk_import_from_x5u()

int r_jwk_import_from_x5u | ( | jwk_t * | jwk,
|  | int | x5u_flags,
|  | const char * | x5u
| ) |  |

Import a certificate from an URL

Parameters

  jwk | the jwk_t * to import to
  x5u_flags | Flags to retrieve x5u certificates Flags available are R_FLAG_IGNORE_SERVER_CERTIFICATE: ignrore if web server certificate is invalid R_FLAG_FOLLOW_REDIRECT: follow redirections if necessary
  x5u | the url to retreive the certificate If jwk is set, values will be overwritten

Returns
  RHN_OK on success, an error value on error

## ◆ r_jwk_import_from_x5c()

int r_jwk_import_from_x5c | ( | jwk_t * | jwk,
|  | const char * | x5c
| ) |  |

Import a key from an x5c value

Parameters

  jwk | the jwk_t * to import to
  x5c | the x5c value If jwk is set, values will be overwritten

Returns
  RHN_OK on success, an error value on error

## ◆ r_jwk_import_from_symmetric_key()

int r_jwk_import_from_symmetric_key | ( | jwk_t * | jwk,
|  | const unsigned char * | key,
|  | size_t | key_len
| ) |  |

Import a symmetric key into a jwk The key will be converted to base64url format

Parameters

  jwk | the jwk_t * to import to
  key | the key to import
  key_len | the size of the key

Returns
  RHN_OK on success, an error value on error

## ◆ r_jwk_import_from_password()

int r_jwk_import_from_password | ( | jwk_t * | jwk,
|  | const char * | password
| ) |  |

Import a password into a jwk The password will be converted to base64url format

Parameters

  jwk | the jwk_t * to import to
  password | the password to import

Returns
  RHN_OK on success, an error value on error

## ◆ r_jwk_extract_pubkey()

int r_jwk_extract_pubkey | ( | jwk_t * | jwk_privkey,
|  | jwk_t * | jwk_pubkey,
|  | int | x5u_flags
| ) |  |

Extract the public key from the private key jwk_privkey and set it into jwk_pubkey

Parameters

  jwk_privkey | the jwt containing a private key
  jwk_pubkey | the jwt that will be set with the public key data
  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

## ◆ r_jwk_quick_import()

jwk_t * r_jwk_quick_import | ( | rhn_import | type,
|  |  | ...
| ) |  |

Import data into a jwk

Parameters

  type | type of the data to import Following parameters must be set of values with the mandatory parameters for each rhn_import See rhn_import documentation

Returns
  a jwk containing key parsed, or NULL on error

## ◆ r_jwk_copy()

jwk_t * r_jwk_copy | ( | jwk_t * | jwk | ) |

Return a copy of the JWK

Parameters

  jwk | the jwk to copy

Returns
  a copy of the jwk

## ◆ r_jwk_equal()

int r_jwk_equal | ( | jwk_t * | jwk1,
|  | jwk_t * | jwk2
| ) |  |

Compare 2 jwk

Parameters

  jwk1 | the first JWK to compare
  jwk2 | the second JWK to compare

Returns
  1 if both jwk1 and jwk2 are equal, 0 otherwise