Exemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ScramShaAuthenticator"/> class.
 /// </summary>
 /// <param name="credential">The credential.</param>
 /// <param name="hashAlgorithName">The hash algorithm name.</param>
 /// <param name="randomStringGenerator">The random string generator.</param>
 /// <param name="h">The H function to use.</param>
 /// <param name="hi">The Hi function to use.</param>
 /// <param name="hmac">The Hmac function to use.</param>
 /// <param name="cache">The cache to use.</param>
 /// <param name="serverApi">The server API.</param>
 internal ScramShaAuthenticator(
     UsernamePasswordCredential credential,
     HashAlgorithmName hashAlgorithName,
     IRandomStringGenerator randomStringGenerator,
     H h,
     Hi hi,
     Hmac hmac,
     ScramCache cache,
     ServerApi serverApi)
     : base(new ScramShaMechanism(credential, hashAlgorithName, randomStringGenerator, h, hi, hmac, cache), serverApi)
 {
     _databaseName = credential.Source;
 }
Exemplo n.º 2
0
 public ClientFirst(
     byte[] bytesToSendToServer,
     string clientFirstMessageBare,
     UsernamePasswordCredential credential,
     string rPrefix,
     H h,
     Hi hi,
     Hmac hmac,
     ScramCache cache)
 {
     _bytesToSendToServer    = bytesToSendToServer;
     _clientFirstMessageBare = clientFirstMessageBare;
     _credential             = credential;
     _h       = h;
     _hi      = hi;
     _hmac    = hmac;
     _rPrefix = rPrefix;
     _cache   = cache;
 }
Exemplo n.º 3
0
 public ScramShaMechanism(
     UsernamePasswordCredential credential,
     HashAlgorithmName hashAlgorithmName,
     IRandomStringGenerator randomStringGenerator,
     H h,
     Hi hi,
     Hmac hmac,
     ScramCache cache)
 {
     _credential = Ensure.IsNotNull(credential, nameof(credential));
     _h          = h;
     _hi         = hi;
     _hmac       = hmac;
     if (!hashAlgorithmName.ToString().StartsWith("SHA", StringComparison.Ordinal))
     {
         throw new ArgumentException("Must specify a SHA algorithm.");
     }
     _name = $"SCRAM-SHA-{hashAlgorithmName.ToString().Substring(3)}";
     _randomStringGenerator = Ensure.IsNotNull(randomStringGenerator, nameof(randomStringGenerator));
     _cache = cache;
 }
 public static ScramCacheEntry _cachedEntry(this ScramCache obj) =>
 (ScramCacheEntry)Reflector.GetFieldValue(obj, nameof(_cachedEntry));