public Signature(string signatureAlgorithm) { if (!SupportedMechanism.Contains(signatureAlgorithm)) { throw new MechanismNotSupportedException(signatureAlgorithm); } if (!EnabledMechanism.Contains(signatureAlgorithm)) { throw new MechanismNotEnabledException(signatureAlgorithm); } _signatureIntPtr = OQS_SIG_new(signatureAlgorithm); if (_signatureIntPtr == IntPtr.Zero) { throw new OpenQuantumSafeException("Failed to initialize signature algorithm."); } _signature = Marshal.PtrToStructure <UnmanagedSignature>(_signatureIntPtr); }
public KeyEncapsulationMechanism(string keyEncapsulationMechanismAlgorithm) { if (!SupportedMechanism.Contains(keyEncapsulationMechanismAlgorithm)) { throw new MechanismNotSupportedException(keyEncapsulationMechanismAlgorithm); } if (!EnabledMechanism.Contains(keyEncapsulationMechanismAlgorithm)) { throw new MechanismNotEnabledException(keyEncapsulationMechanismAlgorithm); } _keyEncapsulationMechanismIntPtr = OQS_KEM_new(keyEncapsulationMechanismAlgorithm); if (_keyEncapsulationMechanismIntPtr == IntPtr.Zero) { throw new OpenQuantumSafeException("Failed to initialize key encapsulation mechanism algorithm."); } _keyEncapsulationMechanism = Marshal.PtrToStructure <UnmanagedKeyEncapsulationMechanism>(_keyEncapsulationMechanismIntPtr); }