// Client Constructor, salt not generated by client public Srp6(byte[] identityHash, String modulus, int generator, String salt, string initialVector = "OFRna73m*aze01xY") : this(initialVector, modulus, generator, identityHash) { // This SRP6 instance is a client instance IsServerInstance = false; // Convert the salt string to a BigInteger Salt = BigIntegerExtensions.CreateBigInteger(salt, 16); // Set the salted identity hash SaltedIdentityHash = Salt.CreateSaltedIdentityHash(identityHash); // Generate a pseudo prime to use for the private key PrivateKey = BigIntegerExtensions.GeneratePseudoPrime(128, 100, new Random()); // g^a (mod N) PublicKey = Generator.ModPow(PrivateKey, Modulus); }
// Server Constructor, Radix 16 strings, 256-bit predef values public Srp6(byte[] identityHash, string modulus, int generator, string inputSalt, int scramblerBits, string initialVector = "OFRna73m*aze01xY") : this(initialVector, modulus, generator, identityHash) { // This SRP6 instance is a server instance IsServerInstance = true; // Generate the Salt Salt = BigIntegerExtensions.CreateBigInteger(inputSalt, 16); // Set the salted identity hash, scrambler, and verifier Scrambler = BigIntegerExtensions.CreateBigInteger(scramblerBits, new Random()); SaltedIdentityHash = Salt.CreateSaltedIdentityHash(identityHash); Verifier = Generator.ModPow(SaltedIdentityHash, Modulus); // Random 128 bit number that is a probable prime PrivateKey = BigIntegerExtensions.GeneratePseudoPrime(128, 100, new Random()); // kv + g^b (mod N) PublicKey = Multiplier.Multiply(Verifier).Add(Generator.ModPow(PrivateKey, Modulus)); }