Add some network-related PP_Error codes and conversion function to map net::Error...
[chromium-blink-merge.git] / crypto / crypto.gyp
blob4ba571b05205d92b31d23463a57d209a9879e177
1 # Copyright (c) 2012 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.
6   'variables': {
7     'chromium_code': 1,
8     # Put all transitive dependencies for Windows HMAC here.
9     # This is required so that we can build them for nacl win64.
10     'hmac_win64_related_sources': [
11       'hmac.cc',
12       'hmac.h',
13       'hmac_win.cc',
14       'secure_util.cc',
15       'secure_util.h',
16       'symmetric_key.h',
17       'symmetric_key_win.cc',
18       'third_party/nss/chromium-sha256.h',
19       'third_party/nss/sha512.cc',
20     ],
21   },
22   'targets': [
23     {
24       'target_name': 'crypto',
25       'type': '<(component)',
26       'product_name': 'crcrypto',  # Avoid colliding with OpenSSL's libcrypto
27       'dependencies': [
28         '../base/base.gyp:base',
29         '../base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations',
30       ],
31       'defines': [
32         'CRYPTO_IMPLEMENTATION',
33       ],
34       'msvs_disabled_warnings': [
35         4018,
36       ],
37       'conditions': [
38         [ 'os_posix == 1 and OS != "mac" and OS != "ios" and OS != "android"', {
39           'dependencies': [
40             '../build/linux/system.gyp:ssl',
41           ],
42           'export_dependent_settings': [
43             '../build/linux/system.gyp:ssl',
44           ],
45           'conditions': [
46             [ 'chromeos==1', {
47                 'sources/': [ ['include', '_chromeos\\.cc$'] ]
48               },
49             ],
50           ],
51         }, {  # os_posix != 1 or OS == "mac" or OS == "ios" or OS == "android"
52             'sources/': [
53               ['exclude', '_nss\.cc$'],
54               ['include', 'ec_private_key_nss\.cc$'],
55               ['include', 'ec_signature_creator_nss\.cc$'],
56               ['include', 'encryptor_nss\.cc$'],
57               ['include', 'hmac_nss\.cc$'],
58               ['include', 'signature_verifier_nss\.cc$'],
59               ['include', 'symmetric_key_nss\.cc$'],
60             ],
61             'sources!': [
62               'hmac_win.cc',
63               'openpgp_symmetric_encryption.cc',
64               'openpgp_symmetric_encryption.h',
65               'symmetric_key_win.cc',
66             ],
67         }],
68         [ 'OS != "mac" and OS != "ios"', {
69           'sources!': [
70             'apple_keychain.h',
71             'mock_apple_keychain.cc',
72             'mock_apple_keychain.h',
73           ],
74         }],
75         [ 'OS == "android"', {
76             'dependencies': [
77               '../third_party/openssl/openssl.gyp:openssl',
78             ],
79             'sources/': [
80               ['exclude', 'ec_private_key_nss\.cc$'],
81               ['exclude', 'ec_signature_creator_nss\.cc$'],
82               ['exclude', 'encryptor_nss\.cc$'],
83               ['exclude', 'hmac_nss\.cc$'],
84               ['exclude', 'signature_verifier_nss\.cc$'],
85               ['exclude', 'symmetric_key_nss\.cc$'],
86             ],
87         }],
88         [ 'os_bsd==1', {
89           'link_settings': {
90             'libraries': [
91               '-L/usr/local/lib -lexecinfo',
92               ],
93             },
94           },
95         ],
96         [ 'OS == "ios"', {
97           'sources!': [
98             # This class is stubbed out on iOS.
99             'rsa_private_key.cc',
100           ],
101         }],
102         [ 'OS == "mac"', {
103           'link_settings': {
104             'libraries': [
105               '$(SDKROOT)/System/Library/Frameworks/Security.framework',
106             ],
107           },
108         }, {  # OS != "mac"
109           'sources!': [
110             'cssm_init.cc',
111             'cssm_init.h',
112             'mac_security_services_lock.cc',
113             'mac_security_services_lock.h',
114           ],
115         }],
116         [ 'OS == "mac" or OS == "ios" or OS == "win"', {
117           'dependencies': [
118             '../third_party/nss/nss.gyp:nspr',
119             '../third_party/nss/nss.gyp:nss',
120           ],
121           'export_dependent_settings': [
122             '../third_party/nss/nss.gyp:nspr',
123             '../third_party/nss/nss.gyp:nss',
124           ],
125         }],
126         [ 'OS != "win"', {
127           'sources!': [
128             'capi_util.h',
129             'capi_util.cc',
130           ],
131         }],
132         [ 'OS == "win"', {
133           # TODO(jschuh): crbug.com/167187 fix size_t to int truncations.
134           'msvs_disabled_warnings': [4267, ],
135         }],
136         [ 'use_openssl==1', {
137             # TODO(joth): Use a glob to match exclude patterns once the
138             #             OpenSSL file set is complete.
139             'sources!': [
140               'ec_private_key_nss.cc',
141               'ec_signature_creator_nss.cc',
142               'encryptor_nss.cc',
143               'hmac_nss.cc',
144               'nss_util.cc',
145               'nss_util.h',
146               'openpgp_symmetric_encryption.cc',
147               'rsa_private_key_nss.cc',
148               'secure_hash_default.cc',
149               'signature_creator_nss.cc',
150               'signature_verifier_nss.cc',
151               'symmetric_key_nss.cc',
152               'third_party/nss/chromium-blapi.h',
153               'third_party/nss/chromium-blapit.h',
154               'third_party/nss/chromium-nss.h',
155               'third_party/nss/chromium-sha256.h',
156               'third_party/nss/pk11akey.cc',
157               'third_party/nss/secsign.cc',
158               'third_party/nss/sha512.cc',
159             ],
160           }, {
161             'sources!': [
162               'ec_private_key_openssl.cc',
163               'ec_signature_creator_openssl.cc',
164               'encryptor_openssl.cc',
165               'hmac_openssl.cc',
166               'openssl_util.cc',
167               'openssl_util.h',
168               'rsa_private_key_openssl.cc',
169               'secure_hash_openssl.cc',
170               'signature_creator_openssl.cc',
171               'signature_verifier_openssl.cc',
172               'symmetric_key_openssl.cc',
173             ],
174         },],
175       ],
176       'sources': [
177         # NOTE: all transitive dependencies of HMAC on windows need
178         #     to be placed in the source list above.
179         '<@(hmac_win64_related_sources)',
180         'apple_keychain.h',
181         'apple_keychain_ios.mm',
182         'apple_keychain_mac.mm',
183         'capi_util.cc',
184         'capi_util.h',
185         'crypto_export.h',
186         'crypto_module_blocking_password_delegate.h',
187         'cssm_init.cc',
188         'cssm_init.h',
189         'curve25519.cc',
190         'curve25519.h',
191         'curve25519-donna.c',
192         'ghash.cc',
193         'ghash.h',
194         'ec_private_key.h',
195         'ec_private_key_nss.cc',
196         'ec_private_key_openssl.cc',
197         'ec_signature_creator.cc',
198         'ec_signature_creator.h',
199         'ec_signature_creator_impl.h',
200         'ec_signature_creator_nss.cc',
201         'ec_signature_creator_openssl.cc',
202         'encryptor.cc',
203         'encryptor.h',
204         'encryptor_nss.cc',
205         'encryptor_openssl.cc',
206         'hkdf.cc',
207         'hkdf.h',
208         'hmac_nss.cc',
209         'hmac_openssl.cc',
210         'mac_security_services_lock.cc',
211         'mac_security_services_lock.h',
212         'mock_apple_keychain.cc',
213         'mock_apple_keychain.h',
214         'mock_apple_keychain_ios.cc',
215         'mock_apple_keychain_mac.cc',
216         'p224_spake.cc',
217         'p224_spake.h',
218         'nss_util.cc',
219         'nss_util.h',
220         'nss_util_internal.h',
221         'openpgp_symmetric_encryption.cc',
222         'openpgp_symmetric_encryption.h',
223         'openssl_util.cc',
224         'openssl_util.h',
225         'p224.cc',
226         'p224.h',
227         'random.h',
228         'random.cc',
229         'rsa_private_key.cc',
230         'rsa_private_key.h',
231         'rsa_private_key_ios.cc',
232         'rsa_private_key_mac.cc',
233         'rsa_private_key_nss.cc',
234         'rsa_private_key_openssl.cc',
235         'rsa_private_key_win.cc',
236         'scoped_capi_types.h',
237         'scoped_nss_types.h',
238         'secure_hash.h',
239         'secure_hash_default.cc',
240         'secure_hash_openssl.cc',
241         'sha2.cc',
242         'sha2.h',
243         'signature_creator.h',
244         'signature_creator_mac.cc',
245         'signature_creator_nss.cc',
246         'signature_creator_openssl.cc',
247         'signature_creator_win.cc',
248         'signature_verifier.h',
249         'signature_verifier_nss.cc',
250         'signature_verifier_openssl.cc',
251         'symmetric_key_nss.cc',
252         'symmetric_key_openssl.cc',
253         'third_party/nss/chromium-blapi.h',
254         'third_party/nss/chromium-blapit.h',
255         'third_party/nss/chromium-nss.h',
256         'third_party/nss/pk11akey.cc',
257         'third_party/nss/secsign.cc',
258       ],
259     },
260     {
261       'target_name': 'crypto_unittests',
262       'type': 'executable',
263       'sources': [
264         # Infrastructure files.
265         'run_all_unittests.cc',
267         # Tests.
268         'curve25519_unittest.cc',
269         'ec_private_key_unittest.cc',
270         'ec_signature_creator_unittest.cc',
271         'encryptor_unittest.cc',
272         'ghash_unittest.cc',
273         'hkdf_unittest.cc',
274         'hmac_unittest.cc',
275         'nss_util_unittest.cc',
276         'p224_unittest.cc',
277         'p224_spake_unittest.cc',
278         'random_unittest.cc',
279         'rsa_private_key_unittest.cc',
280         'rsa_private_key_nss_unittest.cc',
281         'secure_hash_unittest.cc',
282         'sha2_unittest.cc',
283         'signature_creator_unittest.cc',
284         'signature_verifier_unittest.cc',
285         'symmetric_key_unittest.cc',
286         'openpgp_symmetric_encryption_unittest.cc',
287       ],
288       'dependencies': [
289         'crypto',
290         '../base/base.gyp:base',
291         '../base/base.gyp:test_support_base',
292         '../testing/gmock.gyp:gmock',
293         '../testing/gtest.gyp:gtest',
294       ],
295       'conditions': [
296         [ 'os_posix == 1 and OS != "mac" and OS != "android" and OS != "ios"', {
297           'conditions': [
298             [ 'linux_use_tcmalloc==1', {
299                 'dependencies': [
300                   '../base/allocator/allocator.gyp:allocator',
301                 ],
302               },
303             ],
304           ],
305           'dependencies': [
306             '../build/linux/system.gyp:ssl',
307           ],
308         }, {  # os_posix != 1 or OS == "mac" or OS == "android" or OS == "ios"
309           'sources!': [
310             'rsa_private_key_nss_unittest.cc',
311             'openpgp_symmetric_encryption_unittest.cc',
312           ]
313         }],
314         [ 'OS == "mac" or OS == "ios" or OS == "win"', {
315           'dependencies': [
316             '../third_party/nss/nss.gyp:nss',
317           ],
318         }],
319         ['OS == "ios"', {
320           'sources!': [
321             # These tests are excluded because they test classes that are not
322             # implemented on iOS.
323             'rsa_private_key_unittest.cc',
324             'signature_creator_unittest.cc',
325             'signature_verifier_unittest.cc',
326           ],
327         }],
328         [ 'OS == "mac"', {
329           'dependencies': [
330             '../third_party/nss/nss.gyp:nspr',
331           ],
332         }],
333         [ 'OS == "win"', {
334           # TODO(jschuh): crbug.com/167187 fix size_t to int truncations.
335           'msvs_disabled_warnings': [4267, ],
336         }],
337         [ 'use_openssl==1', {
338           'sources!': [
339             'nss_util_unittest.cc',
340             'openpgp_symmetric_encryption_unittest.cc',
341             'rsa_private_key_nss_unittest.cc',
342           ],
343         }],
344       ],
345     },
346   ],
347   'conditions': [
348     ['OS == "win" and target_arch=="ia32"', {
349       'targets': [
350         {
351           'target_name': 'crypto_nacl_win64',
352           # We do not want nacl_helper to depend on NSS because this would
353           # require including a 64-bit copy of NSS. Thus, use the native APIs
354           # for the helper.
355           'type': '<(component)',
356           'dependencies': [
357             '../base/base.gyp:base_nacl_win64',
358             '../base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations_win64',
359           ],
360           'sources': [
361             '<@(hmac_win64_related_sources)',
362           ],
363           'defines': [
364            'CRYPTO_IMPLEMENTATION',
365            '<@(nacl_win64_defines)',
366           ],
367           'msvs_disabled_warnings': [
368             4018,
369           ],
370           'configurations': {
371             'Common_Base': {
372               'msvs_target_platform': 'x64',
373             },
374           },
375         },
376       ],
377     }],
378   ],