summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChih-Hung Hsieh <chh@google.com>2016-07-12 11:53:56 -0700
committerChih-Hung Hsieh <chh@google.com>2016-07-12 11:53:56 -0700
commit5d5e42b081646208e134a96d0cb500e6b6e8f043 (patch)
treeda706815c49226499ae51344315f30af5f0f8488
parent03d4b6d531eb8c2ebcb4d572a3bf118c70a83ff6 (diff)
downloadkeymaster-5d5e42b081646208e134a96d0cb500e6b6e8f043.tar.gz
Declare explicit conversion constructors. Bug: 28341362 Change-Id: Iee7c71c96ca01174bad5d8852888f0af9bc80242 Test: build with clang-tidy
-rw-r--r--aes_key.h2
-rw-r--r--android_keymaster_test_utils.h2
-rw-r--r--hmac_key.h2
-rw-r--r--include/keymaster/android_keymaster_messages.h24
-rw-r--r--include/keymaster/asymmetric_key_factory.h2
-rw-r--r--include/keymaster/ec_key_factory.h2
-rw-r--r--include/keymaster/key_factory.h2
-rw-r--r--include/keymaster/rsa_key_factory.h2
-rw-r--r--include/keymaster/serializable.h2
-rw-r--r--include/keymaster/soft_keymaster_context.h2
-rw-r--r--include/keymaster/soft_keymaster_device.h2
-rw-r--r--iso18033kdf.h2
-rw-r--r--keymaster0_engine.h2
-rw-r--r--keymaster1_engine.h2
-rw-r--r--openssl_utils.h2
-rw-r--r--operation.h2
-rw-r--r--operation_table.h2
-rw-r--r--symmetric_key.h2
18 files changed, 29 insertions, 29 deletions
diff --git a/aes_key.h b/aes_key.h
index fad4569..a4ab2f2 100644
--- a/aes_key.h
+++ b/aes_key.h
@@ -28,7 +28,7 @@ const size_t kMaxGcmTagLength = 16 * 8;
class AesKeyFactory : public SymmetricKeyFactory {
public:
- AesKeyFactory(const KeymasterContext* context) : SymmetricKeyFactory(context) {}
+ explicit AesKeyFactory(const KeymasterContext* context) : SymmetricKeyFactory(context) {}
keymaster_algorithm_t registry_key() const { return KM_ALGORITHM_AES; }
diff --git a/android_keymaster_test_utils.h b/android_keymaster_test_utils.h
index cba1467..1794398 100644
--- a/android_keymaster_test_utils.h
+++ b/android_keymaster_test_utils.h
@@ -320,7 +320,7 @@ class Keymaster2Test : public testing::TestWithParam<InstanceCreatorPtr> {
};
struct Keymaster0CountingWrapper : public keymaster0_device_t {
- Keymaster0CountingWrapper(keymaster0_device_t* device) : device_(device), counter_(0) {
+ explicit Keymaster0CountingWrapper(keymaster0_device_t* device) : device_(device), counter_(0) {
common = device_->common;
common.close = counting_close_device;
client_version = device_->client_version;
diff --git a/hmac_key.h b/hmac_key.h
index 69d5331..c05e6a3 100644
--- a/hmac_key.h
+++ b/hmac_key.h
@@ -25,7 +25,7 @@ const size_t kMinHmacLengthBits = 64;
class HmacKeyFactory : public SymmetricKeyFactory {
public:
- HmacKeyFactory(const KeymasterContext* context) : SymmetricKeyFactory(context) {}
+ explicit HmacKeyFactory(const KeymasterContext* context) : SymmetricKeyFactory(context) {}
keymaster_error_t LoadKey(const KeymasterKeyBlob& key_material,
const AuthorizationSet& additional_params,
diff --git a/include/keymaster/android_keymaster_messages.h b/include/keymaster/android_keymaster_messages.h
index a2936d1..30d3fb7 100644
--- a/include/keymaster/android_keymaster_messages.h
+++ b/include/keymaster/android_keymaster_messages.h
@@ -92,7 +92,7 @@ inline int32_t MessageVersion(uint8_t major_ver, uint8_t minor_ver, uint8_t /* s
}
struct KeymasterMessage : public Serializable {
- KeymasterMessage(int32_t ver) : message_version(ver) { assert(ver >= 0); }
+ explicit KeymasterMessage(int32_t ver) : message_version(ver) { assert(ver >= 0); }
uint32_t message_version;
};
@@ -144,12 +144,12 @@ struct SupportedByAlgorithmRequest : public KeymasterMessage {
};
struct SupportedImportFormatsRequest : public SupportedByAlgorithmRequest {
- SupportedImportFormatsRequest(int32_t ver = MAX_MESSAGE_VERSION)
+ explicit SupportedImportFormatsRequest(int32_t ver = MAX_MESSAGE_VERSION)
: SupportedByAlgorithmRequest(ver) {}
};
struct SupportedExportFormatsRequest : public SupportedByAlgorithmRequest {
- SupportedExportFormatsRequest(int32_t ver = MAX_MESSAGE_VERSION)
+ explicit SupportedExportFormatsRequest(int32_t ver = MAX_MESSAGE_VERSION)
: SupportedByAlgorithmRequest(ver) {}
};
@@ -172,17 +172,17 @@ struct SupportedByAlgorithmAndPurposeRequest : public KeymasterMessage {
};
struct SupportedBlockModesRequest : public SupportedByAlgorithmAndPurposeRequest {
- SupportedBlockModesRequest(int32_t ver = MAX_MESSAGE_VERSION)
+ explicit SupportedBlockModesRequest(int32_t ver = MAX_MESSAGE_VERSION)
: SupportedByAlgorithmAndPurposeRequest(ver) {}
};
struct SupportedPaddingModesRequest : public SupportedByAlgorithmAndPurposeRequest {
- SupportedPaddingModesRequest(int32_t ver = MAX_MESSAGE_VERSION)
+ explicit SupportedPaddingModesRequest(int32_t ver = MAX_MESSAGE_VERSION)
: SupportedByAlgorithmAndPurposeRequest(ver) {}
};
struct SupportedDigestsRequest : public SupportedByAlgorithmAndPurposeRequest {
- SupportedDigestsRequest(int32_t ver = MAX_MESSAGE_VERSION)
+ explicit SupportedDigestsRequest(int32_t ver = MAX_MESSAGE_VERSION)
: SupportedByAlgorithmAndPurposeRequest(ver) {}
};
@@ -226,32 +226,32 @@ template <typename T> struct SupportedResponse : public KeymasterResponse {
};
struct SupportedAlgorithmsResponse : public SupportedResponse<keymaster_algorithm_t> {
- SupportedAlgorithmsResponse(int32_t ver = MAX_MESSAGE_VERSION)
+ explicit SupportedAlgorithmsResponse(int32_t ver = MAX_MESSAGE_VERSION)
: SupportedResponse<keymaster_algorithm_t>(ver) {}
};
struct SupportedBlockModesResponse : public SupportedResponse<keymaster_block_mode_t> {
- SupportedBlockModesResponse(int32_t ver = MAX_MESSAGE_VERSION)
+ explicit SupportedBlockModesResponse(int32_t ver = MAX_MESSAGE_VERSION)
: SupportedResponse<keymaster_block_mode_t>(ver) {}
};
struct SupportedPaddingModesResponse : public SupportedResponse<keymaster_padding_t> {
- SupportedPaddingModesResponse(int32_t ver = MAX_MESSAGE_VERSION)
+ explicit SupportedPaddingModesResponse(int32_t ver = MAX_MESSAGE_VERSION)
: SupportedResponse<keymaster_padding_t>(ver) {}
};
struct SupportedDigestsResponse : public SupportedResponse<keymaster_digest_t> {
- SupportedDigestsResponse(int32_t ver = MAX_MESSAGE_VERSION)
+ explicit SupportedDigestsResponse(int32_t ver = MAX_MESSAGE_VERSION)
: SupportedResponse<keymaster_digest_t>(ver) {}
};
struct SupportedImportFormatsResponse : public SupportedResponse<keymaster_key_format_t> {
- SupportedImportFormatsResponse(int32_t ver = MAX_MESSAGE_VERSION)
+ explicit SupportedImportFormatsResponse(int32_t ver = MAX_MESSAGE_VERSION)
: SupportedResponse<keymaster_key_format_t>(ver) {}
};
struct SupportedExportFormatsResponse : public SupportedResponse<keymaster_key_format_t> {
- SupportedExportFormatsResponse(int32_t ver = MAX_MESSAGE_VERSION)
+ explicit SupportedExportFormatsResponse(int32_t ver = MAX_MESSAGE_VERSION)
: SupportedResponse<keymaster_key_format_t>(ver) {}
};
diff --git a/include/keymaster/asymmetric_key_factory.h b/include/keymaster/asymmetric_key_factory.h
index a306d20..afcfc1c 100644
--- a/include/keymaster/asymmetric_key_factory.h
+++ b/include/keymaster/asymmetric_key_factory.h
@@ -27,7 +27,7 @@ namespace keymaster {
class AsymmetricKey;
class AsymmetricKeyFactory : public KeyFactory {
public:
- AsymmetricKeyFactory(const KeymasterContext* context) : KeyFactory(context) {}
+ explicit AsymmetricKeyFactory(const KeymasterContext* context) : KeyFactory(context) {}
keymaster_error_t LoadKey(const KeymasterKeyBlob& key_material,
const AuthorizationSet& additional_params,
diff --git a/include/keymaster/ec_key_factory.h b/include/keymaster/ec_key_factory.h
index 2715e79..aaeb548 100644
--- a/include/keymaster/ec_key_factory.h
+++ b/include/keymaster/ec_key_factory.h
@@ -26,7 +26,7 @@ namespace keymaster {
class EcKeyFactory : public AsymmetricKeyFactory {
public:
- EcKeyFactory(const KeymasterContext* context) : AsymmetricKeyFactory(context) {}
+ explicit EcKeyFactory(const KeymasterContext* context) : AsymmetricKeyFactory(context) {}
keymaster_algorithm_t keymaster_key_type() const override { return KM_ALGORITHM_EC; }
int evp_key_type() const override { return EVP_PKEY_EC; }
diff --git a/include/keymaster/key_factory.h b/include/keymaster/key_factory.h
index c77275a..18f69c4 100644
--- a/include/keymaster/key_factory.h
+++ b/include/keymaster/key_factory.h
@@ -33,7 +33,7 @@ struct KeymasterKeyBlob;
*/
class KeyFactory {
public:
- KeyFactory(const KeymasterContext* context) : context_(context) {}
+ explicit KeyFactory(const KeymasterContext* context) : context_(context) {}
virtual ~KeyFactory() {}
// Factory methods.
diff --git a/include/keymaster/rsa_key_factory.h b/include/keymaster/rsa_key_factory.h
index 03d2dd1..f651652 100644
--- a/include/keymaster/rsa_key_factory.h
+++ b/include/keymaster/rsa_key_factory.h
@@ -26,7 +26,7 @@ namespace keymaster {
class RsaKeyFactory : public AsymmetricKeyFactory {
public:
- RsaKeyFactory(const KeymasterContext* context) : AsymmetricKeyFactory(context) {}
+ explicit RsaKeyFactory(const KeymasterContext* context) : AsymmetricKeyFactory(context) {}
keymaster_error_t GenerateKey(const AuthorizationSet& key_description,
KeymasterKeyBlob* key_blob, AuthorizationSet* hw_enforced,
diff --git a/include/keymaster/serializable.h b/include/keymaster/serializable.h
index 6dd31b2..8748c55 100644
--- a/include/keymaster/serializable.h
+++ b/include/keymaster/serializable.h
@@ -191,7 +191,7 @@ inline bool copy_uint32_array_from_buf(const uint8_t** buf_ptr, const uint8_t* e
class Buffer : public Serializable {
public:
Buffer() : buffer_(NULL), buffer_size_(0), read_position_(0), write_position_(0) {}
- Buffer(size_t size) : buffer_(NULL) { Reinitialize(size); }
+ explicit Buffer(size_t size) : buffer_(NULL) { Reinitialize(size); }
Buffer(const void* buf, size_t size) : buffer_(NULL) { Reinitialize(buf, size); }
// Grow the buffer so that at least \p size bytes can be written.
diff --git a/include/keymaster/soft_keymaster_context.h b/include/keymaster/soft_keymaster_context.h
index d9c02f2..2091d6f 100644
--- a/include/keymaster/soft_keymaster_context.h
+++ b/include/keymaster/soft_keymaster_context.h
@@ -37,7 +37,7 @@ class Keymaster1Engine;
*/
class SoftKeymasterContext : public KeymasterContext {
public:
- SoftKeymasterContext(const std::string& root_of_trust = "SW");
+ explicit SoftKeymasterContext(const std::string& root_of_trust = "SW");
~SoftKeymasterContext() override;
/**
diff --git a/include/keymaster/soft_keymaster_device.h b/include/keymaster/soft_keymaster_device.h
index e9e325d..4a734f1 100644
--- a/include/keymaster/soft_keymaster_device.h
+++ b/include/keymaster/soft_keymaster_device.h
@@ -50,7 +50,7 @@ class SoftKeymasterDevice {
SoftKeymasterDevice();
// Public only for testing.
- SoftKeymasterDevice(SoftKeymasterContext* context);
+ explicit SoftKeymasterDevice(SoftKeymasterContext* context);
/**
* Set SoftKeymasterDevice to wrap the speicified HW keymaster0 device. Takes ownership of the
diff --git a/iso18033kdf.h b/iso18033kdf.h
index 9e26b49..40fd2d6 100644
--- a/iso18033kdf.h
+++ b/iso18033kdf.h
@@ -57,7 +57,7 @@ class Iso18033Kdf : public Kdf {
size_t output_len) override;
protected:
- Iso18033Kdf(uint32_t start_counter) : start_counter_(start_counter) {}
+ explicit Iso18033Kdf(uint32_t start_counter) : start_counter_(start_counter) {}
private:
uint32_t start_counter_;
diff --git a/keymaster0_engine.h b/keymaster0_engine.h
index 8c4970b..aedd85c 100644
--- a/keymaster0_engine.h
+++ b/keymaster0_engine.h
@@ -39,7 +39,7 @@ class Keymaster0Engine {
* Create a Keymaster0Engine, wrapping the provided keymaster0_device. The engine takes
* ownership of the device, and will close it during destruction.
*/
- Keymaster0Engine(const keymaster0_device_t* keymaster0_device);
+ explicit Keymaster0Engine(const keymaster0_device_t* keymaster0_device);
~Keymaster0Engine();
bool supports_ec() const { return supports_ec_; }
diff --git a/keymaster1_engine.h b/keymaster1_engine.h
index a94332e..9e2f13e 100644
--- a/keymaster1_engine.h
+++ b/keymaster1_engine.h
@@ -40,7 +40,7 @@ class Keymaster1Engine {
* Create a Keymaster1Engine, wrapping the provided keymaster1_device. The engine takes
* ownership of the device, and will close it during destruction.
*/
- Keymaster1Engine(const keymaster1_device_t* keymaster1_device);
+ explicit Keymaster1Engine(const keymaster1_device_t* keymaster1_device);
~Keymaster1Engine();
keymaster_error_t GenerateKey(const AuthorizationSet& key_description,
diff --git a/openssl_utils.h b/openssl_utils.h
index 016aea8..034b129 100644
--- a/openssl_utils.h
+++ b/openssl_utils.h
@@ -34,7 +34,7 @@ struct KeymasterKeyBlob;
class EvpMdCtxCleaner {
public:
- EvpMdCtxCleaner(EVP_MD_CTX* ctx) : ctx_(ctx) {}
+ explicit EvpMdCtxCleaner(EVP_MD_CTX* ctx) : ctx_(ctx) {}
~EvpMdCtxCleaner() { EVP_MD_CTX_cleanup(ctx_); }
private:
diff --git a/operation.h b/operation.h
index 1b87e23..aadc406 100644
--- a/operation.h
+++ b/operation.h
@@ -87,7 +87,7 @@ class OperationFactory {
*/
class Operation {
public:
- Operation(keymaster_purpose_t purpose) : purpose_(purpose) {}
+ explicit Operation(keymaster_purpose_t purpose) : purpose_(purpose) {}
virtual ~Operation() {}
keymaster_purpose_t purpose() const { return purpose_; }
diff --git a/operation_table.h b/operation_table.h
index 231284f..c840ad9 100644
--- a/operation_table.h
+++ b/operation_table.h
@@ -27,7 +27,7 @@ class Operation;
class OperationTable {
public:
- OperationTable(size_t table_size) : table_size_(table_size) {}
+ explicit OperationTable(size_t table_size) : table_size_(table_size) {}
struct Entry {
Entry() {
diff --git a/symmetric_key.h b/symmetric_key.h
index 47f3329..979df62 100644
--- a/symmetric_key.h
+++ b/symmetric_key.h
@@ -27,7 +27,7 @@ class SymmetricKey;
class SymmetricKeyFactory : public KeyFactory {
public:
- SymmetricKeyFactory(const KeymasterContext* context) : KeyFactory(context) {}
+ explicit SymmetricKeyFactory(const KeymasterContext* context) : KeyFactory(context) {}
keymaster_error_t GenerateKey(const AuthorizationSet& key_description,
KeymasterKeyBlob* key_blob, AuthorizationSet* hw_enforced,