The weirdest thing here is that my app works perfectly. It's just that my integration test can't find the .dll or dylib file. I am using liboqs and my projects structure looks like this:
amaranth/
Models, Controllers, Views, etc...
oqs.dll
liboqs.dylib
liboqs.so
amaranth.Tests/
IntegrationTests/
AdminControllerTests.cs
The file that references the dll/dylib files is at `amaranth/Helpers/liboqsRelatedHelpers/Sig.cs and the part of that file that references the dll/dylib files looks like this:
#region OQS native DLL functions
[DllImport("oqs", CallingConvention = CallingConvention.Cdecl)]
extern private static IntPtr OQS_SIG_new(string method_name);
[DllImport("oqs", CallingConvention = CallingConvention.Cdecl)]
extern private static int OQS_SIG_keypair(IntPtr sig, byte[] public_key, byte[] secret_key);
[DllImport("oqs", CallingConvention = CallingConvention.Cdecl)]
extern private static int OQS_SIG_sign(IntPtr sig, byte[] signature, ref UIntPtr sig_len, byte[] message, int message_len, byte[] secret_key);
[DllImport("oqs", CallingConvention = CallingConvention.Cdecl)]
extern private static int OQS_SIG_verify(IntPtr sig, byte[] message, int message_len, byte[] signature, int signature_len, byte[] public_key);
[DllImport("oqs", CallingConvention = CallingConvention.Cdecl)]
extern private static void OQS_SIG_free(IntPtr sig);
[DllImport("oqs", CallingConvention = CallingConvention.Cdecl)]
extern private static IntPtr OQS_SIG_alg_identifier(int index);
[DllImport("oqs", CallingConvention = CallingConvention.Cdecl)]
extern private static int OQS_SIG_alg_count();
[DllImport("oqs", CallingConvention = CallingConvention.Cdecl)]
extern private static int OQS_SIG_alg_is_enabled(string method_name);
#endregion
This is what it looked like when I found the error in Visual Studio for Mac:
What could be causing these file's not to be referenced in the Integration Tests but allowing the files to be referenced in running the actual app?
CodePudding user response:
I had to copy the liboqs builds into bin/Debug/net6.0/
of the amaranth.Tests
directory. So the new project structure is:
amaranth/
Models, Controllers, Views, etc...
oqs.dll
liboqs.dylib
liboqs.so
amaranth.Tests/
IntegrationTests/
AdminControllerTests.cs
bin/
Debug/
net6.0/
oqs.dll
liboqs.dylib
liboqs.so