blob: 55152038d3c19916479bbfb6f8e8d567b8cc4c5c [file] [log] [blame]
Amr Aboelkhere6eac202020-04-08 20:46:44 +00001# Copyright 2020 The Chromium Authors. All rights reserved.
2# 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
9config("shell_encryption_config1") {
Amr Aboelkher3e6c6942020-06-27 00:26:41 +000010 # TODO(crbug.com/1095122) Reenable the warning for unused functions and typedef.
11 cflags = [
12 "-Wno-unused-local-typedef",
13 "-Wno-unused-function",
14 "-Wno-sign-compare",
15 "-Wno-ignored-qualifiers",
16 ]
17
amraboelkher4ae61a62021-11-18 10:54:23 +000018 defines = []
19 if (is_component_build) {
20 defines = [
21 # Build targets inside shell-encryption will need this macro to
22 # be defined in order to correctly export symbols when is_component_build
23 # is true.
24 # For more info see: base/shell_encryption_export.h.
25 "SHELL_ENCRYPTION_ENABLE_SYMBOL_EXPORT",
26 ]
27 }
28
Amr Aboelkhere6eac202020-04-08 20:46:44 +000029 include_dirs = [
30 # Allow includes to be prefixed with shell-encryption/src/ in case it is not an
31 # immediate subdirectory of the top-level.
32 "src",
33
34 # Allow includes to be prefixed with shell-encryption/ in case it is not an
35 # immediate subdirectory of the top-level. That's mainly is being used for
36 # glog/logging.h includes.
37 ".",
38
39 # Just like the root shell-encryption directory is added to include path, the
40 # corresponding directory tree with generated files needs to be added too.
41 # Note: this path does not change depending on the current target, e.g.
42 # it is always "//gen/third_party/shell-encryption/src" when building with Chromium.
43 # See also: http://cs.chromium.org/?q=%5C"default_include_dirs
44 # https://gn.googlesource.com/gn/+/master/docs/reference.md#target_gen_dir"
45 target_gen_dir,
46 ]
47}
48
49# Protos.
50proto_library("serialization_proto") {
51 sources = [ "src/serialization.proto" ]
52 proto_in_dir = "src/"
amraboelkher4ae61a62021-11-18 10:54:23 +000053
54 cc_generator_options = "dllexport_decl=SHELL_ENCRYPTION_EXPORT:"
55 cc_include = "third_party/shell-encryption/base/shell_encryption_export.h"
56 component_build_force_source_set = true
Amr Aboelkhere6eac202020-04-08 20:46:44 +000057}
58
59proto_library("coefficient_polynomial_proto") {
60 sources = [ "src/testing/coefficient_polynomial.proto" ]
61 proto_in_dir = "src/testing/"
amraboelkher4ae61a62021-11-18 10:54:23 +000062
63 cc_generator_options = "dllexport_decl=SHELL_ENCRYPTION_EXPORT:"
64 cc_include = "third_party/shell-encryption/base/shell_encryption_export.h"
65 component_build_force_source_set = true
Amr Aboelkhere6eac202020-04-08 20:46:44 +000066}
67
68# SHELL lib.
Yuta Hijikata8a719752020-12-17 04:00:53 +000069if (is_chromeos_ash) {
amraboelkher4ae61a62021-11-18 10:54:23 +000070 component("shell_encryption") {
Amr Aboelkher6373da62020-09-02 07:30:02 +000071 public_configs = [ ":shell_encryption_config1" ]
72 configs -= [ "//build/config/compiler:chromium_code" ]
73 configs += [ "//build/config/compiler:no_chromium_code" ]
74 public = [
amraboelkher4ae61a62021-11-18 10:54:23 +000075 "base/shell_encryption_export.h",
76 "base/shell_encryption_export_template.h",
Amr Aboelkher6373da62020-09-02 07:30:02 +000077 "glog/logging.h",
78 "src/bits_util.h",
79 "src/constants.h",
80 "src/context.h",
81 "src/error_params.h",
82 "src/galois_key.h",
83 "src/int256.h",
84 "src/integral_types.h",
85 "src/montgomery.h",
86 "src/ntt_parameters.h",
87 "src/polynomial.h",
88 "src/prng/chacha_prng.h",
89 "src/prng/chacha_prng_util.h",
90 "src/prng/integral_prng_types.h",
91 "src/prng/prng.h",
92 "src/prng/single_thread_chacha_prng.h",
93 "src/relinearization_key.h",
94 "src/sample_error.h",
95 "src/status_macros.h",
96 "src/statusor.h",
97 "src/symmetric_encryption.h",
98 "src/symmetric_encryption_with_prng.h",
99 "src/transcription.h",
100 ]
101 sources = [
102 "src/int256.cc",
103 "src/montgomery.cc",
104 "src/ntt_parameters.cc",
105 "src/prng/chacha_prng.cc",
106 "src/prng/chacha_prng_util.cc",
107 "src/prng/single_thread_chacha_prng.cc",
108 "src/relinearization_key.cc",
Amr Aboelkher6373da62020-09-02 07:30:02 +0000109 ]
110 public_deps = [
111 ":serialization_proto",
112 "//base:base",
113 "//third_party/abseil-cpp:absl",
114 "//third_party/boringssl:boringssl",
115 "//third_party/protobuf:protobuf_lite",
116 ]
117 }
Amr Aboelkhere6eac202020-04-08 20:46:44 +0000118}
119
Yuta Hijikata8a719752020-12-17 04:00:53 +0000120if (is_chromeos_ash) {
Kevin Yeo39494742020-09-01 21:30:28 +0000121 source_set("shell_encryption_test_library") {
122 testonly = true
123 public_configs = [ ":shell_encryption_config1" ]
124 configs -= [ "//build/config/compiler:chromium_code" ]
125 configs += [ "//build/config/compiler:no_chromium_code" ]
126 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
148 public_configs = [ ":shell_encryption_config1" ]
149 configs -= [ "//build/config/compiler:chromium_code" ]
150 configs += [ "//build/config/compiler:no_chromium_code" ]
151 sources = [
152 "src/bits_util_test.cc",
153 "src/context_test.cc",
154 "src/error_params_test.cc",
155 "src/galois_key_test.cc",
156 "src/int256_test.cc",
157 "src/montgomery_test.cc",
158 "src/ntt_parameters_test.cc",
159 "src/polynomial_test.cc",
160 "src/prng/prng_test.cc",
161 "src/prng/single_thread_chacha_prng_test.cc",
162 "src/relinearization_key_test.cc",
163 "src/sample_error_test.cc",
164 "src/status_macros_test.cc",
Kevin Yeo39494742020-09-01 21:30:28 +0000165 "src/symmetric_encryption_test.cc",
166 "src/symmetric_encryption_with_prng_test.cc",
167 "src/testing/coefficient_polynomial_ciphertext_test.cc",
168 "src/testing/coefficient_polynomial_test.cc",
169 "src/testing/protobuf_matchers_test.cc",
170 "src/transcription_test.cc",
Amr Aboelkher85341392020-11-30 23:49:19 +0000171 "tests/run_all_unittests.cc",
Kevin Yeo39494742020-09-01 21:30:28 +0000172 ]
173 deps = [
174 ":shell_encryption_test_library",
Amr Aboelkher85341392020-11-30 23:49:19 +0000175 "//base/test:test_support",
176 "//testing/gtest",
Kevin Yeo39494742020-09-01 21:30:28 +0000177 ]
178 }
Amr Aboelkher3e6c6942020-06-27 00:26:41 +0000179}