Intel® Software Guard Extensions (Intel® SGX)
Discussion board focused on hardware-based isolation and memory encryption to provide extended code protection in solutions.

RemoteAttestationSample Client build error

kalogiannis__konstan
1,321 Views

Hello,

While the Server side builds and runs just fine i cant make the client to build in Debug mode.

The ISV-APP build fails with error:

1    error LNK2019: unresolved external symbol __imp__invalid_parameter_noinfo referenced in function memcpy_s in ISV-APP\sgx_ukey_exchange.lib(ukey_exchange.obj)

From what i've manage to gather this error occurs when two projects build in different modes but both project use Multi-threaded Debug DLL.

I have both messed with the configurations(among others the $(Outdir) and Symbols just to be safe)  and reinstalled VS,PSW,SDK,IPPs just to be sure and the problem is consistent.

When i build the code in Release mode the solution builds succesfully and runs albeit with 0x200f which is expected.

Any help will be appreciated

Thanks in advance

 

0 Kudos
1 Solution
Francisco_C_Intel
1,321 Views

As mentioned earlier, the 1.7 SDK and its sample projects are compatible with VS2015.

If the prebuilt "sgx_ukey_exchange.lib" is not compatible with your development environment, you can instead NOT link to the prebuilt static library and add the files included in the 1.7 SDK to your project:

C:\Program Files (x86)\Intel\IntelSGXSDK\src\RemoteAttestation\isv_app\sample_ukey_exchange\

View solution in original post

0 Kudos
14 Replies
Francisco_C_Intel
1,321 Views

Are you building 32 or 64bit? What version of Visual Studio are you using? What compiler / "Platform Toolset" are you using?

0 Kudos
kalogiannis__konstan
1,321 Views

I'm building Debug x64 on Visual Studio 13 premium.

Platform Toolset: Visual Studio 2013(v120)

0 Kudos
Francisco_C_Intel
1,321 Views

The remote key exchange static library, sgx_ukey_exchange[mt].lib, was built for use with Visual Studio 2015. If you are unable to use this static library in your development environment, the source code for a sample untrusted key exchange library is included in the isv_app subfolder of the Remote Attestation sample application that is shipped with this SDK.

You can use the source files instead of linking with the static lib.

0 Kudos
kalogiannis__konstan
1,321 Views

Thank you very much, i did as instructed and the sample worked flawlessly.

Again thanks for the help :)

0 Kudos
Andrej_S_
Beginner
1,321 Views

 

Hi there

I have exact same issue as OP.

"Server side builds and runs just fine i cant make the client to build in Debug mode."

"When i build the code in Release mode the solution builds successfully ​."

Server is built with Visual Studio 2015, Client debug build attempts have been with both (originally) VS2012 Pro and then when sgx_ukey_exchange.lib didn't work, VS2013 Pro.

The ISV-APP build fails with same error using both IDEs in both x32 and x64 Debug:

1    error LNK2019: unresolved external symbol __imp__invalid_parameter_noinfo referenced in function memcpy_s in ISV-APP\sgx_ukey_exchange.lib(ukey_exchange.obj)

I'm using the PDF labelled:Remote Attestation End-to-End Sample Code Installation and User Guide
June, 2016 Revision 1.0 as the configuration guide for sample code at: https://software.intel.com/en-us/articles/intel-software-guard-extensions-remote-attestation-end-to-end-example, ;

What are my options please in resolving the sgx_ukey_exchange.lib​ linker issues in debug mode in the Visual Studio 2013 sample project? Have attached the debug compiler output.

Any help will be appreciated

Thanks in advance

 

 

 

 

 

0 Kudos
Prabu_R_Intel
Employee
1,321 Views

Please verify the required trusted and untrusted libraries are configured properly to the  Intel SGX sample project settings in debug mode (Visual Studio 2013 project). 

 

0 Kudos
Francisco_C_Intel
1,322 Views

As mentioned earlier, the 1.7 SDK and its sample projects are compatible with VS2015.

If the prebuilt "sgx_ukey_exchange.lib" is not compatible with your development environment, you can instead NOT link to the prebuilt static library and add the files included in the 1.7 SDK to your project:

