/usr/include/cjose/jwe.h is in libcjose-dev 0.4.1-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | /*
* Copyrights
*
* Portions created or assigned to Cisco Systems, Inc. are
* Copyright (c) 2014-2016 Cisco Systems, Inc. All Rights Reserved.
*/
/**
* \file jwe.h
* \brief Functions and data structures for interacting with
* JSON Web Encryption (JWE) objects.
*
*/
#ifndef CJOSE_JWE_H
#define CJOSE_JWE_H
#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
#include "header.h"
#include "error.h"
#include "jwk.h"
#ifdef __cplusplus
extern "C"
{
#endif
/**
* An instance of a JWE object.
*/
typedef struct _cjose_jwe_int cjose_jwe_t;
/**
* Creates a new JWE by encrypting the given plaintext within the given header
* and JWK.
*
* If the header provided indicates an algorithm requiring an asymmetric key
* (e.g. RSA-OAEP), the provided JWK must be asymmetric (e.g. RSA or EC).
*
* If the header provided indicates an algorithm requiring a symmetric key
* (e.g. (dir), the provided JWK must be symmetric (e.g. oct).
*
* \param jwk [in] the key to use for encrypting the JWE.
* \param protected_header [in] additional header values to include in the JWE header.
* \param plaintext [in] the plaintext to be encrypted in the JWE payload.
* \param plaintext_len [in] the length of the plaintext.
* \param err [out] An optional error object which can be used to get additional
* information in the event of an error.
* \returns a newly generated JWE with the given plaintext as the payload.
*/
cjose_jwe_t *cjose_jwe_encrypt(
const cjose_jwk_t *jwk,
cjose_header_t *protected_header,
const uint8_t *plaintext,
size_t plaintext_len,
cjose_err *err);
/**
* Creates a serialization of the given JWE object.
*
* Note the current implementation only supports serialization to the JWE
* compact format.
*
* \param jwe [in] The JWE object to be serialized.
* \param err [out] An optional error object which can be used to get additional
* information in the event of an error.
* \returns A pointer to a compact serialization of this JWE. Note
* the returned string pointer is owned by the caller, the caller
* must free it directly when no longer needed, or the memory will be
* leaked.
*/
char *cjose_jwe_export(
cjose_jwe_t *jwe,
cjose_err *err);
/**
* Creates a new JWE object from the given JWE compact serialization.
*
* Note the current implementation only recognizes the JWE compact serialization
* format.
*
* \param compact [in] a JWE in serialized form.
* \param compact_len [in] the length of the compact serialization.
* \param err [out] An optional error object which can be used to get additional
* information in the event of an error.
* \returns a newly generated JWE object from the given JWE serialization.
*/
cjose_jwe_t *cjose_jwe_import(
const char *compact,
size_t compact_len,
cjose_err *err);
/**
* Decrypts the JWE object using the given JWK. Returns the plaintext data of
* the JWE payload.
*
* \param jwe [in] the JWE object to decrypt.
* \param jwk [in] the key to use for decrypting.
* \param content_len [out] The number of byes in the returned buffer.
* \param err [out] An optional error object which can be used to get additional
* information in the event of an error.
* \returns The decrypted content. Note the caller is responseible for free'ing
* this buffer when no longer in use. Failure to do so will result in
* a memory leak.
*/
uint8_t *cjose_jwe_decrypt(
cjose_jwe_t *jwe,
const cjose_jwk_t *jwk,
size_t *content_len,
cjose_err *err);
/**
* Returns the protected header of the JWE object.
*
* **NOTE:** The returned header is still owned by the JWE object. Users must
* call `cjose_header_retain()` if it is expected to be valid after the
* owning `cjose_jwe_t` is released.
*
* \param jwe [in] the JWE object for which the protected header is requested.
* \returns the (parsed) protected header
*/
cjose_header_t *cjose_jwe_get_protected(cjose_jwe_t *jwe);
/**
* Releases the given JWE object.
*
* \param jwe the JWE to be released. If null, this is a no-op.
*/
void cjose_jwe_release(cjose_jwe_t *jwe);
#ifdef __cplusplus
}
#endif
#endif // CJOSE_JWE_H
|