コード例 #1
0
        public SRP6Client(
            HashAlgorithm hashAlgorithm, BigInteger n, BigInteger g, BigInteger b,
            BigInteger salt, byte[] account, byte[] passwordMd5Hex)
        {
            this.smallA = BigIntegerHelper.RandUnsignedBigInteger(19);

            this.hashAlgorithm = hashAlgorithm;
            this.n             = n;
            this.g             = g;
            this.b             = b;
            this.salt          = salt;
            this.account       = account;
            this.p             = hashAlgorithm.ComputeHash(new byte[0]
                                                           .Concat(account)
                                                           .Concat(new[] { (byte)':' })
                                                           .Concat(passwordMd5Hex)
                                                           .ToArray());

            this.a = this.CalculateA();              // A = g ^ a % N
            this.x = this.CalculateX();              // X = H(s, P)
            this.u = this.CalculateU();              // U = H(A, B)
            this.s = this.CalculateS();              // S = (B - (k * g.ModExp(x, N))).ModExp(a + (u * x), N)
            this.k = this.CalculateK();
            this.m = this.CalculateM();              // H(H(N) ^ H(g), H(P), s, A, B, K)
        }