C:\Program Files (x86)\Intel\IntelSGXSDK\src\RemoteAttestation\isv_app\sample_ukey_exchange\

0 Kudos
Andrej_S_
Beginner
1,321 Views

I added the suggested files from the 1.7 SDK to my VS 2013 ISV-APP project and now the client app compiles and runs. Thank you.

0 Kudos
Andrej_S_
Beginner
1,321 Views

Hi there,

On the subject of compilation, I'm now attempting to compile VS 2013 ISV-APP project in "Prelease" mode. The client app is generating the "error 0x200f, failed to create enclave".

I followed the 4 steps in the documentation for preparing to build and run the project in Prerelease mode, and the working directory is set to $(Out).

It appears the enclave is launched in enclave-non-debug mode instead of the documented enclave-debug mode.

Kindly assist with this issue. 

 

0 Kudos
Prabu_R_Intel
Employee
1,321 Views

"A preprocessor flag EDEBUG is defined in the preprocessor settings of the Microsoft Visual Studio enclave project for prelease mode.
When the EDEBUG preprocessor flag is defined, it enables the SGX_DEBUG_FLAG, which in turn, launches the enclave in the enclave debug
mode. In the prerelease configuration NDEBUG and EDEBUG are both defined, which enables SGX_DEBUG_FLAG."

For the enclave to be launched debug mode, both the NDEBUG and EDEBUG flags should be set in the Visual studio project settings of
enclave project built in pre-release mode.

In the Microsoft Visual Studio project settings, the "current working directory" should point to $(OutDir) instead of $(ProjectDir)
for both Application and Enclave.

0 Kudos
Francisco_C_Intel
1,321 Views

From sgx_error.h

SGX_ERROR_ENCLAVE_FILE_ACCESS = SGX_MK_ERROR(0x200f), /* Can't open enclave file. */

So it looks like you cannot open the enclave file. I would double check that your working dir is set to $(OutDir) as mentioned by  Prabu, whereas you indicated it was set to $(Out). If that fails you can use a full path and then debug based on permissions or other issues that would preclude you from being able to access the enclave file.

0 Kudos
Andrej_S_
Beginner
1,321 Views

Hi there,

Apologies, $(Out) was a typo, ISV-APP was indeed set to $(OutDir).

The modifications made are in adding NDEBUG and EDEBUG to Enclave project preprocessor directives and setting the Enclave project's working directory to $(OutDir). Cleaned both projects and rebuilt.

In summary; the Debug solution mode works fine end-to-end. The prerelease solution fails to create an enclave. It is currently configured to:

Enclave project compiling OK in Prerelease (WIn32). Preprocessor directives EDEBUG;NDEBUG;_WINDLL;%(PreprocessorDefinitions)

ISV-APP project compiling OK in Prerelease (x64). Preprocessor directives EDEBUG;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)

Output of prerelease app continues to be:

Enclave will be created in order to complete EncryptDecrypt operation
***** SGX device is enabled ******
App: error 0x200f, failed to create enclave.

 In comparison, output of debug app:

Enclave will be created in order to complete EncryptDecrypt operation
***** SGX device is enabled ******

******Succesfully Created the Enclave******
Unable to open file
Sealed secret file doesn't exist or couldn't be read

*** Enclave Initialized successfully *** ........

So my reading of the output is that enclave creation is failing prior to opening enclave file and app terminates.

Please check on my preprocessor directives, and any other areas I should look at.

Regards

0 Kudos
Francisco_C_Intel
1,321 Views

"Enclave project compiling OK in Prerelease (WIn32)" has a different output directory than

"ISV-APP project compiling OK in Prerelease (x64)" , because of 32bit vs 64bit.

I would check that after building "Enclave Prelease Win32" the enclave is in the $(OutDir) of "ISV-App Prelease Win32", and similarly for 64bit.

0 Kudos
Andrej_S_
Beginner
1,321 Views

Many thanks, collective suggestions steered me in the right direction, and Prerelease issue is now resolved

0 Kudos
Reply