首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SRP6 TrinityCore实现错误吗?

SRP6 TrinityCore实现错误吗?
EN

Stack Overflow用户
提问于 2021-09-02 15:52:58
回答 1查看 464关注 0票数 2

TrinityCore反对在auth表上使用旧的sha_pass_hash列,而支持更安全的SRP6方法。但是,我无法使用这里提供的例子正确计算C#/dotnet或PHP中的验证器。我看过示例,但它似乎不像TrinityCore开发人员建议的那样工作。有没有人知道SRP6可能会发现代码中有什么问题?我也看过这个例子,但是它使用了硬编码的盐类?如果有人能告诉我PHP中出了什么问题,我也许能找出.NET的问题所在

我尝试的代码看起来与第一个示例最接近,但我将数组翻转为小endian。

代码语言:javascript
复制
           public byte[] CalculateVerifier(string username, string password, byte[] salt)
        {
                if (BitConverter.IsLittleEndian)
                {
                    return BigInteger.ModPow(
                                   g,
                                   new BigInteger(Hash(salt, Hash(Encoding.UTF8.GetBytes($"{username.ToUpper()}:{password.ToUpper()}")))),
                                   N
                               ).ToByteArray();
                }
                else
                {
                    return BigInteger.ModPow(
                                   g,
                                   new BigInteger(Hash(salt, Hash(Encoding.UTF8.GetBytes($"{username.ToUpper()}:{password.ToUpper()}")).Reverse().ToArray())),
                                   N
                               ).ToByteArray();
                }
            

        }
        public bool VerifySRP6Login(string username, string password, byte[] salt, byte[] verifier)
        {
            // re-calculate the verifier using the provided username + password and the stored salt
            byte[] checkVerifier = CalculateSRP6Verifier(username, password, salt);
            Console.WriteLine($"{Encoding.ASCII.GetString(verifier)} {verifier.Length} bytes\n{Encoding.ASCII.GetString(checkVerifier)} {checkVerifier.Length} bytes");
            Console.WriteLine($"{new BigInteger(verifier)}\n{new BigInteger(checkVerifier)}");
            // compare it against the stored verifier
            return verifier.SequenceEqual(checkVerifier);
        }
        public byte[] Hash(byte[] componentOne, byte[] componentTwo)
        {
            if (componentOne == null) throw new ArgumentNullException(nameof(componentOne));
            if (componentTwo == null) throw new ArgumentNullException(nameof(componentTwo));

            //WoW expects non-secure SHA1 hashing. SRP6 is deprecated too. We need to do it anyway
            using (SHA1 shaProvider = SHA1.Create())
            {
                //See Jackpoz's Combine function
                return shaProvider.ComputeHash(componentOne.Concat(componentTwo).ToArray());
            }
        }
        public byte[] Hash(byte[] bytes)
        {
            if (bytes == null) throw new ArgumentNullException(nameof(bytes));

            //WoW expects non-secure SHA1 hashing. SRP6 is deprecated too. We need to do it anyway
            using (SHA1 shaProvider = SHA1.Create())
            {
                return shaProvider.ComputeHash(bytes);
            }
        }
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-09-08 00:43:37

答案是在这个解决方案中找到的,显然我没有正确地制作BigInteger,因为数据是一个未签名的int,我将其视为签名。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69033523

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档