File: install_awslc_fips.sh

package info (click to toggle)
aws-crt-python 0.28.4%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 78,428 kB
  • sloc: ansic: 437,955; python: 27,657; makefile: 5,855; sh: 4,289; ruby: 208; java: 82; perl: 73; cpp: 25; xml: 11
file content (82 lines) | stat: -rwxr-xr-x 1,803 bytes parent folder | download
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
#!/usr/bin/env bash
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
set -eu

usage() {
    echo -e "\ninstall_awslc_fips.sh build_dir install_dir version"
    echo -e "\tversion: 2022|2024|next\n"
    exit 1
}

check_dep(){
    if [[ ! -f "$(which $1)" ]]; then
        echo "Could not find $1"
        exit 1
    fi
}

clone(){
    git clone https://github.com/awslabs/aws-lc.git --branch "$AWSLC_BRANCH" --depth 1 $BUILD_DIR
    cd "$BUILD_DIR"
}

build() {
    echo "Building with shared library=$1"
    cmake $BUILD_DIR \
      -Bbuild \
      -GNinja \
      -DBUILD_SHARED_LIBS=$1 \
      -DCMAKE_BUILD_TYPE=relwithdebinfo \
      -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \
      -DCMAKE_C_COMPILER=$(which clang) \
      -DCMAKE_CXX_COMPILER=$(which clang++) \
      -DFIPS="true"
    ninja -j "$(nproc)" -C build install
    ninja -C build clean
}

# main
if [ "$#" -ne "3" ]; then
    usage
fi

# Ensure tooling is available
check_dep clang
check_dep ninja
check_dep go

BUILD_DIR=$1
INSTALL_DIR=$2
VERSION=$3
GH_RELEASE_URL="https://api.github.com/repos/aws/aws-lc/releases"

# Map version to the latest release of the certificate year.
# Note: since the next FIPS validation will be split off from main
# building main with FIPS enabled is the next candidate FIPS branch.
case $VERSION in
  "2022")
    AWSLC_BRANCH=$(curl --silent $GH_RELEASE_URL \
      |grep -Po '"tag_name": "\KAWS-LC-FIPS-2.*?(?=")' |head -1)
    ;;
  "2024")
    AWSLC_BRANCH=$(curl --silent $GH_RELEASE_URL \
      |grep -Po '"tag_name": "\KAWS-LC-FIPS-3.*?(?=")' |head -1)
    ;;
  "next")
    AWSLC_BRANCH=main
    ;;
  *)
    echo "Unknown version: $VERSION"
    usage
    ;;
esac

clone
# Static lib
build false
# Shared lib
build true

rm -rf $BUILD_DIR