Esempio n. 1
0
        public void SetSessionKey(String pubKeyString, String scrambler = null)
        {
            BigInteger pubKey = BigIntegerExtensions.CreateBigInteger(pubKeyString, 16);

            if (IsServerInstance)       // Server SessionKey
            {
                // (Av^u) ^ b (mod N)
                SessionKey = pubKey.Multiply(Verifier.ModPow(Scrambler, Modulus)).ModPow(PrivateKey, Modulus);
            }
            else                        // Client SessionKey
            {
                Scrambler = BigIntegerExtensions.CreateBigInteger(scrambler, 16);
                BigInteger temp = PrivateKey.Add(Scrambler.Multiply(SaltedIdentityHash));
                SessionKey = pubKey.Subtract((Generator.ModPow(SaltedIdentityHash, Modulus))
                                             .Multiply(Multiplier)).ModPow(temp, Modulus);
            }
        }