OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/webcrypto/nss/util_nss.h" | 5 #include "components/webcrypto/nss/util_nss.h" |
6 | 6 |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "components/webcrypto/crypto_data.h" | 8 #include "components/webcrypto/crypto_data.h" |
9 #include "components/webcrypto/platform_crypto.h" | 9 #include "components/webcrypto/platform_crypto.h" |
10 #include "crypto/nss_util.h" | 10 #include "crypto/nss_util.h" |
11 #include "crypto/scoped_nss_types.h" | 11 #include "crypto/scoped_nss_types.h" |
12 | 12 |
13 #if defined(USE_NSS) | 13 #if defined(USE_NSS_CERTS) |
14 #include <dlfcn.h> | 14 #include <dlfcn.h> |
15 #include <secoid.h> | 15 #include <secoid.h> |
16 #endif | 16 #endif |
17 | 17 |
18 namespace webcrypto { | 18 namespace webcrypto { |
19 | 19 |
20 namespace { | 20 namespace { |
21 base::LazyInstance<NssRuntimeSupport>::Leaky g_nss_runtime_support = | 21 base::LazyInstance<NssRuntimeSupport>::Leaky g_nss_runtime_support = |
22 LAZY_INSTANCE_INITIALIZER; | 22 LAZY_INSTANCE_INITIALIZER; |
23 } // namespace | 23 } // namespace |
(...skipping 11 matching lines...) Expand all Loading... |
35 | 35 |
36 CryptoData SECItemToCryptoData(const SECItem& item) { | 36 CryptoData SECItemToCryptoData(const SECItem& item) { |
37 return CryptoData(item.data, item.len); | 37 return CryptoData(item.data, item.len); |
38 } | 38 } |
39 | 39 |
40 NssRuntimeSupport* NssRuntimeSupport::Get() { | 40 NssRuntimeSupport* NssRuntimeSupport::Get() { |
41 return &g_nss_runtime_support.Get(); | 41 return &g_nss_runtime_support.Get(); |
42 } | 42 } |
43 | 43 |
44 NssRuntimeSupport::NssRuntimeSupport() : internal_slot_does_oaep_(false) { | 44 NssRuntimeSupport::NssRuntimeSupport() : internal_slot_does_oaep_(false) { |
45 #if !defined(USE_NSS) | 45 #if !defined(USE_NSS_CERTS) |
46 // Using a bundled version of NSS that is guaranteed to have this symbol. | 46 // Using a bundled version of NSS that is guaranteed to have this symbol. |
47 pk11_encrypt_func_ = PK11_Encrypt; | 47 pk11_encrypt_func_ = PK11_Encrypt; |
48 pk11_decrypt_func_ = PK11_Decrypt; | 48 pk11_decrypt_func_ = PK11_Decrypt; |
49 pk11_pub_encrypt_func_ = PK11_PubEncrypt; | 49 pk11_pub_encrypt_func_ = PK11_PubEncrypt; |
50 pk11_priv_decrypt_func_ = PK11_PrivDecrypt; | 50 pk11_priv_decrypt_func_ = PK11_PrivDecrypt; |
51 internal_slot_does_oaep_ = true; | 51 internal_slot_does_oaep_ = true; |
52 #else | 52 #else |
53 // Using system NSS libraries and PCKS #11 modules, which may not have the | 53 // Using system NSS libraries and PCKS #11 modules, which may not have the |
54 // necessary function (PK11_Encrypt) or mechanism support (CKM_AES_GCM). | 54 // necessary function (PK11_Encrypt) or mechanism support (CKM_AES_GCM). |
55 | 55 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 return NULL; | 104 return NULL; |
105 } | 105 } |
106 | 106 |
107 AlgorithmImplementation* CreatePlatformPbkdf2Implementation() { | 107 AlgorithmImplementation* CreatePlatformPbkdf2Implementation() { |
108 // PBKDF2 will only be implemented for BoringSSL, since the NSS | 108 // PBKDF2 will only be implemented for BoringSSL, since the NSS |
109 // implementation is being deprecated. | 109 // implementation is being deprecated. |
110 return NULL; | 110 return NULL; |
111 } | 111 } |
112 | 112 |
113 } // namespace webcrypto | 113 } // namespace webcrypto |
OLD | NEW |