aboutsummaryrefslogtreecommitdiffstats
path: root/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util
diff options
context:
space:
mode:
Diffstat (limited to 'roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util')
-rw-r--r--roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/32-bit-toolchain.cmake7
-rw-r--r--roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/BUILD.toplevel130
-rw-r--r--roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/all_tests.go383
-rw-r--r--roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/all_tests.json59
-rw-r--r--roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/bot/DEPS144
-rw-r--r--roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/bot/README3
-rw-r--r--roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/bot/UPDATING47
-rw-r--r--roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/bot/cmake-linux64.tar.gz.sha11
-rw-r--r--roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/bot/cmake-mac.tar.gz.sha11
-rw-r--r--roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/bot/cmake-win32.zip.sha11
-rw-r--r--roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/bot/extract.py157
-rwxr-xr-xroms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/bot/go/bootstrap.py296
-rwxr-xr-xroms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/bot/go/env.py49
-rw-r--r--roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/bot/perl-win32.zip.sha11
-rw-r--r--roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/bot/update_clang.py71
-rw-r--r--roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/bot/vs_env.py37
-rw-r--r--roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/bot/vs_toolchain.py113
-rw-r--r--roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/bot/yasm-win32.exe.sha11
-rw-r--r--roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/diff_asm.go112
-rw-r--r--roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/doc.config57
-rw-r--r--roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/doc.css70
-rw-r--r--roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/doc.go728
-rwxr-xr-xroms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/generate-asm-lcov.py152
-rwxr-xr-xroms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/generate-coverage.sh59
-rw-r--r--roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/generate_build_files.py735
-rw-r--r--roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/make_errors.go388
-rw-r--r--roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/run_android_tests.go325
27 files changed, 4127 insertions, 0 deletions
diff --git a/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/32-bit-toolchain.cmake b/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/32-bit-toolchain.cmake
new file mode 100644
index 000000000..f3a10b708
--- /dev/null
+++ b/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/32-bit-toolchain.cmake
@@ -0,0 +1,7 @@
+set(CMAKE_SYSTEM_NAME Linux)
+set(CMAKE_SYSTEM_VERSION 1)
+set(CMAKE_SYSTEM_PROCESSOR "x86")
+
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32 -msse2" CACHE STRING "c++ flags")
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32 -msse2" CACHE STRING "c flags")
+set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -m32 -msse2" CACHE STRING "asm flags")
diff --git a/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/BUILD.toplevel b/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/BUILD.toplevel
new file mode 100644
index 000000000..be3fd96c9
--- /dev/null
+++ b/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/BUILD.toplevel
@@ -0,0 +1,130 @@
+# Copyright (c) 2016, Google Inc.
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+# SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+# OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
+
+licenses(["notice"])
+
+exports_files(["LICENSE"])
+
+load(
+ ":BUILD.generated.bzl",
+ "crypto_headers",
+ "crypto_internal_headers",
+ "crypto_sources",
+ "crypto_sources_linux_x86_64",
+ "crypto_sources_mac_x86_64",
+ "ssl_headers",
+ "ssl_internal_headers",
+ "ssl_c_sources",
+ "ssl_cc_sources",
+ "tool_sources",
+ "tool_headers",
+)
+
+config_setting(
+ name = "linux_x86_64",
+ values = {"cpu": "k8"},
+)
+
+config_setting(
+ name = "mac_x86_64",
+ values = {"cpu": "darwin"},
+)
+
+boringssl_copts = [
+ # Assembler option --noexecstack adds .note.GNU-stack to each object to
+ # ensure that binaries can be built with non-executable stack.
+ "-Wa,--noexecstack",
+
+ # This is needed on Linux systems (at least) to get rwlock in pthread.
+ "-D_XOPEN_SOURCE=700",
+
+ # This list of warnings should match those in the top-level CMakeLists.txt.
+ "-Wall",
+ "-Werror",
+ "-Wformat=2",
+ "-Wsign-compare",
+ "-Wmissing-field-initializers",
+ "-Wwrite-strings",
+ "-Wshadow",
+ "-fno-common",
+
+ # Modern build environments should be able to set this to use atomic
+ # operations for reference counting rather than locks. However, it's
+ # known not to work on some Android builds.
+ # "-DOPENSSL_C11_ATOMIC",
+] + select({
+ ":linux_x86_64": [],
+ ":mac_x86_64": [],
+ "//conditions:default": ["-DOPENSSL_NO_ASM"],
+})
+
+crypto_sources_asm = select({
+ ":linux_x86_64": crypto_sources_linux_x86_64,
+ ":mac_x86_64": crypto_sources_mac_x86_64,
+ "//conditions:default": [],
+})
+
+# For C targets only (not C++), compile with C11 support.
+boringssl_copts_c11 = boringssl_copts + [
+ "-std=c11",
+ "-Wmissing-prototypes",
+ "-Wold-style-definition",
+ "-Wstrict-prototypes",
+]
+
+# For C targets only (not C++), compile with C11 support.
+boringssl_copts_cxx = boringssl_copts + [
+ "-std=c++11",
+ "-Wmissing-declarations",
+]
+
+cc_library(
+ name = "crypto",
+ srcs = crypto_sources + crypto_internal_headers + crypto_sources_asm,
+ hdrs = crypto_headers,
+ copts = boringssl_copts_c11,
+ includes = ["src/include"],
+ linkopts = select({
+ ":mac_x86_64": [],
+ "//conditions:default": ["-lpthread"],
+ }),
+ visibility = ["//visibility:public"],
+)
+
+cc_library(
+ name = "ssl",
+ srcs = ssl_c_sources + ssl_internal_headers,
+ hdrs = ssl_headers,
+ copts = boringssl_copts_c11,
+ includes = ["src/include"],
+ visibility = ["//visibility:public"],
+ deps = [":crypto", ":ssl_cc"],
+)
+
+cc_library(
+ name = "ssl_cc",
+ srcs = ssl_cc_sources + ssl_internal_headers,
+ hdrs = ssl_headers,
+ copts = boringssl_copts,
+ includes = ["src/include"],
+ deps = [":crypto"],
+)
+
+cc_binary(
+ name = "bssl",
+ srcs = tool_sources + tool_headers,
+ copts = boringssl_copts_cxx,
+ visibility = ["//visibility:public"],
+ deps = [":ssl"],
+)
diff --git a/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/all_tests.go b/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/all_tests.go
new file mode 100644
index 000000000..3cf23206b
--- /dev/null
+++ b/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/all_tests.go
@@ -0,0 +1,383 @@
+/* Copyright (c) 2015, Google Inc.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
+
+package main
+
+import (
+ "bytes"
+ "encoding/json"
+ "flag"
+ "fmt"
+ "os"
+ "os/exec"
+ "path"
+ "strconv"
+ "strings"
+ "sync"
+ "syscall"
+ "time"
+)
+
+// TODO(davidben): Link tests with the malloc shim and port -malloc-test to this runner.
+
+var (
+ useValgrind = flag.Bool("valgrind", false, "If true, run code under valgrind")
+ useCallgrind = flag.Bool("callgrind", false, "If true, run code under valgrind to generate callgrind traces.")
+ useGDB = flag.Bool("gdb", false, "If true, run BoringSSL code under gdb")
+ useSDE = flag.Bool("sde", false, "If true, run BoringSSL code under Intel's SDE for each supported chip")
+ buildDir = flag.String("build-dir", "build", "The build directory to run the tests from.")
+ numWorkers = flag.Int("num-workers", 1, "Runs the given number of workers when testing.")
+ jsonOutput = flag.String("json-output", "", "The file to output JSON results to.")
+ mallocTest = flag.Int64("malloc-test", -1, "If non-negative, run each test with each malloc in turn failing from the given number onwards.")
+ mallocTestDebug = flag.Bool("malloc-test-debug", false, "If true, ask each test to abort rather than fail a malloc. This can be used with a specific value for --malloc-test to identity the malloc failing that is causing problems.")
+)
+
+type test struct {
+ args []string
+ // cpu, if not empty, contains an Intel CPU code to simulate. Run
+ // `sde64 -help` to get a list of these codes.
+ cpu string
+}
+
+type result struct {
+ Test test
+ Passed bool
+ Error error
+}
+
+// testOutput is a representation of Chromium's JSON test result format. See
+// https://www.chromium.org/developers/the-json-test-results-format
+type testOutput struct {
+ Version int `json:"version"`
+ Interrupted bool `json:"interrupted"`
+ PathDelimiter string `json:"path_delimiter"`
+ SecondsSinceEpoch float64 `json:"seconds_since_epoch"`
+ NumFailuresByType map[string]int `json:"num_failures_by_type"`
+ Tests map[string]testResult `json:"tests"`
+}
+
+type testResult struct {
+ Actual string `json:"actual"`
+ Expected string `json:"expected"`
+ IsUnexpected bool `json:"is_unexpected"`
+}
+
+// sdeCPUs contains a list of CPU code that we run all tests under when *useSDE
+// is true.
+var sdeCPUs = []string{
+ "p4p", // Pentium4 Prescott
+ "mrm", // Merom
+ "pnr", // Penryn
+ "nhm", // Nehalem
+ "wsm", // Westmere
+ "snb", // Sandy Bridge
+ "ivb", // Ivy Bridge
+ "hsw", // Haswell
+ "bdw", // Broadwell
+ "skx", // Skylake Server
+ "skl", // Skylake Client
+ "cnl", // Cannonlake
+ "knl", // Knights Landing
+ "slt", // Saltwell
+ "slm", // Silvermont
+ "glm", // Goldmont
+}
+
+func newTestOutput() *testOutput {
+ return &testOutput{
+ Version: 3,
+ PathDelimiter: ".",
+ SecondsSinceEpoch: float64(time.Now().UnixNano()) / float64(time.Second/time.Nanosecond),
+ NumFailuresByType: make(map[string]int),
+ Tests: make(map[string]testResult),
+ }
+}
+
+func (t *testOutput) addResult(name, result string) {
+ if _, found := t.Tests[name]; found {
+ panic(name)
+ }
+ t.Tests[name] = testResult{
+ Actual: result,
+ Expected: "PASS",
+ IsUnexpected: result != "PASS",
+ }
+ t.NumFailuresByType[result]++
+}
+
+func (t *testOutput) writeTo(name string) error {
+ file, err := os.Create(name)
+ if err != nil {
+ return err
+ }
+ defer file.Close()
+ out, err := json.MarshalIndent(t, "", " ")
+ if err != nil {
+ return err
+ }
+ _, err = file.Write(out)
+ return err
+}
+
+func valgrindOf(dbAttach bool, path string, args ...string) *exec.Cmd {
+ valgrindArgs := []string{"--error-exitcode=99", "--track-origins=yes", "--leak-check=full", "--quiet"}
+ if dbAttach {
+ valgrindArgs = append(valgrindArgs, "--db-attach=yes", "--db-command=xterm -e gdb -nw %f %p")
+ }
+ valgrindArgs = append(valgrindArgs, path)
+ valgrindArgs = append(valgrindArgs, args...)
+
+ return exec.Command("valgrind", valgrindArgs...)
+}
+
+func callgrindOf(path string, args ...string) *exec.Cmd {
+ valgrindArgs := []string{"-q", "--tool=callgrind", "--dump-instr=yes", "--collect-jumps=yes", "--callgrind-out-file=" + *buildDir + "/callgrind/callgrind.out.%p"}
+ valgrindArgs = append(valgrindArgs, path)
+ valgrindArgs = append(valgrindArgs, args...)
+
+ return exec.Command("valgrind", valgrindArgs...)
+}
+
+func gdbOf(path string, args ...string) *exec.Cmd {
+ xtermArgs := []string{"-e", "gdb", "--args"}
+ xtermArgs = append(xtermArgs, path)
+ xtermArgs = append(xtermArgs, args...)
+
+ return exec.Command("xterm", xtermArgs...)
+}
+
+func sdeOf(cpu, path string, args ...string) *exec.Cmd {
+ sdeArgs := []string{"-" + cpu, "--", path}
+ sdeArgs = append(sdeArgs, args...)
+ return exec.Command("sde", sdeArgs...)
+}
+
+type moreMallocsError struct{}
+
+func (moreMallocsError) Error() string {
+ return "child process did not exhaust all allocation calls"
+}
+
+var errMoreMallocs = moreMallocsError{}
+
+func runTestOnce(test test, mallocNumToFail int64) (passed bool, err error) {
+ prog := path.Join(*buildDir, test.args[0])
+ args := test.args[1:]
+ var cmd *exec.Cmd
+ if *useValgrind {
+ cmd = valgrindOf(false, prog, args...)
+ } else if *useCallgrind {
+ cmd = callgrindOf(prog, args...)
+ } else if *useGDB {
+ cmd = gdbOf(prog, args...)
+ } else if *useSDE {
+ cmd = sdeOf(test.cpu, prog, args...)
+ } else {
+ cmd = exec.Command(prog, args...)
+ }
+ var outBuf bytes.Buffer
+ cmd.Stdout = &outBuf
+ cmd.Stderr = &outBuf
+ if mallocNumToFail >= 0 {
+ cmd.Env = os.Environ()
+ cmd.Env = append(cmd.Env, "MALLOC_NUMBER_TO_FAIL="+strconv.FormatInt(mallocNumToFail, 10))
+ if *mallocTestDebug {
+ cmd.Env = append(cmd.Env, "MALLOC_ABORT_ON_FAIL=1")
+ }
+ cmd.Env = append(cmd.Env, "_MALLOC_CHECK=1")
+ }
+
+ if err := cmd.Start(); err != nil {
+ return false, err
+ }
+ if err := cmd.Wait(); err != nil {
+ if exitError, ok := err.(*exec.ExitError); ok {
+ if exitError.Sys().(syscall.WaitStatus).ExitStatus() == 88 {
+ return false, errMoreMallocs
+ }
+ }
+ fmt.Print(string(outBuf.Bytes()))
+ return false, err
+ }
+
+ // Account for Windows line-endings.
+ stdout := bytes.Replace(outBuf.Bytes(), []byte("\r\n"), []byte("\n"), -1)
+
+ if bytes.HasSuffix(stdout, []byte("PASS\n")) &&
+ (len(stdout) == 5 || stdout[len(stdout)-6] == '\n') {
+ return true, nil
+ }
+
+ // Also accept a googletest-style pass line. This is left here in
+ // transition until the tests are all converted and this script made
+ // unnecessary.
+ if bytes.Contains(stdout, []byte("\n[ PASSED ]")) {
+ return true, nil
+ }
+
+ fmt.Print(string(outBuf.Bytes()))
+ return false, nil
+}
+
+func runTest(test test) (bool, error) {
+ if *mallocTest < 0 {
+ return runTestOnce(test, -1)
+ }
+
+ for mallocNumToFail := int64(*mallocTest); ; mallocNumToFail++ {
+ if passed, err := runTestOnce(test, mallocNumToFail); err != errMoreMallocs {
+ if err != nil {
+ err = fmt.Errorf("at malloc %d: %s", mallocNumToFail, err)
+ }
+ return passed, err
+ }
+ }
+}
+
+// shortTestName returns the short name of a test. Except for evp_test, it
+// assumes that any argument which ends in .txt is a path to a data file and not
+// relevant to the test's uniqueness.
+func shortTestName(test test) string {
+ var args []string
+ for _, arg := range test.args {
+ if test.args[0] == "crypto/evp/evp_test" || !strings.HasSuffix(arg, ".txt") {
+ args = append(args, arg)
+ }
+ }
+ return strings.Join(args, " ") + test.cpuMsg()
+}
+
+// setWorkingDirectory walks up directories as needed until the current working
+// directory is the top of a BoringSSL checkout.
+func setWorkingDirectory() {
+ for i := 0; i < 64; i++ {
+ if _, err := os.Stat("BUILDING.md"); err == nil {
+ return
+ }
+ os.Chdir("..")
+ }
+
+ panic("Couldn't find BUILDING.md in a parent directory!")
+}
+
+func parseTestConfig(filename string) ([]test, error) {
+ in, err := os.Open(filename)
+ if err != nil {
+ return nil, err
+ }
+ defer in.Close()
+
+ decoder := json.NewDecoder(in)
+ var testArgs [][]string
+ if err := decoder.Decode(&testArgs); err != nil {
+ return nil, err
+ }
+
+ var result []test
+ for _, args := range testArgs {
+ result = append(result, test{args: args})
+ }
+ return result, nil
+}
+
+func worker(tests <-chan test, results chan<- result, done *sync.WaitGroup) {
+ defer done.Done()
+ for test := range tests {
+ passed, err := runTest(test)
+ results <- result{test, passed, err}
+ }
+}
+
+func (t test) cpuMsg() string {
+ if len(t.cpu) == 0 {
+ return ""
+ }
+
+ return fmt.Sprintf(" (for CPU %q)", t.cpu)
+}
+
+func main() {
+ flag.Parse()
+ setWorkingDirectory()
+
+ testCases, err := parseTestConfig("util/all_tests.json")
+ if err != nil {
+ fmt.Printf("Failed to parse input: %s\n", err)
+ os.Exit(1)
+ }
+
+ var wg sync.WaitGroup
+ tests := make(chan test, *numWorkers)
+ results := make(chan result, *numWorkers)
+
+ for i := 0; i < *numWorkers; i++ {
+ wg.Add(1)
+ go worker(tests, results, &wg)
+ }
+
+ go func() {
+ for _, test := range testCases {
+ if *useSDE {
+ for _, cpu := range sdeCPUs {
+ testForCPU := test
+ testForCPU.cpu = cpu
+ tests <- testForCPU
+ }
+ } else {
+ tests <- test
+ }
+ }
+ close(tests)
+
+ wg.Wait()
+ close(results)
+ }()
+
+ testOutput := newTestOutput()
+ var failed []test
+ for testResult := range results {
+ test := testResult.Test
+ args := test.args
+
+ fmt.Printf("%s%s\n", strings.Join(args, " "), test.cpuMsg())
+ name := shortTestName(test)
+ if testResult.Error != nil {
+ fmt.Printf("%s failed to complete: %s\n", args[0], testResult.Error)
+ failed = append(failed, test)
+ testOutput.addResult(name, "CRASHED")
+ } else if !testResult.Passed {
+ fmt.Printf("%s failed to print PASS on the last line.\n", args[0])
+ failed = append(failed, test)
+ testOutput.addResult(name, "FAIL")
+ } else {
+ testOutput.addResult(name, "PASS")
+ }
+ }
+
+ if *jsonOutput != "" {
+ if err := testOutput.writeTo(*jsonOutput); err != nil {
+ fmt.Fprintf(os.Stderr, "Error: %s\n", err)
+ }
+ }
+
+ if len(failed) > 0 {
+ fmt.Printf("\n%d of %d tests failed:\n", len(failed), len(testCases))
+ for _, test := range failed {
+ fmt.Printf("\t%s%s\n", strings.Join(test.args, ""), test.cpuMsg())
+ }
+ os.Exit(1)
+ }
+
+ fmt.Printf("\nAll tests passed!\n")
+}
diff --git a/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/all_tests.json b/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/all_tests.json
new file mode 100644
index 000000000..a6e672f6f
--- /dev/null
+++ b/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/all_tests.json
@@ -0,0 +1,59 @@
+[
+ ["crypto/aes/aes_test", "crypto/aes/aes_tests.txt"],
+ ["crypto/asn1/asn1_test"],
+ ["crypto/base64/base64_test"],
+ ["crypto/bio/bio_test"],
+ ["crypto/bn/bn_test", "crypto/bn/bn_tests.txt"],
+ ["crypto/bytestring/bytestring_test"],
+ ["crypto/cipher/aead_test", "aes-128-gcm", "crypto/cipher/test/aes_128_gcm_tests.txt"],
+ ["crypto/cipher/aead_test", "aes-256-gcm", "crypto/cipher/test/aes_256_gcm_tests.txt"],
+ ["crypto/cipher/aead_test", "aes-128-gcm-siv", "crypto/cipher/test/aes_128_gcm_siv_tests.txt"],
+ ["crypto/cipher/aead_test", "aes-256-gcm-siv", "crypto/cipher/test/aes_256_gcm_siv_tests.txt"],
+ ["crypto/cipher/aead_test", "chacha20-poly1305", "crypto/cipher/test/chacha20_poly1305_tests.txt"],
+ ["crypto/cipher/aead_test", "aes-128-cbc-sha1-tls", "crypto/cipher/test/aes_128_cbc_sha1_tls_tests.txt"],
+ ["crypto/cipher/aead_test", "aes-128-cbc-sha1-tls-implicit-iv", "crypto/cipher/test/aes_128_cbc_sha1_tls_implicit_iv_tests.txt"],
+ ["crypto/cipher/aead_test", "aes-128-cbc-sha256-tls", "crypto/cipher/test/aes_128_cbc_sha256_tls_tests.txt"],
+ ["crypto/cipher/aead_test", "aes-256-cbc-sha1-tls", "crypto/cipher/test/aes_256_cbc_sha1_tls_tests.txt"],
+ ["crypto/cipher/aead_test", "aes-256-cbc-sha1-tls-implicit-iv", "crypto/cipher/test/aes_256_cbc_sha1_tls_implicit_iv_tests.txt"],
+ ["crypto/cipher/aead_test", "aes-256-cbc-sha256-tls", "crypto/cipher/test/aes_256_cbc_sha256_tls_tests.txt"],
+ ["crypto/cipher/aead_test", "aes-256-cbc-sha384-tls", "crypto/cipher/test/aes_256_cbc_sha384_tls_tests.txt"],
+ ["crypto/cipher/aead_test", "des-ede3-cbc-sha1-tls", "crypto/cipher/test/des_ede3_cbc_sha1_tls_tests.txt"],
+ ["crypto/cipher/aead_test", "des-ede3-cbc-sha1-tls-implicit-iv", "crypto/cipher/test/des_ede3_cbc_sha1_tls_implicit_iv_tests.txt"],
+ ["crypto/cipher/aead_test", "aes-128-cbc-sha1-ssl3", "crypto/cipher/test/aes_128_cbc_sha1_ssl3_tests.txt"],
+ ["crypto/cipher/aead_test", "aes-256-cbc-sha1-ssl3", "crypto/cipher/test/aes_256_cbc_sha1_ssl3_tests.txt"],
+ ["crypto/cipher/aead_test", "des-ede3-cbc-sha1-ssl3", "crypto/cipher/test/des_ede3_cbc_sha1_ssl3_tests.txt"],
+ ["crypto/cipher/aead_test", "aes-128-ctr-hmac-sha256", "crypto/cipher/test/aes_128_ctr_hmac_sha256.txt"],
+ ["crypto/cipher/aead_test", "aes-256-ctr-hmac-sha256", "crypto/cipher/test/aes_256_ctr_hmac_sha256.txt"],
+ ["crypto/cipher/cipher_test", "crypto/cipher/test/cipher_tests.txt"],
+ ["crypto/cmac/cmac_test"],
+ ["crypto/constant_time_test"],
+ ["crypto/crypto_test"],
+ ["crypto/curve25519/ed25519_test", "crypto/curve25519/ed25519_tests.txt"],
+ ["crypto/curve25519/spake25519_test"],
+ ["crypto/digest/digest_test"],
+ ["crypto/ec/example_mul"],
+ ["crypto/ec/p256-x86_64_test", "crypto/ec/p256-x86_64_tests.txt"],
+ ["crypto/ecdh/ecdh_test", "crypto/ecdh/ecdh_tests.txt"],
+ ["crypto/ecdsa/ecdsa_sign_test", "crypto/ecdsa/ecdsa_sign_tests.txt"],
+ ["crypto/ecdsa/ecdsa_test"],
+ ["crypto/ecdsa/ecdsa_verify_test", "crypto/ecdsa/ecdsa_verify_tests.txt"],
+ ["crypto/evp/evp_test", "crypto/evp/evp_tests.txt"],
+ ["crypto/evp/pbkdf_test"],
+ ["crypto/hkdf/hkdf_test"],
+ ["crypto/hmac/hmac_test", "crypto/hmac/hmac_tests.txt"],
+ ["crypto/lhash/lhash_test"],
+ ["crypto/modes/gcm_test"],
+ ["crypto/obj/obj_test"],
+ ["crypto/pkcs8/pkcs12_test"],
+ ["crypto/pkcs8/pkcs8_test"],
+ ["crypto/poly1305/poly1305_test", "crypto/poly1305/poly1305_tests.txt"],
+ ["crypto/pool/pool_test"],
+ ["crypto/refcount_test"],
+ ["crypto/thread_test"],
+ ["crypto/x509/pkcs7_test"],
+ ["crypto/x509/x509_test"],
+ ["crypto/x509v3/tab_test"],
+ ["crypto/x509v3/v3name_test"],
+ ["decrepit/decrepit_test"],
+ ["ssl/ssl_test"]
+]
diff --git a/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/bot/DEPS b/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/bot/DEPS
new file mode 100644
index 000000000..55eeb8632
--- /dev/null
+++ b/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/bot/DEPS
@@ -0,0 +1,144 @@
+# Copyright (c) 2015, Google Inc.
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+# SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+# OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+vars = {
+ 'chromium_git': 'https://chromium.googlesource.com',
+}
+
+deps = {
+ 'boringssl/util/bot/gyp':
+ Var('chromium_git') + '/external/gyp.git' + '@' + 'e7079f0e0e14108ab0dba58728ff219637458563',
+}
+
+deps_os = {
+ 'android': {
+ 'boringssl/util/bot/android_tools':
+ Var('chromium_git') + '/android_tools.git' + '@' + 'b43a6a289a7588b1769814f04dd6c7d7176974cc',
+ },
+}
+
+recursedeps = [
+ # android_tools pulls in the NDK from a separate repository.
+ 'boringssl/util/bot/android_tools',
+]
+
+hooks = [
+ {
+ 'name': 'cmake_linux64',
+ 'pattern': '.',
+ 'action': [ 'download_from_google_storage',
+ '--no_resume',
+ '--platform=linux*',
+ '--no_auth',
+ '--bucket', 'chromium-tools',
+ '-s', 'boringssl/util/bot/cmake-linux64.tar.gz.sha1',
+ ],
+ },
+ {
+ 'name': 'cmake_mac',
+ 'pattern': '.',
+ 'action': [ 'download_from_google_storage',
+ '--no_resume',
+ '--platform=darwin',
+ '--no_auth',
+ '--bucket', 'chromium-tools',
+ '-s', 'boringssl/util/bot/cmake-mac.tar.gz.sha1',
+ ],
+ },
+ {
+ 'name': 'cmake_win32',
+ 'pattern': '.',
+ 'action': [ 'download_from_google_storage',
+ '--no_resume',
+ '--platform=win32',
+ '--no_auth',
+ '--bucket', 'chromium-tools',
+ '-s', 'boringssl/util/bot/cmake-win32.zip.sha1',
+ ],
+ },
+ {
+ 'name': 'perl_win32',
+ 'pattern': '.',
+ 'action': [ 'download_from_google_storage',
+ '--no_resume',
+ '--platform=win32',
+ '--no_auth',
+ '--bucket', 'chromium-tools',
+ '-s', 'boringssl/util/bot/perl-win32.zip.sha1',
+ ],
+ },
+ {
+ 'name': 'yasm_win32',
+ 'pattern': '.',
+ 'action': [ 'download_from_google_storage',
+ '--no_resume',
+ '--platform=win32',
+ '--no_auth',
+ '--bucket', 'chromium-tools',
+ '-s', 'boringssl/util/bot/yasm-win32.exe.sha1',
+ ],
+ },
+ {
+ 'name': 'win_toolchain',
+ 'pattern': '.',
+ 'action': [ 'python',
+ 'boringssl/util/bot/vs_toolchain.py',
+ 'update',
+ ],
+ },
+ {
+ 'name': 'clang',
+ 'pattern': '.',
+ 'action': [ 'python',
+ 'boringssl/util/bot/update_clang.py',
+ ],
+ },
+ {
+ 'name': 'cmake_linux64_extract',
+ 'pattern': '.',
+ 'action': [ 'python',
+ 'boringssl/util/bot/extract.py',
+ 'boringssl/util/bot/cmake-linux64.tar.gz',
+ 'boringssl/util/bot/cmake-linux64/',
+ ],
+ },
+ {
+ 'name': 'cmake_mac_extract',
+ 'pattern': '.',
+ 'action': [ 'python',
+ 'boringssl/util/bot/extract.py',
+ 'boringssl/util/bot/cmake-mac.tar.gz',
+ 'boringssl/util/bot/cmake-mac/',
+ ],
+ },
+ {
+ 'name': 'cmake_win32_extract',
+ 'pattern': '.',
+ 'action': [ 'python',
+ 'boringssl/util/bot/extract.py',
+ 'boringssl/util/bot/cmake-win32.zip',
+ 'boringssl/util/bot/cmake-win32/',
+ ],
+ },
+ {
+ 'name': 'perl_win32_extract',
+ 'pattern': '.',
+ 'action': [ 'python',
+ 'boringssl/util/bot/extract.py',
+ '--no-prefix',
+ 'boringssl/util/bot/perl-win32.zip',
+ 'boringssl/util/bot/perl-win32/',
+ ],
+ },
+]
diff --git a/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/bot/README b/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/bot/README
new file mode 100644
index 000000000..b7a4332e8
--- /dev/null
+++ b/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/bot/README
@@ -0,0 +1,3 @@
+This directory contains tools for setting up a hermetic toolchain on the
+continuous integration bots. It is in the repository for convenience and can be
+ignored in development.
diff --git a/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/bot/UPDATING b/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/bot/UPDATING
new file mode 100644
index 000000000..2007d46f2
--- /dev/null
+++ b/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/bot/UPDATING
@@ -0,0 +1,47 @@
+This directory consumes tools from other repositories for use on the
+bots. To update to newer revisions, follow these instructions:
+
+DEPS: Set all revisions to those used in Chromium, found at
+ https://chromium.googlesource.com/chromium/src/+/master/DEPS (Search for the
+ corresponding repository name.)
+
+go/bootstrap.py: Set TOOLSET_VERSION to the latest release of Go, found at
+ https://golang.org/dl/.
+
+update_clang.py: Set CLANG_REVISION and CLANG_SUB_REVISION to the values used in
+ Chromium, found at
+ https://chromium.googlesource.com/chromium/src/+/master/tools/clang/scripts/update.py
+
+vs_toolchain.py: Set the hash in TOOLCHAIN_HASH to the toolchain
+ used in Chromium, found at _GetDesiredVsToolchainHashes
+ https://chromium.googlesource.com/chromium/src/+/master/build/vs_toolchain.py
+ This may require taking other updates to that file. If updating MSVS
+ version, also update TOOLCHAIN_VERSION accordingly.
+
+The .sha1 files correspond to files downloaded from Google Cloud Storage. To
+update, place the updated files in their intended location and run:
+
+ upload_to_google_storage.py -b chromium-tools FILE
+
+cmake-linux64.tar.gz: Download the latest CMake source tarball, found at
+ https://cmake.org/download/. Build it with:
+
+ ./bootstrap --prefix=$PWD/cmake-linux64 && make && make install
+ tar -czf cmake-linux64.tar.gz cmake-linux64/
+
+cmake-mac.tar.gz: Follow the same instructions as above on a Mac, but replace
+ cmake-linux64 with cmake-mac.
+
+cmake-win32.zip: Update to the latest prebuilt release of CMake, found at
+ https://cmake.org/download/. Use the file labeled "Windows ZIP". The
+ download will be named cmake-VERSION-win32-x86.zip.
+
+perl-win32.zip: Update to the latest 32-bit prebuilt "PortableZip" edition of
+ Strawberry Perl, found at http://strawberryperl.com/releases.html. The
+ download will be named strawberry-perl-VERSION-32bit-portable.zip.
+
+yasm-win32.exe: Update to the appropriate release of Yasm. Use the same version
+ as Chromium, found at
+ https://chromium.googlesource.com/chromium/src/+/master/third_party/yasm/README.chromium
+ Use the release at http://yasm.tortall.net/Download.html labeled
+ "Win32 .exe". The download will be named yasm-VERSION-win32.exe.
diff --git a/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/bot/cmake-linux64.tar.gz.sha1 b/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/bot/cmake-linux64.tar.gz.sha1
new file mode 100644
index 000000000..404570f6a
--- /dev/null
+++ b/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/bot/cmake-linux64.tar.gz.sha1
@@ -0,0 +1 @@
+6ea4ad07a4bab113ea74c45fafb14b8d0b0feab5 \ No newline at end of file
diff --git a/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/bot/cmake-mac.tar.gz.sha1 b/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/bot/cmake-mac.tar.gz.sha1
new file mode 100644
index 000000000..19c9b61ff
--- /dev/null
+++ b/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/bot/cmake-mac.tar.gz.sha1
@@ -0,0 +1 @@
+f3166dab96234c9516ece56dc2851bf4c8e70fe8 \ No newline at end of file
diff --git a/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/bot/cmake-win32.zip.sha1 b/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/bot/cmake-win32.zip.sha1
new file mode 100644
index 000000000..6bb460eb8
--- /dev/null
+++ b/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/bot/cmake-win32.zip.sha1
@@ -0,0 +1 @@
+ed4e1939d246374b0bae724a1a4200fd60e7efe8 \ No newline at end of file
diff --git a/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/bot/extract.py b/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/bot/extract.py
new file mode 100644
index 000000000..e36ce99b1
--- /dev/null
+++ b/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/bot/extract.py
@@ -0,0 +1,157 @@
+# Copyright (c) 2015, Google Inc.
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+# SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+# OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+"""Extracts archives."""
+
+
+import hashlib
+import optparse
+import os
+import os.path
+import tarfile
+import shutil
+import sys
+import zipfile
+
+
+def CheckedJoin(output, path):
+ """
+ CheckedJoin returns os.path.join(output, path). It does sanity checks to
+ ensure the resulting path is under output, but shouldn't be used on untrusted
+ input.
+ """
+ path = os.path.normpath(path)
+ if os.path.isabs(path) or path.startswith('.'):
+ raise ValueError(path)
+ return os.path.join(output, path)
+
+
+def IterateZip(path):
+ """
+ IterateZip opens the zip file at path and returns a generator of
+ (filename, mode, fileobj) tuples for each file in it.
+ """
+ with zipfile.ZipFile(path, 'r') as zip_file:
+ for info in zip_file.infolist():
+ if info.filename.endswith('/'):
+ continue
+ yield (info.filename, None, zip_file.open(info))
+
+
+def IterateTar(path):
+ """
+ IterateTar opens the tar.gz file at path and returns a generator of
+ (filename, mode, fileobj) tuples for each file in it.
+ """
+ with tarfile.open(path, 'r:gz') as tar_file:
+ for info in tar_file:
+ if info.isdir():
+ continue
+ if not info.isfile():
+ raise ValueError('Unknown entry type "%s"' % (info.name, ))
+ yield (info.name, info.mode, tar_file.extractfile(info))
+
+
+def main(args):
+ parser = optparse.OptionParser(usage='Usage: %prog ARCHIVE OUTPUT')
+ parser.add_option('--no-prefix', dest='no_prefix', action='store_true',
+ help='Do not remove a prefix from paths in the archive.')
+ options, args = parser.parse_args(args)
+
+ if len(args) != 2:
+ parser.print_help()
+ return 1
+
+ archive, output = args
+
+ if not os.path.exists(archive):
+ # Skip archives that weren't downloaded.
+ return 0
+
+ with open(archive) as f:
+ sha256 = hashlib.sha256()
+ while True:
+ chunk = f.read(1024 * 1024)
+ if not chunk:
+ break
+ sha256.update(chunk)
+ digest = sha256.hexdigest()
+
+ stamp_path = os.path.join(output, ".boringssl_archive_digest")
+ if os.path.exists(stamp_path):
+ with open(stamp_path) as f:
+ if f.read().strip() == digest:
+ print "Already up-to-date."
+ return 0
+
+ if archive.endswith('.zip'):
+ entries = IterateZip(archive)
+ elif archive.endswith('.tar.gz'):
+ entries = IterateTar(archive)
+ else:
+ raise ValueError(archive)
+
+ try:
+ if os.path.exists(output):
+ print "Removing %s" % (output, )
+ shutil.rmtree(output)
+
+ print "Extracting %s to %s" % (archive, output)
+ prefix = None
+ num_extracted = 0
+ for path, mode, inp in entries:
+ # Even on Windows, zip files must always use forward slashes.
+ if '\\' in path or path.startswith('/'):
+ raise ValueError(path)
+
+ if not options.no_prefix:
+ new_prefix, rest = path.split('/', 1)
+
+ # Ensure the archive is consistent.
+ if prefix is None:
+ prefix = new_prefix
+ if prefix != new_prefix:
+ raise ValueError((prefix, new_prefix))
+ else:
+ rest = path
+
+ # Extract the file into the output directory.
+ fixed_path = CheckedJoin(output, rest)
+ if not os.path.isdir(os.path.dirname(fixed_path)):
+ os.makedirs(os.path.dirname(fixed_path))
+ with open(fixed_path, 'wb') as out:
+ shutil.copyfileobj(inp, out)
+
+ # Fix up permissions if needbe.
+ # TODO(davidben): To be extra tidy, this should only track the execute bit
+ # as in git.
+ if mode is not None:
+ os.chmod(fixed_path, mode)
+
+ # Print every 100 files, so bots do not time out on large archives.
+ num_extracted += 1
+ if num_extracted % 100 == 0:
+ print "Extracted %d files..." % (num_extracted,)
+ finally:
+ entries.close()
+
+ with open(stamp_path, 'w') as f:
+ f.write(digest)
+
+ print "Done. Extracted %d files." % (num_extracted,)
+ return 0
+
+
+if __name__ == '__main__':
+ sys.exit(main(sys.argv[1:]))
diff --git a/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/bot/go/bootstrap.py b/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/bot/go/bootstrap.py
new file mode 100755
index 000000000..bb64e25b4
--- /dev/null
+++ b/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/bot/go/bootstrap.py
@@ -0,0 +1,296 @@
+#!/usr/bin/env python
+# Copyright 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# Modified from go/bootstrap.py in Chromium infrastructure's repository to patch
+# out everything but the core toolchain.
+#
+# https://chromium.googlesource.com/infra/infra/
+
+"""Prepares a local hermetic Go installation.
+
+- Downloads and unpacks the Go toolset in ../golang.
+"""
+
+import contextlib
+import logging
+import os
+import platform
+import shutil
+import stat
+import subprocess
+import sys
+import tarfile
+import tempfile
+import urllib
+import zipfile
+
+# TODO(vadimsh): Migrate to new golang.org/x/ paths once Golang moves to
+# git completely.
+
+LOGGER = logging.getLogger(__name__)
+
+
+# /path/to/util/bot
+ROOT = os.path.dirname(os.path.abspath(__file__))
+
+# Where to install Go toolset to. GOROOT would be <TOOLSET_ROOT>/go.
+TOOLSET_ROOT = os.path.join(os.path.dirname(ROOT), 'golang')
+
+# Default workspace with infra go code.
+WORKSPACE = os.path.join(ROOT, 'go')
+
+# Platform depended suffix for executable files.
+EXE_SFX = '.exe' if sys.platform == 'win32' else ''
+
+# Pinned version of Go toolset to download.
+TOOLSET_VERSION = 'go1.8'
+
+# Platform dependent portion of a download URL. See http://golang.org/dl/.
+TOOLSET_VARIANTS = {
+ ('darwin', 'x86-64'): 'darwin-amd64.tar.gz',
+ ('linux2', 'x86-32'): 'linux-386.tar.gz',
+ ('linux2', 'x86-64'): 'linux-amd64.tar.gz',
+ ('win32', 'x86-32'): 'windows-386.zip',
+ ('win32', 'x86-64'): 'windows-amd64.zip',
+}
+
+# Download URL root.
+DOWNLOAD_URL_PREFIX = 'https://storage.googleapis.com/golang'
+
+
+class Failure(Exception):
+ """Bootstrap failed."""
+
+
+def get_toolset_url():
+ """URL of a platform specific Go toolset archive."""
+ # TODO(vadimsh): Support toolset for cross-compilation.
+ arch = {
+ 'amd64': 'x86-64',
+ 'x86_64': 'x86-64',
+ 'i386': 'x86-32',
+ 'x86': 'x86-32',
+ }.get(platform.machine().lower())
+ variant = TOOLSET_VARIANTS.get((sys.platform, arch))
+ if not variant:
+ # TODO(vadimsh): Compile go lang from source.
+ raise Failure('Unrecognized platform')
+ return '%s/%s.%s' % (DOWNLOAD_URL_PREFIX, TOOLSET_VERSION, variant)
+
+
+def read_file(path):
+ """Returns contents of a given file or None if not readable."""
+ assert isinstance(path, (list, tuple))
+ try:
+ with open(os.path.join(*path), 'r') as f:
+ return f.read()
+ except IOError:
+ return None
+
+
+def write_file(path, data):
+ """Writes |data| to a file."""
+ assert isinstance(path, (list, tuple))
+ with open(os.path.join(*path), 'w') as f:
+ f.write(data)
+
+
+def remove_directory(path):
+ """Recursively removes a directory."""
+ assert isinstance(path, (list, tuple))
+ p = os.path.join(*path)
+ if not os.path.exists(p):
+ return
+ LOGGER.info('Removing %s', p)
+ # Crutch to remove read-only file (.git/* in particular) on Windows.
+ def onerror(func, path, _exc_info):
+ if not os.access(path, os.W_OK):
+ os.chmod(path, stat.S_IWUSR)
+ func(path)
+ else:
+ raise
+ shutil.rmtree(p, onerror=onerror if sys.platform == 'win32' else None)
+
+
+def install_toolset(toolset_root, url):
+ """Downloads and installs Go toolset.
+
+ GOROOT would be <toolset_root>/go/.
+ """
+ if not os.path.exists(toolset_root):
+ os.makedirs(toolset_root)
+ pkg_path = os.path.join(toolset_root, url[url.rfind('/')+1:])
+
+ LOGGER.info('Downloading %s...', url)
+ download_file(url, pkg_path)
+
+ LOGGER.info('Extracting...')
+ if pkg_path.endswith('.zip'):
+ with zipfile.ZipFile(pkg_path, 'r') as f:
+ f.extractall(toolset_root)
+ elif pkg_path.endswith('.tar.gz'):
+ with tarfile.open(pkg_path, 'r:gz') as f:
+ f.extractall(toolset_root)
+ else:
+ raise Failure('Unrecognized archive format')
+
+ LOGGER.info('Validating...')
+ if not check_hello_world(toolset_root):
+ raise Failure('Something is not right, test program doesn\'t work')
+
+
+def download_file(url, path):
+ """Fetches |url| to |path|."""
+ last_progress = [0]
+ def report(a, b, c):
+ progress = int(a * b * 100.0 / c)
+ if progress != last_progress[0]:
+ print >> sys.stderr, 'Downloading... %d%%' % progress
+ last_progress[0] = progress
+ # TODO(vadimsh): Use something less crippled, something that validates SSL.
+ urllib.urlretrieve(url, path, reporthook=report)
+
+
+@contextlib.contextmanager
+def temp_dir(path):
+ """Creates a temporary directory, then deletes it."""
+ tmp = tempfile.mkdtemp(dir=path)
+ try:
+ yield tmp
+ finally:
+ remove_directory([tmp])
+
+
+def check_hello_world(toolset_root):
+ """Compiles and runs 'hello world' program to verify that toolset works."""
+ with temp_dir(toolset_root) as tmp:
+ path = os.path.join(tmp, 'hello.go')
+ write_file([path], r"""
+ package main
+ func main() { println("hello, world\n") }
+ """)
+ out = subprocess.check_output(
+ [get_go_exe(toolset_root), 'run', path],
+ env=get_go_environ(toolset_root, tmp),
+ stderr=subprocess.STDOUT)
+ if out.strip() != 'hello, world':
+ LOGGER.error('Failed to run sample program:\n%s', out)
+ return False
+ return True
+
+
+def ensure_toolset_installed(toolset_root):
+ """Installs or updates Go toolset if necessary.
+
+ Returns True if new toolset was installed.
+ """
+ installed = read_file([toolset_root, 'INSTALLED_TOOLSET'])
+ available = get_toolset_url()
+ if installed == available:
+ LOGGER.debug('Go toolset is up-to-date: %s', TOOLSET_VERSION)
+ return False
+
+ LOGGER.info('Installing Go toolset.')
+ LOGGER.info(' Old toolset is %s', installed)
+ LOGGER.info(' New toolset is %s', available)
+ remove_directory([toolset_root])
+ install_toolset(toolset_root, available)
+ LOGGER.info('Go toolset installed: %s', TOOLSET_VERSION)
+ write_file([toolset_root, 'INSTALLED_TOOLSET'], available)
+ return True
+
+
+def get_go_environ(
+ toolset_root,
+ workspace=None):
+ """Returns a copy of os.environ with added GO* environment variables.
+
+ Overrides GOROOT, GOPATH and GOBIN. Keeps everything else. Idempotent.
+
+ Args:
+ toolset_root: GOROOT would be <toolset_root>/go.
+ workspace: main workspace directory or None if compiling in GOROOT.
+ """
+ env = os.environ.copy()
+ env['GOROOT'] = os.path.join(toolset_root, 'go')
+ if workspace:
+ env['GOBIN'] = os.path.join(workspace, 'bin')
+ else:
+ env.pop('GOBIN', None)
+
+ all_go_paths = []
+ if workspace:
+ all_go_paths.append(workspace)
+ env['GOPATH'] = os.pathsep.join(all_go_paths)
+
+ # New PATH entries.
+ paths_to_add = [
+ os.path.join(env['GOROOT'], 'bin'),
+ env.get('GOBIN'),
+ ]
+
+ # Make sure not to add duplicates entries to PATH over and over again when
+ # get_go_environ is invoked multiple times.
+ path = env['PATH'].split(os.pathsep)
+ paths_to_add = [p for p in paths_to_add if p and p not in path]
+ env['PATH'] = os.pathsep.join(paths_to_add + path)
+
+ return env
+
+
+def get_go_exe(toolset_root):
+ """Returns path to go executable."""
+ return os.path.join(toolset_root, 'go', 'bin', 'go' + EXE_SFX)
+
+
+def bootstrap(logging_level):
+ """Installs all dependencies in default locations.
+
+ Supposed to be called at the beginning of some script (it modifies logger).
+
+ Args:
+ logging_level: logging level of bootstrap process.
+ """
+ logging.basicConfig()
+ LOGGER.setLevel(logging_level)
+ ensure_toolset_installed(TOOLSET_ROOT)
+
+
+def prepare_go_environ():
+ """Returns dict with environment variables to set to use Go toolset.
+
+ Installs or updates the toolset if necessary.
+ """
+ bootstrap(logging.INFO)
+ return get_go_environ(TOOLSET_ROOT, WORKSPACE)
+
+
+def find_executable(name, workspaces):
+ """Returns full path to an executable in some bin/ (in GOROOT or GOBIN)."""
+ basename = name
+ if EXE_SFX and basename.endswith(EXE_SFX):
+ basename = basename[:-len(EXE_SFX)]
+ roots = [os.path.join(TOOLSET_ROOT, 'go', 'bin')]
+ for path in workspaces:
+ roots.extend([
+ os.path.join(path, 'bin'),
+ ])
+ for root in roots:
+ full_path = os.path.join(root, basename + EXE_SFX)
+ if os.path.exists(full_path):
+ return full_path
+ return name
+
+
+def main(args):
+ if args:
+ print >> sys.stderr, sys.modules[__name__].__doc__,
+ return 2
+ bootstrap(logging.DEBUG)
+ return 0
+
+
+if __name__ == '__main__':
+ sys.exit(main(sys.argv[1:]))
diff --git a/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/bot/go/env.py b/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/bot/go/env.py
new file mode 100755
index 000000000..820968c9b
--- /dev/null
+++ b/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/bot/go/env.py
@@ -0,0 +1,49 @@
+#!/usr/bin/env python
+# Copyright 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# Modified from go/env.py in Chromium infrastructure's repository to patch out
+# everything but the core toolchain.
+#
+# https://chromium.googlesource.com/infra/infra/
+
+"""Can be used to point environment variable to hermetic Go toolset.
+
+Usage (on linux and mac):
+$ eval `./env.py`
+$ go version
+
+Or it can be used to wrap a command:
+
+$ ./env.py go version
+"""
+
+assert __name__ == '__main__'
+
+import imp
+import os
+import subprocess
+import sys
+
+# Do not want to mess with sys.path, load the module directly.
+bootstrap = imp.load_source(
+ 'bootstrap', os.path.join(os.path.dirname(__file__), 'bootstrap.py'))
+
+old = os.environ.copy()
+new = bootstrap.prepare_go_environ()
+
+if len(sys.argv) == 1:
+ for key, value in sorted(new.iteritems()):
+ if old.get(key) != value:
+ print 'export %s="%s"' % (key, value)
+else:
+ exe = sys.argv[1]
+ if exe == 'python':
+ exe = sys.executable
+ else:
+ # Help Windows to find the executable in new PATH, do it only when
+ # executable is referenced by name (and not by path).
+ if os.sep not in exe:
+ exe = bootstrap.find_executable(exe, [bootstrap.WORKSPACE])
+ sys.exit(subprocess.call([exe] + sys.argv[2:], env=new))
diff --git a/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/bot/perl-win32.zip.sha1 b/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/bot/perl-win32.zip.sha1
new file mode 100644
index 000000000..8874fbbb6
--- /dev/null
+++ b/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/bot/perl-win32.zip.sha1
@@ -0,0 +1 @@
+3db2b4964d56f6e23cc48ced40a6cee05419a0af \ No newline at end of file
diff --git a/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/bot/update_clang.py b/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/bot/update_clang.py
new file mode 100644
index 000000000..7e9111315
--- /dev/null
+++ b/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/bot/update_clang.py
@@ -0,0 +1,71 @@
+# Copyright (c) 2015, Google Inc.
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+# SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+# OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+import os.path
+import shutil
+import sys
+import tarfile
+import tempfile
+import urllib
+
+# CLANG_REVISION and CLANG_SUB_REVISION determine the build of clang
+# to use. These should be synced with tools/clang/scripts/update.py in
+# Chromium.
+CLANG_REVISION = "296320"
+CLANG_SUB_REVISION = "1"
+
+PACKAGE_VERSION = "%s-%s" % (CLANG_REVISION, CLANG_SUB_REVISION)
+LLVM_BUILD_DIR = os.path.join(os.path.dirname(__file__), "llvm-build")
+STAMP_FILE = os.path.join(LLVM_BUILD_DIR, "cr_build_revision")
+
+CDS_URL = "https://commondatastorage.googleapis.com/chromium-browser-clang"
+
+def DownloadFile(url, path):
+ """DownloadFile fetches |url| to |path|."""
+ last_progress = [0]
+ def report(a, b, c):
+ progress = int(a * b * 100.0 / c)
+ if progress != last_progress[0]:
+ print >> sys.stderr, "Downloading... %d%%" % progress
+ last_progress[0] = progress
+ urllib.urlretrieve(url, path, reporthook=report)
+
+def main(args):
+ # For now, only download clang on Linux.
+ if not sys.platform.startswith("linux"):
+ return 0
+
+ if os.path.exists(STAMP_FILE):
+ with open(STAMP_FILE) as f:
+ if f.read().strip() == PACKAGE_VERSION:
+ print >> sys.stderr, "Clang already at %s" % (PACKAGE_VERSION,)
+ return 0
+
+ if os.path.exists(LLVM_BUILD_DIR):
+ shutil.rmtree(LLVM_BUILD_DIR)
+
+ print >> sys.stderr, "Downloading Clang %s" % (PACKAGE_VERSION,)
+ cds_full_url = "%s/Linux_x64/clang-%s.tgz" % (CDS_URL, PACKAGE_VERSION)
+ with tempfile.NamedTemporaryFile() as temp:
+ DownloadFile(cds_full_url, temp.name)
+ with tarfile.open(temp.name, "r:gz") as tar_file:
+ tar_file.extractall(LLVM_BUILD_DIR)
+
+ with open(STAMP_FILE, "wb") as stamp_file:
+ stamp_file.write(PACKAGE_VERSION)
+
+ return 0
+
+if __name__ == "__main__":
+ sys.exit(main(sys.argv[1:]))
diff --git a/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/bot/vs_env.py b/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/bot/vs_env.py
new file mode 100644
index 000000000..184750063
--- /dev/null
+++ b/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/bot/vs_env.py
@@ -0,0 +1,37 @@
+# Copyright (c) 2015, Google Inc.
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+# SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+# OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+import subprocess
+import sys
+
+import vs_toolchain
+# vs_toolchain adds gyp to sys.path.
+import gyp.MSVSVersion
+
+if len(sys.argv) < 2:
+ print >>sys.stderr, "Usage: vs_env.py TARGET_ARCH CMD..."
+ sys.exit(1)
+
+target_arch = sys.argv[1]
+cmd = sys.argv[2:]
+
+vs_toolchain.SetEnvironmentAndGetRuntimeDllDirs()
+vs_version = gyp.MSVSVersion.SelectVisualStudioVersion()
+
+# Using shell=True is somewhat ugly, but the alternative is to pull in a copy
+# of the Chromium GN build's setup_toolchain.py which runs the setup script,
+# then 'set', and then parses the environment variables out. (GYP internally
+# does the same thing.)
+sys.exit(subprocess.call(vs_version.SetupScript(target_arch) + ["&&"] + cmd,
+ shell=True))
diff --git a/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/bot/vs_toolchain.py b/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/bot/vs_toolchain.py
new file mode 100644
index 000000000..2e87272ea
--- /dev/null
+++ b/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/bot/vs_toolchain.py
@@ -0,0 +1,113 @@
+# Copyright 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import json
+import os
+import pipes
+import shutil
+import subprocess
+import sys
+
+
+script_dir = os.path.dirname(os.path.realpath(__file__))
+sys.path.insert(0, os.path.join(script_dir, 'gyp', 'pylib'))
+json_data_file = os.path.join(script_dir, 'win_toolchain.json')
+
+
+import gyp
+
+
+TOOLCHAIN_VERSION = '2015'
+TOOLCHAIN_HASH = 'd3cb0e37bdd120ad0ac4650b674b09e81be45616'
+
+
+def SetEnvironmentAndGetRuntimeDllDirs():
+ """Sets up os.environ to use the depot_tools VS toolchain with gyp, and
+ returns the location of the VS runtime DLLs so they can be copied into
+ the output directory after gyp generation.
+ """
+ vs_runtime_dll_dirs = None
+ depot_tools_win_toolchain = \
+ bool(int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', '1')))
+ if sys.platform in ('win32', 'cygwin') and depot_tools_win_toolchain:
+ if not os.path.exists(json_data_file):
+ Update()
+ with open(json_data_file, 'r') as tempf:
+ toolchain_data = json.load(tempf)
+
+ toolchain = toolchain_data['path']
+ version = toolchain_data['version']
+ win_sdk = toolchain_data.get('win_sdk')
+ if not win_sdk:
+ win_sdk = toolchain_data['win8sdk']
+ wdk = toolchain_data['wdk']
+ # TODO(scottmg): The order unfortunately matters in these. They should be
+ # split into separate keys for x86 and x64. (See CopyVsRuntimeDlls call
+ # below). http://crbug.com/345992
+ vs_runtime_dll_dirs = toolchain_data['runtime_dirs']
+
+ os.environ['GYP_MSVS_OVERRIDE_PATH'] = toolchain
+ os.environ['GYP_MSVS_VERSION'] = version
+ # We need to make sure windows_sdk_path is set to the automated
+ # toolchain values in GYP_DEFINES, but don't want to override any
+ # otheroptions.express
+ # values there.
+ gyp_defines_dict = gyp.NameValueListToDict(gyp.ShlexEnv('GYP_DEFINES'))
+ gyp_defines_dict['windows_sdk_path'] = win_sdk
+ os.environ['GYP_DEFINES'] = ' '.join('%s=%s' % (k, pipes.quote(str(v)))
+ for k, v in gyp_defines_dict.iteritems())
+ os.environ['WINDOWSSDKDIR'] = win_sdk
+ os.environ['WDK_DIR'] = wdk
+ # Include the VS runtime in the PATH in case it's not machine-installed.
+ runtime_path = ';'.join(vs_runtime_dll_dirs)
+ os.environ['PATH'] = runtime_path + ';' + os.environ['PATH']
+ return vs_runtime_dll_dirs
+
+
+def FindDepotTools():
+ """Returns the path to depot_tools in $PATH."""
+ for path in os.environ['PATH'].split(os.pathsep):
+ if os.path.isfile(os.path.join(path, 'gclient.py')):
+ return path
+ raise Exception("depot_tools not found!")
+
+
+def Update():
+ """Requests an update of the toolchain to the specific hashes we have at
+ this revision. The update outputs a .json of the various configuration
+ information required to pass to gyp which we use in |GetToolchainDir()|.
+ """
+ depot_tools_win_toolchain = \
+ bool(int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', '1')))
+ if sys.platform in ('win32', 'cygwin') and depot_tools_win_toolchain:
+ depot_tools_path = FindDepotTools()
+ # Necessary so that get_toolchain_if_necessary.py will put the VS toolkit
+ # in the correct directory.
+ os.environ['GYP_MSVS_VERSION'] = TOOLCHAIN_VERSION
+ get_toolchain_args = [
+ sys.executable,
+ os.path.join(depot_tools_path,
+ 'win_toolchain',
+ 'get_toolchain_if_necessary.py'),
+ '--output-json', json_data_file, TOOLCHAIN_HASH,
+ ]
+ subprocess.check_call(get_toolchain_args)
+
+ return 0
+
+
+def main():
+ if not sys.platform.startswith(('win32', 'cygwin')):
+ return 0
+ commands = {
+ 'update': Update,
+ }
+ if len(sys.argv) < 2 or sys.argv[1] not in commands:
+ print >>sys.stderr, 'Expected one of: %s' % ', '.join(commands)
+ return 1
+ return commands[sys.argv[1]](*sys.argv[2:])
+
+
+if __name__ == '__main__':
+ sys.exit(main())
diff --git a/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/bot/yasm-win32.exe.sha1 b/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/bot/yasm-win32.exe.sha1
new file mode 100644
index 000000000..5b8c9aaeb
--- /dev/null
+++ b/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/bot/yasm-win32.exe.sha1
@@ -0,0 +1 @@
+4c4d1951181a610923523cb10d83d9ae9952fbf3 \ No newline at end of file
diff --git a/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/diff_asm.go b/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/diff_asm.go
new file mode 100644
index 000000000..0a0888b05
--- /dev/null
+++ b/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/diff_asm.go
@@ -0,0 +1,112 @@
+/* Copyright (c) 2016, Google Inc.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
+
+package main
+
+import (
+ "flag"
+ "fmt"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "strings"
+ "syscall"
+)
+
+var (
+ boringsslDir = flag.String("boringssl", ".", "The path to the BoringSSL checkout.")
+ opensslDir = flag.String("openssl", filepath.Join("..", "openssl"), "The path to the OpenSSL checkout.")
+)
+
+func mapName(path string) string {
+ switch filepath.ToSlash(path) {
+ case "crypto/rand/asm/rdrand-x86_64.pl":
+ return ""
+ case "crypto/ec/asm/p256-x86_64-asm.pl":
+ return filepath.FromSlash("crypto/ec/asm/ecp_nistz256-x86_64.pl")
+ }
+ return path
+}
+
+func diff(from, to string) error {
+ cmd := exec.Command("diff", "-u", "--", from, to)
+ cmd.Stdout = os.Stdout
+ cmd.Stderr = os.Stderr
+ err := cmd.Run()
+ // diff returns exit code 1 if the files differ but it was otherwise
+ // successful.
+ if exitError, ok := err.(*exec.ExitError); ok && exitError.Sys().(syscall.WaitStatus).ExitStatus() == 1 {
+ return nil
+ }
+ return err
+}
+
+func main() {
+ flag.Usage = func() {
+ fmt.Fprintf(os.Stderr, "Usage: diff_asm [flag...] [filter...]\n")
+ fmt.Fprintf(os.Stderr, "Filter arguments limit to assembly files which match arguments.\n")
+ fmt.Fprintf(os.Stderr, "If not using a filter, piping to `diffstat` may be useful.\n\n")
+ flag.PrintDefaults()
+ }
+ flag.Parse()
+
+ // Find all the assembly files.
+ var files []string
+ err := filepath.Walk(*boringsslDir, func(path string, info os.FileInfo, err error) error {
+ if err != nil {
+ return nil
+ }
+
+ path, err = filepath.Rel(*boringsslDir, path)
+ if err != nil {
+ return err
+ }
+
+ dir := filepath.Base(filepath.Dir(path))
+ if !info.IsDir() && (dir == "asm" || dir == "perlasm") && strings.HasSuffix(filepath.Base(path), ".pl") {
+ files = append(files, path)
+ }
+
+ return nil
+ })
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "Error finding assembly: %s\n", err)
+ os.Exit(1)
+ }
+
+ for _, file := range files {
+ opensslFile := mapName(file)
+ if len(opensslFile) == 0 {
+ continue
+ }
+
+ if flag.NArg() > 0 {
+ var found bool
+ for _, arg := range flag.Args() {
+ if strings.Contains(file, arg) {
+ found = true
+ break
+ }
+ }
+ if !found {
+ continue
+ }
+ }
+
+ if err := diff(filepath.Join(*opensslDir, opensslFile), filepath.Join(*boringsslDir, file)); err != nil {
+ fmt.Fprintf(os.Stderr, "Error comparing %s: %s\n", file, err)
+ os.Exit(1)
+ }
+ }
+}
diff --git a/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/doc.config b/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/doc.config
new file mode 100644
index 000000000..f7e8baa11
--- /dev/null
+++ b/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/doc.config
@@ -0,0 +1,57 @@
+{
+ "BaseDirectory": "..",
+ "Sections": [{
+ "Name": "Low-level infrastructure",
+ "Headers": [
+ "include/openssl/base64.h",
+ "include/openssl/bio.h",
+ "include/openssl/buf.h",
+ "include/openssl/bytestring.h",
+ "include/openssl/err.h",
+ "include/openssl/cpu.h",
+ "include/openssl/crypto.h",
+ "include/openssl/ex_data.h",
+ "include/openssl/lhash.h",
+ "include/openssl/mem.h",
+ "include/openssl/obj.h",
+ "include/openssl/pool.h",
+ "include/openssl/rand.h",
+ "include/openssl/stack.h"
+ ]
+ },{
+ "Name": "Low-level crypto primitives",
+ "Headers": [
+ "include/openssl/aes.h",
+ "include/openssl/bn.h",
+ "include/openssl/cmac.h",
+ "include/openssl/curve25519.h",
+ "include/openssl/des.h",
+ "include/openssl/dh.h",
+ "include/openssl/dsa.h",
+ "include/openssl/ec.h",
+ "include/openssl/ec_key.h",
+ "include/openssl/ecdh.h",
+ "include/openssl/ecdsa.h",
+ "include/openssl/engine.h",
+ "include/openssl/hkdf.h",
+ "include/openssl/hmac.h",
+ "include/openssl/md5.h",
+ "include/openssl/rc4.h",
+ "include/openssl/rsa.h",
+ "include/openssl/sha.h"
+ ]
+ },{
+ "Name": "Crypto interfaces",
+ "Headers": [
+ "include/openssl/digest.h",
+ "include/openssl/cipher.h",
+ "include/openssl/aead.h",
+ "include/openssl/evp.h"
+ ]
+ },{
+ "Name": "SSL implementation",
+ "Headers": [
+ "include/openssl/ssl.h"
+ ]
+ }]
+}
diff --git a/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/doc.css b/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/doc.css
new file mode 100644
index 000000000..a868e4444
--- /dev/null
+++ b/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/doc.css
@@ -0,0 +1,70 @@
+#main {
+ margin-left: auto;
+ margin-right: auto;
+ max-width: 55em;
+ text-align: justify;
+}
+
+h2 {
+ font-family: monospace;
+ background-color: #b2c9db;
+ padding: 7px;
+ border-radius: 7px;
+}
+
+div.title {
+ margin-bottom: 2em;
+}
+
+ol {
+ list-style: none;
+ margin-bottom: 4em;
+}
+
+li a {
+ color: black;
+}
+
+li.header {
+ margin-top: 1em;
+ margin-bottom: 0.3em;
+ font-weight: bold;
+}
+
+div.decl p:first-child {
+ margin-top: 2.5em;
+}
+
+div.decl p:first-child .first-word {
+ font-weight: bold;
+ font-family: monospace;
+}
+
+.sectionpreamble {
+ margin-top: 5em;
+}
+
+.sectionpreamble p:first-child {
+ font-weight: bold;
+ font-size: 1.5em;
+}
+
+.section pre {
+ background-color: #b2c9db;
+ padding: 5px;
+ border-radius: 5px;
+}
+
+td {
+ padding: 2px;
+}
+
+tr:nth-child(even) {
+ background-color: #eee;
+}
+
+tr.header td {
+ font-weight: bold;
+ padding-top: 1em;
+ padding-bottom: 0.5em;
+}
diff --git a/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/doc.go b/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/doc.go
new file mode 100644
index 000000000..987794c92
--- /dev/null
+++ b/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/doc.go
@@ -0,0 +1,728 @@
+// doc generates HTML files from the comments in header files.
+//
+// doc expects to be given the path to a JSON file via the --config option.
+// From that JSON (which is defined by the Config struct) it reads a list of
+// header file locations and generates HTML files for each in the current
+// directory.
+
+package main
+
+import (
+ "bufio"
+ "encoding/json"
+ "errors"
+ "flag"
+ "fmt"
+ "html/template"
+ "io/ioutil"
+ "os"
+ "path/filepath"
+ "strings"
+)
+
+// Config describes the structure of the config JSON file.
+type Config struct {
+ // BaseDirectory is a path to which other paths in the file are
+ // relative.
+ BaseDirectory string
+ Sections []ConfigSection
+}
+
+type ConfigSection struct {
+ Name string
+ // Headers is a list of paths to header files.
+ Headers []string
+}
+
+// HeaderFile is the internal representation of a header file.
+type HeaderFile struct {
+ // Name is the basename of the header file (e.g. "ex_data.html").
+ Name string
+ // Preamble contains a comment for the file as a whole. Each string
+ // is a separate paragraph.
+ Preamble []string
+ Sections []HeaderSection
+ // AllDecls maps all decls to their URL fragments.
+ AllDecls map[string]string
+}
+
+type HeaderSection struct {
+ // Preamble contains a comment for a group of functions.
+ Preamble []string
+ Decls []HeaderDecl
+ // Anchor, if non-empty, is the URL fragment to use in anchor tags.
+ Anchor string
+ // IsPrivate is true if the section contains private functions (as
+ // indicated by its name).
+ IsPrivate bool
+}
+
+type HeaderDecl struct {
+ // Comment contains a comment for a specific function. Each string is a
+ // paragraph. Some paragraph may contain \n runes to indicate that they
+ // are preformatted.
+ Comment []string
+ // Name contains the name of the function, if it could be extracted.
+ Name string
+ // Decl contains the preformatted C declaration itself.
+ Decl string
+ // Anchor, if non-empty, is the URL fragment to use in anchor tags.
+ Anchor string
+}
+
+const (
+ cppGuard = "#if defined(__cplusplus)"
+ commentStart = "/* "
+ commentEnd = " */"
+)
+
+func extractComment(lines []string, lineNo int) (comment []string, rest []string, restLineNo int, err error) {
+ if len(lines) == 0 {
+ return nil, lines, lineNo, nil
+ }
+
+ restLineNo = lineNo
+ rest = lines
+
+ if !strings.HasPrefix(rest[0], commentStart) {
+ panic("extractComment called on non-comment")
+ }
+ commentParagraph := rest[0][len(commentStart):]
+ rest = rest[1:]
+ restLineNo++
+
+ for len(rest) > 0 {
+ i := strings.Index(commentParagraph, commentEnd)
+ if i >= 0 {
+ if i != len(commentParagraph)-len(commentEnd) {
+ err = fmt.Errorf("garbage after comment end on line %d", restLineNo)
+ return
+ }
+ commentParagraph = commentParagraph[:i]
+ if len(commentParagraph) > 0 {
+ comment = append(comment, commentParagraph)
+ }
+ return
+ }
+
+ line := rest[0]
+ if !strings.HasPrefix(line, " *") {
+ err = fmt.Errorf("comment doesn't start with block prefix on line %d: %s", restLineNo, line)
+ return
+ }
+ if len(line) == 2 || line[2] != '/' {
+ line = line[2:]
+ }
+ if strings.HasPrefix(line, " ") {
+ /* Identing the lines of a paragraph marks them as
+ * preformatted. */
+ if len(commentParagraph) > 0 {
+ commentParagraph += "\n"
+ }
+ line = line[3:]
+ }
+ if len(line) > 0 {
+ commentParagraph = commentParagraph + line
+ if len(commentParagraph) > 0 && commentParagraph[0] == ' ' {
+ commentParagraph = commentParagraph[1:]
+ }
+ } else {
+ comment = append(comment, commentParagraph)
+ commentParagraph = ""
+ }
+ rest = rest[1:]
+ restLineNo++
+ }
+
+ err = errors.New("hit EOF in comment")
+ return
+}
+
+func extractDecl(lines []string, lineNo int) (decl string, rest []string, restLineNo int, err error) {
+ if len(lines) == 0 || len(lines[0]) == 0 {
+ return "", lines, lineNo, nil
+ }
+
+ rest = lines
+ restLineNo = lineNo
+
+ var stack []rune
+ for len(rest) > 0 {
+ line := rest[0]
+ for _, c := range line {
+ switch c {
+ case '(', '{', '[':
+ stack = append(stack, c)
+ case ')', '}', ']':
+ if len(stack) == 0 {
+ err = fmt.Errorf("unexpected %c on line %d", c, restLineNo)
+ return
+ }
+ var expected rune
+ switch c {
+ case ')':
+ expected = '('
+ case '}':
+ expected = '{'
+ case ']':
+ expected = '['
+ default:
+ panic("internal error")
+ }
+ if last := stack[len(stack)-1]; last != expected {
+ err = fmt.Errorf("found %c when expecting %c on line %d", c, last, restLineNo)
+ return
+ }
+ stack = stack[:len(stack)-1]
+ }
+ }
+ if len(decl) > 0 {
+ decl += "\n"
+ }
+ decl += line
+ rest = rest[1:]
+ restLineNo++
+
+ if len(stack) == 0 && (len(decl) == 0 || decl[len(decl)-1] != '\\') {
+ break
+ }
+ }
+
+ return
+}
+
+func skipLine(s string) string {
+ i := strings.Index(s, "\n")
+ if i > 0 {
+ return s[i:]
+ }
+ return ""
+}
+
+func getNameFromDecl(decl string) (string, bool) {
+ for strings.HasPrefix(decl, "#if") || strings.HasPrefix(decl, "#elif") {
+ decl = skipLine(decl)
+ }
+
+ if strings.HasPrefix(decl, "typedef ") {
+ return "", false
+ }
+
+ for _, prefix := range []string{"struct ", "enum ", "#define "} {
+ if !strings.HasPrefix(decl, prefix) {
+ continue
+ }
+
+ decl = strings.TrimPrefix(decl, prefix)
+
+ for len(decl) > 0 && decl[0] == ' ' {
+ decl = decl[1:]
+ }
+
+ // struct and enum types can be the return type of a
+ // function.
+ if prefix[0] != '#' && strings.Index(decl, "{") == -1 {
+ break
+ }
+
+ i := strings.IndexAny(decl, "( ")
+ if i < 0 {
+ return "", false
+ }
+ return decl[:i], true
+ }
+ decl = strings.TrimPrefix(decl, "OPENSSL_EXPORT ")
+ decl = strings.TrimPrefix(decl, "STACK_OF(")
+ decl = strings.TrimPrefix(decl, "LHASH_OF(")
+ i := strings.Index(decl, "(")
+ if i < 0 {
+ return "", false
+ }
+ j := strings.LastIndex(decl[:i], " ")
+ if j < 0 {
+ return "", false
+ }
+ for j+1 < len(decl) && decl[j+1] == '*' {
+ j++
+ }
+ return decl[j+1 : i], true
+}
+
+func sanitizeAnchor(name string) string {
+ return strings.Replace(name, " ", "-", -1)
+}
+
+func isPrivateSection(name string) bool {
+ return strings.HasPrefix(name, "Private functions") || strings.HasPrefix(name, "Private structures") || strings.Contains(name, "(hidden)")
+}
+
+func (config *Config) parseHeader(path string) (*HeaderFile, error) {
+ headerPath := filepath.Join(config.BaseDirectory, path)
+
+ headerFile, err := os.Open(headerPath)
+ if err != nil {
+ return nil, err
+ }
+ defer headerFile.Close()
+
+ scanner := bufio.NewScanner(headerFile)
+ var lines, oldLines []string
+ for scanner.Scan() {
+ lines = append(lines, scanner.Text())
+ }
+ if err := scanner.Err(); err != nil {
+ return nil, err
+ }
+
+ lineNo := 1
+ found := false
+ for i, line := range lines {
+ if line == cppGuard {
+ lines = lines[i+1:]
+ lineNo += i + 1
+ found = true
+ break
+ }
+ }
+
+ if !found {
+ return nil, errors.New("no C++ guard found")
+ }
+
+ if len(lines) == 0 || lines[0] != "extern \"C\" {" {
+ return nil, errors.New("no extern \"C\" found after C++ guard")
+ }
+ lineNo += 2
+ lines = lines[2:]
+
+ header := &HeaderFile{
+ Name: filepath.Base(path),
+ AllDecls: make(map[string]string),
+ }
+
+ for i, line := range lines {
+ if len(line) > 0 {
+ lines = lines[i:]
+ lineNo += i
+ break
+ }
+ }
+
+ oldLines = lines
+ if len(lines) > 0 && strings.HasPrefix(lines[0], commentStart) {
+ comment, rest, restLineNo, err := extractComment(lines, lineNo)
+ if err != nil {
+ return nil, err
+ }
+
+ if len(rest) > 0 && len(rest[0]) == 0 {
+ if len(rest) < 2 || len(rest[1]) != 0 {
+ return nil, errors.New("preamble comment should be followed by two blank lines")
+ }
+ header.Preamble = comment
+ lineNo = restLineNo + 2
+ lines = rest[2:]
+ } else {
+ lines = oldLines
+ }
+ }
+
+ allAnchors := make(map[string]struct{})
+
+ for {
+ // Start of a section.
+ if len(lines) == 0 {
+ return nil, errors.New("unexpected end of file")
+ }
+ line := lines[0]
+ if line == cppGuard {
+ break
+ }
+
+ if len(line) == 0 {
+ return nil, fmt.Errorf("blank line at start of section on line %d", lineNo)
+ }
+
+ var section HeaderSection
+
+ if strings.HasPrefix(line, commentStart) {
+ comment, rest, restLineNo, err := extractComment(lines, lineNo)
+ if err != nil {
+ return nil, err
+ }
+ if len(rest) > 0 && len(rest[0]) == 0 {
+ anchor := sanitizeAnchor(firstSentence(comment))
+ if len(anchor) > 0 {
+ if _, ok := allAnchors[anchor]; ok {
+ return nil, fmt.Errorf("duplicate anchor: %s", anchor)
+ }
+ allAnchors[anchor] = struct{}{}
+ }
+
+ section.Preamble = comment
+ section.IsPrivate = len(comment) > 0 && isPrivateSection(comment[0])
+ section.Anchor = anchor
+ lines = rest[1:]
+ lineNo = restLineNo + 1
+ }
+ }
+
+ for len(lines) > 0 {
+ line := lines[0]
+ if len(line) == 0 {
+ lines = lines[1:]
+ lineNo++
+ break
+ }
+ if line == cppGuard {
+ return nil, errors.New("hit ending C++ guard while in section")
+ }
+
+ var comment []string
+ var decl string
+ if strings.HasPrefix(line, commentStart) {
+ comment, lines, lineNo, err = extractComment(lines, lineNo)
+ if err != nil {
+ return nil, err
+ }
+ }
+ if len(lines) == 0 {
+ return nil, errors.New("expected decl at EOF")
+ }
+ declLineNo := lineNo
+ decl, lines, lineNo, err = extractDecl(lines, lineNo)
+ if err != nil {
+ return nil, err
+ }
+ name, ok := getNameFromDecl(decl)
+ if !ok {
+ name = ""
+ }
+ if last := len(section.Decls) - 1; len(name) == 0 && len(comment) == 0 && last >= 0 {
+ section.Decls[last].Decl += "\n" + decl
+ } else {
+ // As a matter of style, comments should start
+ // with the name of the thing that they are
+ // commenting on. We make an exception here for
+ // #defines (because we often have blocks of
+ // them) and collective comments, which are
+ // detected by starting with “The” or “These”.
+ if len(comment) > 0 &&
+ !strings.HasPrefix(comment[0], name) &&
+ !strings.HasPrefix(comment[0], "A "+name) &&
+ !strings.HasPrefix(comment[0], "An "+name) &&
+ !strings.HasPrefix(decl, "#define ") &&
+ !strings.HasPrefix(comment[0], "The ") &&
+ !strings.HasPrefix(comment[0], "These ") {
+ return nil, fmt.Errorf("Comment for %q doesn't seem to match line %s:%d\n", name, path, declLineNo)
+ }
+ anchor := sanitizeAnchor(name)
+ // TODO(davidben): Enforce uniqueness. This is
+ // skipped because #ifdefs currently result in
+ // duplicate table-of-contents entries.
+ allAnchors[anchor] = struct{}{}
+
+ header.AllDecls[name] = anchor
+
+ section.Decls = append(section.Decls, HeaderDecl{
+ Comment: comment,
+ Name: name,
+ Decl: decl,
+ Anchor: anchor,
+ })
+ }
+
+ if len(lines) > 0 && len(lines[0]) == 0 {
+ lines = lines[1:]
+ lineNo++
+ }
+ }
+
+ header.Sections = append(header.Sections, section)
+ }
+
+ return header, nil
+}
+
+func firstSentence(paragraphs []string) string {
+ if len(paragraphs) == 0 {
+ return ""
+ }
+ s := paragraphs[0]
+ i := strings.Index(s, ". ")
+ if i >= 0 {
+ return s[:i]
+ }
+ if lastIndex := len(s) - 1; s[lastIndex] == '.' {
+ return s[:lastIndex]
+ }
+ return s
+}
+
+func markupPipeWords(allDecls map[string]string, s string) template.HTML {
+ ret := ""
+
+ for {
+ i := strings.Index(s, "|")
+ if i == -1 {
+ ret += s
+ break
+ }
+ ret += s[:i]
+ s = s[i+1:]
+
+ i = strings.Index(s, "|")
+ j := strings.Index(s, " ")
+ if i > 0 && (j == -1 || j > i) {
+ ret += "<tt>"
+ anchor, isLink := allDecls[s[:i]]
+ if isLink {
+ ret += fmt.Sprintf("<a href=\"%s\">", template.HTMLEscapeString(anchor))
+ }
+ ret += s[:i]
+ if isLink {
+ ret += "</a>"
+ }
+ ret += "</tt>"
+ s = s[i+1:]
+ } else {
+ ret += "|"
+ }
+ }
+
+ return template.HTML(ret)
+}
+
+func markupFirstWord(s template.HTML) template.HTML {
+ start := 0
+again:
+ end := strings.Index(string(s[start:]), " ")
+ if end > 0 {
+ end += start
+ w := strings.ToLower(string(s[start:end]))
+ // The first word was already marked up as an HTML tag. Don't
+ // mark it up further.
+ if strings.ContainsRune(w, '<') {
+ return s
+ }
+ if w == "a" || w == "an" {
+ start = end + 1
+ goto again
+ }
+ return s[:start] + "<span class=\"first-word\">" + s[start:end] + "</span>" + s[end:]
+ }
+ return s
+}
+
+func newlinesToBR(html template.HTML) template.HTML {
+ s := string(html)
+ if !strings.Contains(s, "\n") {
+ return html
+ }
+ s = strings.Replace(s, "\n", "<br>", -1)
+ s = strings.Replace(s, " ", "&nbsp;", -1)
+ return template.HTML(s)
+}
+
+func generate(outPath string, config *Config) (map[string]string, error) {
+ allDecls := make(map[string]string)
+
+ headerTmpl := template.New("headerTmpl")
+ headerTmpl.Funcs(template.FuncMap{
+ "firstSentence": firstSentence,
+ "markupPipeWords": func(s string) template.HTML { return markupPipeWords(allDecls, s) },
+ "markupFirstWord": markupFirstWord,
+ "newlinesToBR": newlinesToBR,
+ })
+ headerTmpl, err := headerTmpl.Parse(`<!DOCTYPE html>
+<html>
+ <head>
+ <title>BoringSSL - {{.Name}}</title>
+ <meta charset="utf-8">
+ <link rel="stylesheet" type="text/css" href="doc.css">
+ </head>
+
+ <body>
+ <div id="main">
+ <div class="title">
+ <h2>{{.Name}}</h2>
+ <a href="headers.html">All headers</a>
+ </div>
+
+ {{range .Preamble}}<p>{{. | html | markupPipeWords}}</p>{{end}}
+
+ <ol>
+ {{range .Sections}}
+ {{if not .IsPrivate}}
+ {{if .Anchor}}<li class="header"><a href="#{{.Anchor}}">{{.Preamble | firstSentence | html | markupPipeWords}}</a></li>{{end}}
+ {{range .Decls}}
+ {{if .Anchor}}<li><a href="#{{.Anchor}}"><tt>{{.Name}}</tt></a></li>{{end}}
+ {{end}}
+ {{end}}
+ {{end}}
+ </ol>
+
+ {{range .Sections}}
+ {{if not .IsPrivate}}
+ <div class="section" {{if .Anchor}}id="{{.Anchor}}"{{end}}>
+ {{if .Preamble}}
+ <div class="sectionpreamble">
+ {{range .Preamble}}<p>{{. | html | markupPipeWords}}</p>{{end}}
+ </div>
+ {{end}}
+
+ {{range .Decls}}
+ <div class="decl" {{if .Anchor}}id="{{.Anchor}}"{{end}}>
+ {{range .Comment}}
+ <p>{{. | html | markupPipeWords | newlinesToBR | markupFirstWord}}</p>
+ {{end}}
+ <pre>{{.Decl}}</pre>
+ </div>
+ {{end}}
+ </div>
+ {{end}}
+ {{end}}
+ </div>
+ </body>
+</html>`)
+ if err != nil {
+ return nil, err
+ }
+
+ headerDescriptions := make(map[string]string)
+ var headers []*HeaderFile
+
+ for _, section := range config.Sections {
+ for _, headerPath := range section.Headers {
+ header, err := config.parseHeader(headerPath)
+ if err != nil {
+ return nil, errors.New("while parsing " + headerPath + ": " + err.Error())
+ }
+ headerDescriptions[header.Name] = firstSentence(header.Preamble)
+ headers = append(headers, header)
+
+ for name, anchor := range header.AllDecls {
+ allDecls[name] = fmt.Sprintf("%s#%s", header.Name+".html", anchor)
+ }
+ }
+ }
+
+ for _, header := range headers {
+ filename := filepath.Join(outPath, header.Name+".html")
+ file, err := os.OpenFile(filename, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0666)
+ if err != nil {
+ panic(err)
+ }
+ defer file.Close()
+ if err := headerTmpl.Execute(file, header); err != nil {
+ return nil, err
+ }
+ }
+
+ return headerDescriptions, nil
+}
+
+func generateIndex(outPath string, config *Config, headerDescriptions map[string]string) error {
+ indexTmpl := template.New("indexTmpl")
+ indexTmpl.Funcs(template.FuncMap{
+ "baseName": filepath.Base,
+ "headerDescription": func(header string) string {
+ return headerDescriptions[header]
+ },
+ })
+ indexTmpl, err := indexTmpl.Parse(`<!DOCTYPE html5>
+
+ <head>
+ <title>BoringSSL - Headers</title>
+ <meta charset="utf-8">
+ <link rel="stylesheet" type="text/css" href="doc.css">
+ </head>
+
+ <body>
+ <div id="main">
+ <div class="title">
+ <h2>BoringSSL Headers</h2>
+ </div>
+ <table>
+ {{range .Sections}}
+ <tr class="header"><td colspan="2">{{.Name}}</td></tr>
+ {{range .Headers}}
+ <tr><td><a href="{{. | baseName}}.html">{{. | baseName}}</a></td><td>{{. | baseName | headerDescription}}</td></tr>
+ {{end}}
+ {{end}}
+ </table>
+ </div>
+ </body>
+</html>`)
+
+ if err != nil {
+ return err
+ }
+
+ file, err := os.OpenFile(filepath.Join(outPath, "headers.html"), os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0666)
+ if err != nil {
+ panic(err)
+ }
+ defer file.Close()
+
+ if err := indexTmpl.Execute(file, config); err != nil {
+ return err
+ }
+
+ return nil
+}
+
+func copyFile(outPath string, inFilePath string) error {
+ bytes, err := ioutil.ReadFile(inFilePath)
+ if err != nil {
+ return err
+ }
+ return ioutil.WriteFile(filepath.Join(outPath, filepath.Base(inFilePath)), bytes, 0666)
+}
+
+func main() {
+ var (
+ configFlag *string = flag.String("config", "doc.config", "Location of config file")
+ outputDir *string = flag.String("out", ".", "Path to the directory where the output will be written")
+ config Config
+ )
+
+ flag.Parse()
+
+ if len(*configFlag) == 0 {
+ fmt.Printf("No config file given by --config\n")
+ os.Exit(1)
+ }
+
+ if len(*outputDir) == 0 {
+ fmt.Printf("No output directory given by --out\n")
+ os.Exit(1)
+ }
+
+ configBytes, err := ioutil.ReadFile(*configFlag)
+ if err != nil {
+ fmt.Printf("Failed to open config file: %s\n", err)
+ os.Exit(1)
+ }
+
+ if err := json.Unmarshal(configBytes, &config); err != nil {
+ fmt.Printf("Failed to parse config file: %s\n", err)
+ os.Exit(1)
+ }
+
+ headerDescriptions, err := generate(*outputDir, &config)
+ if err != nil {
+ fmt.Printf("Failed to generate output: %s\n", err)
+ os.Exit(1)
+ }
+
+ if err := generateIndex(*outputDir, &config, headerDescriptions); err != nil {
+ fmt.Printf("Failed to generate index: %s\n", err)
+ os.Exit(1)
+ }
+
+ if err := copyFile(*outputDir, "doc.css"); err != nil {
+ fmt.Printf("Failed to copy static file: %s\n", err)
+ os.Exit(1)
+ }
+}
diff --git a/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/generate-asm-lcov.py b/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/generate-asm-lcov.py
new file mode 100755
index 000000000..257ae841c
--- /dev/null
+++ b/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/generate-asm-lcov.py
@@ -0,0 +1,152 @@
+#!/usr/bin/python
+# Copyright (c) 2016, Google Inc.
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+# SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+# OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+import os
+import os.path
+import subprocess
+import sys
+
+# The LCOV output format for each source file is:
+#
+# SF:<filename>
+# DA:<line>,<execution count>
+# ...
+# end_of_record
+#
+# The <execution count> can either be 0 for an unexecuted instruction or a
+# value representing the number of executions. The DA line should be omitted
+# for lines not representing an instruction.
+
+SECTION_SEPERATOR = '-' * 80
+
+def is_asm(l):
+ """Returns whether a line should be considered to be an instruction."""
+ l = l.strip()
+ # Empty lines
+ if l == '':
+ return False
+ # Comments
+ if l.startswith('#'):
+ return False
+ # Assembly Macros
+ if l.startswith('.'):
+ return False
+ # Label
+ if l.endswith(':'):
+ return False
+ return True
+
+def merge(callgrind_files, srcs):
+ """Calls callgrind_annotate over the set of callgrind output
+ |callgrind_files| using the sources |srcs| and merges the results
+ together."""
+ out = ''
+ for file in callgrind_files:
+ data = subprocess.check_output(['callgrind_annotate', file] + srcs)
+ out += '%s\n%s\n' % (data, SECTION_SEPERATOR)
+ return out
+
+def parse(filename, data, current):
+ """Parses an annotated execution flow |data| from callgrind_annotate for
+ source |filename| and updates the current execution counts from |current|."""
+ with open(filename) as f:
+ source = f.read().split('\n')
+
+ out = current
+ if out == None:
+ out = [0 if is_asm(l) else None for l in source]
+
+ # Lines are of the following formats:
+ # -- line: Indicates that analysis continues from a different place.
+ # Ir : Indicates the start of a file.
+ # => : Indicates a call/jump in the control flow.
+ # <Count> <Code>: Indicates that the line has been executed that many times.
+ line = None
+ for l in data:
+ l = l.strip() + ' '
+ if l.startswith('-- line'):
+ line = int(l.split(' ')[2]) - 1
+ elif l.strip() == 'Ir':
+ line = 0
+ elif line != None and l.strip() and '=>' not in l and 'unidentified lines' not in l:
+ count = l.split(' ')[0].replace(',', '').replace('.', '0')
+ instruction = l.split(' ', 1)[1].strip()
+ if count != '0' or is_asm(instruction):
+ if out[line] == None:
+ out[line] = 0
+ out[line] += int(count)
+ line += 1
+
+ return out
+
+
+def generate(data):
+ """Parses the merged callgrind_annotate output |data| and generates execution
+ counts for all annotated files."""
+ out = {}
+ data = [p.strip() for p in data.split(SECTION_SEPERATOR)]
+
+
+ # Most sections are ignored, but a section with:
+ # User-annotated source: <file>
+ # precedes a listing of execution count for that <file>.
+ for i in range(len(data)):
+ if 'User-annotated source' in data[i] and i < len(data) - 1:
+ filename = data[i].split(':', 1)[1].strip()
+ res = data[i + 1]
+ if filename not in out:
+ out[filename] = None
+ if 'No information' in res:
+ res = []
+ else:
+ res = res.split('\n')
+ out[filename] = parse(filename, res, out[filename])
+ return out
+
+def output(data):
+ """Takes a dictionary |data| of filenames and execution counts and generates
+ a LCOV coverage output."""
+ out = ''
+ for filename, counts in data.iteritems():
+ out += 'SF:%s\n' % (os.path.abspath(filename))
+ for line, count in enumerate(counts):
+ if count != None:
+ out += 'DA:%d,%s\n' % (line + 1, count)
+ out += 'end_of_record\n'
+ return out
+
+if __name__ == '__main__':
+ if len(sys.argv) != 3:
+ print '%s <Callgrind Folder> <Build Folder>' % (__file__)
+ sys.exit()
+
+ cg_folder = sys.argv[1]
+ build_folder = sys.argv[2]
+
+ cg_files = []
+ for (cwd, _, files) in os.walk(cg_folder):
+ for f in files:
+ if f.startswith('callgrind.out'):
+ cg_files.append(os.path.abspath(os.path.join(cwd, f)))
+
+ srcs = []
+ for (cwd, _, files) in os.walk(build_folder):
+ for f in files:
+ fn = os.path.join(cwd, f)
+ if fn.endswith('.S'):
+ srcs.append(fn)
+
+ annotated = merge(cg_files, srcs)
+ lcov = generate(annotated)
+ print output(lcov)
diff --git a/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/generate-coverage.sh b/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/generate-coverage.sh
new file mode 100755
index 000000000..e16a9a442
--- /dev/null
+++ b/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/generate-coverage.sh
@@ -0,0 +1,59 @@
+#!/bin/sh
+# Copyright (c) 2016, Google Inc.
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+# SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+# OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+set -xe
+
+SRC=$PWD
+
+BUILD=$(mktemp -d '/tmp/boringssl.XXXXXX')
+BUILD_SRC=$(mktemp -d '/tmp/boringssl-src.XXXXXX')
+LCOV=$(mktemp -d '/tmp/boringssl-lcov.XXXXXX')
+
+if [ -n "$1" ]; then
+ LCOV=$(readlink -f "$1")
+ mkdir -p "$LCOV"
+fi
+
+cd "$BUILD"
+cmake "$SRC" -GNinja -DGCOV=1
+ninja
+
+cp -r "$SRC/crypto" "$SRC/decrepit" "$SRC/include" "$SRC/ssl" "$SRC/tool" \
+ "$BUILD_SRC"
+cp -r "$BUILD"/* "$BUILD_SRC"
+mkdir "$BUILD/callgrind/"
+
+cd "$SRC"
+go run "$SRC/util/all_tests.go" -build-dir "$BUILD" -callgrind -num-workers 16
+util/generate-asm-lcov.py "$BUILD/callgrind" "$BUILD" > "$BUILD/asm.info"
+
+go run "util/all_tests.go" -build-dir "$BUILD"
+
+cd "$SRC/ssl/test/runner"
+go test -shim-path "$BUILD/ssl/test/bssl_shim" -num-workers 1
+
+cd "$LCOV"
+lcov -c -d "$BUILD" -b "$BUILD" -o "$BUILD/lcov.info"
+lcov -r "$BUILD/lcov.info" "*_test.c" -o "$BUILD/lcov-1.info"
+lcov -r "$BUILD/lcov-1.info" "*_test.cc" -o "$BUILD/lcov-2.info"
+cat "$BUILD/lcov-2.info" "$BUILD/asm.info" > "$BUILD/final.info"
+sed -i "s;$BUILD;$BUILD_SRC;g" "$BUILD/final.info"
+sed -i "s;$SRC;$BUILD_SRC;g" "$BUILD/final.info"
+genhtml -p "$BUILD_SRC" "$BUILD/final.info"
+
+rm -rf "$BUILD"
+rm -rf "$BUILD_SRC"
+
+xdg-open index.html
diff --git a/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/generate_build_files.py b/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/generate_build_files.py
new file mode 100644
index 000000000..a3435f2bc
--- /dev/null
+++ b/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/generate_build_files.py
@@ -0,0 +1,735 @@
+# Copyright (c) 2015, Google Inc.
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+# SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+# OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+"""Enumerates source files for consumption by various build systems."""
+
+import optparse
+import os
+import subprocess
+import sys
+import json
+
+
+# OS_ARCH_COMBOS maps from OS and platform to the OpenSSL assembly "style" for
+# that platform and the extension used by asm files.
+OS_ARCH_COMBOS = [
+ ('linux', 'arm', 'linux32', [], 'S'),
+ ('linux', 'aarch64', 'linux64', [], 'S'),
+ ('linux', 'ppc64le', 'ppc64le', [], 'S'),
+ ('linux', 'x86', 'elf', ['-fPIC', '-DOPENSSL_IA32_SSE2'], 'S'),
+ ('linux', 'x86_64', 'elf', [], 'S'),
+ ('mac', 'x86', 'macosx', ['-fPIC', '-DOPENSSL_IA32_SSE2'], 'S'),
+ ('mac', 'x86_64', 'macosx', [], 'S'),
+ ('win', 'x86', 'win32n', ['-DOPENSSL_IA32_SSE2'], 'asm'),
+ ('win', 'x86_64', 'nasm', [], 'asm'),
+]
+
+# NON_PERL_FILES enumerates assembly files that are not processed by the
+# perlasm system.
+NON_PERL_FILES = {
+ ('linux', 'arm'): [
+ 'src/crypto/curve25519/asm/x25519-asm-arm.S',
+ 'src/crypto/poly1305/poly1305_arm_asm.S',
+ ],
+ ('linux', 'x86_64'): [
+ 'src/crypto/curve25519/asm/x25519-asm-x86_64.S',
+ ],
+ ('mac', 'x86_64'): [
+ 'src/crypto/curve25519/asm/x25519-asm-x86_64.S',
+ ],
+}
+
+PREFIX = None
+
+
+def PathOf(x):
+ return x if not PREFIX else os.path.join(PREFIX, x)
+
+
+class Android(object):
+
+ def __init__(self):
+ self.header = \
+"""# Copyright (C) 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# This file is created by generate_build_files.py. Do not edit manually.
+
+"""
+
+ def PrintVariableSection(self, out, name, files):
+ out.write('%s := \\\n' % name)
+ for f in sorted(files):
+ out.write(' %s\\\n' % f)
+ out.write('\n')
+
+ def WriteFiles(self, files, asm_outputs):
+ # New Android.bp format
+ with open('sources.bp', 'w+') as blueprint:
+ blueprint.write(self.header.replace('#', '//'))
+
+ blueprint.write('cc_defaults {\n')
+ blueprint.write(' name: "libcrypto_sources",\n')
+ blueprint.write(' srcs: [\n')
+ for f in sorted(files['crypto']):
+ blueprint.write(' "%s",\n' % f)
+ blueprint.write(' ],\n')
+ blueprint.write(' target: {\n')
+
+ for ((osname, arch), asm_files) in asm_outputs:
+ if osname != 'linux' or arch == 'ppc64le':
+ continue
+ if arch == 'aarch64':
+ arch = 'arm64'
+
+ blueprint.write(' android_%s: {\n' % arch)
+ blueprint.write(' srcs: [\n')
+ for f in sorted(asm_files):
+ blueprint.write(' "%s",\n' % f)
+ blueprint.write(' ],\n')
+ blueprint.write(' },\n')
+
+ if arch == 'x86' or arch == 'x86_64':
+ blueprint.write(' linux_%s: {\n' % arch)
+ blueprint.write(' srcs: [\n')
+ for f in sorted(asm_files):
+ blueprint.write(' "%s",\n' % f)
+ blueprint.write(' ],\n')
+ blueprint.write(' },\n')
+
+ blueprint.write(' },\n')
+ blueprint.write('}\n\n')
+
+ blueprint.write('cc_defaults {\n')
+ blueprint.write(' name: "libssl_sources",\n')
+ blueprint.write(' srcs: [\n')
+ for f in sorted(files['ssl']):
+ blueprint.write(' "%s",\n' % f)
+ blueprint.write(' ],\n')
+ blueprint.write('}\n\n')
+
+ blueprint.write('cc_defaults {\n')
+ blueprint.write(' name: "bssl_sources",\n')
+ blueprint.write(' srcs: [\n')
+ for f in sorted(files['tool']):
+ blueprint.write(' "%s",\n' % f)
+ blueprint.write(' ],\n')
+ blueprint.write('}\n\n')
+
+ blueprint.write('cc_defaults {\n')
+ blueprint.write(' name: "boringssl_test_support_sources",\n')
+ blueprint.write(' srcs: [\n')
+ for f in sorted(files['test_support']):
+ blueprint.write(' "%s",\n' % f)
+ blueprint.write(' ],\n')
+ blueprint.write('}\n\n')
+
+ blueprint.write('cc_defaults {\n')
+ blueprint.write(' name: "boringssl_crypto_test_sources",\n')
+ blueprint.write(' srcs: [\n')
+ for f in sorted(files['crypto_test']):
+ blueprint.write(' "%s",\n' % f)
+ blueprint.write(' ],\n')
+ blueprint.write('}\n\n')
+
+ blueprint.write('cc_defaults {\n')
+ blueprint.write(' name: "boringssl_ssl_test_sources",\n')
+ blueprint.write(' srcs: [\n')
+ for f in sorted(files['ssl_test']):
+ blueprint.write(' "%s",\n' % f)
+ blueprint.write(' ],\n')
+ blueprint.write('}\n\n')
+
+ blueprint.write('cc_defaults {\n')
+ blueprint.write(' name: "boringssl_tests_sources",\n')
+ blueprint.write(' srcs: [\n')
+ for f in sorted(files['test']):
+ blueprint.write(' "%s",\n' % f)
+ blueprint.write(' ],\n')
+ blueprint.write('}\n')
+
+ # Legacy Android.mk format, only used by Trusty in new branches
+ with open('sources.mk', 'w+') as makefile:
+ makefile.write(self.header)
+
+ self.PrintVariableSection(makefile, 'crypto_sources', files['crypto'])
+
+ for ((osname, arch), asm_files) in asm_outputs:
+ if osname != 'linux':
+ continue
+ self.PrintVariableSection(
+ makefile, '%s_%s_sources' % (osname, arch), asm_files)
+
+
+class Bazel(object):
+ """Bazel outputs files suitable for including in Bazel files."""
+
+ def __init__(self):
+ self.firstSection = True
+ self.header = \
+"""# This file is created by generate_build_files.py. Do not edit manually.
+
+"""
+
+ def PrintVariableSection(self, out, name, files):
+ if not self.firstSection:
+ out.write('\n')
+ self.firstSection = False
+
+ out.write('%s = [\n' % name)
+ for f in sorted(files):
+ out.write(' "%s",\n' % PathOf(f))
+ out.write(']\n')
+
+ def WriteFiles(self, files, asm_outputs):
+ with open('BUILD.generated.bzl', 'w+') as out:
+ out.write(self.header)
+
+ self.PrintVariableSection(out, 'ssl_headers', files['ssl_headers'])
+ self.PrintVariableSection(
+ out, 'ssl_internal_headers', files['ssl_internal_headers'])
+ self.PrintVariableSection(out, 'ssl_sources', files['ssl'])
+ self.PrintVariableSection(out, 'ssl_c_sources', files['ssl_c'])
+ self.PrintVariableSection(out, 'ssl_cc_sources', files['ssl_cc'])
+ self.PrintVariableSection(out, 'crypto_headers', files['crypto_headers'])
+ self.PrintVariableSection(
+ out, 'crypto_internal_headers', files['crypto_internal_headers'])
+ self.PrintVariableSection(out, 'crypto_sources', files['crypto'])
+ self.PrintVariableSection(out, 'tool_sources', files['tool'])
+ self.PrintVariableSection(out, 'tool_headers', files['tool_headers'])
+
+ for ((osname, arch), asm_files) in asm_outputs:
+ self.PrintVariableSection(
+ out, 'crypto_sources_%s_%s' % (osname, arch), asm_files)
+
+ with open('BUILD.generated_tests.bzl', 'w+') as out:
+ out.write(self.header)
+
+ out.write('test_support_sources = [\n')
+ for filename in sorted(files['test_support'] +
+ files['test_support_headers'] +
+ files['crypto_internal_headers'] +
+ files['ssl_internal_headers']):
+ if os.path.basename(filename) == 'malloc.cc':
+ continue
+ out.write(' "%s",\n' % PathOf(filename))
+
+ out.write(']\n\n')
+
+ self.PrintVariableSection(out, 'crypto_test_sources',
+ files['crypto_test'])
+ self.PrintVariableSection(out, 'ssl_test_sources', files['ssl_test'])
+
+ out.write('def create_tests(copts, crypto, ssl):\n')
+ name_counts = {}
+ for test in files['tests']:
+ name = os.path.basename(test[0])
+ name_counts[name] = name_counts.get(name, 0) + 1
+
+ first = True
+ for test in files['tests']:
+ name = os.path.basename(test[0])
+ if name_counts[name] > 1:
+ if '/' in test[1]:
+ name += '_' + os.path.splitext(os.path.basename(test[1]))[0]
+ else:
+ name += '_' + test[1].replace('-', '_')
+
+ if not first:
+ out.write('\n')
+ first = False
+
+ src_prefix = 'src/' + test[0]
+ for src in files['test']:
+ if src.startswith(src_prefix):
+ src = src
+ break
+ else:
+ raise ValueError("Can't find source for %s" % test[0])
+
+ out.write(' native.cc_test(\n')
+ out.write(' name = "%s",\n' % name)
+ out.write(' size = "small",\n')
+ out.write(' srcs = ["%s"] + test_support_sources,\n' %
+ PathOf(src))
+
+ data_files = []
+ if len(test) > 1:
+
+ out.write(' args = [\n')
+ for arg in test[1:]:
+ if '/' in arg:
+ out.write(' "$(location %s)",\n' %
+ PathOf(os.path.join('src', arg)))
+ data_files.append('src/%s' % arg)
+ else:
+ out.write(' "%s",\n' % arg)
+ out.write(' ],\n')
+
+ out.write(' copts = copts + ["-DBORINGSSL_SHARED_LIBRARY"],\n')
+
+ if len(data_files) > 0:
+ out.write(' data = [\n')
+ for filename in data_files:
+ out.write(' "%s",\n' % PathOf(filename))
+ out.write(' ],\n')
+
+ if 'ssl/' in test[0]:
+ out.write(' deps = [\n')
+ out.write(' crypto,\n')
+ out.write(' ssl,\n')
+ out.write(' ],\n')
+ else:
+ out.write(' deps = [crypto],\n')
+ out.write(' )\n')
+
+
+class GN(object):
+
+ def __init__(self):
+ self.firstSection = True
+ self.header = \
+"""# Copyright (c) 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# This file is created by generate_build_files.py. Do not edit manually.
+
+"""
+
+ def PrintVariableSection(self, out, name, files):
+ if not self.firstSection:
+ out.write('\n')
+ self.firstSection = False
+
+ out.write('%s = [\n' % name)
+ for f in sorted(files):
+ out.write(' "%s",\n' % f)
+ out.write(']\n')
+
+ def WriteFiles(self, files, asm_outputs):
+ with open('BUILD.generated.gni', 'w+') as out:
+ out.write(self.header)
+
+ self.PrintVariableSection(out, 'crypto_sources',
+ files['crypto'] + files['crypto_headers'] +
+ files['crypto_internal_headers'])
+ self.PrintVariableSection(out, 'ssl_sources',
+ files['ssl'] + files['ssl_headers'] +
+ files['ssl_internal_headers'])
+
+ for ((osname, arch), asm_files) in asm_outputs:
+ self.PrintVariableSection(
+ out, 'crypto_sources_%s_%s' % (osname, arch), asm_files)
+
+ fuzzers = [os.path.splitext(os.path.basename(fuzzer))[0]
+ for fuzzer in files['fuzz']]
+ self.PrintVariableSection(out, 'fuzzers', fuzzers)
+
+ with open('BUILD.generated_tests.gni', 'w+') as out:
+ self.firstSection = True
+ out.write(self.header)
+
+ self.PrintVariableSection(out, 'test_support_sources',
+ files['test_support'] +
+ files['test_support_headers'])
+ self.PrintVariableSection(out, 'crypto_test_sources',
+ files['crypto_test'])
+ self.PrintVariableSection(out, 'ssl_test_sources', files['ssl_test'])
+ out.write('\n')
+
+ out.write('template("create_tests") {\n')
+
+ all_tests = []
+ for test in sorted(files['test']):
+ test_name = 'boringssl_%s' % os.path.splitext(os.path.basename(test))[0]
+ all_tests.append(test_name)
+
+ out.write(' executable("%s") {\n' % test_name)
+ out.write(' sources = [\n')
+ out.write(' "%s",\n' % test)
+ out.write(' ]\n')
+ out.write(' sources += test_support_sources\n')
+ out.write(' if (defined(invoker.configs_exclude)) {\n')
+ out.write(' configs -= invoker.configs_exclude\n')
+ out.write(' }\n')
+ out.write(' configs += invoker.configs\n')
+ out.write(' deps = invoker.deps\n')
+ out.write(' }\n')
+ out.write('\n')
+
+ out.write(' group(target_name) {\n')
+ out.write(' deps = [\n')
+ for test_name in sorted(all_tests):
+ out.write(' ":%s",\n' % test_name)
+ out.write(' ]\n')
+ out.write(' }\n')
+ out.write('}\n')
+
+
+class GYP(object):
+
+ def __init__(self):
+ self.header = \
+"""# Copyright (c) 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# This file is created by generate_build_files.py. Do not edit manually.
+
+"""
+
+ def PrintVariableSection(self, out, name, files):
+ out.write(' \'%s\': [\n' % name)
+ for f in sorted(files):
+ out.write(' \'%s\',\n' % f)
+ out.write(' ],\n')
+
+ def WriteFiles(self, files, asm_outputs):
+ with open('boringssl.gypi', 'w+') as gypi:
+ gypi.write(self.header + '{\n \'variables\': {\n')
+
+ self.PrintVariableSection(gypi, 'boringssl_ssl_sources',
+ files['ssl'] + files['ssl_headers'] +
+ files['ssl_internal_headers'])
+ self.PrintVariableSection(gypi, 'boringssl_crypto_sources',
+ files['crypto'] + files['crypto_headers'] +
+ files['crypto_internal_headers'])
+
+ for ((osname, arch), asm_files) in asm_outputs:
+ self.PrintVariableSection(gypi, 'boringssl_%s_%s_sources' %
+ (osname, arch), asm_files)
+
+ gypi.write(' }\n}\n')
+
+
+def FindCMakeFiles(directory):
+ """Returns list of all CMakeLists.txt files recursively in directory."""
+ cmakefiles = []
+
+ for (path, _, filenames) in os.walk(directory):
+ for filename in filenames:
+ if filename == 'CMakeLists.txt':
+ cmakefiles.append(os.path.join(path, filename))
+
+ return cmakefiles
+
+
+def NoTests(dent, is_dir):
+ """Filter function that can be passed to FindCFiles in order to remove test
+ sources."""
+ if is_dir:
+ return dent != 'test'
+ return 'test.' not in dent and not dent.startswith('example_')
+
+
+def OnlyTests(dent, is_dir):
+ """Filter function that can be passed to FindCFiles in order to remove
+ non-test sources."""
+ if is_dir:
+ return dent != 'test'
+ return '_test.' in dent or dent.startswith('example_')
+
+
+def AllFiles(dent, is_dir):
+ """Filter function that can be passed to FindCFiles in order to include all
+ sources."""
+ return True
+
+
+def NotGTestMain(dent, is_dir):
+ return dent != 'gtest_main.cc'
+
+
+def SSLHeaderFiles(dent, is_dir):
+ return dent in ['ssl.h', 'tls1.h', 'ssl23.h', 'ssl3.h', 'dtls1.h']
+
+
+def FindCFiles(directory, filter_func):
+ """Recurses through directory and returns a list of paths to all the C source
+ files that pass filter_func."""
+ cfiles = []
+
+ for (path, dirnames, filenames) in os.walk(directory):
+ for filename in filenames:
+ if not filename.endswith('.c') and not filename.endswith('.cc'):
+ continue
+ if not filter_func(filename, False):
+ continue
+ cfiles.append(os.path.join(path, filename))
+
+ for (i, dirname) in enumerate(dirnames):
+ if not filter_func(dirname, True):
+ del dirnames[i]
+
+ return cfiles
+
+
+def FindHeaderFiles(directory, filter_func):
+ """Recurses through directory and returns a list of paths to all the header files that pass filter_func."""
+ hfiles = []
+
+ for (path, dirnames, filenames) in os.walk(directory):
+ for filename in filenames:
+ if not filename.endswith('.h'):
+ continue
+ if not filter_func(filename, False):
+ continue
+ hfiles.append(os.path.join(path, filename))
+
+ for (i, dirname) in enumerate(dirnames):
+ if not filter_func(dirname, True):
+ del dirnames[i]
+
+ return hfiles
+
+
+def ExtractPerlAsmFromCMakeFile(cmakefile):
+ """Parses the contents of the CMakeLists.txt file passed as an argument and
+ returns a list of all the perlasm() directives found in the file."""
+ perlasms = []
+ with open(cmakefile) as f:
+ for line in f:
+ line = line.strip()
+ if not line.startswith('perlasm('):
+ continue
+ if not line.endswith(')'):
+ raise ValueError('Bad perlasm line in %s' % cmakefile)
+ # Remove "perlasm(" from start and ")" from end
+ params = line[8:-1].split()
+ if len(params) < 2:
+ raise ValueError('Bad perlasm line in %s' % cmakefile)
+ perlasms.append({
+ 'extra_args': params[2:],
+ 'input': os.path.join(os.path.dirname(cmakefile), params[1]),
+ 'output': os.path.join(os.path.dirname(cmakefile), params[0]),
+ })
+
+ return perlasms
+
+
+def ReadPerlAsmOperations():
+ """Returns a list of all perlasm() directives found in CMake config files in
+ src/."""
+ perlasms = []
+ cmakefiles = FindCMakeFiles('src')
+
+ for cmakefile in cmakefiles:
+ perlasms.extend(ExtractPerlAsmFromCMakeFile(cmakefile))
+
+ return perlasms
+
+
+def PerlAsm(output_filename, input_filename, perlasm_style, extra_args):
+ """Runs the a perlasm script and puts the output into output_filename."""
+ base_dir = os.path.dirname(output_filename)
+ if not os.path.isdir(base_dir):
+ os.makedirs(base_dir)
+ subprocess.check_call(
+ ['perl', input_filename, perlasm_style] + extra_args + [output_filename])
+
+
+def ArchForAsmFilename(filename):
+ """Returns the architectures that a given asm file should be compiled for
+ based on substrings in the filename."""
+
+ if 'x86_64' in filename or 'avx2' in filename:
+ return ['x86_64']
+ elif ('x86' in filename and 'x86_64' not in filename) or '586' in filename:
+ return ['x86']
+ elif 'armx' in filename:
+ return ['arm', 'aarch64']
+ elif 'armv8' in filename:
+ return ['aarch64']
+ elif 'arm' in filename:
+ return ['arm']
+ elif 'ppc' in filename:
+ return ['ppc64le']
+ else:
+ raise ValueError('Unknown arch for asm filename: ' + filename)
+
+
+def WriteAsmFiles(perlasms):
+ """Generates asm files from perlasm directives for each supported OS x
+ platform combination."""
+ asmfiles = {}
+
+ for osarch in OS_ARCH_COMBOS:
+ (osname, arch, perlasm_style, extra_args, asm_ext) = osarch
+ key = (osname, arch)
+ outDir = '%s-%s' % key
+
+ for perlasm in perlasms:
+ filename = os.path.basename(perlasm['input'])
+ output = perlasm['output']
+ if not output.startswith('src'):
+ raise ValueError('output missing src: %s' % output)
+ output = os.path.join(outDir, output[4:])
+ if output.endswith('-armx.${ASM_EXT}'):
+ output = output.replace('-armx',
+ '-armx64' if arch == 'aarch64' else '-armx32')
+ output = output.replace('${ASM_EXT}', asm_ext)
+
+ if arch in ArchForAsmFilename(filename):
+ PerlAsm(output, perlasm['input'], perlasm_style,
+ perlasm['extra_args'] + extra_args)
+ asmfiles.setdefault(key, []).append(output)
+
+ for (key, non_perl_asm_files) in NON_PERL_FILES.iteritems():
+ asmfiles.setdefault(key, []).extend(non_perl_asm_files)
+
+ return asmfiles
+
+
+def IsGTest(path):
+ with open(path) as f:
+ return "#include <gtest/gtest.h>" in f.read()
+
+
+def main(platforms):
+ crypto_c_files = FindCFiles(os.path.join('src', 'crypto'), NoTests)
+ ssl_source_files = FindCFiles(os.path.join('src', 'ssl'), NoTests)
+ tool_c_files = FindCFiles(os.path.join('src', 'tool'), NoTests)
+ tool_h_files = FindHeaderFiles(os.path.join('src', 'tool'), AllFiles)
+
+ # Generate err_data.c
+ with open('err_data.c', 'w+') as err_data:
+ subprocess.check_call(['go', 'run', 'err_data_generate.go'],
+ cwd=os.path.join('src', 'crypto', 'err'),
+ stdout=err_data)
+ crypto_c_files.append('err_data.c')
+
+ test_support_c_files = FindCFiles(os.path.join('src', 'crypto', 'test'),
+ NotGTestMain)
+ test_support_h_files = (
+ FindHeaderFiles(os.path.join('src', 'crypto', 'test'), AllFiles) +
+ FindHeaderFiles(os.path.join('src', 'ssl', 'test'), AllFiles))
+
+ test_c_files = []
+ crypto_test_files = ['src/crypto/test/gtest_main.cc']
+ # TODO(davidben): Remove this loop once all tests are converted.
+ for path in FindCFiles(os.path.join('src', 'crypto'), OnlyTests):
+ if IsGTest(path):
+ crypto_test_files.append(path)
+ else:
+ test_c_files.append(path)
+
+ ssl_test_files = FindCFiles(os.path.join('src', 'ssl'), OnlyTests)
+ ssl_test_files.append('src/crypto/test/gtest_main.cc')
+
+ fuzz_c_files = FindCFiles(os.path.join('src', 'fuzz'), NoTests)
+
+ ssl_h_files = (
+ FindHeaderFiles(
+ os.path.join('src', 'include', 'openssl'),
+ SSLHeaderFiles))
+
+ def NotSSLHeaderFiles(filename, is_dir):
+ return not SSLHeaderFiles(filename, is_dir)
+ crypto_h_files = (
+ FindHeaderFiles(
+ os.path.join('src', 'include', 'openssl'),
+ NotSSLHeaderFiles))
+
+ ssl_internal_h_files = FindHeaderFiles(os.path.join('src', 'ssl'), NoTests)
+ crypto_internal_h_files = FindHeaderFiles(
+ os.path.join('src', 'crypto'), NoTests)
+
+ with open('src/util/all_tests.json', 'r') as f:
+ tests = json.load(f)
+ # For now, GTest-based tests are specified manually.
+ tests = [test for test in tests if test[0] not in ['crypto/crypto_test',
+ 'decrepit/decrepit_test',
+ 'ssl/ssl_test']]
+ test_binaries = set([test[0] for test in tests])
+ test_sources = set([
+ test.replace('.cc', '').replace('.c', '').replace(
+ 'src/',
+ '')
+ for test in test_c_files])
+ if test_binaries != test_sources:
+ print 'Test sources and configured tests do not match'
+ a = test_binaries.difference(test_sources)
+ if len(a) > 0:
+ print 'These tests are configured without sources: ' + str(a)
+ b = test_sources.difference(test_binaries)
+ if len(b) > 0:
+ print 'These test sources are not configured: ' + str(b)
+
+ files = {
+ 'crypto': crypto_c_files,
+ 'crypto_headers': crypto_h_files,
+ 'crypto_internal_headers': crypto_internal_h_files,
+ 'crypto_test': sorted(crypto_test_files),
+ 'fuzz': fuzz_c_files,
+ 'ssl': ssl_source_files,
+ 'ssl_c': [s for s in ssl_source_files if s.endswith('.c')],
+ 'ssl_cc': [s for s in ssl_source_files if s.endswith('.cc')],
+ 'ssl_headers': ssl_h_files,
+ 'ssl_internal_headers': ssl_internal_h_files,
+ 'ssl_test': sorted(ssl_test_files),
+ 'tool': tool_c_files,
+ 'tool_headers': tool_h_files,
+ 'test': test_c_files,
+ 'test_support': test_support_c_files,
+ 'test_support_headers': test_support_h_files,
+ 'tests': tests,
+ }
+
+ asm_outputs = sorted(WriteAsmFiles(ReadPerlAsmOperations()).iteritems())
+
+ for platform in platforms:
+ platform.WriteFiles(files, asm_outputs)
+
+ return 0
+
+
+if __name__ == '__main__':
+ parser = optparse.OptionParser(usage='Usage: %prog [--prefix=<path>]'
+ ' [android|bazel|gn|gyp]')
+ parser.add_option('--prefix', dest='prefix',
+ help='For Bazel, prepend argument to all source files')
+ options, args = parser.parse_args(sys.argv[1:])
+ PREFIX = options.prefix
+
+ if not args:
+ parser.print_help()
+ sys.exit(1)
+
+ platforms = []
+ for s in args:
+ if s == 'android':
+ platforms.append(Android())
+ elif s == 'bazel':
+ platforms.append(Bazel())
+ elif s == 'gn':
+ platforms.append(GN())
+ elif s == 'gyp':
+ platforms.append(GYP())
+ else:
+ parser.print_help()
+ sys.exit(1)
+
+ sys.exit(main(platforms))
diff --git a/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/make_errors.go b/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/make_errors.go
new file mode 100644
index 000000000..c1aef82d5
--- /dev/null
+++ b/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/make_errors.go
@@ -0,0 +1,388 @@
+// Copyright (c) 2014, Google Inc.
+//
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+package main
+
+import (
+ "bufio"
+ "errors"
+ "flag"
+ "fmt"
+ "io"
+ "os"
+ "path/filepath"
+ "sort"
+ "strconv"
+ "strings"
+)
+
+// ssl.h reserves values 1000 and above for error codes corresponding to
+// alerts. If automatically assigned reason codes exceed this value, this script
+// will error. This must be kept in sync with SSL_AD_REASON_OFFSET in ssl.h.
+const reservedReasonCode = 1000
+
+var resetFlag *bool = flag.Bool("reset", false, "If true, ignore current assignments and reassign from scratch")
+
+func makeErrors(reset bool) error {
+ topLevelPath, err := findToplevel()
+ if err != nil {
+ return err
+ }
+
+ dirName, err := os.Getwd()
+ if err != nil {
+ return err
+ }
+
+ lib := filepath.Base(dirName)
+ headerPath := filepath.Join(topLevelPath, "include", "openssl", lib+".h")
+ errDir := filepath.Join(topLevelPath, "crypto", "err")
+ dataPath := filepath.Join(errDir, lib+".errordata")
+
+ headerFile, err := os.Open(headerPath)
+ if err != nil {
+ if os.IsNotExist(err) {
+ return fmt.Errorf("No header %s. Run in the right directory or touch the file.", headerPath)
+ }
+
+ return err
+ }
+
+ prefix := strings.ToUpper(lib)
+ reasons, err := parseHeader(prefix, headerFile)
+ headerFile.Close()
+
+ if reset {
+ err = nil
+ // Retain any reason codes above reservedReasonCode.
+ newReasons := make(map[string]int)
+ for key, value := range reasons {
+ if value >= reservedReasonCode {
+ newReasons[key] = value
+ }
+ }
+ reasons = newReasons
+ }
+
+ if err != nil {
+ return err
+ }
+
+ dir, err := os.Open(".")
+ if err != nil {
+ return err
+ }
+ defer dir.Close()
+
+ filenames, err := dir.Readdirnames(-1)
+ if err != nil {
+ return err
+ }
+
+ for _, name := range filenames {
+ if !strings.HasSuffix(name, ".c") {
+ continue
+ }
+
+ if err := addReasons(reasons, name, prefix); err != nil {
+ return err
+ }
+ }
+
+ assignNewValues(reasons, reservedReasonCode)
+
+ headerFile, err = os.Open(headerPath)
+ if err != nil {
+ return err
+ }
+ defer headerFile.Close()
+
+ newHeaderFile, err := os.OpenFile(headerPath+".tmp", os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0666)
+ if err != nil {
+ return err
+ }
+ defer newHeaderFile.Close()
+
+ if err := writeHeaderFile(newHeaderFile, headerFile, prefix, reasons); err != nil {
+ return err
+ }
+ os.Rename(headerPath+".tmp", headerPath)
+
+ dataFile, err := os.OpenFile(dataPath, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0644)
+ if err != nil {
+ return err
+ }
+
+ outputStrings(dataFile, lib, reasons)
+ dataFile.Close()
+
+ return nil
+}
+
+func findToplevel() (path string, err error) {
+ path = ".."
+ buildingPath := filepath.Join(path, "BUILDING.md")
+
+ _, err = os.Stat(buildingPath)
+ if err != nil && os.IsNotExist(err) {
+ path = filepath.Join("..", path)
+ buildingPath = filepath.Join(path, "BUILDING.md")
+ _, err = os.Stat(buildingPath)
+ }
+ if err != nil {
+ return "", errors.New("Cannot find BUILDING.md file at the top-level")
+ }
+ return path, nil
+}
+
+type assignment struct {
+ key string
+ value int
+}
+
+type assignmentsSlice []assignment
+
+func (a assignmentsSlice) Len() int {
+ return len(a)
+}
+
+func (a assignmentsSlice) Less(i, j int) bool {
+ return a[i].value < a[j].value
+}
+
+func (a assignmentsSlice) Swap(i, j int) {
+ a[i], a[j] = a[j], a[i]
+}
+
+func outputAssignments(w io.Writer, assignments map[string]int) {
+ var sorted assignmentsSlice
+
+ for key, value := range assignments {
+ sorted = append(sorted, assignment{key, value})
+ }
+
+ sort.Sort(sorted)
+
+ for _, assignment := range sorted {
+ fmt.Fprintf(w, "#define %s %d\n", assignment.key, assignment.value)
+ }
+}
+
+func parseDefineLine(line, lib string) (key string, value int, ok bool) {
+ if !strings.HasPrefix(line, "#define ") {
+ return
+ }
+
+ fields := strings.Fields(line)
+ if len(fields) != 3 {
+ return
+ }
+
+ key = fields[1]
+ if !strings.HasPrefix(key, lib+"_R_") {
+ return
+ }
+
+ var err error
+ if value, err = strconv.Atoi(fields[2]); err != nil {
+ return
+ }
+
+ ok = true
+ return
+}
+
+func writeHeaderFile(w io.Writer, headerFile io.Reader, lib string, reasons map[string]int) error {
+ var last []byte
+ var haveLast, sawDefine bool
+ newLine := []byte("\n")
+
+ scanner := bufio.NewScanner(headerFile)
+ for scanner.Scan() {
+ line := scanner.Text()
+ _, _, ok := parseDefineLine(line, lib)
+ if ok {
+ sawDefine = true
+ continue
+ }
+
+ if haveLast {
+ w.Write(last)
+ w.Write(newLine)
+ }
+
+ if len(line) > 0 || !sawDefine {
+ last = []byte(line)
+ haveLast = true
+ } else {
+ haveLast = false
+ }
+ sawDefine = false
+ }
+
+ if err := scanner.Err(); err != nil {
+ return err
+ }
+
+ outputAssignments(w, reasons)
+ w.Write(newLine)
+
+ if haveLast {
+ w.Write(last)
+ w.Write(newLine)
+ }
+
+ return nil
+}
+
+func outputStrings(w io.Writer, lib string, assignments map[string]int) {
+ lib = strings.ToUpper(lib)
+ prefixLen := len(lib + "_R_")
+
+ keys := make([]string, 0, len(assignments))
+ for key := range assignments {
+ keys = append(keys, key)
+ }
+ sort.Strings(keys)
+
+ for _, key := range keys {
+ fmt.Fprintf(w, "%s,%d,%s\n", lib, assignments[key], key[prefixLen:])
+ }
+}
+
+func assignNewValues(assignments map[string]int, reserved int) {
+ // Needs to be in sync with the reason limit in
+ // |ERR_reason_error_string|.
+ max := 99
+
+ for _, value := range assignments {
+ if reserved >= 0 && value >= reserved {
+ continue
+ }
+ if value > max {
+ max = value
+ }
+ }
+
+ max++
+
+ // Sort the keys, so this script is reproducible.
+ keys := make([]string, 0, len(assignments))
+ for key, value := range assignments {
+ if value == -1 {
+ keys = append(keys, key)
+ }
+ }
+ sort.Strings(keys)
+
+ for _, key := range keys {
+ if reserved >= 0 && max >= reserved {
+ // If this happens, try passing -reset. Otherwise bump
+ // up reservedReasonCode.
+ panic("Automatically-assigned values exceeded limit!")
+ }
+ assignments[key] = max
+ max++
+ }
+}
+
+func handleDeclareMacro(line, join, macroName string, m map[string]int) {
+ if i := strings.Index(line, macroName); i >= 0 {
+ contents := line[i+len(macroName):]
+ if i := strings.Index(contents, ")"); i >= 0 {
+ contents = contents[:i]
+ args := strings.Split(contents, ",")
+ for i := range args {
+ args[i] = strings.TrimSpace(args[i])
+ }
+ if len(args) != 2 {
+ panic("Bad macro line: " + line)
+ }
+ token := args[0] + join + args[1]
+ if _, ok := m[token]; !ok {
+ m[token] = -1
+ }
+ }
+ }
+}
+
+func addReasons(reasons map[string]int, filename, prefix string) error {
+ file, err := os.Open(filename)
+ if err != nil {
+ return err
+ }
+ defer file.Close()
+
+ reasonPrefix := prefix + "_R_"
+
+ scanner := bufio.NewScanner(file)
+ for scanner.Scan() {
+ line := scanner.Text()
+
+ handleDeclareMacro(line, "_R_", "OPENSSL_DECLARE_ERROR_REASON(", reasons)
+
+ for len(line) > 0 {
+ i := strings.Index(line, prefix+"_")
+ if i == -1 {
+ break
+ }
+
+ line = line[i:]
+ end := strings.IndexFunc(line, func(r rune) bool {
+ return !(r == '_' || (r >= 'A' && r <= 'Z') || (r >= '0' && r <= '9'))
+ })
+ if end == -1 {
+ end = len(line)
+ }
+
+ var token string
+ token, line = line[:end], line[end:]
+
+ switch {
+ case strings.HasPrefix(token, reasonPrefix):
+ if _, ok := reasons[token]; !ok {
+ reasons[token] = -1
+ }
+ }
+ }
+ }
+
+ return scanner.Err()
+}
+
+func parseHeader(lib string, file io.Reader) (reasons map[string]int, err error) {
+ reasons = make(map[string]int)
+
+ scanner := bufio.NewScanner(file)
+ for scanner.Scan() {
+ key, value, ok := parseDefineLine(scanner.Text(), lib)
+ if !ok {
+ continue
+ }
+
+ reasons[key] = value
+ }
+
+ err = scanner.Err()
+ return
+}
+
+func main() {
+ flag.Parse()
+
+ if err := makeErrors(*resetFlag); err != nil {
+ fmt.Fprintf(os.Stderr, "%s\n", err)
+ os.Exit(1)
+ }
+}
diff --git a/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/run_android_tests.go b/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/run_android_tests.go
new file mode 100644
index 000000000..92deac0bc
--- /dev/null
+++ b/roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl/util/run_android_tests.go
@@ -0,0 +1,325 @@
+// Copyright (c) 2016, Google Inc.
+//
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+package main
+
+import (
+ "bytes"
+ "encoding/json"
+ "flag"
+ "fmt"
+ "io"
+ "io/ioutil"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "strconv"
+ "strings"
+)
+
+var (
+ buildDir = flag.String("build-dir", "build", "Specifies the build directory to push.")
+ adbPath = flag.String("adb", "adb", "Specifies the adb binary to use. Defaults to looking in PATH.")
+ device = flag.String("device", "", "Specifies the device or emulator. See adb's -s argument.")
+ aarch64 = flag.Bool("aarch64", false, "Build the test runners for aarch64 instead of arm.")
+ arm = flag.Int("arm", 7, "Which arm revision to build for.")
+ suite = flag.String("suite", "all", "Specifies the test suites to run (all, unit, or ssl).")
+ allTestsArgs = flag.String("all-tests-args", "", "Specifies space-separated arguments to pass to all_tests.go")
+ runnerArgs = flag.String("runner-args", "", "Specifies space-separated arguments to pass to ssl/test/runner")
+ jsonOutput = flag.String("json-output", "", "The file to output JSON results to.")
+)
+
+func enableUnitTests() bool {
+ return *suite == "all" || *suite == "unit"
+}
+
+func enableSSLTests() bool {
+ return *suite == "all" || *suite == "ssl"
+}
+
+func adb(args ...string) error {
+ if len(*device) > 0 {
+ args = append([]string{"-s", *device}, args...)
+ }
+ cmd := exec.Command(*adbPath, args...)
+ cmd.Stdout = os.Stdout
+ cmd.Stderr = os.Stderr
+ return cmd.Run()
+}
+
+func adbShell(shellCmd string) (int, error) {
+ var args []string
+ if len(*device) > 0 {
+ args = append([]string{"-s", *device}, args...)
+ }
+ args = append(args, "shell")
+
+ const delimiter = "___EXIT_CODE___"
+
+ // Older versions of adb and Android do not preserve the exit
+ // code, so work around this.
+ // https://code.google.com/p/android/issues/detail?id=3254
+ shellCmd += "; echo " + delimiter + " $?"
+ args = append(args, shellCmd)
+
+ cmd := exec.Command(*adbPath, args...)
+ stdout, err := cmd.StdoutPipe()
+ if err != nil {
+ return 0, err
+ }
+ cmd.Stderr = os.Stderr
+ if err := cmd.Start(); err != nil {
+ return 0, err
+ }
+
+ var stdoutBytes bytes.Buffer
+ for {
+ var buf [1024]byte
+ n, err := stdout.Read(buf[:])
+ stdoutBytes.Write(buf[:n])
+ os.Stdout.Write(buf[:n])
+ if err != nil {
+ break
+ }
+ }
+
+ if err := cmd.Wait(); err != nil {
+ return 0, err
+ }
+
+ stdoutStr := stdoutBytes.String()
+ idx := strings.LastIndex(stdoutStr, delimiter)
+ if idx < 0 {
+ return 0, fmt.Errorf("Could not find delimiter in output.")
+ }
+
+ return strconv.Atoi(strings.TrimSpace(stdoutStr[idx+len(delimiter):]))
+}
+
+func goTool(args ...string) error {
+ cmd := exec.Command("go", args...)
+ cmd.Stdout = os.Stdout
+ cmd.Stderr = os.Stderr
+
+ cmd.Env = os.Environ()
+ if *aarch64 {
+ cmd.Env = append(cmd.Env, "GOARCH=arm64")
+ } else {
+ cmd.Env = append(cmd.Env, "GOARCH=arm")
+ cmd.Env = append(cmd.Env, fmt.Sprintf("GOARM=%d", *arm))
+ }
+ return cmd.Run()
+}
+
+// setWorkingDirectory walks up directories as needed until the current working
+// directory is the top of a BoringSSL checkout.
+func setWorkingDirectory() {
+ for i := 0; i < 64; i++ {
+ if _, err := os.Stat("BUILDING.md"); err == nil {
+ return
+ }
+ os.Chdir("..")
+ }
+
+ panic("Couldn't find BUILDING.md in a parent directory!")
+}
+
+type test []string
+
+func parseTestConfig(filename string) ([]test, error) {
+ in, err := os.Open(filename)
+ if err != nil {
+ return nil, err
+ }
+ defer in.Close()
+
+ decoder := json.NewDecoder(in)
+ var result []test
+ if err := decoder.Decode(&result); err != nil {
+ return nil, err
+ }
+ return result, nil
+}
+
+func copyFile(dst, src string) error {
+ srcFile, err := os.Open(src)
+ if err != nil {
+ return err
+ }
+ defer srcFile.Close()
+
+ srcInfo, err := srcFile.Stat()
+ if err != nil {
+ return err
+ }
+
+ dir := filepath.Dir(dst)
+ if err := os.MkdirAll(dir, 0777); err != nil {
+ return err
+ }
+
+ dstFile, err := os.OpenFile(dst, os.O_CREATE|os.O_WRONLY, srcInfo.Mode())
+ if err != nil {
+ return err
+ }
+ defer dstFile.Close()
+
+ _, err = io.Copy(dstFile, srcFile)
+ return err
+}
+
+func main() {
+ flag.Parse()
+
+ if *suite == "all" && *jsonOutput != "" {
+ fmt.Printf("To use -json-output flag, select only one test suite with -suite.\n")
+ os.Exit(1)
+ }
+
+ setWorkingDirectory()
+
+ // Clear the target directory.
+ if err := adb("shell", "rm -Rf /data/local/tmp/boringssl-tmp"); err != nil {
+ fmt.Printf("Failed to clear target directory: %s\n", err)
+ os.Exit(1)
+ }
+
+ // Stage everything in a temporary directory.
+ tmpDir, err := ioutil.TempDir("", "boringssl-android")
+ if err != nil {
+ fmt.Printf("Error making temporary directory: %s\n", err)
+ os.Exit(1)
+ }
+ defer os.RemoveAll(tmpDir)
+
+ var binaries, files []string
+
+ if enableUnitTests() {
+ files = append(files,
+ "util/all_tests.json",
+ "BUILDING.md",
+ )
+
+ tests, err := parseTestConfig("util/all_tests.json")
+ if err != nil {
+ fmt.Printf("Failed to parse input: %s\n", err)
+ os.Exit(1)
+ }
+
+ seenBinary := make(map[string]struct{})
+ for _, test := range tests {
+ if _, ok := seenBinary[test[0]]; !ok {
+ binaries = append(binaries, test[0])
+ seenBinary[test[0]] = struct{}{}
+ }
+ for _, arg := range test[1:] {
+ if strings.Contains(arg, "/") {
+ files = append(files, arg)
+ }
+ }
+ }
+
+ fmt.Printf("Building all_tests...\n")
+ if err := goTool("build", "-o", filepath.Join(tmpDir, "util/all_tests"), "util/all_tests.go"); err != nil {
+ fmt.Printf("Error building all_tests.go: %s\n", err)
+ os.Exit(1)
+ }
+ }
+
+ if enableSSLTests() {
+ binaries = append(binaries, "ssl/test/bssl_shim")
+ files = append(files,
+ "BUILDING.md",
+ "ssl/test/runner/cert.pem",
+ "ssl/test/runner/channel_id_key.pem",
+ "ssl/test/runner/ecdsa_p224_cert.pem",
+ "ssl/test/runner/ecdsa_p224_key.pem",
+ "ssl/test/runner/ecdsa_p256_cert.pem",
+ "ssl/test/runner/ecdsa_p256_key.pem",
+ "ssl/test/runner/ecdsa_p384_cert.pem",
+ "ssl/test/runner/ecdsa_p384_key.pem",
+ "ssl/test/runner/ecdsa_p521_cert.pem",
+ "ssl/test/runner/ecdsa_p521_key.pem",
+ "ssl/test/runner/key.pem",
+ "ssl/test/runner/rsa_1024_cert.pem",
+ "ssl/test/runner/rsa_1024_key.pem",
+ "ssl/test/runner/rsa_chain_cert.pem",
+ "ssl/test/runner/rsa_chain_key.pem",
+ "util/all_tests.json",
+ )
+
+ fmt.Printf("Building runner...\n")
+ if err := goTool("test", "-c", "-o", filepath.Join(tmpDir, "ssl/test/runner/runner"), "./ssl/test/runner/"); err != nil {
+ fmt.Printf("Error building runner: %s\n", err)
+ os.Exit(1)
+ }
+ }
+
+ fmt.Printf("Copying test binaries...\n")
+ for _, binary := range binaries {
+ if err := copyFile(filepath.Join(tmpDir, "build", binary), filepath.Join(*buildDir, binary)); err != nil {
+ fmt.Printf("Failed to copy %s: %s\n", binary, err)
+ os.Exit(1)
+ }
+ }
+
+ fmt.Printf("Copying data files...\n")
+ for _, file := range files {
+ if err := copyFile(filepath.Join(tmpDir, file), file); err != nil {
+ fmt.Printf("Failed to copy %s: %s\n", file, err)
+ os.Exit(1)
+ }
+ }
+
+ fmt.Printf("Uploading files...\n")
+ if err := adb("push", "-p", tmpDir, "/data/local/tmp/boringssl-tmp"); err != nil {
+ fmt.Printf("Failed to push runner: %s\n", err)
+ os.Exit(1)
+ }
+
+ var unitTestExit int
+ if enableUnitTests() {
+ fmt.Printf("Running unit tests...\n")
+ unitTestExit, err = adbShell(fmt.Sprintf("cd /data/local/tmp/boringssl-tmp && ./util/all_tests -json-output results.json %s", *allTestsArgs))
+ if err != nil {
+ fmt.Printf("Failed to run unit tests: %s\n", err)
+ os.Exit(1)
+ }
+ }
+
+ var sslTestExit int
+ if enableSSLTests() {
+ fmt.Printf("Running SSL tests...\n")
+ sslTestExit, err = adbShell(fmt.Sprintf("cd /data/local/tmp/boringssl-tmp/ssl/test/runner && ./runner -json-output ../../../results.json %s", *runnerArgs))
+ if err != nil {
+ fmt.Printf("Failed to run SSL tests: %s\n", err)
+ os.Exit(1)
+ }
+ }
+
+ if *jsonOutput != "" {
+ if err := adb("pull", "-p", "/data/local/tmp/boringssl-tmp/results.json", *jsonOutput); err != nil {
+ fmt.Printf("Failed to extract results.json: %s\n", err)
+ os.Exit(1)
+ }
+ }
+
+ if unitTestExit != 0 {
+ os.Exit(unitTestExit)
+ }
+
+ if sslTestExit != 0 {
+ os.Exit(sslTestExit)
+ }
+}