-
-
Notifications
You must be signed in to change notification settings - Fork 932
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support ETM (Encrypt-then-MAC) variants for HMAC
- Loading branch information
Showing
10 changed files
with
167 additions
and
55 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using System; | ||
using System.Security.Cryptography; | ||
|
||
namespace Renci.SshNet.Security.Cryptography | ||
{ | ||
/// <summary> | ||
/// Represents the info for Message Authentication Code (MAC). | ||
/// </summary> | ||
public sealed class HMAC : IDisposable | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="HMAC"/> class. | ||
/// </summary> | ||
/// <param name="hashAlgorithm">The hash algorithm.</param> | ||
public HMAC(HashAlgorithm hashAlgorithm) | ||
: this(hashAlgorithm, etm: false) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="HMAC"/> class. | ||
/// </summary> | ||
/// <param name="hashAlgorithm">The hash algorithm.</param> | ||
/// <param name="etm"><see langword="true"/> to enable encrypt-then-MAC, <see langword="false"/> to use encrypt-and-MAC.</param> | ||
public HMAC( | ||
HashAlgorithm hashAlgorithm, | ||
bool etm) | ||
{ | ||
HashAlgorithm = hashAlgorithm; | ||
ETM = etm; | ||
} | ||
|
||
/// <inheritdoc/> | ||
public void Dispose() | ||
{ | ||
HashAlgorithm?.Dispose(); | ||
} | ||
|
||
/// <summary> | ||
/// Gets the hash algorithem. | ||
/// </summary> | ||
public HashAlgorithm HashAlgorithm { get; private set; } | ||
|
||
/// <summary> | ||
/// Gets a value indicating whether enable encryption-to-mac or encryption-then-mac. | ||
/// </summary> | ||
public bool ETM { get; private set; } | ||
} | ||
} |
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
Oops, something went wrong.