You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by mi...@apache.org on 2023/05/22 17:07:53 UTC
svn commit: r1909999 - in /apr/apr/trunk: include/apr_jose.h jose/apr_jose.c jose/apr_jose_decode.c
Author: minfrin
Date: Mon May 22 17:07:53 2023
New Revision: 1909999
URL: http://svn.apache.org/viewvc?rev=1909999&view=rev
Log:
apr_jose: Allow a user specified context to be passed with a signature or
recipient.
Modified:
apr/apr/trunk/include/apr_jose.h
apr/apr/trunk/jose/apr_jose.c
apr/apr/trunk/jose/apr_jose_decode.c
Modified: apr/apr/trunk/include/apr_jose.h
URL: http://svn.apache.org/viewvc/apr/apr/trunk/include/apr_jose.h?rev=1909999&r1=1909998&r2=1909999&view=diff
==============================================================================
--- apr/apr/trunk/include/apr_jose.h (original)
+++ apr/apr/trunk/include/apr_jose.h Mon May 22 17:07:53 2023
@@ -537,6 +537,8 @@ typedef struct apr_jose_signature_t {
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 @@ typedef struct apr_jose_recipient_t {
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 @@ APR_DECLARE(apr_jose_t *) apr_jose_jwks_
* @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.
Modified: apr/apr/trunk/jose/apr_jose.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/jose/apr_jose.c?rev=1909999&r1=1909998&r2=1909999&view=diff
==============================================================================
--- apr/apr/trunk/jose/apr_jose.c (original)
+++ apr/apr/trunk/jose/apr_jose.c Mon May 22 17:07:53 2023
@@ -79,7 +79,7 @@ APR_DECLARE(apr_jose_t *) apr_jose_json_
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 @@ APR_DECLARE(apr_jose_signature_t *) apr_
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 @@ APR_DECLARE(apr_jose_recipient_t *) apr_
}
recipient->header = header;
+ recipient->ctx = ctx;
return recipient;
}
Modified: apr/apr/trunk/jose/apr_jose_decode.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/jose/apr_jose_decode.c?rev=1909999&r1=1909998&r2=1909999&view=diff
==============================================================================
--- apr/apr/trunk/jose/apr_jose_decode.c (original)
+++ apr/apr/trunk/jose/apr_jose_decode.c Mon May 22 17:07:53 2023
@@ -426,7 +426,7 @@ apr_status_t apr_jose_decode_compact_jws
* 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 @@ apr_status_t apr_jose_decode_compact_jwe
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 @@ apr_status_t apr_jose_decode_json_jws(ap
}
jws->signature = apr_jose_signature_make(NULL, NULL, NULL,
- pool);
+ NULL, pool);
if (!jws->signature) {
return APR_ENOMEM;
}