-
Notifications
You must be signed in to change notification settings - Fork 463
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unamrked HMAC SHA based algorithms as insecure and obsolete (#478)
* Reverted #384. * Bumped version to 10.1.0 * Updated changelog
- Loading branch information
1 parent
906002e
commit 2c76ee0
Showing
7 changed files
with
28 additions
and
37 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,22 @@ | ||
using System; | ||
using System.Security.Cryptography; | ||
|
||
namespace JWT.Algorithms | ||
{ | ||
[Obsolete(ObsoleteMessage, error: false)] | ||
public abstract class HMACSHAAlgorithm : IJwtAlgorithm | ||
{ | ||
internal const string ObsoleteMessage = "HMAC SHA based algorithms are not secure to protect modern web applications. Consider switching to RSASSA or ECDSA."; | ||
|
||
/// <inheritdoc /> | ||
public abstract string Name { get; } | ||
|
||
/// <inheritdoc /> | ||
public abstract HashAlgorithmName HashAlgorithmName { get; } | ||
|
||
/// <inheritdoc /> | ||
public byte[] Sign(byte[] key, byte[] bytesToSign) | ||
{ | ||
using var sha = CreateAlgorithm(key); | ||
return sha.ComputeHash(bytesToSign); | ||
} | ||
|
||
protected abstract HMAC CreateAlgorithm(byte[] key); | ||
} | ||
using System.Security.Cryptography; | ||
|
||
namespace JWT.Algorithms | ||
{ | ||
public abstract class HMACSHAAlgorithm : IJwtAlgorithm | ||
{ | ||
/// <inheritdoc /> | ||
public abstract string Name { get; } | ||
|
||
/// <inheritdoc /> | ||
public abstract HashAlgorithmName HashAlgorithmName { get; } | ||
|
||
/// <inheritdoc /> | ||
public byte[] Sign(byte[] key, byte[] bytesToSign) | ||
{ | ||
using var sha = CreateAlgorithm(key); | ||
return sha.ComputeHash(bytesToSign); | ||
} | ||
|
||
protected abstract HMAC CreateAlgorithm(byte[] key); | ||
} | ||
} |
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