/// <summary>
        /// A static publicly exposed version of GetDerivedKeyBytes_PBKDF2_HMACSHA512 which matches the exact specification in Rfc2898 PBKDF2 using HMACSHA512
        /// </summary>
        /// <param name="P">Password passed as a Byte Array</param>
        /// <param name="S">Salt passed as a Byte Array</param>
        /// <param name="c">Iterations to perform the underlying PRF over</param>
        /// <param name="dkLen">Length of Bytes to return, an AES 256 key wold require 32 Bytes</param>
        /// <returns>Derived Key in Byte Array form ready for use by chosen encryption function</returns>
        public static Byte[] PBKDF2(Byte[] P, Byte[] S, int c = CMinIterations, int dkLen = hLen)
        {
            Rfc2898_pbkdf2_hmacsha512 rfcObj = new Rfc2898_pbkdf2_hmacsha512(P, S, c);

            return(rfcObj.GetDerivedKeyBytes_PBKDF2_HMACSHA512(dkLen));
        }
예제 #2
0
파일: BIP39.cs 프로젝트: tezos-blue/client
 /// <summary>
 /// Supply a mnemonic sentence with any words of your choosing not restricted to wordlists and be given seed bytes hex encoded as a string in return
 /// </summary>
 /// <param name="mnemonicSentence">The mnemonic sentence we will use to derive seed bytes</param>
 /// <param name="passphrase">Optional passphrase to protect the seed bytes, defaults to empty string</param>
 /// <returns>Hex string encoded seed bytes that can be used to create a root in BIP32</returns>
 public static string GetSeedBytesHexString(string mnemonicSentence, string passphrase = cEmptyString)
 {
     mnemonicSentence = Utilities.NormaliseStringNfkd(mnemonicSentence);
     byte[] salt = Utilities.MergeByteArrays(UTF8Encoding.UTF8.GetBytes(cSaltHeader), UTF8Encoding.UTF8.GetBytes(Utilities.NormaliseStringNfkd(passphrase)));
     return(Utilities.BytesToHexString(Rfc2898_pbkdf2_hmacsha512.PBKDF2(UTF8Encoding.UTF8.GetBytes(mnemonicSentence), salt)));
 }