diff --git a/example-setup/setup-full-ids b/example-setup/setup-full-ids index dc7ea918..ab9a80c5 100755 --- a/example-setup/setup-full-ids +++ b/example-setup/setup-full-ids @@ -3,15 +3,10 @@ set -euo pipefail trap '[ $? -eq 0 ] && exit 0; printf "%s failed\n" "$0"' EXIT +dir="$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd -P)" +source "${dir}/utils.sh" export PATH=${PATH}:${HOME}/go/bin -function abs_path() { - if [[ -d "$(dirname "$1")" ]] - then - echo "$(cd "$(dirname "$1")" && pwd)/$(basename "$1")" || true - fi -} - if [[ "$#" -ne 3 ]]; then echo "Usage: ./setup-full-ids " exit 1 diff --git a/example-setup/setup-full-simple b/example-setup/setup-full-simple index f9f0ad00..b89ffe71 100755 --- a/example-setup/setup-full-simple +++ b/example-setup/setup-full-simple @@ -3,15 +3,10 @@ set -euo pipefail trap '[ $? -eq 0 ] && exit 0; printf "%s failed\n" "$0"' EXIT +dir="$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd -P)" +source "${dir}/utils.sh" export PATH=${PATH}:${HOME}/go/bin -abs_path() { - if [[ -d "$(dirname "$1")" ]] - then - echo "$(cd "$(dirname "$1")" && pwd)/$(basename "$1")" || true - fi -} - if [[ "$#" -ne 3 ]]; then echo "Usage: ./setup-full-simple " exit diff --git a/example-setup/sgx-setup-sample b/example-setup/sgx-setup-sample index 1112abbb..57dc043c 100755 --- a/example-setup/sgx-setup-sample +++ b/example-setup/sgx-setup-sample @@ -3,17 +3,12 @@ set -euo pipefail trap '[ $? -eq 0 ] && exit 0; printf "%s failed\n" "$0"' EXIT +dir="$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd -P)" +source "${dir}/utils.sh" export PATH=${PATH}:${HOME}/go/bin -abs_path() { - if [[ -d "$(dirname "$1")" ]] - then - echo "$(cd "$(dirname "$1")" && pwd)/$(basename "$1")" || true - fi -} - -if [[ "$#" -ne 3 ]]; then - echo "Usage: ./setup-full-simple " +if [[ "$#" -ne 5 ]]; then + echo "Usage: ./setup-full-simple " exit fi @@ -21,13 +16,15 @@ fi cmc="$(abs_path "${1}")" data="$(abs_path "${2}")" ser="${3}" +mrenclave="${4}" +mrsigner="${5}" if [[ ! -d "$cmc" ]]; then echo "cmc directory does not exist. Did you clone the repository? Abort.." exit 1 fi -if [[ ! -d "${data}" ]]; then +if [[ ! -d "${data}" ]]; then mkdir -p "${data}" fi @@ -80,7 +77,7 @@ decoded=$(printf '%b' "$(echo "$cert_chain" | sed 's/SGX-PCK-Certificate-Issuer- root_ca=$(echo -e "$decoded" | sed -n '/-----END CERTIFICATE-----/,$p' | sed '1d') ca_fingerprint=$(openssl x509 -in <(echo "$root_ca") -noout -sha256 -fingerprint | awk -F= '{print $2}' | tr -d ': ' | tr '[:upper:]' '[:lower:]') -# GET TCB Info +# GET TCB Info tcb_info="$(curl -s -X GET "https://api.trustedservices.intel.com/sgx/certification/v4/tcb?fmspc=$fmspc" | jq -c .)" echo "$tcb_info" > "${data}/metadata-raw/tcb_info.json" @@ -98,7 +95,7 @@ jq --argjson tcb_info "$tcb_info" --argjson qe_identity "$qe_identity" --argjson "sgx": { "version": 3, "collateral": { - "teeType": 0, + "teeType": 0, "tcbInfo": $tcb_info, "tcbInfoSize": $tcb_info_size, "qeIdentity": $qe_identity, diff --git a/example-setup/update-app-manifest b/example-setup/update-app-manifest index 8c6bd9fb..7f6a5d3f 100755 --- a/example-setup/update-app-manifest +++ b/example-setup/update-app-manifest @@ -3,24 +3,10 @@ set -euo pipefail trap '[ $? -eq 0 ] && exit 0; printf "%s failed\n" "$0"' EXIT +dir="$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd -P)" +source "${dir}/utils.sh" export PATH=${PATH}:${HOME}/go/bin -abs_path() { - if [[ -d "$(dirname "$1")" ]] - then - echo "$(cd "$(dirname "$1")" && pwd)/$(basename "$1")" || true - fi -} - -extendarr() { - local key=$1 - shift - local param=$1 - - # Add new value - json="$(echo "${json}" | jq ".${key} += [${param}]")" -} - if [[ "$#" -ne 2 ]]; then echo "Usage: ./update-app-manifest " exit 1 @@ -39,9 +25,6 @@ fi echo "Using ${data} as directory for local data" -# Load manifest -json=$(cat "${data}/metadata-raw/app.manifest.json") - # Calculate the IMA app reference values referenceValues=$(sudo calculate-ima-pcr -t 10 -i ima-ng -p /usr/bin) diff --git a/example-setup/update-app-manifest-live b/example-setup/update-app-manifest-live index 81f20e62..aa53a3a5 100755 --- a/example-setup/update-app-manifest-live +++ b/example-setup/update-app-manifest-live @@ -5,22 +5,6 @@ set -euo pipefail trap '[ $? -eq 0 ] && exit 0; printf "%s failed\n" "$0"' EXIT export PATH=${PATH}:${HOME}/go/bin -abs_path() { - if [[ -d "$(dirname "$1")" ]] - then - echo "$(cd "$(dirname "$1")" && pwd)/$(basename "$1")" || true - fi -} - -extendarr() { - local key=$1 - shift - local param=$1 - - # Add new value - json="$(echo "${json}" | jq ".${key} += [${param}]")" -} - if [[ "$#" -ne 2 ]]; then echo "Usage: ./update-app-manifest-live " exit 1 diff --git a/example-setup/update-full-ids b/example-setup/update-full-ids index 1c78115c..b7cc1761 100755 --- a/example-setup/update-full-ids +++ b/example-setup/update-full-ids @@ -3,15 +3,10 @@ set -euo pipefail trap '[ $? -eq 0 ] && exit 0; printf "%s failed\n" "$0"' EXIT +dir="$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd -P)" +source "${dir}/utils.sh" export PATH=${PATH}:${HOME}/go/bin -function abs_path() { - if [[ -d "$(dirname "$1")" ]] - then - echo "$(cd "$(dirname "$1")" && pwd)/$(basename "$1")" || true - fi -} - if [[ "$#" -ne 2 ]]; then echo "Usage: ./update-full-ids " exit 1 diff --git a/example-setup/update-full-simple b/example-setup/update-full-simple index 6c3785e2..bcd75611 100755 --- a/example-setup/update-full-simple +++ b/example-setup/update-full-simple @@ -3,16 +3,10 @@ set -euo pipefail trap '[ $? -eq 0 ] && exit 0; printf "%s failed\n" "$0"' EXIT +dir="$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd -P)" +source "${dir}/utils.sh" export PATH=${PATH}:${HOME}/go/bin -abs_path() { - if [[ -d "$(dirname "$1")" ]] - then - echo "$(cd "$(dirname "$1")" && pwd)/$(basename "$1")" || true - fi -} - - if [[ "$#" -ne 2 ]]; then echo "Usage: ./update-full-simple " exit 1 diff --git a/example-setup/utils.sh b/example-setup/utils.sh new file mode 100644 index 00000000..f651eba4 --- /dev/null +++ b/example-setup/utils.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +abs_path() { + if [[ -d "$(dirname "$1")" ]] + then + echo "$(cd "$(dirname "$1")" && pwd)/$(basename "$1")" || true + fi +} + +extendarr() { + local key=$1 + shift + local param=$1 + + # Add new value + json="$(echo "${json}" | jq ".${key} += [${param}]")" +} \ No newline at end of file