libsodiumでenclave.soのビルドができない
code:sh
$ ./test.sh
..
warning: 2 warnings emitted
Compiling erc20-enclave v0.1.0 (/root/anonify/example/erc20/enclave)
mkdir -p ../build/lib
mkdir -p ../build
/opt/sgxsdk/bin/x64/sgx_edger8r --trusted ../edl/Anonify_common.edl --search-path /opt/sgxsdk/include --search-path /root/sgx/edl --trusted-dir ../build
/opt/sgxsdk/bin/x64/sgx_edger8r --untrusted ../edl/Anonify_common.edl --search-path /opt/sgxsdk/include --search-path /root/sgx/edl --untrusted-dir ../build
GEN => ../core/enclave/Anonify_common_t.c ../core/enclave/Anonify_common_t.h ../core/host/Anonify_common_u.c ../core/host/Anonify_common_u.h
mkdir -p ../build
/opt/sgxsdk/bin/x64/sgx_edger8r --trusted ../edl/Anonify_common.edl --search-path /opt/sgxsdk/include --search-path /root/sgx/edl --trusted-dir ../build
/opt/sgxsdk/bin/x64/sgx_edger8r --untrusted ../edl/Anonify_common.edl --search-path /opt/sgxsdk/include --search-path /root/sgx/edl --untrusted-dir ../build
GEN => ../core/enclave/Anonify_common_t.c ../core/enclave/Anonify_common_t.h ../core/host/Anonify_common_u.c ../core/host/Anonify_common_u.h
mkdir -p ../build
/opt/sgxsdk/bin/x64/sgx_edger8r --trusted ../edl/Anonify_common.edl --search-path /opt/sgxsdk/include --search-path /root/sgx/edl --trusted-dir ../build
/opt/sgxsdk/bin/x64/sgx_edger8r --untrusted ../edl/Anonify_common.edl --search-path /opt/sgxsdk/include --search-path /root/sgx/edl --untrusted-dir ../build
GEN => ../core/enclave/Anonify_common_t.c ../core/enclave/Anonify_common_t.h ../core/host/Anonify_common_u.c ../core/host/Anonify_common_u.h
mkdir -p ../build
/opt/sgxsdk/bin/x64/sgx_edger8r --trusted ../edl/Anonify_common.edl --search-path /opt/sgxsdk/include --search-path /root/sgx/edl --trusted-dir ../build
/opt/sgxsdk/bin/x64/sgx_edger8r --untrusted ../edl/Anonify_common.edl --search-path /opt/sgxsdk/include --search-path /root/sgx/edl --untrusted-dir ../build
GEN => ../core/enclave/Anonify_common_t.c ../core/enclave/Anonify_common_t.h ../core/host/Anonify_common_u.c ../core/host/Anonify_common_u.h
CC <= ../core/enclave/Anonify_common_t.c
/usr/local/bin/ld: ../build/lib/libenclave.a(libsodium_la-core.o): in function `sodium_crit_enter':
/root/anonify/target/debug/build/libsodium-sys-fb96fa707666c09b/out/source/libsodium/src/libsodium/sodium/core.c:118: undefined reference to `pthread_mutex_lock'
/usr/local/bin/ld: ../build/lib/libenclave.a(libsodium_la-core.o): in function `sodium_crit_leave':
/root/anonify/target/debug/build/libsodium-sys-fb96fa707666c09b/out/source/libsodium/src/libsodium/sodium/core.c:136: undefined reference to `pthread_mutex_unlock'
/usr/local/bin/ld: ../build/lib/libenclave.a(libsodium_la-utils.o): in function `sodium_memzero':
/root/anonify/target/debug/build/libsodium-sys-fb96fa707666c09b/out/source/libsodium/src/libsodium/sodium/utils.c:127: undefined reference to `explicit_bzero'
/usr/local/bin/ld: ../build/lib/libenclave.a(libsodium_la-randombytes_sysrandom.o): in function `safe_read':
/root/anonify/target/debug/build/libsodium-sys-fb96fa707666c09b/out/source/libsodium/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c:135: undefined reference to `read'
/usr/local/bin/ld: ../build/lib/libenclave.a(libsodium_la-randombytes_sysrandom.o): in function `randombytes_block_on_dev_random':
/root/anonify/target/debug/build/libsodium-sys-fb96fa707666c09b/out/source/libsodium/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c:158: undefined reference to `open'
/usr/local/bin/ld: /root/anonify/target/debug/build/libsodium-sys-fb96fa707666c09b/out/source/libsodium/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c:166: undefined reference to `poll'
/usr/local/bin/ld: /root/anonify/target/debug/build/libsodium-sys-fb96fa707666c09b/out/source/libsodium/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c:169: undefined reference to `close'
/usr/local/bin/ld: /root/anonify/target/debug/build/libsodium-sys-fb96fa707666c09b/out/source/libsodium/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c:173: undefined reference to `close'
/usr/local/bin/ld: ../build/lib/libenclave.a(libsodium_la-randombytes_sysrandom.o): in function `randombytes_sysrandom_random_dev_open':
/root/anonify/target/debug/build/libsodium-sys-fb96fa707666c09b/out/source/libsodium/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c:197: undefined reference to `open'
/usr/local/bin/ld: /root/anonify/target/debug/build/libsodium-sys-fb96fa707666c09b/out/source/libsodium/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c:199: undefined reference to `fstat'
/usr/local/bin/ld: /root/anonify/target/debug/build/libsodium-sys-fb96fa707666c09b/out/source/libsodium/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c:209: undefined reference to `fcntl'
/usr/local/bin/ld: /root/anonify/target/debug/build/libsodium-sys-fb96fa707666c09b/out/source/libsodium/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c:209: undefined reference to `fcntl'
/usr/local/bin/ld: /root/anonify/target/debug/build/libsodium-sys-fb96fa707666c09b/out/source/libsodium/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c:213: undefined reference to `close'
/usr/local/bin/ld: ../build/lib/libenclave.a(libsodium_la-randombytes_sysrandom.o): in function `_randombytes_linux_getrandom':
/root/anonify/target/debug/build/libsodium-sys-fb96fa707666c09b/out/source/libsodium/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c:233: undefined reference to `getrandom'
/usr/local/bin/ld: ../build/lib/libenclave.a(libsodium_la-randombytes_sysrandom.o): in function `randombytes_sysrandom_close':
/root/anonify/target/debug/build/libsodium-sys-fb96fa707666c09b/out/source/libsodium/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c:318: undefined reference to `close'
collect2: error: ld returned 1 exit status
Makefile:138: recipe for target '../build/enclave.so' failed
code:sh
set -e
source /root/.docker_bashrc
export PATH=~/.cargo/bin:$PATH
export SGX_MODE=HW
export RUSTFLAGS=-Ctarget-feature=+aes,+sse2,+sse4.1,+ssse3
dirpath=$(cd $(dirname $0) && pwd)
cd "${dirpath}/.."
solc -o contract-build --bin --abi --optimize --overwrite contracts/Anonify.sol
cd frame/types
cargo build
cd ../../scripts
# Generate a enclave.signed.so in $HOME/.anonify
make DEBUG=1 ENCLAVE_DIR=example/erc20/enclave
# Testings
echo "Integration testing..."
cd ../tests/integration
RUST_BACKTRACE=1 RUST_LOG=debug cargo test -- --nocapture
cd ../../example/erc20/server
RUST_BACKTRACE=1 RUST_LOG=debug cargo test test_deploy_post -- --nocapture
sleep 1
RUST_BACKTRACE=1 RUST_LOG=debug cargo test test_multiple_messages -- --nocapture
sleep 1
RUST_BACKTRACE=1 RUST_LOG=debug cargo test test_skip_invalid_event -- --nocapture
sleep 1
RUST_BACKTRACE=1 RUST_LOG=debug cargo test test_node_recovery -- --nocapture
sleep 1
RUST_BACKTRACE=1 RUST_LOG=debug cargo test test_join_group_then_handshake -- --nocapture
echo "Unit testing..."
cd ../../../scripts
make DEBUG=1 TEST=1 ENCLAVE_DIR=tests/units/enclave
cd ..
RUST_BACKTRACE=1 RUST_LOG=debug cargo test -p unit-tests-host -p anonify-eth-driver -p frame-runtime -- --nocapture
# Buildings
./scripts/build-cli.sh
echo "Building ERC20 server..."
cd example/erc20/server
RUST_BACKTRACE=1 RUST_LOG=debug cargo build
makeに失敗してる
code:Makefile
$(Enclave_EDL_Files): $(SGX_EDGER8R) $(ANONIFY_EDL_DIR)/$(EDL_FILE)
@echo "ccccccccc" # 到達
mkdir -p $(ANONIFY_BUILD_DIR)
$(SGX_EDGER8R) --trusted $(ANONIFY_EDL_DIR)/$(EDL_FILE) --search-path $(SGX_SDK)/include --search-path $(CUSTOM_EDL_PATH) --trusted-dir $(ANONIFY_BUILD_DIR)
$(SGX_EDGER8R) --untrusted $(ANONIFY_EDL_DIR)/$(EDL_FILE) --search-path $(SGX_SDK)/include --search-path $(CUSTOM_EDL_PATH) --untrusted-dir $(ANONIFY_BUILD_DIR)
@echo "GEN => $(Enclave_EDL_Files)" # 到達
######## Enclave Objects ########
$(ANONIFY_BUILD_DIR)/$(T_O_FILE): $(Enclave_EDL_Files)
@echo "dddddddddddd" # 到達
@$(CC) $(RustEnclave_Compile_Flags) -c $(ANONIFY_BUILD_DIR)/$(T_C_FILE) -o $(ANONIFY_BUILD_DIR)/$(T_O_FILE)
@echo "CC <= $<" # 到達
$(Rust_Enclave_Name): $(Rust_Enclave_Files)
@echo "Rust_Enclave_Name <= $(PWD)"
@cd $(ANONIFY_ROOT_DIR)/$(ENCLAVE_DIR) && RUST_LOG=debug cargo build $(CARGO_FLAGS) $(FEATURE_FLAGS)
@echo "aaaaaaaaaa" # 到達
mkdir -p $(CUSTOM_LIBRARY_PATH)
@cp $(ANONIFY_ROOT_DIR)/target/$(Rust_target_dir)/libanonifyenclave.a $(CUSTOM_LIBRARY_PATH)/libenclave.a
@echo "bbbbbbbbbb" # 到達
$(RustEnclave_Name): $(Rust_Enclave_Name) $(ANONIFY_BUILD_DIR)/$(T_O_FILE)
@echo "eeeeeeeeeee" # 到達
@$(CXX) $(ANONIFY_BUILD_DIR)/$(T_O_FILE) -o $@ $(RustEnclave_Link_Flags)
@echo "LINK => $@" # 未到達!!
$(Signed_RustEnclave_Name): $(RustEnclave_Name)
@echo "ffffffffffffffff"
mkdir -p $(ANONIFY_BIN_DIR)
@$(SGX_ENCLAVE_SIGNER) sign -key $(CONFIG_DIR)/Test_Enclave_private.pem -enclave $(RustEnclave_Name) -out $@ -config $(CONFIG_DIR)/Enclave.config.xml
@echo "SIGN => $@"
code:sh
aaaaaaaaaa
mkdir -p ../build/lib
bbbbbbbbbb
ccccccccc
mkdir -p ../build
/opt/sgxsdk/bin/x64/sgx_edger8r --trusted ../edl/Anonify_common.edl --search-path /opt/sgxsdk/include --search-path /root/sgx/edl --trusted-dir ../build
/opt/sgxsdk/bin/x64/sgx_edger8r --untrusted ../edl/Anonify_common.edl --search-path /opt/sgxsdk/include --search-path /root/sgx/edl --untrusted-dir ../build
GEN => ../core/enclave/Anonify_common_t.c ../core/enclave/Anonify_common_t.h ../core/host/Anonify_common_u.c ../core/host/Anonify_common_u.h
ccccccccc
mkdir -p ../build
/opt/sgxsdk/bin/x64/sgx_edger8r --trusted ../edl/Anonify_common.edl --search-path /opt/sgxsdk/include --search-path /root/sgx/edl --trusted-dir ../build
/opt/sgxsdk/bin/x64/sgx_edger8r --untrusted ../edl/Anonify_common.edl --search-path /opt/sgxsdk/include --search-path /root/sgx/edl --untrusted-dir ../build
GEN => ../core/enclave/Anonify_common_t.c ../core/enclave/Anonify_common_t.h ../core/host/Anonify_common_u.c ../core/host/Anonify_common_u.h
ccccccccc
mkdir -p ../build
/opt/sgxsdk/bin/x64/sgx_edger8r --trusted ../edl/Anonify_common.edl --search-path /opt/sgxsdk/include --search-path /root/sgx/edl --trusted-dir ../build
/opt/sgxsdk/bin/x64/sgx_edger8r --untrusted ../edl/Anonify_common.edl --search-path /opt/sgxsdk/include --search-path /root/sgx/edl --untrusted-dir ../build
GEN => ../core/enclave/Anonify_common_t.c ../core/enclave/Anonify_common_t.h ../core/host/Anonify_common_u.c ../core/host/Anonify_common_u.h
ccccccccc
mkdir -p ../build
/opt/sgxsdk/bin/x64/sgx_edger8r --trusted ../edl/Anonify_common.edl --search-path /opt/sgxsdk/include --search-path /root/sgx/edl --trusted-dir ../build
/opt/sgxsdk/bin/x64/sgx_edger8r --untrusted ../edl/Anonify_common.edl --search-path /opt/sgxsdk/include --search-path /root/sgx/edl --untrusted-dir ../build
GEN => ../core/enclave/Anonify_common_t.c ../core/enclave/Anonify_common_t.h ../core/host/Anonify_common_u.c ../core/host/Anonify_common_u.h
dddddddddddd
CC <= ../core/enclave/Anonify_common_t.c
eeeeeeeeeee
/usr/local/bin/ld: ../build/lib/libenclave.a(libsodium_la-core.o): in function `sodium_crit_enter':
code:sh
/usr/local/bin/ld: ../build/lib/libenclave.a(libsodium_la-core.o): in function `sodium_crit_enter':
的なエラーが出ているので、libenclave.a生成時にlibsodiumも関連付けられてしまう。
でも中で使っているヘッダが見つからない的な感じかな。
cargo checkならいけるか?
code:sh
root@dadaf683d068:~/anonify# cargo check
..
errorE0254: the name localstd is defined multiple times --> config/src/lib.rs:7:5
|
5 | extern crate sgx_tstd as localstd;
| ---------------------------------- previous import of the extern crate localstd here
7 | use std as localstd;
| ^^^^^^^^^^^^^^^ localstd reimported here
|
= note: localstd must be defined only once in the type namespace of this module
help: you can use as to change the binding name of the import
|
7 | use std as other_localstd;
| ^^^^^^^^^^^^^^^^^^^^^
errorE0252: the name local_anyhow is defined multiple times --> config/src/lib.rs:13:5
|
11 | use anyhow_sgx as local_anyhow;
| -------------------------- previous import of the module local_anyhow here
13 | use anyhow_std as local_anyhow;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ local_anyhow reimported here
|
= note: local_anyhow must be defined only once in the type namespace of this module
help: you can use as to change the binding name of the import
|
13 | use anyhow_std as other_local_anyhow;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: duplicate lang item in crate sgx_tstd (which config depends on): f32_runtime.
|
= note: the lang item is first defined in crate std (which config depends on)
= note: first definition in std loaded from /root/.rustup/toolchains/nightly-2020-10-25-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-3010daceac92f8fa.rlib
= note: second definition in sgx_tstd loaded from /root/anonify/target/debug/deps/libsgx_tstd-a8085a227b81351e.rmeta
error: duplicate lang item in crate sgx_tstd (which config depends on): f64_runtime.
|
= note: the lang item is first defined in crate std (which config depends on)
= note: first definition in std loaded from /root/.rustup/toolchains/nightly-2020-10-25-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-3010daceac92f8fa.rlib
= note: second definition in sgx_tstd loaded from /root/anonify/target/debug/deps/libsgx_tstd-a8085a227b81351e.rmeta
error: duplicate lang item in crate sgx_tstd (which config depends on): panic_impl.
|
= note: the lang item is first defined in crate std (which config depends on)
= note: first definition in std loaded from /root/.rustup/toolchains/nightly-2020-10-25-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-3010daceac92f8fa.rlib
= note: second definition in sgx_tstd loaded from /root/anonify/target/debug/deps/libsgx_tstd-a8085a227b81351e.rmeta
error: duplicate lang item in crate sgx_tstd (which config depends on): begin_panic.
|
= note: the lang item is first defined in crate std (which config depends on)
= note: first definition in std loaded from /root/.rustup/toolchains/nightly-2020-10-25-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-3010daceac92f8fa.rlib
= note: second definition in sgx_tstd loaded from /root/anonify/target/debug/deps/libsgx_tstd-a8085a227b81351e.rmeta
error: duplicate lang item in crate sgx_tstd (which config depends on): oom.
|
= note: the lang item is first defined in crate std (which config depends on)
= note: first definition in std loaded from /root/.rustup/toolchains/nightly-2020-10-25-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-3010daceac92f8fa.rlib
= note: second definition in sgx_tstd loaded from /root/anonify/target/debug/deps/libsgx_tstd-a8085a227b81351e.rmeta
error: aborting due to 7 previous errors
Some errors have detailed explanations: E0252, E0254.
For more information about an error, try rustc --explain E0252.
error: could not compile config
当然、masterで
code:sh
# make DEBUG=1 ENCLAVE_DIR=example/erc20/enclave
はうまく動く
code:sh
../build/Anonify_common_t.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), with debug_info, not stripped
code:sh
# buildディレクトリ内にて。
g++ ../build/Anonify_common_t.o -o ./enclave.so -m64 -O0 -g -Wl,--no-undefined -nostdlib -nodefaultlibs -nostartfiles -L/opt/sgxsdk/lib64 -Wl,--whole-archive -lsgx_trts -Wl,--no-whole-archive -Wl,--start-group -lsgx_tstdc -lsgx_tservice -lsgx_tcrypto -L../build/lib -lenclave -Wl,--end-group -Wl,-Bstatic -Wl,-Bsymbolic -Wl,--no-undefined -Wl,-pie,-eenclave_entry -Wl,--export-dynamic -Wl,--defsym,__ImageBase=0 -Wl,--gc-sections -Wl,--version-script=../config/Enclave.lds -Wl,--safe_read
code:sh
root@dadaf683d068:~/anonify/scripts# ls -la /usr/lib/x86_64-linux-gnu/ | grep sodi
lrwxrwxrwx 1 root root 19 Dec 26 2017 libsodium.so.23 -> libsodium.so.23.1.0
-rw-r--r-- 1 root root 330440 Dec 26 2017 libsodium.so.23.1.0
root@dadaf683d068:~/anonify/scripts# fun
変わらず
export SODIUM_SHARED=1も必要?
変わらず
上記を設定した状態でtarget以下を削除
make DEBUG=1 ENCLAVE_DIR=example/erc20/enclave
したらエラーが変わった。
code:sh
RustEnclave_Link_Flags => -m64 -O0 -g -Wl,--no-undefined -nostdlib -nodefaultlibs -nostartfiles -L/opt/sgxsdk/lib64 -Wl,--whole-archive -lsgx_trts -Wl,--no-whole-archive -Wl,--start-group -lsgx_tstdc -lsgx_tservice -lsgx_tcrypto -L../build/lib -lenclave -Wl,--end-group -Wl,-Bstatic -Wl,-Bsymbolic -Wl,--no-undefined -Wl,-pie,-eenclave_entry -Wl,--export-dynamic -Wl,--defsym,__ImageBase=0 -Wl,--gc-sections -Wl,--version-script=../config/Enclave.lds -m64 -O0 -g -Wl,--no-undefined -nostdlib -nodefaultlibs -nostartfiles -L/opt/sgxsdk/lib64 -Wl,--whole-archive -lsgx_trts -Wl,--no-whole-archive -Wl,--start-group -lsgx_tstdc -lsgx_tservice -lsgx_tcrypto -L../build/lib -lenclave -Wl,--end-group -Wl,-Bstatic -Wl,-Bsymbolic -Wl,--no-undefined -Wl,-pie,-eenclave_entry -Wl,--export-dynamic -Wl,--defsym,__ImageBase=0 -Wl,--gc-sections -Wl,--version-script=../config/Enclave.lds
/usr/local/bin/ld: ../build/lib/libenclave.a(sodiumoxide-af6c10de889870c9.sodiumoxide.83t8a1rp-cgu.0.rcgu.o): in function `sodiumoxide::crypto::box_::curve25519xsalsa20poly1305::SecretKey::public_key':
/root/.cargo/registry/src/github.com-1ecc6299db9ec823/sodiumoxide-0.2.6/src/crypto/box_/curve25519xsalsa20poly1305.rs:65: undefined reference to `crypto_scalarmult_base'
/usr/local/bin/ld: ../build/lib/libenclave.a(sodiumoxide-af6c10de889870c9.sodiumoxide.83t8a1rp-cgu.0.rcgu.o): in function `sodiumoxide::crypto::box_::curve25519xsalsa20poly1305::gen_keypair':
/root/.cargo/registry/src/github.com-1ecc6299db9ec823/sodiumoxide-0.2.6/src/crypto/box_/curve25519xsalsa20poly1305.rs:92: undefined reference to `crypto_box_curve25519xsalsa20poly1305_keypair'
/usr/local/bin/ld: ../build/lib/libenclave.a(sodiumoxide-af6c10de889870c9.sodiumoxide.83t8a1rp-cgu.0.rcgu.o): in function `sodiumoxide::crypto::box_::curve25519xsalsa20poly1305::open':
/root/.cargo/registry/src/github.com-1ecc6299db9ec823/sodiumoxide-0.2.6/src/crypto/box_/curve25519xsalsa20poly1305.rs:174: undefined reference to `crypto_box_open_easy'
/usr/local/bin/ld: ../build/lib/libenclave.a(sodiumoxide-af6c10de889870c9.sodiumoxide.83t8a1rp-cgu.4.rcgu.o): in function `sodiumoxide::utils::memzero':
/root/.cargo/registry/src/github.com-1ecc6299db9ec823/sodiumoxide-0.2.6/src/utils.rs:8: undefined reference to `sodium_memzero'
collect2: error: ld returned 1 exit status
Makefile:140: recipe for target '../build/enclave.so' failed
code:sh
tar -zxvf libsodium-1.0.18-stable.tar.gz
cd libsodium-stable
./configure
make && make check
code:sh
sudo make install
code:sh
Making install in builds
make1: Entering directory '/root/sodium/libsodium-stable/builds' make2: Entering directory '/root/sodium/libsodium-stable/builds' make2: Nothing to be done for 'install-exec-am'. make2: Nothing to be done for 'install-data-am'. make2: Leaving directory '/root/sodium/libsodium-stable/builds' make1: Leaving directory '/root/sodium/libsodium-stable/builds' Making install in contrib
make1: Entering directory '/root/sodium/libsodium-stable/contrib' make2: Entering directory '/root/sodium/libsodium-stable/contrib' make2: Nothing to be done for 'install-exec-am'. make2: Nothing to be done for 'install-data-am'. make2: Leaving directory '/root/sodium/libsodium-stable/contrib' make1: Leaving directory '/root/sodium/libsodium-stable/contrib' Making install in dist-build
make1: Entering directory '/root/sodium/libsodium-stable/dist-build' make2: Entering directory '/root/sodium/libsodium-stable/dist-build' make2: Nothing to be done for 'install-exec-am'. make2: Nothing to be done for 'install-data-am'. make2: Leaving directory '/root/sodium/libsodium-stable/dist-build' make1: Leaving directory '/root/sodium/libsodium-stable/dist-build' Making install in msvc-scripts
make1: Entering directory '/root/sodium/libsodium-stable/msvc-scripts' make2: Entering directory '/root/sodium/libsodium-stable/msvc-scripts' make2: Nothing to be done for 'install-exec-am'. make2: Nothing to be done for 'install-data-am'. make2: Leaving directory '/root/sodium/libsodium-stable/msvc-scripts' make1: Leaving directory '/root/sodium/libsodium-stable/msvc-scripts' Making install in src
make1: Entering directory '/root/sodium/libsodium-stable/src' Making install in libsodium
make2: Entering directory '/root/sodium/libsodium-stable/src/libsodium' Making install in include
make3: Entering directory '/root/sodium/libsodium-stable/src/libsodium/include' make4: Entering directory '/root/sodium/libsodium-stable/src/libsodium/include' make4: Nothing to be done for 'install-exec-am'. /bin/mkdir -p '/usr/local/include'
/bin/mkdir -p '/usr/local/include/sodium'
/usr/bin/install -c -m 644 sodium/core.h sodium/crypto_aead_aes256gcm.h sodium/crypto_aead_chacha20poly1305.h sodium/crypto_aead_xchacha20poly1305.h sodium/crypto_auth.h sodium/crypto_auth_hmacsha256.h sodium/crypto_auth_hmacsha512.h sodium/crypto_auth_hmacsha512256.h sodium/crypto_box.h sodium/crypto_box_curve25519xchacha20poly1305.h sodium/crypto_box_curve25519xsalsa20poly1305.h sodium/crypto_core_ed25519.h sodium/crypto_core_ristretto255.h sodium/crypto_core_hchacha20.h sodium/crypto_core_hsalsa20.h sodium/crypto_core_salsa20.h sodium/crypto_core_salsa2012.h sodium/crypto_core_salsa208.h sodium/crypto_generichash.h sodium/crypto_generichash_blake2b.h sodium/crypto_hash.h sodium/crypto_hash_sha256.h sodium/crypto_hash_sha512.h sodium/crypto_kdf.h sodium/crypto_kdf_blake2b.h sodium/crypto_kx.h sodium/crypto_onetimeauth.h sodium/crypto_onetimeauth_poly1305.h sodium/crypto_pwhash.h sodium/crypto_pwhash_argon2i.h sodium/crypto_pwhash_argon2id.h sodium/crypto_pwhash_scryptsalsa208sha256.h sodium/crypto_scalarmult.h sodium/crypto_scalarmult_curve25519.h sodium/crypto_scalarmult_ed25519.h sodium/crypto_scalarmult_ristretto255.h sodium/crypto_secretbox.h sodium/crypto_secretbox_xchacha20poly1305.h sodium/crypto_secretbox_xsalsa20poly1305.h sodium/crypto_secretstream_xchacha20poly1305.h '/usr/local/include/sodium'
/usr/bin/install -c -m 644 sodium.h '/usr/local/include/.'
/bin/mkdir -p '/usr/local/include/sodium'
/usr/bin/install -c -m 644 sodium/crypto_shorthash.h sodium/crypto_shorthash_siphash24.h sodium/crypto_sign.h sodium/crypto_sign_ed25519.h sodium/crypto_sign_edwards25519sha512batch.h sodium/crypto_stream.h sodium/crypto_stream_chacha20.h sodium/crypto_stream_salsa20.h sodium/crypto_stream_salsa2012.h sodium/crypto_stream_salsa208.h sodium/crypto_stream_xchacha20.h sodium/crypto_stream_xsalsa20.h sodium/crypto_verify_16.h sodium/crypto_verify_32.h sodium/crypto_verify_64.h sodium/export.h sodium/randombytes.h sodium/randombytes_internal_random.h sodium/randombytes_sysrandom.h sodium/runtime.h sodium/utils.h '/usr/local/include/sodium'
/bin/mkdir -p '/usr/local/include'
/bin/mkdir -p '/usr/local/include/sodium'
/usr/bin/install -c -m 644 sodium/version.h '/usr/local/include/sodium'
make4: Leaving directory '/root/sodium/libsodium-stable/src/libsodium/include' make3: Leaving directory '/root/sodium/libsodium-stable/src/libsodium/include' make3: Entering directory '/root/sodium/libsodium-stable/src/libsodium' make4: Entering directory '/root/sodium/libsodium-stable/src/libsodium' /bin/mkdir -p '/usr/local/lib'
/bin/bash ../../libtool --mode=install /usr/bin/install -c libsodium.la '/usr/local/lib'
libtool: install: /usr/bin/install -c .libs/libsodium.so.23.3.0 /usr/local/lib/libsodium.so.23.3.0
libtool: install: (cd /usr/local/lib && { ln -s -f libsodium.so.23.3.0 libsodium.so.23 || { rm -f libsodium.so.23 && ln -s libsodium.so.23.3.0 libsodium.so.23; }; })
libtool: install: (cd /usr/local/lib && { ln -s -f libsodium.so.23.3.0 libsodium.so || { rm -f libsodium.so && ln -s libsodium.so.23.3.0 libsodium.so; }; })
libtool: install: /usr/bin/install -c .libs/libsodium.lai /usr/local/lib/libsodium.la
libtool: install: /usr/bin/install -c .libs/libsodium.a /usr/local/lib/libsodium.a
libtool: install: chmod 644 /usr/local/lib/libsodium.a
libtool: install: ranlib /usr/local/lib/libsodium.a
libtool: finish: PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/sbin" ldconfig -n /usr/local/lib
----------------------------------------------------------------------
Libraries have been installed in:
/usr/local/lib
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the '-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the 'LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the 'LD_RUN_PATH' environment variable
during linking
- use the '-Wl,-rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to '/etc/ld.so.conf'
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
make4: Nothing to be done for 'install-data-am'. make4: Leaving directory '/root/sodium/libsodium-stable/src/libsodium' make3: Leaving directory '/root/sodium/libsodium-stable/src/libsodium' make2: Leaving directory '/root/sodium/libsodium-stable/src/libsodium' make2: Entering directory '/root/sodium/libsodium-stable/src' make3: Entering directory '/root/sodium/libsodium-stable/src' make3: Nothing to be done for 'install-exec-am'. make3: Nothing to be done for 'install-data-am'. make3: Leaving directory '/root/sodium/libsodium-stable/src' make2: Leaving directory '/root/sodium/libsodium-stable/src' make1: Leaving directory '/root/sodium/libsodium-stable/src' Making install in test
make1: Entering directory '/root/sodium/libsodium-stable/test' Making install in default
make2: Entering directory '/root/sodium/libsodium-stable/test/default' make3: Entering directory '/root/sodium/libsodium-stable/test/default' make3: Nothing to be done for 'install-exec-am'. make3: Nothing to be done for 'install-data-am'. make3: Leaving directory '/root/sodium/libsodium-stable/test/default' make2: Leaving directory '/root/sodium/libsodium-stable/test/default' make2: Entering directory '/root/sodium/libsodium-stable/test' make3: Entering directory '/root/sodium/libsodium-stable/test' make3: Nothing to be done for 'install-exec-am'. make3: Nothing to be done for 'install-data-am'. make3: Leaving directory '/root/sodium/libsodium-stable/test' make2: Leaving directory '/root/sodium/libsodium-stable/test' make1: Leaving directory '/root/sodium/libsodium-stable/test' make1: Entering directory '/root/sodium/libsodium-stable' make2: Entering directory '/root/sodium/libsodium-stable' make2: Nothing to be done for 'install-exec-am'. /bin/mkdir -p '/usr/local/lib/pkgconfig'
/usr/bin/install -c -m 644 libsodium.pc '/usr/local/lib/pkgconfig'
make2: Leaving directory '/root/sodium/libsodium-stable' make1: Leaving directory '/root/sodium/libsodium-stable' root@dadaf683d068:~/sodium/libsodium-stable# ls -la /usr/lib/x86_64-linux-gnu/ | grep sodi
lrwxrwxrwx 1 root root 19 Dec 26 2017 libsodium.so.23 -> libsodium.so.23.1.0
-rw-r--r-- 1 root root 330440 Dec 26 2017 libsodium.so.23.1.0
root@dadaf683d068:~/sodium/libsodium-stable# ls -la /usr/lib/ | grep sodi
root@dadaf683d068:~/sodium/libsodium-stable# ls -la /usr/local/lib/ | grep sodi
-rw-r--r-- 1 root root 2077266 Nov 30 09:19 libsodium.a
-rwxr-xr-x 1 root root 943 Nov 30 09:19 libsodium.la
lrwxrwxrwx 1 root root 19 Nov 30 09:19 libsodium.so -> libsodium.so.23.3.0
lrwxrwxrwx 1 root root 19 Nov 30 09:19 libsodium.so.23 -> libsodium.so.23.3.0
-rwxr-xr-x 1 root root 2132624 Nov 30 09:19 libsodium.so.23.3.0
code:sh
export SODIUM_LIB_DIR=/usr/local/lib/
もう一度targetを消してmake DEBUG=1
エラー変わらず
sodiumを1.0.18から1.0.17にしてみる
code:sh
libtool: install: /usr/bin/install -c .libs/libsodium.so.23.2.0 /usr/local/lib/libsodium.so.23.2.0
libtool: install: (cd /usr/local/lib && { ln -s -f libsodium.so.23.2.0 libsodium.so.23 || { rm -f libsodium.so.23 && ln -s libsodium.so.23.2.0 libsodium.so.23; }; })
libtool: install: (cd /usr/local/lib && { ln -s -f libsodium.so.23.2.0 libsodium.so || { rm -f libsodium.so && ln -s libsodium.so.23.2.0 libsodium.so; }; })
libtool: install: /usr/bin/install -c .libs/libsodium.lai /usr/local/lib/libsodium.la
libtool: install: /usr/bin/install -c .libs/libsodium.a /usr/local/lib/libsodium.a
libtool: install: chmod 644 /usr/local/lib/libsodium.a
libtool: install: ranlib /usr/local/lib/libsodium.a
libtool: finish: PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/sbin" ldconfig -n /usr/local/lib
23.3.0から23.2.0になった
もう一度make DEBUG=1
github内にあるsubmoduleのcommitにしてみる
code:sh
git checkout ecbe5316ddf4af023d62fecd5d775b8463dd71f3
code:sh
/bin/bash ../../libtool --mode=install /usr/bin/install -c libsodium.la '/usr/local/lib'
libtool: install: /usr/bin/install -c .libs/libsodium.so.23.3.0 /usr/local/lib/libsodium.so.23.3.0
libtool: install: (cd /usr/local/lib && { ln -s -f libsodium.so.23.3.0 libsodium.so.23 || { rm -f libsodium.so.23 && ln -s libsodium.so.23.3.0 libsodium.so.23; }; })
libtool: install: (cd /usr/local/lib && { ln -s -f libsodium.so.23.3.0 libsodium.so || { rm -f libsodium.so && ln -s libsodium.so.23.3.0 libsodium.so; }; })
code:sh
root@dadaf683d068:~/sodium/libsodium# ls -la /usr/local/lib | grep sodi
-rw-r--r-- 1 root root 2076978 Nov 30 10:03 libsodium.a
-rwxr-xr-x 1 root root 943 Nov 30 10:03 libsodium.la
lrwxrwxrwx 1 root root 19 Nov 30 10:03 libsodium.so -> libsodium.so.23.3.0
lrwxrwxrwx 1 root root 19 Nov 30 10:03 libsodium.so.23 -> libsodium.so.23.3.0
-rwxr-xr-x 1 root root 2094464 Nov 30 09:43 libsodium.so.23.2.0
-rwxr-xr-x 1 root root 2132640 Nov 30 10:03 libsodium.so.23.3.0
g++でコンパイルするときに-lsodiumを追加
code:sh
RustEnclave_Link_Flags => -m64 -O0 -g -Wl,--no-undefined -nostdlib -nodefaultlibs -nostartfiles -L/opt/sgxsdk/lib64 -Wl,--whole-archive -lsgx_trts -Wl,--no-whole-archive -Wl,--start-group -lsgx_tstdc -lsgx_tservice -lsgx_tcrypto -lsodium -L../build/lib -lenclave -Wl,--end-group -Wl,-Bstatic -Wl,-Bsymbolic -Wl,--no-undefined -Wl,-pie,-eenclave_entry -Wl,--export-dynamic -Wl,--defsym,__ImageBase=0 -Wl,--gc-sections -Wl,--version-script=../config/Enclave.lds
LINK => ../build/enclave.so
mkdir -p ../.anonify
<!-- Please refer to User's Guide for the explanation of each field -->
<EnclaveConfiguration>
<ProdID>0</ProdID>
<ISVSVN>0</ISVSVN>
<StackMaxSize>0x40000</StackMaxSize>
<HeapMaxSize>0x100000</HeapMaxSize>
<TCSNum>6</TCSNum>
<TCSPolicy>1</TCSPolicy>
<DisableDebug>0</DisableDebug>
<MiscSelect>0</MiscSelect>
<MiscMask>0xFFFFFFFF</MiscMask>
</EnclaveConfiguration>
Symbol table incorrect
The input enclave file is not correct.
Error happened while signing the enclave.
Makefile:149: recipe for target '../.anonify/enclave.signed.so' failed
雑にビルドしたせい?
targetを削除してもう一度
→同じ結果
symbol 'crypto_scalarmult_base' is undefinedでググってみる
→めぼしい記事とかないなぁ
をみているとdynamic libraryの指定が間違っていそう
-L/usr/local/libを追加
→変わらず
/usr/lib/x86_64-linux-gnu/配下のlibsodiumを消すか
→シンボリックリンクを貼り直す
code:sh
root@dadaf683d068:/usr/lib/x86_64-linux-gnu# unlink libsodium.so.23
root@dadaf683d068:/usr/lib/x86_64-linux-gnu# ln -s /usr/local/lib/libsodium.so.23.3.0 /usr/lib/x86_64-linux-gnu/libsodium.so.23
root@dadaf683d068:/usr/lib/x86_64-linux-gnu# ls -la /usr/lib/x86_64-linux-gnu/ | grep sodi
lrwxrwxrwx 1 root root 34 Dec 1 05:17 libsodium.so.23 -> /usr/local/lib/libsodium.so.23.3.0
-rw-r--r-- 1 root root 330440 Dec 26 2017 libsodium.so.23.1.0
→変わらず
code:sh
root@dadaf683d068:~/anonify/build# nm --undefined-only enclave.so
w _Z9pcl_entryPvS_
U crypto_box_curve25519xsalsa20poly1305_keypair
U crypto_box_open_easy
U crypto_scalarmult_base
U sodium_memzero
未定義シンボル、他にもあるのにcrypto_scalarmult_baseだけエラーなのなんで。
code:sh
❯ rg crypto_box_curve25519xsalsa20poly1305_keypair
include/sodium/crypto_box_curve25519xsalsa20poly1305.h
52:int crypto_box_curve25519xsalsa20poly1305_keypair(unsigned char *pk,
code:sh
~/Documents/sand/mysamples/nacl/libsodium-stable/src/libsodium master*
include/sodium/crypto_box.h
67:int crypto_box_open_easy(unsigned char *m, const unsigned char *c,
code:sh
~/Documents/sand/mysamples/nacl/libsodium-stable/src/libsodium master*
include/sodium/crypto_scalarmult.h
26:int crypto_scalarmult_base(unsigned char *q, const unsigned char *n)
code:sh
❯ rg sodium_memzero
include/sodium/utils.h
22:void sodium_memzero(void * const pnt, const size_t len);
code:sh
root@dadaf683d068:~/anonify/build# nm /usr/local/lib/libsodium.so | grep crypto_box_open_easy
000000000000e760 T crypto_box_open_easy
000000000000e730 T crypto_box_open_easy_afternm
root@dadaf683d068:~/anonify/build# nm /usr/local/lib/libsodium.so | grep crypto_scalarmult_base
00000000000211b0 T crypto_scalarmult_base
root@dadaf683d068:~/anonify/build# nm /usr/local/lib/libsodium.so | grep crypto_box_curve25519xsalsa20poly1305_keypair
000000000000ea60 T crypto_box_curve25519xsalsa20poly1305_keypair
root@dadaf683d068:~/anonify/build# nm /usr/local/lib/libsodium.so | grep sodium_memzero
0000000000026000 T sodium_memzero