blob: fa2bf850df5dac32d03c7dfdba8e1921b1cf85e2 [file] [log] [blame]
Avi Drissmane23d5ea2022-09-29 21:35:50 +00001# Copyright 2020 The Chromium Authors
Amr Aboelkhere6eac202020-04-08 20:46:44 +00002# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
Yuta Hijikata639e5d92020-10-24 01:12:54 +00005import("//build/config/chromeos/ui_mode.gni")
Amr Aboelkhere6eac202020-04-08 20:46:44 +00006import("//testing/test.gni")
7import("//third_party/protobuf/proto_library.gni")
8
Henrique Ferreiro50f6a7d2022-10-07 08:09:46 +00009config("shell_encryption_internal_config") {
amraboelkher4ae61a62021-11-18 10:54:23 +000010 defines = []
11 if (is_component_build) {
12 defines = [
13 # Build targets inside shell-encryption will need this macro to
14 # be defined in order to correctly export symbols when is_component_build
15 # is true.
16 # For more info see: base/shell_encryption_export.h.
17 "SHELL_ENCRYPTION_ENABLE_SYMBOL_EXPORT",
18 ]
19 }
Henrique Ferreiro50f6a7d2022-10-07 08:09:46 +000020}
amraboelkher4ae61a62021-11-18 10:54:23 +000021
Henrique Ferreiro50f6a7d2022-10-07 08:09:46 +000022config("shell_encryption_config") {
Amr Aboelkhere6eac202020-04-08 20:46:44 +000023 include_dirs = [
24 # Allow includes to be prefixed with shell-encryption/src/ in case it is not an
25 # immediate subdirectory of the top-level.
26 "src",
27
28 # Allow includes to be prefixed with shell-encryption/ in case it is not an
29 # immediate subdirectory of the top-level. That's mainly is being used for
30 # glog/logging.h includes.
31 ".",
32
33 # Just like the root shell-encryption directory is added to include path, the
34 # corresponding directory tree with generated files needs to be added too.
35 # Note: this path does not change depending on the current target, e.g.
36 # it is always "//gen/third_party/shell-encryption/src" when building with Chromium.
37 # See also: http://cs.chromium.org/?q=%5C"default_include_dirs
38 # https://gn.googlesource.com/gn/+/master/docs/reference.md#target_gen_dir"
39 target_gen_dir,
40 ]
41}
42
43# Protos.
44proto_library("serialization_proto") {
45 sources = [ "src/serialization.proto" ]
46 proto_in_dir = "src/"
amraboelkher4ae61a62021-11-18 10:54:23 +000047
48 cc_generator_options = "dllexport_decl=SHELL_ENCRYPTION_EXPORT:"
49 cc_include = "third_party/shell-encryption/base/shell_encryption_export.h"
50 component_build_force_source_set = true
Amr Aboelkhere6eac202020-04-08 20:46:44 +000051}
52
53proto_library("coefficient_polynomial_proto") {
54 sources = [ "src/testing/coefficient_polynomial.proto" ]
55 proto_in_dir = "src/testing/"
amraboelkher4ae61a62021-11-18 10:54:23 +000056
57 cc_generator_options = "dllexport_decl=SHELL_ENCRYPTION_EXPORT:"
58 cc_include = "third_party/shell-encryption/base/shell_encryption_export.h"
59 component_build_force_source_set = true
Amr Aboelkhere6eac202020-04-08 20:46:44 +000060}
61
62# SHELL lib.
Roland Bock5b67b0d2023-02-02 16:25:37 +000063if (is_chromeos) {
amraboelkher4ae61a62021-11-18 10:54:23 +000064 component("shell_encryption") {
Henrique Ferreiro50f6a7d2022-10-07 08:09:46 +000065 public_configs = [ ":shell_encryption_config" ]
Amr Aboelkher6373da62020-09-02 07:30:02 +000066 configs -= [ "//build/config/compiler:chromium_code" ]
Henrique Ferreiro50f6a7d2022-10-07 08:09:46 +000067 configs += [
68 ":shell_encryption_internal_config",
69 "//build/config/compiler:no_chromium_code",
70 ]
Amr Aboelkher6373da62020-09-02 07:30:02 +000071 public = [
amraboelkher4ae61a62021-11-18 10:54:23 +000072 "base/shell_encryption_export.h",
73 "base/shell_encryption_export_template.h",
Amr Aboelkher6373da62020-09-02 07:30:02 +000074 "glog/logging.h",
75 "src/bits_util.h",
76 "src/constants.h",
77 "src/context.h",
78 "src/error_params.h",
79 "src/galois_key.h",
80 "src/int256.h",
81 "src/integral_types.h",
82 "src/montgomery.h",
83 "src/ntt_parameters.h",
84 "src/polynomial.h",
85 "src/prng/chacha_prng.h",
86 "src/prng/chacha_prng_util.h",
87 "src/prng/integral_prng_types.h",
88 "src/prng/prng.h",
89 "src/prng/single_thread_chacha_prng.h",
90 "src/relinearization_key.h",
91 "src/sample_error.h",
92 "src/status_macros.h",
93 "src/statusor.h",
94 "src/symmetric_encryption.h",
95 "src/symmetric_encryption_with_prng.h",
96 "src/transcription.h",
97 ]
98 sources = [
99 "src/int256.cc",
100 "src/montgomery.cc",
101 "src/ntt_parameters.cc",
102 "src/prng/chacha_prng.cc",
103 "src/prng/chacha_prng_util.cc",
104 "src/prng/single_thread_chacha_prng.cc",
105 "src/relinearization_key.cc",
Amr Aboelkher6373da62020-09-02 07:30:02 +0000106 ]
107 public_deps = [
108 ":serialization_proto",
109 "//base:base",
110 "//third_party/abseil-cpp:absl",
111 "//third_party/boringssl:boringssl",
112 "//third_party/protobuf:protobuf_lite",
113 ]
114 }
Amr Aboelkhere6eac202020-04-08 20:46:44 +0000115}
116
Roland Bock5b67b0d2023-02-02 16:25:37 +0000117if (is_chromeos) {
Kevin Yeo39494742020-09-01 21:30:28 +0000118 source_set("shell_encryption_test_library") {
119 testonly = true
Henrique Ferreiro50f6a7d2022-10-07 08:09:46 +0000120 public_configs = [ ":shell_encryption_config" ]
Kevin Yeo39494742020-09-01 21:30:28 +0000121 configs -= [ "//build/config/compiler:chromium_code" ]
Henrique Ferreiro50f6a7d2022-10-07 08:09:46 +0000122 configs += [
123 ":shell_encryption_internal_config",
124 "//build/config/compiler:no_chromium_code",
125 ]
Kevin Yeo39494742020-09-01 21:30:28 +0000126 public = [
127 "src/prng/integral_prng_testing_types.h",
128 "src/testing/coefficient_polynomial.h",
129 "src/testing/coefficient_polynomial_ciphertext.h",
130 "src/testing/parameters.h",
131 "src/testing/protobuf_matchers.h",
132 "src/testing/status_matchers.h",
133 "src/testing/status_testing.h",
134 "src/testing/testing_prng.h",
135 "src/testing/testing_utils.h",
136 ]
137 public_deps = [
138 ":coefficient_polynomial_proto",
amraboelkher4ae61a62021-11-18 10:54:23 +0000139 ":serialization_proto",
Kevin Yeo39494742020-09-01 21:30:28 +0000140 ":shell_encryption",
141 "//testing/gmock:gmock",
142 "//testing/gtest:gtest",
143 ]
144 }
Amr Aboelkher3e6c6942020-06-27 00:26:41 +0000145
Amr Aboelkher85341392020-11-30 23:49:19 +0000146 test("shell_encryption_unittests") {
Kevin Yeo39494742020-09-01 21:30:28 +0000147 testonly = true
Kevin Yeo39494742020-09-01 21:30:28 +0000148 configs -= [ "//build/config/compiler:chromium_code" ]
Henrique Ferreiro50f6a7d2022-10-07 08:09:46 +0000149 configs += [
150 ":shell_encryption_internal_config",
151 "//build/config/compiler:no_chromium_code",
152 ]
Kevin Yeo39494742020-09-01 21:30:28 +0000153 sources = [
154 "src/bits_util_test.cc",
155 "src/context_test.cc",
156 "src/error_params_test.cc",
157 "src/galois_key_test.cc",
158 "src/int256_test.cc",
159 "src/montgomery_test.cc",
160 "src/ntt_parameters_test.cc",
161 "src/polynomial_test.cc",
162 "src/prng/prng_test.cc",
163 "src/prng/single_thread_chacha_prng_test.cc",
164 "src/relinearization_key_test.cc",
165 "src/sample_error_test.cc",
166 "src/status_macros_test.cc",
Kevin Yeo39494742020-09-01 21:30:28 +0000167 "src/symmetric_encryption_test.cc",
168 "src/symmetric_encryption_with_prng_test.cc",
169 "src/testing/coefficient_polynomial_ciphertext_test.cc",
170 "src/testing/coefficient_polynomial_test.cc",
171 "src/testing/protobuf_matchers_test.cc",
172 "src/transcription_test.cc",
Amr Aboelkher85341392020-11-30 23:49:19 +0000173 "tests/run_all_unittests.cc",
Kevin Yeo39494742020-09-01 21:30:28 +0000174 ]
175 deps = [
176 ":shell_encryption_test_library",
Amr Aboelkher85341392020-11-30 23:49:19 +0000177 "//base/test:test_support",
178 "//testing/gtest",
Kevin Yeo39494742020-09-01 21:30:28 +0000179 ]
180 }
Amr Aboelkher3e6c6942020-06-27 00:26:41 +0000181}