/// <summary> /// Computes a derived cryptographic key from a password according to PBKDF2 /// http://en.wikipedia.org/wiki/PBKDF2. The function will only return a derived key /// if at least 'salt' is present in the 'extra' dictionary. The complete set of /// attributes that can be set in 'extra': /// salt: The salt value to be used. /// iterations: Number of iterations of derivation algorithm to run. /// keylen: Key length to derive. /// </summary> /// <param name="secret">The secret key from which to derive. </param> /// <param name="extra"> Extra data for salting the secret. Possible key values 'salt' /// (required, otherwise returns @secret), 'iterations' (1000 default), /// and/or 'keylen' (32 default). </param> /// <returns>A derived key (Base64 encoded) if a salt is provided in the extra parameter, or the /// value of parameter 'secret' if not.</returns> public static string DeriveKey(string secret, IDictionary <string, string> extra) { IWampCraChallenge adapter = CraChallenge.Create(extra); string result = DeriveKey(secret, adapter); return(result); }
/// <summary> /// Compute the authentication signature from an authentication challenge and a secret. /// </summary> /// <param name="authChallenge">The authentication challenge. </param> /// <param name="authSecret">The authentication secret. </param> /// <param name="authExtra">Extra data for salting the secret. Possible key values 'salt' /// (required, otherwise uses @authSecret), 'iterations' (1000 /// default), and/or 'keylen' (32 default). </param> /// <returns>The authentication signature.</returns> public static string AuthSignature(string authChallenge, string authSecret, IDictionary <string, string> authExtra) { return(AuthSignature(authChallenge, authSecret, CraChallenge.Create(authExtra))); }