Skip to content

Reuse DataProtectionProvider to create JWT SigningCredentials #24966

Discussion options

You must be logged in to vote

The DataProtection APIs are an authenticated encryption with additional data (AEAD) mechanism (see docs for implementation details). Every call to Protect introduces some randomness by design, which will result in unique outputs, even given identical inputs.

AEAD mechanisms can be used to produce a MAC (a symmetric "signature"). This is normally done by passing a zero-length plaintext and feeding all of the to-be-signed data into the additional data argument of the algorithm. In the DataProtection stack, this additional data argument is the "purpose" string; though I strongly suggest reading the docs about best practices when generating these strings, including prepending typeof(T).FullName

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by huysentruitw
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants