Beispiel #1
0
        private ReadOnlyMemory <byte> String2Key(byte[] password, string salt, byte[] param)
        {
            var passwordBytes = KerberosConstants.UnicodeBytesToUtf8(password);

            var iterations = GetIterations(param, 4096);

            var saltBytes = KerberosConstants.UnicodeStringToUtf8(salt);

            var random = PBKDF2(passwordBytes, saltBytes, iterations, KeySize);

            return(DK(random, KerberosConstant, KeySize, BlockSize));
        }
Beispiel #2
0
        private static ReadOnlySpan <byte> GetSaltBytes(string salt, string pepper)
        {
            var saltBytes = KerberosConstants.UnicodeStringToUtf8(salt);

            if (string.IsNullOrWhiteSpace(pepper))
            {
                return(saltBytes);
            }

            var pepperBytes = KerberosConstants.UnicodeStringToUtf8(pepper);

            var results = new Span <byte>(new byte[saltBytes.Length + 1 + pepperBytes.Length]);

            pepperBytes.CopyTo(results);

            saltBytes.CopyTo(results.Slice(pepperBytes.Length + 1, saltBytes.Length));

            return(results);
        }