/// <summary> /// Constructs a KEM object. /// </summary> /// <param name="kemAlg">An OQS KEM algorithm identifier; must be a value from <see cref="EnabledMechanisms"/>.</param> /// <exception cref="MechanismNotEnabledException">Thrown if the algorithm is supported but not enabled by the OQS runtime.</exception> /// <exception cref="MechanismNotSupportedException">Thrown if the algorithm is not supported by OQS.</exception> /// <exception cref="OQSException">Thrown if the OQS KEM object can't be initialized.</exception> public KEM(string kemAlg) { if (!SupportedMechanisms.Contains(kemAlg)) { throw new MechanismNotSupportedException(kemAlg); } if (!EnabledMechanisms.Contains(kemAlg)) { throw new MechanismNotEnabledException(kemAlg); } oqs_ptr = OQS_KEM_new(kemAlg); if (oqs_ptr == IntPtr.Zero) { throw new OQSException("Failed to initialize KEM mechanism"); } oqs_kem = Marshal.PtrToStructure <OQS_KEM>(oqs_ptr); }
/// <summary> /// Constructs a signature object. /// </summary> /// <param name="sigAlg">An OQS signature algorithm identifier; must be a value from <see cref="EnabledMechanisms"/>.</param> /// <exception cref="MechanismNotEnabledException">Thrown if the algorithm is supported but not enabled by the OQS runtime.</exception> /// <exception cref="MechanismNotSupportedException">Thrown if the algorithm is not supported by OQS.</exception> /// <exception cref="OQSException">Thrown if the OQS signature object can't be initialized.</exception> public Sig(string sigAlg) { if (!SupportedMechanisms.Contains(sigAlg)) { throw new MechanismNotSupportedException(sigAlg); } if (!EnabledMechanisms.Contains(sigAlg)) { throw new MechanismNotEnabledException(sigAlg); } oqs_ptr = OQS_SIG_new(sigAlg); if (oqs_ptr == IntPtr.Zero) { throw new OQSException("Failed to initialize signature mechanism"); } oqs_sig = Marshal.PtrToStructure <OQS_SIG>(oqs_ptr); }