This repository has been archived by the owner on Jan 29, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
87 additions
and
3 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
69 changes: 69 additions & 0 deletions
69
XMPP_API/Classes/Network/XML/Messages/Features/SASL/SHA1/ScramSHA256SASLMechanism.cs
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,69 @@ | ||
namespace XMPP_API.Classes.Network.XML.Messages.Features.SASL.SHA1 | ||
{ | ||
public class ScramSHA256SASLMechanism : ScramSHA1SASLMechanism | ||
{ | ||
// https://tools.ietf.org/html/rfc7677 | ||
//--------------------------------------------------------Attributes:-----------------------------------------------------------------\\ | ||
#region --Attributes-- | ||
private const byte CLIENT_NONCE_LENGTH = 32; | ||
|
||
private readonly string CLIENT_NONCE_BASE_64; | ||
private readonly string PASSWORD_NORMALIZED; | ||
private string serverNonce; | ||
private string saltBase64; | ||
private string clientFirstMsg; | ||
private string serverFirstMsg; | ||
|
||
#endregion | ||
//--------------------------------------------------------Constructor:----------------------------------------------------------------\\ | ||
#region --Constructors-- | ||
/// <summary> | ||
/// Basic Constructor | ||
/// </summary> | ||
/// <history> | ||
/// 06/01/2019 Created [Fabian Sauter] | ||
/// </history> | ||
public ScramSHA256SASLMechanism(string id, string password) : base(id, password) | ||
{ | ||
} | ||
|
||
public ScramSHA256SASLMechanism(string id, string password, string clientNonceBase64) : base(id, password, clientNonceBase64) | ||
{ | ||
} | ||
|
||
#endregion | ||
//--------------------------------------------------------Set-, Get- Methods:---------------------------------------------------------\\ | ||
#region --Set-, Get- Methods-- | ||
|
||
|
||
#endregion | ||
//--------------------------------------------------------Misc Methods:---------------------------------------------------------------\\ | ||
#region --Misc Methods (Public)-- | ||
public override SelectSASLMechanismMessage getSelectSASLMechanismMessage() | ||
{ | ||
clientFirstMsg = "n=" + ID + ",r=" + CLIENT_NONCE_BASE_64; | ||
string encClientFirstMsg = encodeStringBase64("n,," + clientFirstMsg); | ||
|
||
return new SelectSASLMechanismMessage("SCRAM-SHA-256", encClientFirstMsg); | ||
} | ||
|
||
#endregion | ||
|
||
#region --Misc Methods (Private)-- | ||
|
||
#endregion | ||
|
||
#region --Misc Methods (Protected)-- | ||
protected override bool isValidIterationsCount(int iters) | ||
{ | ||
return iters >= 4096; | ||
} | ||
|
||
#endregion | ||
//--------------------------------------------------------Events:---------------------------------------------------------------------\\ | ||
#region --Events-- | ||
|
||
|
||
#endregion | ||
} | ||
} |
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