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

MPIR in SGX

Benny_F_
Beginner
706 Views

Hello,

I want to calculate with huge numbers inside of SGX. Therefore, I want to use MPIR (from http://mpir.org/) inside of an enclave. Has anybody tried this already and had success?

This library has some IO functions like printf or raw file read. I did remove them, because they are not required, but I don't get it to work. I compiled the library without the IO functions and included the header directory into the enclave project, added the library directory to the enclave project and also the static mpir.lib library. It works if I do the same in a normal application.

However, I get the following errors if I do it in an enclave project:

>mpir.lib(mulmod_2expm1.obj) : error LNK2001: unresolved external symbol _RTC_AllocaHelper
1>mpir.lib(toom8h_mul.obj) : error LNK2001: unresolved external symbol _RTC_AllocaHelper
1>mpir.lib(toom4_mul_n.obj) : error LNK2001: unresolved external symbol _RTC_AllocaHelper
1>mpir.lib(toom8_sqr_n.obj) : error LNK2001: unresolved external symbol _RTC_AllocaHelper
1>mpir.lib(mulmod_2expp1.obj) : error LNK2001: unresolved external symbol _RTC_AllocaHelper
1>mpir.lib(inv_div_qr_n.obj) : error LNK2001: unresolved external symbol _RTC_AllocaHelper
1>mpir.lib(dc_div_qr.obj) : error LNK2001: unresolved external symbol _RTC_AllocaHelper
1>mpir.lib(hgcd_reduce.obj) : error LNK2001: unresolved external symbol _RTC_AllocaHelper
1>mpir.lib(toom4_mul.obj) : error LNK2001: unresolved external symbol _RTC_AllocaHelper
1>mpir.lib(mul.obj) : error LNK2001: unresolved external symbol _RTC_AllocaHelper
1>mpir.lib(mul_n.obj) : error LNK2001: unresolved external symbol _RTC_AllocaHelper
1>mpir.lib(invert.obj) : error LNK2001: unresolved external symbol _RTC_AllocaHelper
1>mpir.lib(inv_div_qr.obj) : error LNK2001: unresolved external symbol _RTC_AllocaHelper
1>mpir.lib(gcd.obj) : error LNK2001: unresolved external symbol _RTC_AllocaHelper
1>mpir.lib(set_str.obj) : error LNK2001: unresolved external symbol _RTC_AllocaHelper
1>mpir.lib(gcd.obj) : error LNK2001: unresolved external symbol _RTC_AllocaHelper
1>mpir.lib(tdiv_qr.obj) : error LNK2001: unresolved external symbol _RTC_AllocaHelper
1>mpir.lib(mulmod_2expm1.obj) : error LNK2001: unresolved external symbol _RTC_CheckStackVars2
1>mpir.lib(toom8h_mul.obj) : error LNK2001: unresolved external symbol _RTC_CheckStackVars2
1>mpir.lib(toom4_mul_n.obj) : error LNK2001: unresolved external symbol _RTC_CheckStackVars2
1>mpir.lib(toom8_sqr_n.obj) : error LNK2001: unresolved external symbol _RTC_CheckStackVars2
1>mpir.lib(mulmod_2expp1.obj) : error LNK2001: unresolved external symbol _RTC_CheckStackVars2
1>mpir.lib(inv_div_qr_n.obj) : error LNK2001: unresolved external symbol _RTC_CheckStackVars2
1>mpir.lib(dc_div_qr.obj) : error LNK2001: unresolved external symbol _RTC_CheckStackVars2
1>mpir.lib(hgcd_reduce.obj) : error LNK2001: unresolved external symbol _RTC_CheckStackVars2
1>mpir.lib(toom4_mul.obj) : error LNK2001: unresolved external symbol _RTC_CheckStackVars2
1>mpir.lib(mul.obj) : error LNK2001: unresolved external symbol _RTC_CheckStackVars2
1>mpir.lib(mul_n.obj) : error LNK2001: unresolved external symbol _RTC_CheckStackVars2
1>mpir.lib(invert.obj) : error LNK2001: unresolved external symbol _RTC_CheckStackVars2
1>mpir.lib(inv_div_qr.obj) : error LNK2001: unresolved external symbol _RTC_CheckStackVars2
1>mpir.lib(gcd.obj) : error LNK2001: unresolved external symbol _RTC_CheckStackVars2
1>mpir.lib(set_str.obj) : error LNK2001: unresolved external symbol _RTC_CheckStackVars2
1>mpir.lib(gcd.obj) : error LNK2001: unresolved external symbol _RTC_CheckStackVars2
1>mpir.lib(tdiv_qr.obj) : error LNK2001: unresolved external symbol _RTC_CheckStackVars2
1>mpir.lib(butterfly_rshB.obj) : error LNK2019: unresolved external symbol _RTC_InitBase referenced in function __mpir_butterfly_rshB
1>mpir.lib(ifft_trunc.obj) : error LNK2001: unresolved external symbol _RTC_InitBase
1>mpir.lib(revbin.obj) : error LNK2001: unresolved external symbol _RTC_InitBase
1>mpir.lib(ifft_radix2.obj) : error LNK2001: unresolved external symbol _RTC_InitBase
1>mpir.lib(mul_2expmod_2expp1.obj) : error LNK2001: unresolved external symbol _RTC_InitBase
1>mpir.lib(butterfly_lshB.obj) : error LNK2001: unresolved external symbol _RTC_InitBase
1>mpir.lib(fft_trunc.obj) : error LNK2001: unresolved external symbol _RTC_InitBase
1>mpir.lib(neg_n.obj) : error LNK2001: unresolved external symbol _RTC_InitBase
1>mpir.lib(adjust.obj) : error LNK2001: unresolved external symbol _RTC_InitBase
1>mpir.lib(adjust_sqrt2.obj) : error LNK2001: unresolved external symbol _RTC_InitBase
1>mpir.lib(fft_radix2.obj) : error LNK2001: unresolved external symbol _RTC_InitBase
1>mpir.lib(ifft_trunc_sqrt2.obj) : error LNK2001: unresolved external symbol _RTC_InitBase
1>mpir.lib(fft_mfa_trunc_sqrt2.obj) : error LNK2001: unresolved external symbol _RTC_InitBase
1>mpir.lib(ifft_mfa_trunc_sqrt2.obj) : error LNK2001: unresolved external symbol _RTC_InitBase
1>mpir.lib(fft_mfa_trunc_sqrt2_inner.obj) : error LNK2001: unresolved external symbol _RTC_InitBase
1>mpir.lib(ifft_negacyclic.obj) : error LNK2001: unresolved external symbol _RTC_InitBase
1>mpir.lib(normmod_2expp1.obj) : error LNK2001: unresolved external symbol _RTC_InitBase
1>mpir.lib(div_2expmod_2expp1.obj) : error LNK2001: unresolved external symbol _RTC_InitBase
1>mpir.lib(fft_trunc_sqrt2.obj) : error LNK2001: unresolved external symbol _RTC_InitBase
1>mpir.lib(zero.obj) : error LNK2001: unresolved external symbol _RTC_InitBase
1>mpir.lib(combine_bits.obj) : error LNK2001: unresolved external symbol _RTC_InitBase
1>mpir.lib(split_bits.obj) : error LNK2001: unresolved external symbol _RTC_InitBase
1>mpir.lib(fft_negacyclic.obj) : error LNK2001: unresolved external symbol _RTC_InitBase
1>mpir.lib(toom_interpolate_16pts.obj) : error LNK2001: unresolved external symbol _RTC_InitBase
1>mpir.lib(toom_couple_handling.obj) : error LNK2001: unresolved external symbol _RTC_InitBase
1>mpir.lib(mulmod_bexpp1.obj) : error LNK2001: unresolved external symbol _RTC_InitBase
1>mpir.lib(mulmod_2expp1_basecase.obj) : error LNK2001: unresolved external symbol _RTC_InitBase
1>mpir.lib(toom_eval_pm1.obj) : error LNK2001: unresolved external symbol _RTC_InitBase
1>mpir.lib(toom_eval_pm2.obj) : error LNK2001: unresolved external symbol _RTC_InitBase
1>mpir.lib(toom_eval_pm2exp.obj) : error LNK2001: unresolved external symbol _RTC_InitBase
1>mpir.lib(toom_eval_pm2rexp.obj) : error LNK2001: unresolved external symbol _RTC_InitBase
1>mpir.lib(mulmod_2expm1.obj) : error LNK2001: unresolved external symbol _RTC_InitBase
1>mpir.lib(mul_trunc_sqrt2.obj) : error LNK2001: unresolved external symbol _RTC_InitBase
1>mpir.lib(mul_mfa_trunc_sqrt2.obj) : error LNK2001: unresolved external symbol _RTC_InitBase
1>mpir.lib(toom_eval_dgr3_pm1.obj) : error LNK2001: unresolved external symbol _RTC_InitBase
1>mpir.lib(divrem_euclidean_r_1.obj) : error LNK2001: unresolved external symbol _RTC_InitBase
1>mpir.lib(rsh_divrem_hensel_qr_1.obj) : error LNK2001: unresolved external symbol _RTC_InitBase
1>mpir.lib(mulmod_2expp1.obj) : error LNK2001: unresolved external symbol _RTC_InitBase
1>mpir.lib(hgcd_appr.obj) : error LNK2001: unresolved external symbol _RTC_InitBase
1>mpir.lib(toom8h_mul.obj) : error LNK2001: unresolved external symbol _RTC_InitBase
1>mpir.lib(toom3_mul_n.obj) : error LNK2001: unresolved external symbol _RTC_InitBase
1>mpir.lib(toom4_mul_n.obj) : error LNK2001: unresolved external symbol _RTC_InitBase
1>mpir.lib(toom8_sqr_n.obj) : error LNK2001: unresolved external symbol _RTC_InitBase
1>mpir.lib(hgcd_reduce.obj) : error LNK2001: unresolved external symbol _RTC_InitBase
...

Does anybody know what I can do about it?

Thank you
Benny

0 Kudos
2 Replies
Francisco_C_Intel
706 Views

If I understand correctly, you

1) took the source for MPIR,

2) removed the printf statements,

3) then built the mpir.lib static library

4) added the mpir.lib static library to an enclave

5) built the enclave and received the errors above

In Step 3, how did you build it? If you built the way you would normally build a regular static library it may be pulling in unsupported functions from a traditional C runtime.

I would try to create a new Visual Studio Project, "Intel SGX Enclave Project", "Enclave library" as described in https://software.intel.com/sites/default/files/managed/b4/cf/Intel-SGX-SDK-Developer-Reference-for-Windows-OS.pdf page 13, then add the MPIR files and build the mpir static library this way.

This is my first-guess as to why it doesn't work, http://stackoverflow.com/questions/10158013/unresolved-external-symbols-rtc-in-windows-programming-tutorial suggests it may be sufficient to simply change the build options in the project you already have.

 

0 Kudos
Zhang__Huiqiang
Beginner
706 Views

Hi,Benny,Did you resolve this problem? the same as you,I want use the mpir in enclave  too .if you resolved ,share with us,thank you.

0 Kudos
Reply