0

Rename CRYPTO_API to CRYPTO_EXPORT.

R=rvargas@chromium.org
Review URL: http://codereview.chromium.org/7491061

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@95652 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
darin@chromium.org
2011-08-05 20:59:11 +00:00
parent 5036f187c5
commit d613a990ce
16 changed files with 64 additions and 63 deletions

@@ -9,7 +9,7 @@
#include <windows.h> #include <windows.h>
#include <wincrypt.h> #include <wincrypt.h>
#include "crypto/crypto_api.h" #include "crypto/crypto_export.h"
namespace crypto { namespace crypto {
@@ -23,11 +23,11 @@ namespace crypto {
// "The CryptAcquireContext function is generally thread safe unless // "The CryptAcquireContext function is generally thread safe unless
// CRYPT_NEWKEYSET or CRYPT_DELETEKEYSET is specified in the dwFlags // CRYPT_NEWKEYSET or CRYPT_DELETEKEYSET is specified in the dwFlags
// parameter." // parameter."
CRYPTO_API BOOL CryptAcquireContextLocked(HCRYPTPROV* prov, CRYPTO_EXPORT BOOL CryptAcquireContextLocked(HCRYPTPROV* prov,
LPCWSTR container, LPCWSTR container,
LPCWSTR provider, LPCWSTR provider,
DWORD prov_type, DWORD prov_type,
DWORD flags); DWORD flags);
} // namespace crypto } // namespace crypto

@@ -113,7 +113,7 @@
'sources': [ 'sources': [
'capi_util.cc', 'capi_util.cc',
'capi_util.h', 'capi_util.h',
'crypto_api.h', 'crypto_export.h',
'crypto_module_blocking_password_delegate.h', 'crypto_module_blocking_password_delegate.h',
'cssm_init.cc', 'cssm_init.cc',
'cssm_init.h', 'cssm_init.h',

@@ -2,25 +2,25 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CRYPTO_CRYPTO_API_H_ #ifndef CRYPTO_CRYPTO_EXPORT_H_
#define CRYPTO_CRYPTO_API_H_ #define CRYPTO_CRYPTO_EXPORT_H_
#pragma once #pragma once
#if defined(COMPONENT_BUILD) #if defined(COMPONENT_BUILD)
#if defined(WIN32) #if defined(WIN32)
#if defined(CRYPTO_IMPLEMENTATION) #if defined(CRYPTO_IMPLEMENTATION)
#define CRYPTO_API __declspec(dllexport) #define CRYPTO_EXPORT __declspec(dllexport)
#else #else
#define CRYPTO_API __declspec(dllimport) #define CRYPTO_EXPORT __declspec(dllimport)
#endif // defined(CRYPTO_IMPLEMENTATION) #endif // defined(CRYPTO_IMPLEMENTATION)
#else // defined(WIN32) #else // defined(WIN32)
#define CRYPTO_API __attribute__((visibility("default"))) #define CRYPTO_EXPORT __attribute__((visibility("default")))
#endif #endif
#else // defined(COMPONENT_BUILD) #else // defined(COMPONENT_BUILD)
#define CRYPTO_API #define CRYPTO_EXPORT
#endif #endif
#endif // CRYPTO_CRYPTO_API_H_ #endif // CRYPTO_CRYPTO_EXPORT_H_

@@ -9,33 +9,33 @@
#include <Security/cssm.h> #include <Security/cssm.h>
#include "base/basictypes.h" #include "base/basictypes.h"
#include "crypto/crypto_api.h" #include "crypto/crypto_export.h"
namespace crypto { namespace crypto {
// Initialize CSSM if it isn't already initialized. This must be called before // Initialize CSSM if it isn't already initialized. This must be called before
// any other CSSM functions. This function is thread-safe, and CSSM will only // any other CSSM functions. This function is thread-safe, and CSSM will only
// ever be initialized once. CSSM will be properly shut down on program exit. // ever be initialized once. CSSM will be properly shut down on program exit.
CRYPTO_API void EnsureCSSMInit(); CRYPTO_EXPORT void EnsureCSSMInit();
// Returns the shared CSP handle used by CSSM functions. // Returns the shared CSP handle used by CSSM functions.
CSSM_CSP_HANDLE GetSharedCSPHandle(); CSSM_CSP_HANDLE GetSharedCSPHandle();
// Returns the shared CL handle used by CSSM functions. // Returns the shared CL handle used by CSSM functions.
CRYPTO_API CSSM_CL_HANDLE GetSharedCLHandle(); CRYPTO_EXPORT CSSM_CL_HANDLE GetSharedCLHandle();
// Returns the shared TP handle used by CSSM functions. // Returns the shared TP handle used by CSSM functions.
CRYPTO_API CSSM_TP_HANDLE GetSharedTPHandle(); CRYPTO_EXPORT CSSM_TP_HANDLE GetSharedTPHandle();
// Set of pointers to memory function wrappers that are required for CSSM // Set of pointers to memory function wrappers that are required for CSSM
extern const CSSM_API_MEMORY_FUNCS kCssmMemoryFunctions; extern const CSSM_API_MEMORY_FUNCS kCssmMemoryFunctions;
// Utility function to log an error message including the error name. // Utility function to log an error message including the error name.
CRYPTO_API void LogCSSMError(const char *function_name, CSSM_RETURN err); CRYPTO_EXPORT void LogCSSMError(const char *function_name, CSSM_RETURN err);
// Utility functions to allocate and release CSSM memory. // Utility functions to allocate and release CSSM memory.
void* CSSMMalloc(CSSM_SIZE size); void* CSSMMalloc(CSSM_SIZE size);
CRYPTO_API void CSSMFree(void* ptr); CRYPTO_EXPORT void CSSMFree(void* ptr);
// Wrapper class for CSSM_DATA type. This should only be used when using the // Wrapper class for CSSM_DATA type. This should only be used when using the
// CL/TP/CSP handles from above, since that's the only time we're guaranteed (or // CL/TP/CSP handles from above, since that's the only time we're guaranteed (or

@@ -12,7 +12,7 @@
#include "base/scoped_ptr.h" #include "base/scoped_ptr.h"
#include "base/string_piece.h" #include "base/string_piece.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "crypto/crypto_api.h" #include "crypto/crypto_export.h"
#if defined(USE_NSS) #if defined(USE_NSS)
#include "crypto/scoped_nss_types.h" #include "crypto/scoped_nss_types.h"
@@ -24,7 +24,7 @@ namespace crypto {
class SymmetricKey; class SymmetricKey;
class CRYPTO_API Encryptor { class CRYPTO_EXPORT Encryptor {
public: public:
enum Mode { enum Mode {
CBC, CBC,

@@ -13,14 +13,14 @@
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "base/string_piece.h" #include "base/string_piece.h"
#include "crypto/crypto_api.h" #include "crypto/crypto_export.h"
namespace crypto { namespace crypto {
// Simplify the interface and reduce includes by abstracting out the internals. // Simplify the interface and reduce includes by abstracting out the internals.
struct HMACPlatformData; struct HMACPlatformData;
class CRYPTO_API HMAC { class CRYPTO_EXPORT HMAC {
public: public:
// The set of supported hash functions. Extend as required. // The set of supported hash functions. Extend as required.
enum HashAlgorithm { enum HashAlgorithm {

@@ -6,7 +6,7 @@
#define CRYPTO_MAC_SECURITY_SERVICES_LOCK_H_ #define CRYPTO_MAC_SECURITY_SERVICES_LOCK_H_
#pragma once #pragma once
#include "crypto/crypto_api.h" #include "crypto/crypto_export.h"
namespace base { namespace base {
class Lock; class Lock;
@@ -20,7 +20,7 @@ namespace crypto {
// problematic. // problematic.
// //
// http://developer.apple.com/mac/library/documentation/Security/Reference/certifkeytrustservices/Reference/reference.html // http://developer.apple.com/mac/library/documentation/Security/Reference/certifkeytrustservices/Reference/reference.html
CRYPTO_API base::Lock& GetMacSecurityServicesLock(); CRYPTO_EXPORT base::Lock& GetMacSecurityServicesLock();
} // namespace crypto } // namespace crypto

@@ -8,7 +8,7 @@
#include <string> #include <string>
#include "base/basictypes.h" #include "base/basictypes.h"
#include "crypto/crypto_api.h" #include "crypto/crypto_export.h"
#if defined(USE_NSS) #if defined(USE_NSS)
class FilePath; class FilePath;
@@ -28,17 +28,17 @@ namespace crypto {
// EarlySetupForNSSInit performs lightweight setup which must occur before the // EarlySetupForNSSInit performs lightweight setup which must occur before the
// process goes multithreaded. This does not initialise NSS. For test, see // process goes multithreaded. This does not initialise NSS. For test, see
// EnsureNSSInit. // EnsureNSSInit.
CRYPTO_API void EarlySetupForNSSInit(); CRYPTO_EXPORT void EarlySetupForNSSInit();
#endif #endif
// Initialize NRPR if it isn't already initialized. This function is // Initialize NRPR if it isn't already initialized. This function is
// thread-safe, and NSPR will only ever be initialized once. // thread-safe, and NSPR will only ever be initialized once.
void CRYPTO_API EnsureNSPRInit(); CRYPTO_EXPORT void EnsureNSPRInit();
// Initialize NSS if it isn't already initialized. This must be called before // Initialize NSS if it isn't already initialized. This must be called before
// any other NSS functions. This function is thread-safe, and NSS will only // any other NSS functions. This function is thread-safe, and NSS will only
// ever be initialized once. // ever be initialized once.
void CRYPTO_API EnsureNSSInit(); CRYPTO_EXPORT void EnsureNSSInit();
// Call this before calling EnsureNSSInit() will force NSS to initialize // Call this before calling EnsureNSSInit() will force NSS to initialize
// without a persistent DB. This is used for the special case where access of // without a persistent DB. This is used for the special case where access of
@@ -55,7 +55,7 @@ void CRYPTO_API EnsureNSSInit();
// Calling this method only has effect on Linux. // Calling this method only has effect on Linux.
// //
// WARNING: Use this with caution. // WARNING: Use this with caution.
CRYPTO_API void ForceNSSNoDBInit(); CRYPTO_EXPORT void ForceNSSNoDBInit();
// This methods is used to disable checks in NSS when used in a forked process. // This methods is used to disable checks in NSS when used in a forked process.
// NSS checks whether it is running a forked process to avoid problems when // NSS checks whether it is running a forked process to avoid problems when
@@ -66,7 +66,7 @@ CRYPTO_API void ForceNSSNoDBInit();
// This method must be called before EnsureNSSInit() to take effect. // This method must be called before EnsureNSSInit() to take effect.
// //
// WARNING: Use this with caution. // WARNING: Use this with caution.
CRYPTO_API void DisableNSSForkCheck(); CRYPTO_EXPORT void DisableNSSForkCheck();
// Load NSS library files. This function has no effect on Mac and Windows. // Load NSS library files. This function has no effect on Mac and Windows.
// This loads the necessary NSS library files so that NSS can be initialized // This loads the necessary NSS library files so that NSS can be initialized
@@ -75,7 +75,7 @@ CRYPTO_API void DisableNSSForkCheck();
// //
// Note that this does not load libnssckbi.so which contains the root // Note that this does not load libnssckbi.so which contains the root
// certificates. // certificates.
CRYPTO_API void LoadNSSLibraries(); CRYPTO_EXPORT void LoadNSSLibraries();
// Check if the current NSS version is greater than or equals to |version|. // Check if the current NSS version is greater than or equals to |version|.
// A sample version string is "3.12.3". // A sample version string is "3.12.3".
@@ -85,11 +85,11 @@ bool CheckNSSVersion(const char* version);
// Open the r/w nssdb that's stored inside the user's encrypted home // Open the r/w nssdb that's stored inside the user's encrypted home
// directory. This is the default slot returned by // directory. This is the default slot returned by
// GetPublicNSSKeySlot(). // GetPublicNSSKeySlot().
CRYPTO_API void OpenPersistentNSSDB(); CRYPTO_EXPORT void OpenPersistentNSSDB();
// A delegate class that we can use to access the cros API for // A delegate class that we can use to access the cros API for
// communication with cryptohomed and the TPM. // communication with cryptohomed and the TPM.
class CRYPTO_API TPMTokenInfoDelegate { class CRYPTO_EXPORT TPMTokenInfoDelegate {
public: public:
TPMTokenInfoDelegate(); TPMTokenInfoDelegate();
virtual ~TPMTokenInfoDelegate(); virtual ~TPMTokenInfoDelegate();
@@ -113,37 +113,38 @@ class CRYPTO_API TPMTokenInfoDelegate {
// GetPrivateNSSKeySlot() will return the TPM slot if one was found. // GetPrivateNSSKeySlot() will return the TPM slot if one was found.
// Takes ownership of the passed-in delegate object so it can access // Takes ownership of the passed-in delegate object so it can access
// the cros library to talk to cryptohomed. // the cros library to talk to cryptohomed.
CRYPTO_API void EnableTPMTokenForNSS(TPMTokenInfoDelegate* delegate); CRYPTO_EXPORT void EnableTPMTokenForNSS(TPMTokenInfoDelegate* delegate);
// Get name and user PIN for the built-in TPM token on ChromeOS. // Get name and user PIN for the built-in TPM token on ChromeOS.
// Either one can safely be NULL. Should only be called after // Either one can safely be NULL. Should only be called after
// EnableTPMTokenForNSS has been called with a non-null delegate. // EnableTPMTokenForNSS has been called with a non-null delegate.
CRYPTO_API void GetTPMTokenInfo(std::string* token_name, std::string* user_pin); CRYPTO_EXPORT void GetTPMTokenInfo(std::string* token_name,
std::string* user_pin);
// Returns true if the machine has a TPM and it can be used to store tokens. // Returns true if the machine has a TPM and it can be used to store tokens.
CRYPTO_API bool IsTPMTokenAvailable(); CRYPTO_EXPORT bool IsTPMTokenAvailable();
// Returns true if the TPM is owned and PKCS#11 initialized with the // Returns true if the TPM is owned and PKCS#11 initialized with the
// user and security officer PINs, and has been enabled in NSS by // user and security officer PINs, and has been enabled in NSS by
// calling EnableTPMForNSS, and opencryptoki has been successfully // calling EnableTPMForNSS, and opencryptoki has been successfully
// loaded into NSS. // loaded into NSS.
CRYPTO_API bool IsTPMTokenReady(); CRYPTO_EXPORT bool IsTPMTokenReady();
// Same as IsTPMTokenReady() except this attempts to initialize the token // Same as IsTPMTokenReady() except this attempts to initialize the token
// if necessary. // if necessary.
CRYPTO_API bool EnsureTPMTokenReady(); CRYPTO_EXPORT bool EnsureTPMTokenReady();
#endif #endif
// Convert a NSS PRTime value into a base::Time object. // Convert a NSS PRTime value into a base::Time object.
// We use a int64 instead of PRTime here to avoid depending on NSPR headers. // We use a int64 instead of PRTime here to avoid depending on NSPR headers.
CRYPTO_API base::Time PRTimeToBaseTime(int64 prtime); CRYPTO_EXPORT base::Time PRTimeToBaseTime(int64 prtime);
#if defined(USE_NSS) #if defined(USE_NSS)
// Exposed for unittests only. |path| should be an existing directory under // Exposed for unittests only. |path| should be an existing directory under
// which the DB files will be placed. |description| is a user-visible name for // which the DB files will be placed. |description| is a user-visible name for
// the DB, as a utf8 string, which will be truncated at 32 bytes. // the DB, as a utf8 string, which will be truncated at 32 bytes.
CRYPTO_API bool OpenTestNSSDB(const FilePath& path, const char* description); CRYPTO_EXPORT bool OpenTestNSSDB(const FilePath& path, const char* description);
CRYPTO_API void CloseTestNSSDB(); CRYPTO_EXPORT void CloseTestNSSDB();
// NSS has a bug which can cause a deadlock or stall in some cases when writing // NSS has a bug which can cause a deadlock or stall in some cases when writing
// to the certDB and keyDB. It also has a bug which causes concurrent key pair // to the certDB and keyDB. It also has a bug which causes concurrent key pair
@@ -157,7 +158,7 @@ base::Lock* GetNSSWriteLock();
// A helper class that acquires the NSS write Lock while the AutoNSSWriteLock // A helper class that acquires the NSS write Lock while the AutoNSSWriteLock
// is in scope. // is in scope.
class CRYPTO_API AutoNSSWriteLock { class CRYPTO_EXPORT AutoNSSWriteLock {
public: public:
AutoNSSWriteLock(); AutoNSSWriteLock();
~AutoNSSWriteLock(); ~AutoNSSWriteLock();

@@ -8,7 +8,7 @@
#include <secmodt.h> #include <secmodt.h>
#include "crypto/crypto_api.h" #include "crypto/crypto_export.h"
// These functions return a type defined in an NSS header, and so cannot be // These functions return a type defined in an NSS header, and so cannot be
// declared in nss_util.h. Hence, they are declared here. // declared in nss_util.h. Hence, they are declared here.
@@ -18,14 +18,14 @@ namespace crypto {
// Returns a reference to the default NSS key slot for storing // Returns a reference to the default NSS key slot for storing
// public-key data only (e.g. server certs). Caller must release // public-key data only (e.g. server certs). Caller must release
// returned reference with PK11_FreeSlot. // returned reference with PK11_FreeSlot.
CRYPTO_API PK11SlotInfo* GetPublicNSSKeySlot(); CRYPTO_EXPORT PK11SlotInfo* GetPublicNSSKeySlot();
// Returns a reference to the default slot for storing private-key and // Returns a reference to the default slot for storing private-key and
// mixed private-key/public-key data. Returns a hardware (TPM) NSS // mixed private-key/public-key data. Returns a hardware (TPM) NSS
// key slot if on ChromeOS and EnableTPMForNSS() has been called // key slot if on ChromeOS and EnableTPMForNSS() has been called
// successfully. Caller must release returned reference with // successfully. Caller must release returned reference with
// PK11_FreeSlot. // PK11_FreeSlot.
CRYPTO_API PK11SlotInfo* GetPrivateNSSKeySlot(); CRYPTO_EXPORT PK11SlotInfo* GetPrivateNSSKeySlot();
// A helper class that acquires the SECMOD list read lock while the // A helper class that acquires the SECMOD list read lock while the
// AutoSECMODListReadLock is in scope. // AutoSECMODListReadLock is in scope.

@@ -9,7 +9,7 @@
#include <string> #include <string>
#include "base/string_piece.h" #include "base/string_piece.h"
#include "crypto/crypto_api.h" #include "crypto/crypto_export.h"
namespace crypto { namespace crypto {
@@ -20,7 +20,7 @@ namespace crypto {
// //
// Likewise, the output of this can be decrypted on the command line with: // Likewise, the output of this can be decrypted on the command line with:
// gpg < input // gpg < input
class CRYPTO_API OpenPGPSymmetricEncrytion { class CRYPTO_EXPORT OpenPGPSymmetricEncrytion {
public: public:
enum Result { enum Result {
OK, OK,

@@ -23,7 +23,7 @@ struct SECKEYPublicKeyStr;
#include <vector> #include <vector>
#include "base/basictypes.h" #include "base/basictypes.h"
#include "crypto/crypto_api.h" #include "crypto/crypto_export.h"
#if defined(OS_WIN) #if defined(OS_WIN)
#include "crypto/scoped_capi_types.h" #include "crypto/scoped_capi_types.h"
@@ -171,7 +171,7 @@ class PrivateKeyInfoCodec {
// Encapsulates an RSA private key. Can be used to generate new keys, export // Encapsulates an RSA private key. Can be used to generate new keys, export
// keys to other formats, or to extract a public key. // keys to other formats, or to extract a public key.
// TODO(hclam): This class should be ref-counted so it can be reused easily. // TODO(hclam): This class should be ref-counted so it can be reused easily.
class CRYPTO_API RSAPrivateKey { class CRYPTO_EXPORT RSAPrivateKey {
public: public:
~RSAPrivateKey(); ~RSAPrivateKey();

@@ -7,13 +7,13 @@
#pragma once #pragma once
#include "base/basictypes.h" #include "base/basictypes.h"
#include "crypto/crypto_api.h" #include "crypto/crypto_export.h"
namespace crypto { namespace crypto {
// A wrapper to calculate secure hashes incrementally, allowing to // A wrapper to calculate secure hashes incrementally, allowing to
// be used when the full input is not known in advance. // be used when the full input is not known in advance.
class CRYPTO_API SecureHash { class CRYPTO_EXPORT SecureHash {
public: public:
enum Algorithm { enum Algorithm {
SHA256, SHA256,

@@ -8,7 +8,7 @@
#include <string> #include <string>
#include "crypto/crypto_api.h" #include "crypto/crypto_export.h"
namespace crypto { namespace crypto {
@@ -23,12 +23,12 @@ enum {
// Computes the SHA-256 hash of the input string 'str' and stores the first // Computes the SHA-256 hash of the input string 'str' and stores the first
// 'len' bytes of the hash in the output buffer 'output'. If 'len' > 32, // 'len' bytes of the hash in the output buffer 'output'. If 'len' > 32,
// only 32 bytes (the full hash) are stored in the 'output' buffer. // only 32 bytes (the full hash) are stored in the 'output' buffer.
CRYPTO_API void SHA256HashString(const std::string& str, CRYPTO_EXPORT void SHA256HashString(const std::string& str,
void* output, size_t len); void* output, size_t len);
// Convenience version of the above that returns the result in a 32-byte // Convenience version of the above that returns the result in a 32-byte
// string. // string.
CRYPTO_API std::string SHA256HashString(const std::string& str); CRYPTO_EXPORT std::string SHA256HashString(const std::string& str);
} // namespace crypto } // namespace crypto

@@ -21,7 +21,7 @@ struct SGNContextStr;
#include <vector> #include <vector>
#include "base/basictypes.h" #include "base/basictypes.h"
#include "crypto/crypto_api.h" #include "crypto/crypto_export.h"
#include "crypto/rsa_private_key.h" #include "crypto/rsa_private_key.h"
#if defined(OS_WIN) #if defined(OS_WIN)
@@ -32,7 +32,7 @@ namespace crypto {
// Signs data using a bare private key (as opposed to a full certificate). // Signs data using a bare private key (as opposed to a full certificate).
// Currently can only sign data using SHA-1 with RSA encryption. // Currently can only sign data using SHA-1 with RSA encryption.
class CRYPTO_API SignatureCreator { class CRYPTO_EXPORT SignatureCreator {
public: public:
~SignatureCreator(); ~SignatureCreator();

@@ -17,7 +17,7 @@
#include <vector> #include <vector>
#include "base/basictypes.h" #include "base/basictypes.h"
#include "crypto/crypto_api.h" #include "crypto/crypto_export.h"
#if defined(OS_WIN) #if defined(OS_WIN)
#include "crypto/scoped_capi_types.h" #include "crypto/scoped_capi_types.h"
@@ -27,7 +27,7 @@ namespace crypto {
// The SignatureVerifier class verifies a signature using a bare public key // The SignatureVerifier class verifies a signature using a bare public key
// (as opposed to a certificate). // (as opposed to a certificate).
class CRYPTO_API SignatureVerifier { class CRYPTO_EXPORT SignatureVerifier {
public: public:
SignatureVerifier(); SignatureVerifier();
~SignatureVerifier(); ~SignatureVerifier();

@@ -9,7 +9,7 @@
#include <string> #include <string>
#include "base/basictypes.h" #include "base/basictypes.h"
#include "crypto/crypto_api.h" #include "crypto/crypto_export.h"
#if defined(USE_NSS) #if defined(USE_NSS)
#include "crypto/scoped_nss_types.h" #include "crypto/scoped_nss_types.h"
@@ -23,7 +23,7 @@ namespace crypto {
// Wraps a platform-specific symmetric key and allows it to be held in a // Wraps a platform-specific symmetric key and allows it to be held in a
// scoped_ptr. // scoped_ptr.
class CRYPTO_API SymmetricKey { class CRYPTO_EXPORT SymmetricKey {
public: public:
// Defines the algorithm that a key will be used with. See also // Defines the algorithm that a key will be used with. See also
// classs Encrptor. // classs Encrptor.