-
Notifications
You must be signed in to change notification settings - Fork 0
/
quick-start.sh
executable file
·103 lines (83 loc) · 3.15 KB
/
quick-start.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/bin/bash
set -e
echo -e "This is a quick-start build script for the Keystone CA, it
will clone and build all the necessary parts to run the demo
server/applcation and client on a RISC-V platform (ex: qemu). Please
ensure you have cloned keystone completely and that you have fully
built the sdk tests and run them successfully in qemu.
You must set KEYSTONE_SDK_DIR to the install directory of Keystone SDK.
You must have the riscv64 gcc on-path as well. (e.g. run
'source source.sh' in the Keystone directory.
If you have already started building Mbed TLS / etc, it is not
recommended to use this script."
read -r -p "Continue? [Y/n] " response
response=${response,,}
if [[ "$response" =~ ^(no|n)$ ]]
then
exit 0
fi
# Check location/tools
if [[ ! -v KEYSTONE_SDK_DIR ]]
then
echo "KEYSTONE_SDK_DIR not set! Please set this to the location where Keystone SDK has been installed."
exit 0
fi
if [[ ! $(command -v riscv64-unknown-linux-gnu-gcc) ]]
then
echo "No riscv64 gcc available. Make sure you've run \"source source.sh\" in the Keystone directory (or equivalent.)";
exit 0
fi
DEMO_DIR=$(pwd)
set -e
mkdir -p mbedtls_builds
cd mbedtls_builds
# Clone, checkout, and build the mbedtls library
if [ ! -d mbedtls_eapp ]
then
git clone https://github.com/Mbed-TLS/mbedtls.git mbedtls_eapp
cd mbedtls_eapp
git checkout 3c3b94a31b9d91e1579c48165658486171c82a36
python3 -m pip install --user -r scripts/basic.requirements.txt
patch -p1 < $DEMO_DIR/patches/mbedtls_eapp.patch
mkdir build && cd build
cmake -DCMAKE_TOOLCHAIN_FILE=$DEMO_DIR/riscv-toolchain.cmake -DENABLE_TESTING=0ff ..
cmake --build .
cd ../..
fi
export MBEDTLS_DIR_EAPP=$(pwd)/mbedtls_eapp
if [ ! -d mbedtls_host ]
then
git clone https://github.com/Mbed-TLS/mbedtls.git mbedtls_host
cd mbedtls_host
git checkout 3c3b94a31b9d91e1579c48165658486171c82a36
python3 -m pip install --user -r scripts/basic.requirements.txt
mkdir build && cd build
cmake -DCMAKE_TOOLCHAIN_FILE=$DEMO_DIR/riscv-toolchain.cmake -DENABLE_TESTING=0ff ..
cmake --build .
cd ../..
fi
export MBEDTLS_DIR_HOST=$(pwd)/mbedtls_host
cd ..
# if [ ! -d openssl ]
# then
# git clone https://github.com/openssl/openssl.git openssl
# cd openssl
# CC=gcc CXX=g++ CROSS_COMPILE=riscv64-unknown-linux-gnu- ./Configure linux64-riscv64 --prefix=/home/giacomo/Documents/keystone-CA/openssl_install_dir --openssldir=/home/giacomo/Documents/keystone-CA/openssl_install_dir/ssl --cross-compile-prefix=riscv64-unknown-linux-gnu- no-deprecated no-hw no-threads no-apps no-async no-shared no-dynamic-engine no-comp no-dso no-module no-pinshared -static
# make
# make install
# cd ..
# fi
# export OPENSSL_DIR=$(pwd)/openssl_install_dir
# Build the demo
mkdir -p build
cd build
cmake ..
make
make enclave-Alice-package
# copy enclave packages - only for me
cp enclave-Alice/enclave-Alice.ke ../../keystone/build/overlay/root/
cp server-CA/server-CA.riscv ../../keystone/build/overlay/root/
# Done!
echo -e "************ Demo binaries built and copied into overlay directory. ***************
Run 'make image' in the Keystone build dir, and the demo binaries should
be available in qemu next time you start it!"