apr_jose: Allow a user specified context to be passed with a signature or
recipient.
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1909999 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/include/apr_jose.h b/include/apr_jose.h
index 59d0dca..695fafc 100644
--- a/include/apr_jose.h
+++ b/include/apr_jose.h
@@ -537,6 +537,8 @@
apr_json_value_t *protected_header;
/** JWS Signature */
apr_jose_data_t sig;
+ /** Caller specified context */
+ void *ctx;
/** Result of verification for this signature */
apr_status_t status;
} apr_jose_signature_t;
@@ -583,6 +585,8 @@
apr_json_value_t *header;
/** JWE Encrypted Key */
apr_jose_data_t ekey;
+ /** Caller specified context */
+ void *ctx;
/** Result of decryption for this recipient */
apr_status_t status;
} apr_jose_recipient_t;
@@ -962,25 +966,27 @@
* @param signature the result.
* @param header the unprotected header.
* @param protected the protected header.
+ * @param ctx user supplied context
* @param pool the pool to use.
* @return The apr_jose_signature_t is returned.
*/
APR_DECLARE(apr_jose_signature_t *) apr_jose_signature_make(
apr_jose_signature_t *signature, apr_json_value_t *header,
- apr_json_value_t *protected, apr_pool_t *pool)
- __attribute__((nonnull(4)));
+ apr_json_value_t *protected, void *ctx, apr_pool_t *pool)
+ __attribute__((nonnull(5)));
/**
* Make a recipient structure for JWE.
*
* @param recipient the result.
* @param unprotected the unprotected header.
+ * @param ctx user supplied context
* @param pool the pool to use.
* @return The apr_jose_recipient_t is returned.
*/
APR_DECLARE(apr_jose_recipient_t *) apr_jose_recipient_make(apr_jose_recipient_t *recipient,
- apr_json_value_t *unprotected, apr_pool_t *pool)
- __attribute__((nonnull(3)));
+ apr_json_value_t *unprotected, void *ctx, apr_pool_t *pool)
+ __attribute__((nonnull(4)));
/**
* Make an encryption structure for JWE.
diff --git a/jose/apr_jose.c b/jose/apr_jose.c
index 2f53840..4c4bd6b 100644
--- a/jose/apr_jose.c
+++ b/jose/apr_jose.c
@@ -79,7 +79,7 @@
APR_DECLARE(apr_jose_signature_t *) apr_jose_signature_make(
apr_jose_signature_t *signature, apr_json_value_t *header,
- apr_json_value_t *protected, apr_pool_t *pool)
+ apr_json_value_t *protected, void *ctx, apr_pool_t *pool)
{
if (!signature) {
@@ -91,13 +91,14 @@
signature->header = header;
signature->protected_header = protected;
+ signature->ctx = ctx;
return signature;
}
APR_DECLARE(apr_jose_recipient_t *) apr_jose_recipient_make(
apr_jose_recipient_t *recipient, apr_json_value_t *header,
- apr_pool_t *pool)
+ void *ctx, apr_pool_t *pool)
{
if (!recipient) {
@@ -108,6 +109,7 @@
}
recipient->header = header;
+ recipient->ctx = ctx;
return recipient;
}
diff --git a/jose/apr_jose_decode.c b/jose/apr_jose_decode.c
index 24017c8..af10e35 100644
--- a/jose/apr_jose_decode.c
+++ b/jose/apr_jose_decode.c
@@ -426,7 +426,7 @@
* the JWS Protected Header.
*/
- jws->signature = apr_jose_signature_make(NULL, NULL, ph, pool);
+ jws->signature = apr_jose_signature_make(NULL, NULL, ph, NULL, pool);
if (!jws->signature) {
return APR_ENOMEM;
}
@@ -525,7 +525,7 @@
return APR_ENOMEM;
}
- jwe->recipient = apr_jose_recipient_make(NULL, NULL, pool);
+ jwe->recipient = apr_jose_recipient_make(NULL, NULL, NULL, pool);
if (!jwe->recipient) {
return APR_ENOMEM;
}
@@ -1066,7 +1066,7 @@
}
jws->signature = apr_jose_signature_make(NULL, NULL, NULL,
- pool);
+ NULL, pool);
if (!jws->signature) {
return APR_ENOMEM;
}