-
Notifications
You must be signed in to change notification settings - Fork 0
/
tink-cc-2.1.1.diff
260 lines (248 loc) · 8.34 KB
/
tink-cc-2.1.1.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
diff -ur tink-cc-2.1.1/cmake/TinkWorkspace.cmake tink-cc/cmake/TinkWorkspace.cmake
--- tink-cc-2.1.1/cmake/TinkWorkspace.cmake 2023-11-30 18:26:00.000000000 -0500
+++ tink-cc/cmake/TinkWorkspace.cmake 2024-03-27 04:01:56.319966030 -0400
@@ -88,13 +88,15 @@
else()
# This is everything that needs to be done here. Abseil already defines its
# targets, which gets linked in tink_cc_(library|test).
- find_package(absl REQUIRED)
+ find_package(absl CONFIG REQUIRED)
+ add_library(absl::string_view ALIAS absl::strings)
endif()
# Don't fetch BoringSSL or look for OpenSSL if target `crypto` is already
# defined.
if (NOT TARGET crypto)
if (NOT TINK_USE_SYSTEM_OPENSSL)
+ set(BUILD_SHARED_LIBS OFF)
# Commit from Feb 15, 2023.
# NOTE: This is one commit ahead of Bazel; the commit fixes a CMake issue,
# which made build fail on CMake 3.10.
@@ -108,7 +110,9 @@
# BoringSSL targets do not carry include directory info, this fixes it.
target_include_directories(crypto PUBLIC
"$<BUILD_INTERFACE:${boringssl_SOURCE_DIR}/src/include>")
+ set(BUILD_SHARED_LIBS ON)
else()
+ list(APPEND CMAKE_FIND_ROOT_PATH "$ENV{OPENSSL_CUSTOM_ROOT_DIR}")
# Support for ED25519 was added from 1.1.1.
find_package(OpenSSL 1.1.1 REQUIRED)
_create_interface_target(crypto OpenSSL::Crypto)
@@ -123,21 +127,29 @@
set(RAPIDJSON_BUILD_EXAMPLES OFF CACHE BOOL "Tink dependency override" FORCE)
set(RAPIDJSON_BUILD_TESTS OFF CACHE BOOL "Tink dependency override" FORCE)
-http_archive(
- NAME rapidjson
- URL https://github.com/Tencent/rapidjson/archive/v1.1.0.tar.gz
- SHA256 bf7ced29704a1e696fbccf2a2b4ea068e7774fa37f6d7dd4039d0787f8bed98e
-)
-# Rapidjson is a header-only library with no explicit target. Here we create one.
-add_library(rapidjson INTERFACE)
-target_include_directories(rapidjson INTERFACE "${rapidjson_SOURCE_DIR}")
+if (NOT TINK_USE_INSTALLED_RAPIDJSON)
+ http_archive(
+ NAME rapidjson
+ URL https://github.com/Tencent/rapidjson/archive/v1.1.0.tar.gz
+ SHA256 bf7ced29704a1e696fbccf2a2b4ea068e7774fa37f6d7dd4039d0787f8bed98e
+ )
+ # Rapidjson is a header-only library with no explicit target. Here we create one.
+ add_library(rapidjson INTERFACE)
+ target_include_directories(rapidjson INTERFACE "${rapidjson_SOURCE_DIR}")
+else()
+ add_library(rapidjson INTERFACE)
+endif()
set(protobuf_BUILD_TESTS OFF CACHE BOOL "Tink dependency override" FORCE)
set(protobuf_BUILD_EXAMPLES OFF CACHE BOOL "Tink dependency override" FORCE)
-## Use protobuf X.21.9.
-http_archive(
- NAME com_google_protobuf
- URL https://github.com/protocolbuffers/protobuf/archive/v21.9.zip
- SHA256 5babb8571f1cceafe0c18e13ddb3be556e87e12ceea3463d6b0d0064e6cc1ac3
- CMAKE_SUBDIR cmake
-)
+if(NOT TINK_USE_INSTALLED_PROTOBUF)
+ ## Use protobuf X.21.9.
+ http_archive(
+ NAME com_google_protobuf
+ URL https://github.com/protocolbuffers/protobuf/archive/v21.9.zip
+ SHA256 5babb8571f1cceafe0c18e13ddb3be556e87e12ceea3463d6b0d0064e6cc1ac3
+ CMAKE_SUBDIR cmake
+ )
+else()
+ find_package(Protobuf REQUIRED)
+endif()
Only in tink-cc: cmake-build-debug
diff -ur tink-cc-2.1.1/CMakeLists.txt tink-cc/CMakeLists.txt
--- tink-cc-2.1.1/CMakeLists.txt 2023-11-30 18:26:00.000000000 -0500
+++ tink-cc/CMakeLists.txt 2024-03-26 05:21:39.194502916 -0400
@@ -1,6 +1,15 @@
cmake_minimum_required(VERSION 3.13)
project(Tink VERSION 2.1.1 LANGUAGES CXX)
+set(CMAKE_C_STANDARD 11)
+set(CMAKE_CXX_STANDARD 17)
+set(CMAKE_CXX_STANDARD_REQUIRED true)
+set(CMAKE_C_STANDARD_REQUIRED true)
+set(THREADS_PREFER_PTHREAD_FLAG ON)
+set(CMAKE_BUILD_TYPE Release)
+set(CMAKE_POSITION_INDEPENDENT_CODE ON)
+set(BUILD_SHARED_LIBS ON)
+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
option(TINK_BUILD_TESTS "Build Tink tests" OFF)
@@ -8,6 +17,16 @@
option(TINK_USE_INSTALLED_ABSEIL "Build Tink linking to Abseil installed in the system" OFF)
option(TINK_USE_INSTALLED_GOOGLETEST "Build Tink linking to GTest installed in the system" OFF)
option(USE_ONLY_FIPS "Enables the FIPS only mode in Tink" OFF)
+option(TINK_BUILD_SHARED_LIB "Build libtink bundle it with the headers" OFF)
+option(TINK_USE_INSTALLED_PROTOBUF "Build Tink linking to Protobuf installed in the system" OFF)
+option(TINK_USE_INSTALLED_RAPIDJSON "Build Tink linking to Rapidjson installed in the system" OFF)
+
+if (TINK_BUILD_SHARED_LIB)
+ set(CMAKE_POSITION_INDEPENDENT_CODE ON CACHE BOOL "libtink override" FORCE)
+ include_directories("${CMAKE_INSTALL_PREFIX}")
+ link_directories("${CMAKE_INSTALL_PREFIX}/lib")
+ set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib" )
+endif()
set(CPACK_GENERATOR TGZ)
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
@@ -34,3 +53,25 @@
add_subdirectory(tink)
add_subdirectory(proto)
+
+if (TINK_BUILD_SHARED_LIB)
+ install(
+ DIRECTORY
+ "${CMAKE_CURRENT_SOURCE_DIR}/tink/"
+ "${TINK_GENFILE_DIR}/tink/"
+ DESTINATION "include/tink"
+ FILES_MATCHING PATTERN "*.h"
+ )
+
+ install(
+ DIRECTORY
+ "${TINK_GENFILE_DIR}/proto"
+ DESTINATION "include"
+ FILES_MATCHING PATTERN "*.h"
+ )
+
+# export(EXPORT Tink FILE tinkConfig.cmake)
+# install(FILES "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
+# DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
+# )
+endif()
Only in tink-cc: .idea
diff -ur tink-cc-2.1.1/tink/CMakeLists.txt tink-cc/tink/CMakeLists.txt
--- tink-cc-2.1.1/tink/CMakeLists.txt 2023-11-30 18:26:00.000000000 -0500
+++ tink-cc/tink/CMakeLists.txt 2024-03-26 05:26:12.669604059 -0400
@@ -25,9 +25,7 @@
set(TINK_VERSION_H "${TINK_GENFILE_DIR}/tink/version.h")
-tink_cc_library(
- NAME cc
- SRCS
+set(TINK_PUBLIC_APIS
aead.h
aead_config.h
aead_factory.h
@@ -73,8 +71,18 @@
streaming_aead_key_templates.h
streaming_mac.h
tink_config.h
+ jwt/jwt_mac.h
+ jwt/jwt_public_key_sign.h
+ jwt/jwt_public_key_verify.h
+ jwt/jwt_signature_config.h
+ jwt/jwt_key_templates.h
+ jwt/jwt_validator.h
+ jwt/raw_jwt.h
+ jwt/jwk_set_converter.h
+ jwt/jwt_mac_config.h
"${TINK_VERSION_H}"
- DEPS
+)
+set(TINK_PUBLIC_API_DEPS
tink::core::aead
tink::core::binary_keyset_reader
tink::core::binary_keyset_writer
@@ -139,6 +147,22 @@
tink::util::validation
tink::proto::config_cc_proto
tink::proto::tink_cc_proto
+ tink::jwt::jwt_mac
+ tink::jwt::jwt_public_key_sign
+ tink::jwt::jwt_public_key_verify
+ tink::jwt::jwt_signature_config
+ tink::jwt::jwt_key_templates
+ tink::jwt::jwt_validator
+ tink::jwt::raw_jwt
+ tink::jwt::jwk_set_converter
+ tink::jwt::jwt_mac_config
+)
+tink_cc_library(
+ NAME cc
+ SRCS
+ ${TINK_PUBLIC_APIS}
+ DEPS
+ ${TINK_PUBLIC_API_DEPS}
PUBLIC
)
@@ -1135,3 +1159,39 @@
absl::strings
absl::string_view
)
+
+if (TINK_BUILD_SHARED_LIB)
+ add_library(tink SHARED
+ ${TINK_PUBLIC_APIS}
+ version_script.lds
+ exported_symbols.lds
+ )
+ target_include_directories(tink PUBLIC ${TINK_INCLUDE_DIRS})
+ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
+ target_link_libraries(tink
+ PRIVATE
+ -Wl,-all_load
+ ${TINK_PUBLIC_API_DEPS}
+ )
+ else()
+ target_link_libraries(tink
+ PRIVATE
+ -fuse-ld=gold # GNU ld does not support ICF.
+ -Wl,--version-script="${CMAKE_CURRENT_SOURCE_DIR}/version_script.lds"
+ -Wl,--gc-sections
+ -Wl,--icf=all
+ -Wl,--strip-all
+ )
+ target_link_libraries(tink
+ PRIVATE
+ -Wl,--whole-archive
+ ${TINK_PUBLIC_API_DEPS}
+ -Wl,--no-whole-archive
+ )
+ endif()
+ set_target_properties(tink PROPERTIES SOVERSION ${TINK_CC_VERSION_LABEL})
+
+ install(TARGETS tink EXPORT Tink LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
+endif()
+
+
diff -ur tink-cc-2.1.1/tink/internal/CMakeLists.txt tink-cc/tink/internal/CMakeLists.txt
--- tink-cc-2.1.1/tink/internal/CMakeLists.txt 2023-11-30 18:26:00.000000000 -0500
+++ tink-cc/tink/internal/CMakeLists.txt 2024-03-26 05:26:50.154575901 -0400
@@ -230,7 +230,7 @@
DEPS
tink::internal::key_info
gmock
- protobuf::libprotobuf-lite
+ protobuf::libprotobuf
tink::proto::tink_cc_proto
)
diff -ur tink-cc-2.1.1/tink/util/CMakeLists.txt tink-cc/tink/util/CMakeLists.txt
--- tink-cc-2.1.1/tink/util/CMakeLists.txt 2023-11-30 18:26:00.000000000 -0500
+++ tink-cc/tink/util/CMakeLists.txt 2024-03-26 05:27:23.275434360 -0400
@@ -226,7 +226,7 @@
SRCS
protobuf_helper.h
DEPS
- protobuf::libprotobuf-lite
+ protobuf::libprotobuf
)
tink_cc_library(