public void KeyEncapsulationMechanismEncapsulateAndDecapsulateTest() { Parallel.ForEach(KeyEncapsulationMechanism.EnabledMechanism, enabledMechanism => { using (var keyEncapsulationMechanismAlgorithm = new KeyEncapsulationMechanism(enabledMechanism)) { keyEncapsulationMechanismAlgorithm.GenerateKeypair(out var publicKey, out var secretKey); keyEncapsulationMechanismAlgorithm.Encapsulation(out var cipherText, out var sharedSecret, publicKey); keyEncapsulationMechanismAlgorithm.Decapsulation(out var sharedSecret2, cipherText, secretKey); if (sharedSecret.Length != sharedSecret2.Length) { throw new OpenQuantumSafeException("Verified failed."); } for (var i = 0; i < sharedSecret.Length; i++) { if (sharedSecret[i] != sharedSecret2[i]) { throw new OpenQuantumSafeException("Verified failed."); } } } }); }
public void KeyEncapsulationMechanismNotSupportedTest() { Assert.Throws <MechanismNotSupportedException>(() => { using (var _ = new KeyEncapsulationMechanism(null)) { } }); }
public void KeyEncapsulationMechanismEnabledTest() { foreach (var enabledMechanism in KeyEncapsulationMechanism.EnabledMechanism) { using (var _ = new KeyEncapsulationMechanism(enabledMechanism)) { } } }