Debian Codegraph @

crt/s2n/codebuild/bin/install_awslc_fips.sh

raw symbols SCIP
1 #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash
2 # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 # SPDX-License-Identifier: Apache-2.0
4 set -eu
5
6 usagescip-shell shell shell-project 0.0.0 usage().() {
7 echoscip-shell system . . echo. -e "\ninstall_awslc_fips.sh build_dir install_dir version"
8 echoscip-shell system . . echo. -e "\tversion: 2022|2024|next\n"
9 exit 1
10 }
11
12 check_depscip-shell shell shell-project 0.0.0 check_dep().(){
13 if [[ ! -f "$(which $1)" ]]; then
14 echoscip-shell system . . echo. "Could not find $1"
15 exit 1
16 fi
17 }
18
19 clonescip-shell shell shell-project 0.0.0 clone().(){
20 gitscip-shell system . . git. clone https://github.com/awslabs/aws-lc.git --branch "$AWSLC_BRANCH" --depth 1 $BUILD_DIR
21 cd "$BUILD_DIR"
22 }
23
24 buildscip-shell shell shell-project 0.0.0 build().() {
25 echoscip-shell system . . echo. "Building with shared library=$1"
26 cmakescip-shell system . . cmake. $BUILD_DIR \
27 -Bbuild \
28 -GNinja \
29 -DBUILD_SHARED_LIBS=$1 \
30 -DCMAKE_BUILD_TYPE=relwithdebinfo \
31 -DCMAKE_INSTALL_PREFIX="scip-shell system . . which.${INSTALL_DIR}" \
32 -DCMAKE_C_COMPILER=$(whichscip-shell system . . which. clang) \
33 -DCMAKE_CXX_COMPILER=$(which clang++) \
34 -DFIPS="true"
35 ninjascip-shell system . . ninja. -j "$(nprocscip-shell system . . nproc.)" -C build install
36 ninjascip-shell system . . ninja. -C build clean
37 }
38
39 # main
40 if [scip-shell system . . `[`. "$#" -ne "3" ]; then
41 usagescip-shell shell shell-project 0.0.0 usage().
42 fi
43
44 # Ensure tooling is available
45 check_depscip-shell shell shell-project 0.0.0 check_dep(). clang
46 check_depscip-shell shell shell-project 0.0.0 check_dep(). ninja
47 check_depscip-shell shell shell-project 0.0.0 check_dep(). go
48
49 BUILD_DIR=$1
50 INSTALL_DIR=$2
51 VERSION=$3
52 # This url only returns the latest 30 releases (configurable via `per_page`). AWS-LC-FIPS-3.x is the current major version.
53 GH_RELEASE_URL="https://api.github.com/repos/aws/aws-lc/releases"
54 # Latest release of AWS-LC-FIPS-2.x
55 FIPS2_RELEASE_URL="https://api.github.com/repos/aws/aws-lc/releases/tags/AWS-LC-FIPS-2.0.17"
56
57 # Map version to the latest release of the certificate year.
58 # Note: since the next FIPS validation will be split off from main
59 # building main with FIPS enabled is the next candidate FIPS branch.
60 case $VERSION in
61 "2022")
62 AWSLC_BRANCH=$(curlscip-shell system . . curl. --silent $FIPS2_RELEASE_URL \
63 |grep -Po '"tag_name": "\KAWS-LC-FIPS-2.*?(?=")' |head -1)
64 ;;
65 "2024")
66 AWSLC_BRANCH=$(curlscip-shell system . . curl. --silent $GH_RELEASE_URL \
67 |grep -Po '"tag_name": "\KAWS-LC-FIPS-3.*?(?=")' |head -1)
68 ;;
69 "next")
70 AWSLC_BRANCH=main
71 ;;
72 *)
73 echoscip-shell system . . echo. "Unknown version: $VERSION"
74 usagescip-shell shell shell-project 0.0.0 usage().
75 ;;
76 esac
77
78 clonescip-shell shell shell-project 0.0.0 clone().
79 # Static lib
80 buildscip-shell shell shell-project 0.0.0 build(). false
81 # Shared lib
82 buildscip-shell shell shell-project 0.0.0 build(). true
83
84 rmscip-shell system . . rm. -rf $BUILD_DIR
85