-
Notifications
You must be signed in to change notification settings - Fork 464
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for SHA384 and SHA512 hashing algorithms with RSASSA-PK…
…CS1-v1_5 (#305) * Added RSAAlgorithm abstract base class which all RSA algorithms derive from * Added RS384Algorithm, RS512Algorithm * Refactored RSAlgorithmFactory * Updated, added tests * Bumped version to 8.0.0
- Loading branch information
1 parent
93d9139
commit 263d6d1
Showing
15 changed files
with
573 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using System.Security.Cryptography; | ||
using System.Security.Cryptography.X509Certificates; | ||
|
||
namespace JWT.Algorithms | ||
{ | ||
/// <summary> | ||
/// RSASSA-PKCS1-v1_5 using SHA-384 | ||
/// </summary> | ||
public sealed class RS384Algorithm : RSAlgorithm | ||
{ | ||
/// <summary> | ||
/// Creates an instance of <see cref="RS384Algorithm" /> using the provided pair of public and private keys. | ||
/// </summary> | ||
/// <param name="publicKey">The public key for verifying the data.</param> | ||
/// <param name="privateKey">The private key for signing the data.</param> | ||
public RS384Algorithm(RSA publicKey, RSA privateKey) | ||
: base(publicKey, privateKey) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Creates an instance of <see cref="RS384Algorithm" /> using the provided public key only. | ||
/// </summary> | ||
/// <remarks> | ||
/// An instance created using this constructor can only be used for verifying the data, not for signing it. | ||
/// </remarks> | ||
/// <param name="publicKey">The public key for verifying the data.</param> | ||
public RS384Algorithm(RSA publicKey) | ||
: base(publicKey) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Creates an instance using the provided certificate. | ||
/// </summary> | ||
/// <param name="cert">The certificate having a public key and an optional private key.</param> | ||
public RS384Algorithm(X509Certificate2 cert) | ||
: base(cert) | ||
{ | ||
} | ||
|
||
/// <inheritdoc /> | ||
public override string Name => JwtAlgorithmName.RS384.ToString(); | ||
|
||
#if NET35 || NET40 | ||
protected override string HashAlgorithmInternal => HashAlgorithmName.SHA384; | ||
#else | ||
protected override HashAlgorithmName HashAlgorithmInternal => HashAlgorithmName.SHA384; | ||
#endif | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using System.Security.Cryptography; | ||
using System.Security.Cryptography.X509Certificates; | ||
|
||
namespace JWT.Algorithms | ||
{ | ||
/// <summary> | ||
/// RSASSA-PKCS1-v1_5 using SHA-512 | ||
/// </summary> | ||
public sealed class RS512Algorithm : RSAlgorithm | ||
{ | ||
/// <summary> | ||
/// Creates an instance of <see cref="RS512Algorithm" /> using the provided pair of public and private keys. | ||
/// </summary> | ||
/// <param name="publicKey">The public key for verifying the data.</param> | ||
/// <param name="privateKey">The private key for signing the data.</param> | ||
public RS512Algorithm(RSA publicKey, RSA privateKey) | ||
: base(publicKey, privateKey) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Creates an instance of <see cref="RS512Algorithm" /> using the provided public key only. | ||
/// </summary> | ||
/// <remarks> | ||
/// An instance created using this constructor can only be used for verifying the data, not for signing it. | ||
/// </remarks> | ||
/// <param name="publicKey">The public key for verifying the data.</param> | ||
public RS512Algorithm(RSA publicKey) | ||
: base(publicKey) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Creates an instance using the provided certificate. | ||
/// </summary> | ||
/// <param name="cert">The certificate having a public key and an optional private key.</param> | ||
public RS512Algorithm(X509Certificate2 cert) | ||
: base(cert) | ||
{ | ||
} | ||
|
||
/// <inheritdoc /> | ||
public override string Name => JwtAlgorithmName.RS512.ToString(); | ||
|
||
#if NET35 || NET40 | ||
protected override string HashAlgorithmInternal => HashAlgorithmName.SHA512; | ||
#else | ||
protected override HashAlgorithmName HashAlgorithmInternal => HashAlgorithmName.SHA512; | ||
#endif | ||
} | ||
} |
Oops, something went wrong.