diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2012-04-28 19:56:30 -0700 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2012-04-28 20:01:00 -0700 |
commit | ea4325d172d8a2bc925ed362f1c35560b8c1f13e (patch) | |
tree | a04960f4cddd7f2223df83b03e89300c5051434c /src/DotNetOpenAuth.OAuth2/OAuth2/Crypto/JweRsaEncryptionAlgorithm.cs | |
parent | 01d8c73f818d30b20f86630d35d230b5168215d1 (diff) | |
download | DotNetOpenAuth-ea4325d172d8a2bc925ed362f1c35560b8c1f13e.zip DotNetOpenAuth-ea4325d172d8a2bc925ed362f1c35560b8c1f13e.tar.gz DotNetOpenAuth-ea4325d172d8a2bc925ed362f1c35560b8c1f13e.tar.bz2 |
Work toward support JWT access tokens.origin/jwt
Diffstat (limited to 'src/DotNetOpenAuth.OAuth2/OAuth2/Crypto/JweRsaEncryptionAlgorithm.cs')
-rw-r--r-- | src/DotNetOpenAuth.OAuth2/OAuth2/Crypto/JweRsaEncryptionAlgorithm.cs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/DotNetOpenAuth.OAuth2/OAuth2/Crypto/JweRsaEncryptionAlgorithm.cs b/src/DotNetOpenAuth.OAuth2/OAuth2/Crypto/JweRsaEncryptionAlgorithm.cs new file mode 100644 index 0000000..0d2159d --- /dev/null +++ b/src/DotNetOpenAuth.OAuth2/OAuth2/Crypto/JweRsaEncryptionAlgorithm.cs @@ -0,0 +1,29 @@ +namespace DotNetOpenAuth.OAuth2.Crypto { + using System; + using System.Collections.Generic; + using System.Linq; + using System.Security.Cryptography; + using System.Text; + + internal class JweRsaEncryptionAlgorithm : JwtEncryptionAlgorithm { + private readonly RSACryptoServiceProvider recipientPublicKey; + + private readonly bool useOaepPadding; + + internal JweRsaEncryptionAlgorithm(RSACryptoServiceProvider recipientPublicKey, bool useOaepPadding = true) + : base(useOaepPadding ? JsonWebEncryptionAlgorithms.RSA_OAEP : JsonWebEncryptionAlgorithms.RSA1_5, JsonWebEncryptionMethods.A256CBC) { + Requires.NotNull(recipientPublicKey, "recipientPublicKey"); + this.recipientPublicKey = recipientPublicKey; + this.useOaepPadding = useOaepPadding; + } + + internal override void Encrypt(byte[] plainText, out byte[] cipherText, out byte[] integrityValue) { + cipherText = this.recipientPublicKey.Encrypt(plainText, this.useOaepPadding); + integrityValue = null; // RSA is an AEAD algorithm, so it doesn't need a separate integrity check. + } + + internal override byte[] Decrypt(byte[] cipherText, byte[] integrityValue) { + throw new NotImplementedException(); + } + } +} |