/// <summary> /// Constructor. /// </summary> /// <param name="groupType">DH group defined in [RFC2412] and MS-AIPS.</param> public Oakley(DhGroupType groupType) { // The prime used for DH group string primeString = null; // Generator of the prime, both 768 bit and 1024 bit use the same value. switch (groupType) { case DhGroupType.MODP768Bit: primeString = Modp768BitPrimeString; break; case DhGroupType.MODP1024Bit: primeString = Modp1024BitPrimeString; break; case DhGroupType.MODP2048Bit: primeString = Modp2048BitPrimeString; break; case DhGroupType.ECP256: case DhGroupType.ECP384: throw new NotImplementedException(); default: throw new InvalidOperationException("Invalid DH group type"); } this.randomExponentLength = bitLength; this.exponent = RandomBigInteger(randomExponentLength); this.prime = BigInteger.Parse(primeString); this.baseNum = new BigInteger(new byte[] { 0x02 }); }