diff options
author | T.J. Mercier <tjmercier@google.com> | 2022-07-26 23:20:07 +0000 |
---|---|---|
committer | T.J. Mercier <tjmercier@google.com> | 2022-07-26 23:20:07 +0000 |
commit | aed61b19553d125a7c54c73b42f8b8b4a498d9e7 (patch) | |
tree | 058bfad78577a29ad52203a5f8d87cb3d7e9aa3c | |
parent | 39b1ba37020e565a50eec930ebdd99697fa8ab73 (diff) | |
download | keymaster-aed61b19553d125a7c54c73b42f8b8b4a498d9e7.tar.gz |
Fix 6357 warnings from unqualified calls to std::move and std::forward
These warnings are emitted during a build of keymaster:
warning: unqualified call to std::move [-Wunqualified-std-cast-call]
warning: unqualified call to std::forward [-Wunqualified-std-cast-call]
While this package specifies -Werror, unfortunately
-Wno-error=unqualified-std-cast-call is set by the toolchain and is not
overrideable. [1]
Fully qualify uses in headers. Add missing utility include where needed. A
using-declaration in implementation files does not eliminate the warnings,
so fully qualify these as well.
Bug: 239662094
Test: Now builds without these warnings:
Test: $ zcat $ANDROID_BUILD_TOP/out/verbose.log.gz | grep "unqualified call to" | grep keymaster
Test: $
Test: atest keymaster_tests
[1] https://cs.android.com/android/platform/superproject/+/master:build/soong/cc/config/global.go;l=242
Change-Id: Id139061ee2f9fb9edd3a836cc5387d8effb6ccd8
50 files changed, 278 insertions, 163 deletions
diff --git a/android_keymaster/android_keymaster.cpp b/android_keymaster/android_keymaster.cpp index 420bbf2..30c5038 100644 --- a/android_keymaster/android_keymaster.cpp +++ b/android_keymaster/android_keymaster.cpp @@ -16,6 +16,7 @@ #include <keymaster/android_keymaster.h> +#include <utility> #include <vector> #include <assert.h> @@ -146,7 +147,7 @@ AndroidKeymaster::AndroidKeymaster(KeymasterContext* context, size_t operation_t AndroidKeymaster::~AndroidKeymaster() {} AndroidKeymaster::AndroidKeymaster(AndroidKeymaster&& other) - : context_(move(other.context_)), operation_table_(move(other.operation_table_)), + : context_(std::move(other.context_)), operation_table_(std::move(other.operation_table_)), message_version_(other.message_version_) {} // TODO(swillden): Unify support analysis. Right now, we have per-keytype methods that determine if @@ -350,7 +351,7 @@ void AndroidKeymaster::GenerateKey(const GenerateKeyRequest& request, response->enforced.Clear(); response->unenforced.Clear(); response->error = factory->GenerateKey(request.key_description, - move(attest_key), // + std::move(attest_key), // request.issuer_subject, &response->key_blob, // &response->enforced, @@ -528,8 +529,8 @@ void AndroidKeymaster::GetKeyCharacteristics(const GetKeyCharacteristicsRequest& if (response->error != KM_ERROR_OK) return; // scavenge the key object for the auth lists - response->enforced = move(key->hw_enforced()); - response->unenforced = move(key->sw_enforced()); + response->enforced = std::move(key->hw_enforced()); + response->unenforced = std::move(key->sw_enforced()); response->error = CheckVersionInfo(response->enforced, response->unenforced, *context_); } @@ -553,7 +554,7 @@ void AndroidKeymaster::BeginOperation(const BeginOperationRequest& request, uint32_t sd_slot = key->secure_deletion_slot(); OperationPtr operation( - factory->CreateOperation(move(*key), request.additional_params, &response->error)); + factory->CreateOperation(std::move(*key), request.additional_params, &response->error)); if (operation.get() == nullptr) return; operation->set_secure_deletion_slot(sd_slot); @@ -581,7 +582,7 @@ void AndroidKeymaster::BeginOperation(const BeginOperationRequest& request, if (response->error != KM_ERROR_OK) return; response->op_handle = operation->operation_handle(); - response->error = operation_table_->Add(move(operation)); + response->error = operation_table_->Add(std::move(operation)); } void AndroidKeymaster::UpdateOperation(const UpdateOperationRequest& request, @@ -799,7 +800,7 @@ void AndroidKeymaster::ImportKey(const ImportKeyRequest& request, ImportKeyRespo response->error = factory->ImportKey(request.key_description, // request.key_format, // request.key_data, // - move(attest_key), // + std::move(attest_key), // request.issuer_subject, // &response->key_blob, // &response->enforced, // diff --git a/android_keymaster/operation_table.cpp b/android_keymaster/operation_table.cpp index 50d47f5..0d8b431 100644 --- a/android_keymaster/operation_table.cpp +++ b/android_keymaster/operation_table.cpp @@ -14,6 +14,8 @@ * limitations under the License. */ +#include <utility> + #include <keymaster/android_keymaster_utils.h> #include <keymaster/operation.h> #include <keymaster/operation_table.h> @@ -27,7 +29,7 @@ keymaster_error_t OperationTable::Add(OperationPtr&& operation) { } for (size_t i = 0; i < table_size_; ++i) { if (!table_[i]) { - table_[i] = move(operation); + table_[i] = std::move(operation); return KM_ERROR_OK; } } diff --git a/contexts/keymaster1_passthrough_context.cpp b/contexts/keymaster1_passthrough_context.cpp index 02c4623..8dcd5cf 100644 --- a/contexts/keymaster1_passthrough_context.cpp +++ b/contexts/keymaster1_passthrough_context.cpp @@ -17,6 +17,8 @@ #include <keymaster/contexts/keymaster1_passthrough_context.h> +#include <utility> + #include <keymaster/contexts/soft_attestation_cert.h> #include <keymaster/key_blob_utils/integrity_assured_key_blob.h> #include <keymaster/key_blob_utils/ocb_utils.h> @@ -171,8 +173,8 @@ Keymaster1PassthroughContext::ParseKeyBlob(const KeymasterKeyBlob& blob, } auto factory = GetKeyFactory(algorithm); - return factory->LoadKey(move(key_material), additional_params, move(hw_enforced), - move(sw_enforced), key); + return factory->LoadKey(std::move(key_material), additional_params, std::move(hw_enforced), + std::move(sw_enforced), key); } keymaster_error_t Keymaster1PassthroughContext::DeleteKey(const KeymasterKeyBlob& blob) const { diff --git a/contexts/keymaster2_passthrough_context.cpp b/contexts/keymaster2_passthrough_context.cpp index 75ed9b6..23fc145 100644 --- a/contexts/keymaster2_passthrough_context.cpp +++ b/contexts/keymaster2_passthrough_context.cpp @@ -17,6 +17,8 @@ #include <keymaster/contexts/keymaster2_passthrough_context.h> +#include <utility> + #include <keymaster/legacy_support/keymaster_passthrough_engine.h> #include <keymaster/legacy_support/keymaster_passthrough_key.h> @@ -105,8 +107,8 @@ Keymaster2PassthroughContext::ParseKeyBlob(const KeymasterKeyBlob& blob, KeymasterKeyBlob key_material = blob; auto factory = GetKeyFactory(algorithm); - return factory->LoadKey(move(key_material), additional_params, move(hw_enforced), - move(sw_enforced), key); + return factory->LoadKey(std::move(key_material), additional_params, std::move(hw_enforced), + std::move(sw_enforced), key); } keymaster_error_t Keymaster2PassthroughContext::DeleteKey(const KeymasterKeyBlob& blob) const { diff --git a/contexts/pure_soft_keymaster_context.cpp b/contexts/pure_soft_keymaster_context.cpp index 937238b..95b1d29 100644 --- a/contexts/pure_soft_keymaster_context.cpp +++ b/contexts/pure_soft_keymaster_context.cpp @@ -18,6 +18,7 @@ #include <assert.h> #include <memory> +#include <utility> #include <openssl/aes.h> #include <openssl/evp.h> @@ -324,8 +325,8 @@ keymaster_error_t PureSoftKeymasterContext::ParseKeyBlob(const KeymasterKeyBlob& } auto factory = GetKeyFactory(algorithm); - return factory->LoadKey(move(key_material), additional_params, move(hw_enforced), - move(sw_enforced), key); + return factory->LoadKey(std::move(key_material), additional_params, std::move(hw_enforced), + std::move(sw_enforced), key); }; AuthorizationSet hidden; @@ -416,7 +417,8 @@ PureSoftKeymasterContext::GenerateAttestation(const Key& key, AttestKeyInfo attest_key_info(attest_key, &issuer_subject, error); if (*error != KM_ERROR_OK) return {}; - return generate_attestation(asymmetric_key, attest_params, move(attest_key_info), *this, error); + return generate_attestation(asymmetric_key, attest_params, std::move(attest_key_info), *this, + error); } CertificateChain PureSoftKeymasterContext::GenerateSelfSignedCertificate( @@ -508,7 +510,7 @@ keymaster_error_t PureSoftKeymasterContext::UnwrapKey( AuthorizationSet out_params; OperationPtr operation( - operation_factory->CreateOperation(move(*key), wrapping_key_params, &error)); + operation_factory->CreateOperation(std::move(*key), wrapping_key_params, &error)); if (!operation.get()) return error; error = operation->Begin(wrapping_key_params, &out_params); @@ -559,15 +561,16 @@ keymaster_error_t PureSoftKeymasterContext::UnwrapKey( if (!aes_factory) return KM_ERROR_UNKNOWN_ERROR; UniquePtr<Key> aes_key; - error = aes_factory->LoadKey(move(key_material), gcm_params, move(transit_key_authorizations), - AuthorizationSet(), &aes_key); + error = aes_factory->LoadKey(std::move(key_material), gcm_params, + std::move(transit_key_authorizations), AuthorizationSet(), + &aes_key); if (error != KM_ERROR_OK) return error; auto aes_operation_factory = GetOperationFactory(KM_ALGORITHM_AES, KM_PURPOSE_DECRYPT); if (!aes_operation_factory) return KM_ERROR_UNKNOWN_ERROR; OperationPtr aes_operation( - aes_operation_factory->CreateOperation(move(*aes_key), gcm_params, &error)); + aes_operation_factory->CreateOperation(std::move(*aes_key), gcm_params, &error)); if (!aes_operation.get()) return error; error = aes_operation->Begin(gcm_params, &out_params); diff --git a/contexts/soft_keymaster_context.cpp b/contexts/soft_keymaster_context.cpp index 66c1a57..ed216b1 100644 --- a/contexts/soft_keymaster_context.cpp +++ b/contexts/soft_keymaster_context.cpp @@ -273,8 +273,8 @@ keymaster_error_t SoftKeymasterContext::ParseKeyBlob(const KeymasterKeyBlob& blo return KM_ERROR_INVALID_ARGUMENT; } auto factory = GetKeyFactory(algorithm); - return factory->LoadKey(move(key_material), additional_params, move(hw_enforced), - move(sw_enforced), key); + return factory->LoadKey(std::move(key_material), additional_params, std::move(hw_enforced), + std::move(sw_enforced), key); }; error = BuildHiddenAuthorizations(additional_params, &hidden, root_of_trust_); diff --git a/include/keymaster/android_keymaster_messages.h b/include/keymaster/android_keymaster_messages.h index 6e38860..528eb78 100644 --- a/include/keymaster/android_keymaster_messages.h +++ b/include/keymaster/android_keymaster_messages.h @@ -23,6 +23,7 @@ #include <string> #include <string_view> +#include <utility> #include <vector> #include <keymaster/android_keymaster_utils.h> @@ -768,11 +769,11 @@ using ConfigureResponse = EmptyKeymasterResponse; struct HmacSharingParameters : public Serializable { HmacSharingParameters() : seed({}) { memset(nonce, 0, sizeof(nonce)); } HmacSharingParameters(HmacSharingParameters&& other) { - seed = move(other.seed); + seed = std::move(other.seed); memcpy(nonce, other.nonce, sizeof(nonce)); } - void SetSeed(KeymasterBlob&& value) { seed = move(value); } + void SetSeed(KeymasterBlob&& value) { seed = std::move(value); } size_t SerializedSize() const override; uint8_t* Serialize(uint8_t* buf, const uint8_t* end) const override; @@ -808,9 +809,9 @@ struct GetHmacSharingParametersRequest : public EmptyKeymasterRequest { struct GetHmacSharingParametersResponse : public KeymasterResponse { explicit GetHmacSharingParametersResponse(int32_t ver) : KeymasterResponse(ver) {} GetHmacSharingParametersResponse(GetHmacSharingParametersResponse&& other) - : KeymasterResponse(other.message_version), params(move(other.params)) {} + : KeymasterResponse(other.message_version), params(std::move(other.params)) {} - void SetSeed(KeymasterBlob&& seed_data) { params.SetSeed(move(seed_data)); } + void SetSeed(KeymasterBlob&& seed_data) { params.SetSeed(std::move(seed_data)); } size_t NonErrorSerializedSize() const override { return params.SerializedSize(); } uint8_t* NonErrorSerialize(uint8_t* buf, const uint8_t* end) const override { @@ -841,7 +842,7 @@ struct ComputeSharedHmacResponse : public KeymasterResponse { explicit ComputeSharedHmacResponse(int32_t ver) : KeymasterResponse(ver) {} ComputeSharedHmacResponse(ComputeSharedHmacResponse&& other) : KeymasterResponse(other.message_version) { - sharing_check = move(other.sharing_check); + sharing_check = std::move(other.sharing_check); } size_t NonErrorSerializedSize() const override; @@ -901,7 +902,7 @@ struct HardwareAuthToken : public Serializable { authenticator_id = other.authenticator_id; authenticator_type = other.authenticator_type; timestamp = other.timestamp; - mac = move(other.mac); + mac = std::move(other.mac); } size_t SerializedSize() const override; @@ -921,9 +922,9 @@ struct VerificationToken : public Serializable { VerificationToken(VerificationToken&& other) { challenge = other.challenge; timestamp = other.timestamp; - parameters_verified = move(other.parameters_verified); + parameters_verified = std::move(other.parameters_verified); security_level = other.security_level; - mac = move(other.mac); + mac = std::move(other.mac); } size_t SerializedSize() const override; @@ -996,7 +997,7 @@ struct EarlyBootEndedResponse : public KeymasterResponse { struct DeviceLockedRequest : public KeymasterMessage { explicit DeviceLockedRequest(int32_t ver) : KeymasterMessage(ver) {} explicit DeviceLockedRequest(int32_t ver, bool passwordOnly_, VerificationToken&& token_) - : KeymasterMessage(ver), passwordOnly(passwordOnly_), token(move(token_)) {} + : KeymasterMessage(ver), passwordOnly(passwordOnly_), token(std::move(token_)) {} size_t SerializedSize() const override { return 1; } uint8_t* Serialize(uint8_t* buf, const uint8_t* end) const override { @@ -1059,7 +1060,7 @@ struct TimestampToken : public Serializable { challenge = other.challenge; timestamp = other.timestamp; security_level = other.security_level; - mac = move(other.mac); + mac = std::move(other.mac); } size_t SerializedSize() const override { return sizeof(challenge) + sizeof(timestamp) + sizeof(security_level) + diff --git a/include/keymaster/android_keymaster_utils.h b/include/keymaster/android_keymaster_utils.h index 324287a..519bd82 100644 --- a/include/keymaster/android_keymaster_utils.h +++ b/include/keymaster/android_keymaster_utils.h @@ -16,6 +16,8 @@ #pragma once +#include <utility> + #include <stdint.h> #include <time.h> // for time_t. @@ -253,7 +255,7 @@ keymaster_error_t EcCurveToKeySize(keymaster_ec_curve_t curve, uint32_t* key_siz template <class F> class final_action { public: - explicit final_action(F f) : f_(move(f)) {} + explicit final_action(F f) : f_(std::move(f)) {} ~final_action() { f_(); } private: @@ -280,7 +282,8 @@ struct CertificateChain : public keymaster_cert_chain_t { } } - CertificateChain(CertificateChain&& other) : keymaster_cert_chain_t{} { *this = move(other); } + CertificateChain(CertificateChain&& other) : keymaster_cert_chain_t{} + { *this = std::move(other); } ~CertificateChain() { Clear(); } diff --git a/include/keymaster/authorization_set.h b/include/keymaster/authorization_set.h index ce3ef75..6fff0d3 100644 --- a/include/keymaster/authorization_set.h +++ b/include/keymaster/authorization_set.h @@ -16,6 +16,8 @@ #pragma once +#include <utility> + #include <keymaster/UniquePtr.h> #include <hardware/keymaster_defs.h> @@ -692,18 +694,18 @@ class AuthProxy { : hw_enforced_(hw_enforced), sw_enforced_(sw_enforced) {} template <typename... ARGS> bool Contains(ARGS&&... args) const { - return hw_enforced_.Contains(forward<ARGS>(args)...) || - sw_enforced_.Contains(forward<ARGS>(args)...); + return hw_enforced_.Contains(std::forward<ARGS>(args)...) || + sw_enforced_.Contains(std::forward<ARGS>(args)...); } template <typename... ARGS> bool GetTagValue(ARGS&&... args) const { - return hw_enforced_.GetTagValue(forward<ARGS>(args)...) || - sw_enforced_.GetTagValue(forward<ARGS>(args)...); + return hw_enforced_.GetTagValue(std::forward<ARGS>(args)...) || + sw_enforced_.GetTagValue(std::forward<ARGS>(args)...); } template <typename... ARGS> bool GetTagCount(ARGS&&... args) const { - return hw_enforced_.GetTagCount(forward<ARGS>(args)...) || - sw_enforced_.GetTagCount(forward<ARGS>(args)...); + return hw_enforced_.GetTagCount(std::forward<ARGS>(args)...) || + sw_enforced_.GetTagCount(std::forward<ARGS>(args)...); } AuthProxyIterator begin() const { return AuthProxyIterator(hw_enforced_, sw_enforced_); } diff --git a/include/keymaster/key.h b/include/keymaster/key.h index eb0f026..2653e24 100644 --- a/include/keymaster/key.h +++ b/include/keymaster/key.h @@ -17,6 +17,8 @@ #ifndef SYSTEM_KEYMASTER_KEY_H_ #define SYSTEM_KEYMASTER_KEY_H_ +#include <utility> + #include <assert.h> #include <hardware/keymaster_defs.h> @@ -53,9 +55,9 @@ class Key { // Methods to move data out of the key. These could be overloads of the methods above, with ref // qualifiers, but naming them differently makes it harder to accidentally make a temporary copy // when we mean to move. - AuthorizationSet&& hw_enforced_move() { return move(hw_enforced_); } - AuthorizationSet&& sw_enforced_move() { return move(sw_enforced_); } - KeymasterKeyBlob&& key_material_move() { return move(key_material_); } + AuthorizationSet&& hw_enforced_move() { return std::move(hw_enforced_); } + AuthorizationSet&& sw_enforced_move() { return std::move(sw_enforced_); } + KeymasterKeyBlob&& key_material_move() { return std::move(key_material_); } const KeyFactory* key_factory() const { return key_factory_; } const KeyFactory*& key_factory() { return key_factory_; } @@ -66,7 +68,7 @@ class Key { protected: Key(AuthorizationSet&& hw_enforced, AuthorizationSet&& sw_enforced, const KeyFactory* key_factory) - : hw_enforced_(move(hw_enforced)), sw_enforced_(move(sw_enforced)), + : hw_enforced_(std::move(hw_enforced)), sw_enforced_(std::move(sw_enforced)), key_factory_(key_factory) {} protected: diff --git a/include/keymaster/km_openssl/aes_key.h b/include/keymaster/km_openssl/aes_key.h index f00a665..95cfc5f 100644 --- a/include/keymaster/km_openssl/aes_key.h +++ b/include/keymaster/km_openssl/aes_key.h @@ -16,6 +16,8 @@ #pragma once +#include <utility> + #include <openssl/aes.h> #include "symmetric_key.h" @@ -52,7 +54,8 @@ class AesKey : public SymmetricKey { public: AesKey(KeymasterKeyBlob&& key_material, AuthorizationSet&& hw_enforced, AuthorizationSet&& sw_enforced, const KeyFactory* key_factory) - : SymmetricKey(move(key_material), move(hw_enforced), move(sw_enforced), key_factory) {} + : SymmetricKey(std::move(key_material), std::move(hw_enforced), std::move(sw_enforced), + key_factory) {} }; } // namespace keymaster diff --git a/include/keymaster/km_openssl/asymmetric_key.h b/include/keymaster/km_openssl/asymmetric_key.h index b523116..816930e 100644 --- a/include/keymaster/km_openssl/asymmetric_key.h +++ b/include/keymaster/km_openssl/asymmetric_key.h @@ -17,6 +17,8 @@ #ifndef SYSTEM_KEYMASTER_ASYMMETRIC_KEY_H #define SYSTEM_KEYMASTER_ASYMMETRIC_KEY_H +#include <utility> + #include <openssl/evp.h> #include <keymaster/key.h> @@ -28,7 +30,7 @@ class AsymmetricKey : public Key { public: AsymmetricKey(AuthorizationSet&& hw_enforced, AuthorizationSet&& sw_enforced, const KeyFactory* key_factory) - : Key(move(hw_enforced), move(sw_enforced), key_factory) {} + : Key(std::move(hw_enforced), std::move(sw_enforced), key_factory) {} virtual ~AsymmetricKey() {} virtual int evp_key_type() const = 0; diff --git a/include/keymaster/km_openssl/curve25519_key.h b/include/keymaster/km_openssl/curve25519_key.h index f5f168e..c1aedef 100644 --- a/include/keymaster/km_openssl/curve25519_key.h +++ b/include/keymaster/km_openssl/curve25519_key.h @@ -16,6 +16,8 @@ #pragma once +#include <utility> + #include <keymaster/km_openssl/asymmetric_key.h> #include <keymaster/km_openssl/openssl_utils.h> @@ -36,10 +38,10 @@ class Curve25519Key : public AsymmetricKey { public: Curve25519Key(AuthorizationSet hw_enforced, AuthorizationSet sw_enforced, const KeyFactory* factory) - : AsymmetricKey(move(hw_enforced), move(sw_enforced), factory) {} + : AsymmetricKey(std::move(hw_enforced), std::move(sw_enforced), factory) {} Curve25519Key(AuthorizationSet hw_enforced, AuthorizationSet sw_enforced, const KeyFactory* factory, const KeymasterKeyBlob& key_material) - : AsymmetricKey(move(hw_enforced), move(sw_enforced), factory) { + : AsymmetricKey(std::move(hw_enforced), std::move(sw_enforced), factory) { key_material_ = key_material; } diff --git a/include/keymaster/km_openssl/ec_key.h b/include/keymaster/km_openssl/ec_key.h index 9ad5c70..e7feb1e 100644 --- a/include/keymaster/km_openssl/ec_key.h +++ b/include/keymaster/km_openssl/ec_key.h @@ -16,6 +16,8 @@ #pragma once +#include <utility> + #include <openssl/ec.h> #include <keymaster/km_openssl/asymmetric_key.h> @@ -28,10 +30,11 @@ class EcdsaOperationFactory; class EcKey : public AsymmetricKey { public: EcKey(AuthorizationSet hw_enforced, AuthorizationSet sw_enforced, const KeyFactory* factory) - : AsymmetricKey(move(hw_enforced), move(sw_enforced), factory) {} + : AsymmetricKey(std::move(hw_enforced), std::move(sw_enforced), factory) {} EcKey(AuthorizationSet hw_enforced, AuthorizationSet sw_enforced, const KeyFactory* factory, EC_KEY_Ptr ec_key) - : AsymmetricKey(move(hw_enforced), move(sw_enforced), factory), ec_key_(move(ec_key)) {} + : AsymmetricKey(std::move(hw_enforced), std::move(sw_enforced), factory), + ec_key_(std::move(ec_key)) {} int evp_key_type() const override { return EVP_PKEY_EC; } @@ -43,7 +46,8 @@ class EcKey : public AsymmetricKey { protected: EcKey(EC_KEY* ec_key, AuthorizationSet hw_enforced, AuthorizationSet sw_enforced, const KeyFactory* key_factory) - : AsymmetricKey(move(hw_enforced), move(sw_enforced), key_factory), ec_key_(ec_key) {} + : AsymmetricKey(std::move(hw_enforced), std::move(sw_enforced), key_factory), + ec_key_(ec_key) {} private: EC_KEY_Ptr ec_key_; diff --git a/include/keymaster/km_openssl/ecdh_operation.h b/include/keymaster/km_openssl/ecdh_operation.h index 6a96009..00b8a2c 100644 --- a/include/keymaster/km_openssl/ecdh_operation.h +++ b/include/keymaster/km_openssl/ecdh_operation.h @@ -17,6 +17,8 @@ #ifndef SYSTEM_KEYMASTER_ECDH_OPERATION_H_ #define SYSTEM_KEYMASTER_ECDH_OPERATION_H_ +#include <utility> + #include <openssl/ec.h> #include <openssl/evp.h> @@ -31,7 +33,8 @@ namespace keymaster { class EcdhOperation : public Operation { public: EcdhOperation(AuthorizationSet&& hw_enforced, AuthorizationSet&& sw_enforced, EVP_PKEY* key) - : Operation(KM_PURPOSE_AGREE_KEY, move(hw_enforced), move(sw_enforced)), ecdh_key_(key) {} + : Operation(KM_PURPOSE_AGREE_KEY, std::move(hw_enforced), std::move(sw_enforced)), + ecdh_key_(key) {} keymaster_error_t Abort() override { return KM_ERROR_OK; } @@ -51,7 +54,7 @@ class EcdhOperation : public Operation { class X25519Operation : public EcdhOperation { public: X25519Operation(AuthorizationSet&& hw_enforced, AuthorizationSet&& sw_enforced, EVP_PKEY* key) - : EcdhOperation(move(hw_enforced), move(sw_enforced), key) {} + : EcdhOperation(std::move(hw_enforced), std::move(sw_enforced), key) {} keymaster_error_t Finish(const AuthorizationSet& additional_params, const Buffer& input, const Buffer& signature, AuthorizationSet* output_params, diff --git a/include/keymaster/km_openssl/ecdsa_operation.h b/include/keymaster/km_openssl/ecdsa_operation.h index 457c381..f423bef 100644 --- a/include/keymaster/km_openssl/ecdsa_operation.h +++ b/include/keymaster/km_openssl/ecdsa_operation.h @@ -17,6 +17,8 @@ #ifndef SYSTEM_KEYMASTER_ECDSA_OPERATION_H_ #define SYSTEM_KEYMASTER_ECDSA_OPERATION_H_ +#include <utility> + #include <openssl/ec.h> #include <openssl/evp.h> @@ -32,7 +34,7 @@ class EcdsaOperation : public Operation { public: EcdsaOperation(AuthorizationSet&& hw_enforced, AuthorizationSet&& sw_enforced, keymaster_purpose_t purpose, keymaster_digest_t digest, EVP_PKEY* key) - : Operation(purpose, move(hw_enforced), move(sw_enforced)), digest_(digest), + : Operation(purpose, std::move(hw_enforced), std::move(sw_enforced)), digest_(digest), digest_algorithm_(nullptr), ecdsa_key_(key) { EVP_MD_CTX_init(&digest_ctx_); } @@ -55,7 +57,8 @@ class EcdsaSignOperation : public EcdsaOperation { public: EcdsaSignOperation(AuthorizationSet&& hw_enforced, AuthorizationSet&& sw_enforced, keymaster_digest_t digest, EVP_PKEY* key) - : EcdsaOperation(move(hw_enforced), move(sw_enforced), KM_PURPOSE_SIGN, digest, key) {} + : EcdsaOperation(std::move(hw_enforced), std::move(sw_enforced), KM_PURPOSE_SIGN, digest, + key) {} keymaster_error_t Begin(const AuthorizationSet& input_params, AuthorizationSet* output_params) override; keymaster_error_t Update(const AuthorizationSet& additional_params, const Buffer& input, @@ -70,7 +73,8 @@ class EcdsaVerifyOperation : public EcdsaOperation { public: EcdsaVerifyOperation(AuthorizationSet&& hw_enforced, AuthorizationSet&& sw_enforced, keymaster_digest_t digest, EVP_PKEY* key) - : EcdsaOperation(move(hw_enforced), move(sw_enforced), KM_PURPOSE_VERIFY, digest, key) {} + : EcdsaOperation(std::move(hw_enforced), std::move(sw_enforced), KM_PURPOSE_VERIFY, digest, + key) {} keymaster_error_t Begin(const AuthorizationSet& input_params, AuthorizationSet* output_params) override; keymaster_error_t Update(const AuthorizationSet& additional_params, const Buffer& input, @@ -85,7 +89,7 @@ class Ed25519SignOperation : public EcdsaSignOperation { public: Ed25519SignOperation(AuthorizationSet&& hw_enforced, AuthorizationSet&& sw_enforced, keymaster_digest_t digest, EVP_PKEY* key) - : EcdsaSignOperation(move(hw_enforced), move(sw_enforced), digest, key) {} + : EcdsaSignOperation(std::move(hw_enforced), std::move(sw_enforced), digest, key) {} keymaster_error_t Begin(const AuthorizationSet& input_params, AuthorizationSet* output_params) override; keymaster_error_t Update(const AuthorizationSet& additional_params, const Buffer& input, @@ -119,10 +123,10 @@ class EcdsaSignOperationFactory : public EcdsaOperationFactory { keymaster_digest_t digest, EVP_PKEY* key) override { if (IsEd25519Key(hw_enforced, sw_enforced)) { return new (std::nothrow) - Ed25519SignOperation(move(hw_enforced), move(sw_enforced), digest, key); + Ed25519SignOperation(std::move(hw_enforced), std::move(sw_enforced), digest, key); } else { return new (std::nothrow) - EcdsaSignOperation(move(hw_enforced), move(sw_enforced), digest, key); + EcdsaSignOperation(std::move(hw_enforced), std::move(sw_enforced), digest, key); } } }; @@ -133,7 +137,7 @@ class EcdsaVerifyOperationFactory : public EcdsaOperationFactory { Operation* InstantiateOperation(AuthorizationSet&& hw_enforced, AuthorizationSet&& sw_enforced, keymaster_digest_t digest, EVP_PKEY* key) override { return new (std::nothrow) - EcdsaVerifyOperation(move(hw_enforced), move(sw_enforced), digest, key); + EcdsaVerifyOperation(std::move(hw_enforced), std::move(sw_enforced), digest, key); } }; diff --git a/include/keymaster/km_openssl/hmac_key.h b/include/keymaster/km_openssl/hmac_key.h index 55d802a..3e2df2b 100644 --- a/include/keymaster/km_openssl/hmac_key.h +++ b/include/keymaster/km_openssl/hmac_key.h @@ -16,6 +16,8 @@ #pragma once +#include <utility> + #include "symmetric_key.h" namespace keymaster { @@ -50,7 +52,8 @@ class HmacKey : public SymmetricKey { public: HmacKey(KeymasterKeyBlob&& key_material, AuthorizationSet&& hw_enforced, AuthorizationSet&& sw_enforced, const KeyFactory* key_factory) - : SymmetricKey(move(key_material), move(hw_enforced), move(sw_enforced), key_factory) {} + : SymmetricKey(std::move(key_material), std::move(hw_enforced), std::move(sw_enforced), + key_factory) {} }; } // namespace keymaster diff --git a/include/keymaster/km_openssl/rsa_key.h b/include/keymaster/km_openssl/rsa_key.h index 3cd7c3a..6ea6919 100644 --- a/include/keymaster/km_openssl/rsa_key.h +++ b/include/keymaster/km_openssl/rsa_key.h @@ -17,6 +17,8 @@ #ifndef SYSTEM_KEYMASTER_RSA_KEY_H_ #define SYSTEM_KEYMASTER_RSA_KEY_H_ +#include <utility> + #include <openssl/rsa.h> #include <keymaster/km_openssl/openssl_utils.h> @@ -28,10 +30,11 @@ namespace keymaster { class RsaKey : public AsymmetricKey { public: RsaKey(AuthorizationSet hw_enforced, AuthorizationSet sw_enforced, const KeyFactory* factory) - : AsymmetricKey(move(hw_enforced), move(sw_enforced), factory) {} + : AsymmetricKey(std::move(hw_enforced), std::move(sw_enforced), factory) {} RsaKey(AuthorizationSet hw_enforced, AuthorizationSet sw_enforced, const KeyFactory* factory, RSA_Ptr rsa_key) - : AsymmetricKey(move(hw_enforced), move(sw_enforced), factory), rsa_key_(move(rsa_key)) {} + : AsymmetricKey(std::move(hw_enforced), std::move(sw_enforced), factory), + rsa_key_(std::move(rsa_key)) {} int evp_key_type() const override { return EVP_PKEY_RSA; } @@ -46,7 +49,8 @@ class RsaKey : public AsymmetricKey { protected: RsaKey(RSA* rsa, AuthorizationSet hw_enforced, AuthorizationSet sw_enforced, const KeyFactory* key_factory) - : AsymmetricKey(move(hw_enforced), move(sw_enforced), key_factory), rsa_key_(rsa) {} + : AsymmetricKey(std::move(hw_enforced), std::move(sw_enforced), key_factory), rsa_key_(rsa) + {} private: RSA_Ptr rsa_key_; diff --git a/include/keymaster/km_openssl/rsa_operation.h b/include/keymaster/km_openssl/rsa_operation.h index 99004f2..cb4422f 100644 --- a/include/keymaster/km_openssl/rsa_operation.h +++ b/include/keymaster/km_openssl/rsa_operation.h @@ -17,6 +17,8 @@ #ifndef SYSTEM_KEYMASTER_RSA_OPERATION_H_ #define SYSTEM_KEYMASTER_RSA_OPERATION_H_ +#include <utility> + #include <keymaster/UniquePtr.h> #include <openssl/evp.h> @@ -36,7 +38,7 @@ class RsaOperation : public Operation { RsaOperation(AuthorizationSet&& hw_enforced, AuthorizationSet&& sw_enforced, keymaster_purpose_t purpose, keymaster_digest_t digest, keymaster_padding_t padding, EVP_PKEY* key) - : Operation(purpose, move(hw_enforced), move(sw_enforced)), rsa_key_(key), + : Operation(purpose, std::move(hw_enforced), std::move(sw_enforced)), rsa_key_(key), padding_(padding), digest_(digest), digest_algorithm_(nullptr) {} ~RsaOperation(); @@ -91,8 +93,8 @@ class RsaSignOperation : public RsaDigestingOperation { public: RsaSignOperation(AuthorizationSet&& hw_enforced, AuthorizationSet&& sw_enforced, keymaster_digest_t digest, keymaster_padding_t padding, EVP_PKEY* key) - : RsaDigestingOperation(move(hw_enforced), move(sw_enforced), KM_PURPOSE_SIGN, digest, - padding, key) {} + : RsaDigestingOperation(std::move(hw_enforced), std::move(sw_enforced), KM_PURPOSE_SIGN, + digest, padding, key) {} keymaster_error_t Begin(const AuthorizationSet& input_params, AuthorizationSet* output_params) override; @@ -115,8 +117,8 @@ class RsaVerifyOperation : public RsaDigestingOperation { public: RsaVerifyOperation(AuthorizationSet&& hw_enforced, AuthorizationSet&& sw_enforced, keymaster_digest_t digest, keymaster_padding_t padding, EVP_PKEY* key) - : RsaDigestingOperation(move(hw_enforced), move(sw_enforced), KM_PURPOSE_VERIFY, digest, - padding, key) {} + : RsaDigestingOperation(std::move(hw_enforced), std::move(sw_enforced), KM_PURPOSE_VERIFY, + digest, padding, key) {} keymaster_error_t Begin(const AuthorizationSet& input_params, AuthorizationSet* output_params) override; @@ -140,7 +142,8 @@ class RsaCryptOperation : public RsaOperation { RsaCryptOperation(AuthorizationSet&& hw_enforced, AuthorizationSet&& sw_enforced, keymaster_purpose_t purpose, keymaster_digest_t digest, keymaster_padding_t padding, EVP_PKEY* key) - : RsaOperation(move(hw_enforced), move(sw_enforced), purpose, digest, padding, key), + : RsaOperation(std::move(hw_enforced), std::move(sw_enforced), purpose, digest, padding, + key), mgf_digest_(KM_DIGEST_SHA1), mgf_digest_algorithm_(nullptr) {} keymaster_digest_t oaepMgfDigest() { return mgf_digest_; } void setOaepMgfDigest(keymaster_digest_t mgf_digest) { mgf_digest_ = mgf_digest; } @@ -165,8 +168,8 @@ class RsaEncryptOperation : public RsaCryptOperation { public: RsaEncryptOperation(AuthorizationSet&& hw_enforced, AuthorizationSet&& sw_enforced, keymaster_digest_t digest, keymaster_padding_t padding, EVP_PKEY* key) - : RsaCryptOperation(move(hw_enforced), move(sw_enforced), KM_PURPOSE_ENCRYPT, digest, - padding, key) {} + : RsaCryptOperation(std::move(hw_enforced), std::move(sw_enforced), KM_PURPOSE_ENCRYPT, + digest, padding, key) {} keymaster_error_t Finish(const AuthorizationSet& additional_params, const Buffer& input, const Buffer& signature, AuthorizationSet* output_params, Buffer* output) override; @@ -179,8 +182,8 @@ class RsaDecryptOperation : public RsaCryptOperation { public: RsaDecryptOperation(AuthorizationSet&& hw_enforced, AuthorizationSet&& sw_enforced, keymaster_digest_t digest, keymaster_padding_t padding, EVP_PKEY* key) - : RsaCryptOperation(move(hw_enforced), move(sw_enforced), KM_PURPOSE_DECRYPT, digest, - padding, key) {} + : RsaCryptOperation(std::move(hw_enforced), std::move(sw_enforced), KM_PURPOSE_DECRYPT, + digest, padding, key) {} keymaster_error_t Finish(const AuthorizationSet& additional_params, const Buffer& input, const Buffer& signature, AuthorizationSet* output_params, Buffer* output) override; @@ -197,7 +200,7 @@ class RsaOperationFactory : public OperationFactory { OperationPtr CreateOperation(Key&& key, const AuthorizationSet& begin_params, keymaster_error_t* error) override { - return OperationPtr(CreateRsaOperation(move(key), begin_params, error)); + return OperationPtr(CreateRsaOperation(std::move(key), begin_params, error)); } const keymaster_digest_t* SupportedDigests(size_t* digest_count) const override; @@ -246,7 +249,7 @@ class RsaSigningOperationFactory : public RsaDigestingOperationFactory { AuthorizationSet&& sw_enforced, keymaster_digest_t digest, keymaster_padding_t padding, EVP_PKEY* key) override { return new (std::nothrow) - RsaSignOperation(move(hw_enforced), move(sw_enforced), digest, padding, key); + RsaSignOperation(std::move(hw_enforced), std::move(sw_enforced), digest, padding, key); } }; @@ -259,7 +262,8 @@ class RsaVerificationOperationFactory : public RsaDigestingOperationFactory { AuthorizationSet&& sw_enforced, keymaster_digest_t digest, keymaster_padding_t padding, EVP_PKEY* key) override { return new (std::nothrow) - RsaVerifyOperation(move(hw_enforced), move(sw_enforced), digest, padding, key); + RsaVerifyOperation(std::move(hw_enforced), std::move(sw_enforced), digest, padding, + key); } }; @@ -272,7 +276,8 @@ class RsaEncryptionOperationFactory : public RsaCryptingOperationFactory { AuthorizationSet&& sw_enforced, keymaster_digest_t digest, keymaster_padding_t padding, EVP_PKEY* key) override { return new (std::nothrow) - RsaEncryptOperation(move(hw_enforced), move(sw_enforced), digest, padding, key); + RsaEncryptOperation(std::move(hw_enforced), std::move(sw_enforced), digest, padding, + key); } }; @@ -285,7 +290,8 @@ class RsaDecryptionOperationFactory : public RsaCryptingOperationFactory { AuthorizationSet&& sw_enforced, keymaster_digest_t digest, keymaster_padding_t padding, EVP_PKEY* key) override { return new (std::nothrow) - RsaDecryptOperation(move(hw_enforced), move(sw_enforced), digest, padding, key); + RsaDecryptOperation(std::move(hw_enforced), std::move(sw_enforced), digest, padding, + key); } }; diff --git a/include/keymaster/km_openssl/triple_des_key.h b/include/keymaster/km_openssl/triple_des_key.h index a03d595..5e8f3fc 100644 --- a/include/keymaster/km_openssl/triple_des_key.h +++ b/include/keymaster/km_openssl/triple_des_key.h @@ -17,6 +17,8 @@ #ifndef SYSTEM_KEYMASTER_TRIPLE_DES_KEY_H_ #define SYSTEM_KEYMASTER_TRIPLE_DES_KEY_H_ +#include <utility> + #include <openssl/des.h> #include "symmetric_key.h" @@ -53,7 +55,8 @@ class TripleDesKey : public SymmetricKey { public: TripleDesKey(KeymasterKeyBlob&& key_material, AuthorizationSet&& hw_enforced, AuthorizationSet&& sw_enforced, const KeyFactory* key_factory) - : SymmetricKey(move(key_material), move(hw_enforced), move(sw_enforced), key_factory) {} + : SymmetricKey(std::move(key_material), std::move(hw_enforced), std::move(sw_enforced), + key_factory) {} }; } // namespace keymaster diff --git a/include/keymaster/legacy_support/ec_keymaster1_key.h b/include/keymaster/legacy_support/ec_keymaster1_key.h index d695c74..88adf64 100644 --- a/include/keymaster/legacy_support/ec_keymaster1_key.h +++ b/include/keymaster/legacy_support/ec_keymaster1_key.h @@ -16,6 +16,8 @@ #pragma once +#include <utility> + #include <openssl/ecdsa.h> #include <hardware/keymaster1.h> @@ -77,7 +79,7 @@ class EcdsaKeymaster1Key : public EcKey { public: EcdsaKeymaster1Key(EC_KEY* ecdsa_key, AuthorizationSet&& hw_enforced, AuthorizationSet&& sw_enforced, const KeyFactory* key_factory) - : EcKey(ecdsa_key, move(hw_enforced), move(sw_enforced), key_factory) {} + : EcKey(ecdsa_key, std::move(hw_enforced), std::move(sw_enforced), key_factory) {} }; } // namespace keymaster diff --git a/include/keymaster/legacy_support/keymaster1_legacy_support.h b/include/keymaster/legacy_support/keymaster1_legacy_support.h index a09b5e5..531f1a1 100644 --- a/include/keymaster/legacy_support/keymaster1_legacy_support.h +++ b/include/keymaster/legacy_support/keymaster1_legacy_support.h @@ -18,6 +18,7 @@ #pragma once #include <map> +#include <utility> #include <vector> #include <hardware/keymaster1.h> @@ -61,7 +62,7 @@ template <typename KM1_SOFTDIGEST_FACTORY> class Keymaster1ArbitrationFactory : Keymaster1ArbitrationFactory(const KeymasterPassthroughEngine* ptengine, keymaster_algorithm_t algorithm, const keymaster1_device_t* dev, SOFT_FACTORY_CONSRUCTOR_ARGS&&... args) - : software_digest_factory_(forward<SOFT_FACTORY_CONSRUCTOR_ARGS>(args)...), + : software_digest_factory_(std::forward<SOFT_FACTORY_CONSRUCTOR_ARGS>(args)...), passthrough_factory_(ptengine, algorithm), legacy_support_(dev) {} keymaster_error_t GenerateKey(const AuthorizationSet& key_description, UniquePtr<Key> attest_key, // @@ -71,11 +72,11 @@ template <typename KM1_SOFTDIGEST_FACTORY> class Keymaster1ArbitrationFactory : AuthorizationSet* sw_enforced, CertificateChain* cert_chain) const { if (legacy_support_.RequiresSoftwareDigesting(key_description)) { - return software_digest_factory_.GenerateKey(key_description, move(attest_key), + return software_digest_factory_.GenerateKey(key_description, std::move(attest_key), issuer_subject, key_blob, hw_enforced, sw_enforced, cert_chain); } else { - return passthrough_factory_.GenerateKey(key_description, move(attest_key), + return passthrough_factory_.GenerateKey(key_description, std::move(attest_key), issuer_subject, key_blob, hw_enforced, sw_enforced, cert_chain); } @@ -91,12 +92,14 @@ template <typename KM1_SOFTDIGEST_FACTORY> class Keymaster1ArbitrationFactory : AuthorizationSet* sw_enforced, CertificateChain* cert_chain) const { if (legacy_support_.RequiresSoftwareDigesting(key_description)) { return software_digest_factory_.ImportKey( - key_description, input_key_material_format, input_key_material, move(attest_key), - issuer_subject, output_key_blob, hw_enforced, sw_enforced, cert_chain); + key_description, input_key_material_format, input_key_material, + std::move(attest_key), issuer_subject, output_key_blob, hw_enforced, sw_enforced, + cert_chain); } else { return passthrough_factory_.ImportKey( - key_description, input_key_material_format, input_key_material, move(attest_key), - issuer_subject, output_key_blob, hw_enforced, sw_enforced, cert_chain); + key_description, input_key_material_format, input_key_material, + std::move(attest_key), issuer_subject, output_key_blob, hw_enforced, sw_enforced, + cert_chain); } } @@ -111,11 +114,13 @@ template <typename KM1_SOFTDIGEST_FACTORY> class Keymaster1ArbitrationFactory : if (legacy_support_.RequiresSoftwareDigesting(digest, AuthProxy(hw_enforced, sw_enforced))) { - return software_digest_factory_.LoadKey(move(key_material), additional_params, - move(hw_enforced), move(sw_enforced), key); + return software_digest_factory_.LoadKey(std::move(key_material), additional_params, + std::move(hw_enforced), std::move(sw_enforced), + key); } else { - return passthrough_factory_.LoadKey(move(key_material), additional_params, - move(hw_enforced), move(sw_enforced), key); + return passthrough_factory_.LoadKey(std::move(key_material), additional_params, + std::move(hw_enforced), std::move(sw_enforced), + key); } } diff --git a/include/keymaster/legacy_support/keymaster_passthrough_key.h b/include/keymaster/legacy_support/keymaster_passthrough_key.h index e262181..859a864 100644 --- a/include/keymaster/legacy_support/keymaster_passthrough_key.h +++ b/include/keymaster/legacy_support/keymaster_passthrough_key.h @@ -17,6 +17,8 @@ #pragma once +#include <utility> + #include <keymaster/android_keymaster_utils.h> #include <keymaster/authorization_set.h> #include <keymaster/key.h> @@ -84,9 +86,9 @@ class KeymasterPassthroughKey : public Key { AuthorizationSet&& sw_enforced, const KeyFactory* key_factory, keymaster_error_t* error, const AuthorizationSet& additional_parameters, const KeymasterPassthroughEngine* engine) - : Key(move(hw_enforced), move(sw_enforced), key_factory), + : Key(std::move(hw_enforced), std::move(sw_enforced), key_factory), additional_parameters_(additional_parameters), engine_(engine) { - key_material_ = move(key_material); + key_material_ = std::move(key_material); if (*error != KM_ERROR_OK) return; if (additional_parameters.is_valid() != additional_parameters_.is_valid() && additional_parameters_.is_valid() == AuthorizationSet::ALLOCATION_FAILURE) { diff --git a/include/keymaster/legacy_support/rsa_keymaster1_key.h b/include/keymaster/legacy_support/rsa_keymaster1_key.h index e114aef..939f9d8 100644 --- a/include/keymaster/legacy_support/rsa_keymaster1_key.h +++ b/include/keymaster/legacy_support/rsa_keymaster1_key.h @@ -16,6 +16,8 @@ #pragma once +#include <utility> + #include <openssl/rsa.h> #include <keymaster/km_openssl/rsa_key.h> @@ -79,7 +81,7 @@ class RsaKeymaster1Key : public RsaKey { public: RsaKeymaster1Key(RSA* rsa_key, AuthorizationSet&& hw_enforced, AuthorizationSet&& sw_enforced, const KeyFactory* key_factory) - : RsaKey(rsa_key, move(hw_enforced), move(sw_enforced), key_factory) {} + : RsaKey(rsa_key, std::move(hw_enforced), std::move(sw_enforced), key_factory) {} }; } // namespace keymaster diff --git a/include/keymaster/mem.h b/include/keymaster/mem.h index 6d5de1b..6593099 100644 --- a/include/keymaster/mem.h +++ b/include/keymaster/mem.h @@ -18,9 +18,6 @@ namespace keymaster { -using std::forward; -using std::move; - /* * Array Manipulation functions. This set of templated inline functions provides some nice tools * for operating on c-style arrays. C-style arrays actually do have a defined size associated with diff --git a/include/keymaster/operation.h b/include/keymaster/operation.h index aa02599..5643595 100644 --- a/include/keymaster/operation.h +++ b/include/keymaster/operation.h @@ -17,6 +17,8 @@ #ifndef SYSTEM_KEYMASTER_OPERATION_H_ #define SYSTEM_KEYMASTER_OPERATION_H_ +#include <utility> + #include <assert.h> #include <stdint.h> #include <stdlib.h> @@ -93,7 +95,8 @@ class Operation { public: explicit Operation(keymaster_purpose_t purpose, AuthorizationSet&& hw_enforced, AuthorizationSet&& sw_enforced) - : purpose_(purpose), hw_enforced_(move(hw_enforced)), sw_enforced_(move(sw_enforced)) {} + : purpose_(purpose), hw_enforced_(std::move(hw_enforced)), + sw_enforced_(std::move(sw_enforced)) {} virtual ~Operation() {} Operation(const Operation&) = delete; diff --git a/include/keymaster/serializable.h b/include/keymaster/serializable.h index f043574..09e98b1 100644 --- a/include/keymaster/serializable.h +++ b/include/keymaster/serializable.h @@ -22,6 +22,7 @@ #include <string.h> #include <iterator> +#include <utility> #include <keymaster/UniquePtr.h> #include <keymaster/logger.h> @@ -251,14 +252,14 @@ class Buffer : public Serializable { Buffer() : buffer_(nullptr), buffer_size_(0), read_position_(0), write_position_(0) {} explicit Buffer(size_t size) : buffer_(nullptr) { Reinitialize(size); } Buffer(const void* buf, size_t size) : buffer_(nullptr) { Reinitialize(buf, size); } - Buffer(Buffer&& b) { *this = move(b); } + Buffer(Buffer&& b) { *this = std::move(b); } Buffer(const Buffer&) = delete; ~Buffer() { Clear(); } Buffer& operator=(Buffer&& other) { if (this == &other) return *this; - buffer_ = move(other.buffer_); + buffer_ = std::move(other.buffer_); buffer_size_ = other.buffer_size_; other.buffer_size_ = 0; read_position_ = other.read_position_; diff --git a/key_blob_utils/auth_encrypted_key_blob.cpp b/key_blob_utils/auth_encrypted_key_blob.cpp index 3cdcf5c..c726d4d 100644 --- a/key_blob_utils/auth_encrypted_key_blob.cpp +++ b/key_blob_utils/auth_encrypted_key_blob.cpp @@ -16,6 +16,8 @@ #include <keymaster/key_blob_utils/auth_encrypted_key_blob.h> +#include <utility> + #include <openssl/digest.h> #include <openssl/evp.h> #include <openssl/hkdf.h> @@ -139,7 +141,7 @@ KmErrorOr<EncryptedKey> AesGcmEncryptKey(const AuthorizationSet& hw_enforced, EncryptedKey retval; retval.format = format; retval.ciphertext = KeymasterKeyBlob(ciphertext_len); - retval.nonce = move(nonce); + retval.nonce = std::move(nonce); retval.tag = Buffer(kAesGcmTagLength); if (!(EVP_EncryptInit_ex(ctx.get(), EVP_aes_256_gcm(), nullptr /* engine */, kek->peek_read(), diff --git a/km_openssl/aes_key.cpp b/km_openssl/aes_key.cpp index 5df9e9e..04fa087 100644 --- a/km_openssl/aes_key.cpp +++ b/km_openssl/aes_key.cpp @@ -16,6 +16,8 @@ #include <keymaster/km_openssl/aes_key.h> +#include <utility> + #include <assert.h> #include <openssl/err.h> @@ -60,7 +62,8 @@ keymaster_error_t AesKeyFactory::LoadKey(KeymasterKeyBlob&& key_material, keymaster_error_t error = KM_ERROR_OK; key->reset(new (std::nothrow) - AesKey(move(key_material), move(hw_enforced), move(sw_enforced), this)); + AesKey(std::move(key_material), std::move(hw_enforced), std::move(sw_enforced), + this)); if (!key->get()) error = KM_ERROR_MEMORY_ALLOCATION_FAILED; return error; } diff --git a/km_openssl/asymmetric_key_factory.cpp b/km_openssl/asymmetric_key_factory.cpp index 963694c..2fa1018 100644 --- a/km_openssl/asymmetric_key_factory.cpp +++ b/km_openssl/asymmetric_key_factory.cpp @@ -16,6 +16,8 @@ #include <keymaster/asymmetric_key_factory.h> +#include <utility> + #include <keymaster/android_keymaster_utils.h> #include <keymaster/km_openssl/asymmetric_key.h> @@ -44,11 +46,12 @@ keymaster_error_t AsymmetricKeyFactory::LoadKey(KeymasterKeyBlob&& key_material, AuthorizationSet&& sw_enforced, UniquePtr<Key>* key) const { UniquePtr<AsymmetricKey> asym_key; - keymaster_error_t error = CreateEmptyKey(move(hw_enforced), move(sw_enforced), &asym_key); + keymaster_error_t error = CreateEmptyKey(std::move(hw_enforced), std::move(sw_enforced), + &asym_key); if (error != KM_ERROR_OK) return error; const uint8_t* tmp = key_material.key_material; - asym_key->key_material() = move(key_material); + asym_key->key_material() = std::move(key_material); EVP_PKEY* pkey = d2i_PrivateKey(asym_key->evp_key_type(), nullptr /* pkey */, &tmp, asym_key->key_material().key_material_size); diff --git a/km_openssl/attestation_utils.cpp b/km_openssl/attestation_utils.cpp index e9a6aa3..a288446 100644 --- a/km_openssl/attestation_utils.cpp +++ b/km_openssl/attestation_utils.cpp @@ -15,6 +15,8 @@ ** limitations under the License. */ +#include <utility> + #include <openssl/evp.h> #include <openssl/x509v3.h> @@ -146,7 +148,7 @@ keymaster_error_t make_attestation_cert(const EVP_PKEY* evp_pkey, const X509_NAM return error; } - *cert_out = move(certificate); + *cert_out = std::move(certificate); return KM_ERROR_OK; } @@ -266,7 +268,7 @@ CertificateChain generate_attestation(const AsymmetricKey& key, } return generate_attestation(pkey.get(), key.sw_enforced(), key.hw_enforced(), attest_params, - move(attest_key), context, error); + std::move(attest_key), context, error); } CertificateChain generate_attestation(const EVP_PKEY* evp_key, // @@ -317,7 +319,7 @@ CertificateChain generate_attestation(const EVP_PKEY* evp_key, // *error = sign_cert(certificate.get(), signing_key_ptr); if (*error != KM_ERROR_OK) return {}; - return make_cert_chain(certificate.get(), move(cert_chain), error); + return make_cert_chain(certificate.get(), std::move(cert_chain), error); } } // namespace keymaster diff --git a/km_openssl/block_cipher_operation.cpp b/km_openssl/block_cipher_operation.cpp index a381e75..296cb9c 100644 --- a/km_openssl/block_cipher_operation.cpp +++ b/km_openssl/block_cipher_operation.cpp @@ -16,6 +16,8 @@ #include "block_cipher_operation.h" +#include <utility> + #include <stdio.h> #include <keymaster/UniquePtr.h> @@ -117,11 +119,12 @@ OperationPtr BlockCipherOperationFactory::CreateOperation(Key&& key, switch (purpose_) { case KM_PURPOSE_ENCRYPT: op.reset(new (std::nothrow) BlockCipherEvpEncryptOperation( // - block_mode, padding, caller_nonce, tag_length, move(key), GetCipherDescription())); + block_mode, padding, caller_nonce, tag_length, std::move(key), + GetCipherDescription())); break; case KM_PURPOSE_DECRYPT: op.reset(new (std::nothrow) BlockCipherEvpDecryptOperation( - block_mode, padding, tag_length, move(key), GetCipherDescription())); + block_mode, padding, tag_length, std::move(key), GetCipherDescription())); break; default: *error = KM_ERROR_UNSUPPORTED_PURPOSE; diff --git a/km_openssl/block_cipher_operation.h b/km_openssl/block_cipher_operation.h index 9c25bda..cd78805 100644 --- a/km_openssl/block_cipher_operation.h +++ b/km_openssl/block_cipher_operation.h @@ -17,6 +17,8 @@ #ifndef SYSTEM_KEYMASTER_BLOCK_CIPHER_OPERATION_H_ #define SYSTEM_KEYMASTER_BLOCK_CIPHER_OPERATION_H_ +#include <utility> + #include <openssl/evp.h> #include <keymaster/operation.h> @@ -121,7 +123,7 @@ class BlockCipherEvpEncryptOperation : public BlockCipherEvpOperation { bool caller_iv, size_t tag_length, Key&& key, const EvpCipherDescription& cipher_description) : BlockCipherEvpOperation(KM_PURPOSE_ENCRYPT, block_mode, padding, caller_iv, tag_length, - move(key), cipher_description) {} + std::move(key), cipher_description) {} keymaster_error_t Begin(const AuthorizationSet& input_params, AuthorizationSet* output_params) override; @@ -141,7 +143,7 @@ class BlockCipherEvpDecryptOperation : public BlockCipherEvpOperation { size_t tag_length, Key&& key, const EvpCipherDescription& cipher_description) : BlockCipherEvpOperation(KM_PURPOSE_DECRYPT, block_mode, padding, - false /* caller_iv -- don't care */, tag_length, move(key), + false /* caller_iv -- don't care */, tag_length, std::move(key), cipher_description) {} keymaster_error_t Begin(const AuthorizationSet& input_params, diff --git a/km_openssl/certificate_utils.cpp b/km_openssl/certificate_utils.cpp index 9118c68..17a34b0 100644 --- a/km_openssl/certificate_utils.cpp +++ b/km_openssl/certificate_utils.cpp @@ -15,6 +15,7 @@ */ #include <iostream> +#include <utility> #include <openssl/asn1.h> #include <openssl/evp.h> @@ -40,7 +41,7 @@ constexpr int kKeyAgreementKeyUsageBit = 4; constexpr int kMaxKeyUsageBit = 8; template <typename T> T&& min(T&& a, T&& b) { - return (a < b) ? forward<T>(a) : forward<T>(b); + return (a < b) ? std::forward<T>(a) : std::forward<T>(b); } keymaster_error_t fake_sign_cert(X509* cert) { @@ -76,7 +77,7 @@ keymaster_error_t make_name_from_str(const char name[], X509_NAME_Ptr* name_out) 0 /* set */)) { return TranslateLastOpenSslError(); } - *name_out = move(x509_name); + *name_out = std::move(x509_name); return KM_ERROR_OK; } @@ -89,7 +90,7 @@ keymaster_error_t make_name_from_der(const keymaster_blob_t& name, X509_NAME_Ptr return TranslateLastOpenSslError(); } - *name_out = move(x509_name); + *name_out = std::move(x509_name); return KM_ERROR_OK; } @@ -124,7 +125,7 @@ keymaster_error_t get_certificate_params(const AuthorizationSet& caller_params, // Default serial is one. BN_one(serial.get()); } - cert_params->serial = move(serial); + cert_params->serial = std::move(serial); cert_params->active_date_time = 0; cert_params->expire_date_time = kUndefinedExpirationDateTime; @@ -228,7 +229,7 @@ keymaster_error_t make_key_usage_extension(bool is_signing_key, bool is_encrypti return TranslateLastOpenSslError(); } - *usage_extension_out = move(key_usage_extension); + *usage_extension_out = std::move(key_usage_extension); return KM_ERROR_OK; } @@ -285,7 +286,7 @@ keymaster_error_t make_cert_rump(const X509_NAME* issuer, return TranslateLastOpenSslError(); } - *cert_out = move(certificate); + *cert_out = std::move(certificate); return KM_ERROR_OK; } @@ -315,7 +316,7 @@ keymaster_error_t make_cert(const EVP_PKEY* evp_pkey, const X509_NAME* issuer, return TranslateLastOpenSslError(); } - *cert_out = move(certificate); + *cert_out = std::move(certificate); return KM_ERROR_OK; } diff --git a/km_openssl/ec_key_factory.cpp b/km_openssl/ec_key_factory.cpp index 64b0f7b..087ca63 100644 --- a/km_openssl/ec_key_factory.cpp +++ b/km_openssl/ec_key_factory.cpp @@ -16,6 +16,8 @@ #include <keymaster/km_openssl/ec_key_factory.h> +#include <utility> + #include <openssl/curve25519.h> #include <openssl/evp.h> @@ -178,14 +180,14 @@ keymaster_error_t EcKeyFactory::GenerateKey(const AuthorizationSet& key_descript } else if (is_x25519) { key.reset(new (std::nothrow) X25519Key(*hw_enforced, *sw_enforced, this, key_material)); } else { - key.reset(new (std::nothrow) EcKey(*hw_enforced, *sw_enforced, this, move(ec_key))); + key.reset(new (std::nothrow) EcKey(*hw_enforced, *sw_enforced, this, std::move(ec_key))); } if (key == nullptr) { return KM_ERROR_MEMORY_ALLOCATION_FAILED; } if (key_description.Contains(TAG_ATTESTATION_CHALLENGE)) { - *cert_chain = context_.GenerateAttestation(*key, key_description, move(attest_key), + *cert_chain = context_.GenerateAttestation(*key, key_description, std::move(attest_key), issuer_subject, &error); } else if (attest_key.get() != nullptr) { return KM_ERROR_ATTESTATION_CHALLENGE_MISSING; @@ -207,8 +209,8 @@ keymaster_error_t EcKeyFactory::ImportKey(const AuthorizationSet& key_descriptio AuthorizationSet* sw_enforced, CertificateChain* cert_chain) const { if (input_key_material_format == KM_KEY_FORMAT_RAW) { - return ImportRawKey(key_description, input_key_material, move(attest_key), issuer_subject, - output_key_blob, hw_enforced, sw_enforced, cert_chain); + return ImportRawKey(key_description, input_key_material, std::move(attest_key), + issuer_subject, output_key_blob, hw_enforced, sw_enforced, cert_chain); } if (!output_key_blob || !hw_enforced || !sw_enforced) return KM_ERROR_OUTPUT_PARAMETER_NULL; @@ -254,7 +256,7 @@ keymaster_error_t EcKeyFactory::ImportKey(const AuthorizationSet& key_descriptio EC_KEY_Ptr ec_key(EVP_PKEY_get1_EC_KEY(pkey.get())); if (!ec_key.get()) return KM_ERROR_INVALID_ARGUMENT; - key.reset(new (std::nothrow) EcKey(*hw_enforced, *sw_enforced, this, move(ec_key))); + key.reset(new (std::nothrow) EcKey(*hw_enforced, *sw_enforced, this, std::move(ec_key))); if (key.get() == nullptr) { return KM_ERROR_MEMORY_ALLOCATION_FAILED; } @@ -268,7 +270,7 @@ keymaster_error_t EcKeyFactory::ImportKey(const AuthorizationSet& key_descriptio } if (key_description.Contains(KM_TAG_ATTESTATION_CHALLENGE)) { - *cert_chain = context_.GenerateAttestation(*key, key_description, move(attest_key), + *cert_chain = context_.GenerateAttestation(*key, key_description, std::move(attest_key), issuer_subject, &error); } else if (attest_key.get() != nullptr) { return KM_ERROR_ATTESTATION_CHALLENGE_MISSING; @@ -359,7 +361,7 @@ keymaster_error_t EcKeyFactory::ImportRawKey(const AuthorizationSet& key_descrip } if (key_description.Contains(KM_TAG_ATTESTATION_CHALLENGE)) { - *cert_chain = context_.GenerateAttestation(*key, key_description, move(attest_key), + *cert_chain = context_.GenerateAttestation(*key, key_description, std::move(attest_key), issuer_subject, &error); } else if (attest_key.get() != nullptr) { return KM_ERROR_ATTESTATION_CHALLENGE_MISSING; @@ -509,11 +511,13 @@ keymaster_error_t EcKeyFactory::CreateEmptyKey(AuthorizationSet&& hw_enforced, if (is_x25519) { return KM_ERROR_INCOMPATIBLE_PURPOSE; } - key->reset(new (std::nothrow) Ed25519Key(move(hw_enforced), move(sw_enforced), this)); + key->reset(new (std::nothrow) Ed25519Key(std::move(hw_enforced), std::move(sw_enforced), + this)); } else if (is_x25519) { - key->reset(new (std::nothrow) X25519Key(move(hw_enforced), move(sw_enforced), this)); + key->reset(new (std::nothrow) X25519Key(std::move(hw_enforced), std::move(sw_enforced), + this)); } else { - key->reset(new (std::nothrow) EcKey(move(hw_enforced), move(sw_enforced), this)); + key->reset(new (std::nothrow) EcKey(std::move(hw_enforced), std::move(sw_enforced), this)); } if (!(*key)) return KM_ERROR_MEMORY_ALLOCATION_FAILED; return KM_ERROR_OK; diff --git a/km_openssl/ecdh_operation.cpp b/km_openssl/ecdh_operation.cpp index a35b130..1fa68df 100644 --- a/km_openssl/ecdh_operation.cpp +++ b/km_openssl/ecdh_operation.cpp @@ -16,13 +16,15 @@ #include <keymaster/km_openssl/ecdh_operation.h> +#include <utility> +#include <vector> + #include <keymaster/km_openssl/ec_key.h> #include <keymaster/km_openssl/openssl_err.h> #include <keymaster/km_openssl/openssl_utils.h> #include <keymaster/logger.h> #include <openssl/curve25519.h> #include <openssl/err.h> -#include <vector> namespace keymaster { @@ -151,12 +153,12 @@ OperationPtr EcdhOperationFactory::CreateOperation(Key&& key, EcdhOperation* op = nullptr; switch (EVP_PKEY_id(pkey.get())) { case EVP_PKEY_X25519: - op = new (std::nothrow) X25519Operation(move(key.hw_enforced_move()), - move(key.sw_enforced_move()), pkey.release()); + op = new (std::nothrow) X25519Operation(std::move(key.hw_enforced_move()), + std::move(key.sw_enforced_move()), pkey.release()); break; case EVP_PKEY_EC: - op = new (std::nothrow) EcdhOperation(move(key.hw_enforced_move()), - move(key.sw_enforced_move()), pkey.release()); + op = new (std::nothrow) EcdhOperation(std::move(key.hw_enforced_move()), + std::move(key.sw_enforced_move()), pkey.release()); break; default: *error = KM_ERROR_UNKNOWN_ERROR; diff --git a/km_openssl/hmac_key.cpp b/km_openssl/hmac_key.cpp index d74ff37..c8f2444 100644 --- a/km_openssl/hmac_key.cpp +++ b/km_openssl/hmac_key.cpp @@ -16,6 +16,8 @@ #include <keymaster/km_openssl/hmac_key.h> +#include <utility> + #include <openssl/err.h> #include <openssl/rand.h> @@ -52,7 +54,8 @@ keymaster_error_t HmacKeyFactory::LoadKey(KeymasterKeyBlob&& key_material, } key->reset(new (std::nothrow) - HmacKey(move(key_material), move(hw_enforced), move(sw_enforced), this)); + HmacKey(std::move(key_material), std::move(hw_enforced), std::move(sw_enforced), + this)); if (!key->get()) return KM_ERROR_MEMORY_ALLOCATION_FAILED; return KM_ERROR_OK; } diff --git a/km_openssl/hmac_operation.cpp b/km_openssl/hmac_operation.cpp index 759ca12..a05e200 100644 --- a/km_openssl/hmac_operation.cpp +++ b/km_openssl/hmac_operation.cpp @@ -16,6 +16,8 @@ #include "hmac_operation.h" +#include <utility> + #include <openssl/evp.h> #include <openssl/hmac.h> @@ -69,7 +71,7 @@ OperationPtr HmacOperationFactory::CreateOperation(Key&& key, const Authorizatio } UniquePtr<HmacOperation> op(new (std::nothrow) HmacOperation( - move(key), purpose(), digest, mac_length_bits / 8, min_mac_length_bits / 8)); + std::move(key), purpose(), digest, mac_length_bits / 8, min_mac_length_bits / 8)); if (!op.get()) *error = KM_ERROR_MEMORY_ALLOCATION_FAILED; else @@ -77,7 +79,7 @@ OperationPtr HmacOperationFactory::CreateOperation(Key&& key, const Authorizatio if (*error != KM_ERROR_OK) return nullptr; - return move(op); + return std::move(op); } static keymaster_digest_t supported_digests[] = {KM_DIGEST_SHA1, KM_DIGEST_SHA_2_224, diff --git a/km_openssl/rsa_key_factory.cpp b/km_openssl/rsa_key_factory.cpp index ed7162d..27f64e4 100644 --- a/km_openssl/rsa_key_factory.cpp +++ b/km_openssl/rsa_key_factory.cpp @@ -16,6 +16,8 @@ #include <keymaster/km_openssl/rsa_key_factory.h> +#include <utility> + #include <keymaster/keymaster_context.h> #include <keymaster/km_openssl/openssl_err.h> #include <keymaster/km_openssl/openssl_utils.h> @@ -101,9 +103,9 @@ keymaster_error_t RsaKeyFactory::GenerateKey(const AuthorizationSet& key_descrip if (context_.GetKmVersion() < KmVersion::KEYMINT_1) return KM_ERROR_OK; if (!cert_chain) return KM_ERROR_UNEXPECTED_NULL_POINTER; - RsaKey key(*hw_enforced, *sw_enforced, this, move(rsa_key)); + RsaKey key(*hw_enforced, *sw_enforced, this, std::move(rsa_key)); if (key_description.Contains(TAG_ATTESTATION_CHALLENGE)) { - *cert_chain = context_.GenerateAttestation(key, key_description, move(attest_key), + *cert_chain = context_.GenerateAttestation(key, key_description, std::move(attest_key), issuer_subject, &error); } else if (attest_key.get() != nullptr) { return KM_ERROR_ATTESTATION_CHALLENGE_MISSING; @@ -148,9 +150,9 @@ keymaster_error_t RsaKeyFactory::ImportKey(const AuthorizationSet& key_descripti RSA_Ptr rsa_key(EVP_PKEY_get1_RSA(pkey.get())); if (!rsa_key.get()) return KM_ERROR_INVALID_ARGUMENT; - RsaKey key(*hw_enforced, *sw_enforced, this, move(rsa_key)); + RsaKey key(*hw_enforced, *sw_enforced, this, std::move(rsa_key)); if (key_description.Contains(KM_TAG_ATTESTATION_CHALLENGE)) { - *cert_chain = context_.GenerateAttestation(key, key_description, move(attest_key), + *cert_chain = context_.GenerateAttestation(key, key_description, std::move(attest_key), issuer_subject, &error); } else if (attest_key.get() != nullptr) { return KM_ERROR_ATTESTATION_CHALLENGE_MISSING; @@ -212,7 +214,7 @@ keymaster_error_t RsaKeyFactory::UpdateImportKeyDescription(const AuthorizationS keymaster_error_t RsaKeyFactory::CreateEmptyKey(AuthorizationSet&& hw_enforced, AuthorizationSet&& sw_enforced, UniquePtr<AsymmetricKey>* key) const { - key->reset(new (std::nothrow) RsaKey(move(hw_enforced), move(sw_enforced), this)); + key->reset(new (std::nothrow) RsaKey(std::move(hw_enforced), std::move(sw_enforced), this)); if (!(*key)) return KM_ERROR_MEMORY_ALLOCATION_FAILED; return KM_ERROR_OK; } diff --git a/km_openssl/rsa_operation.cpp b/km_openssl/rsa_operation.cpp index a4710d4..e445321 100644 --- a/km_openssl/rsa_operation.cpp +++ b/km_openssl/rsa_operation.cpp @@ -16,6 +16,8 @@ #include <keymaster/km_openssl/rsa_operation.h> +#include <utility> + #include <limits.h> #include <openssl/err.h> @@ -98,7 +100,7 @@ RsaOperation* RsaCryptingOperationFactory::CreateRsaOperation(Key&& key, *error = GetAndValidateMgfDigest(begin_params, key, &mgf_digest); if (*error != KM_ERROR_OK) return nullptr; UniquePtr<RsaOperation> op( - RsaOperationFactory::CreateRsaOperation(move(key), begin_params, error)); + RsaOperationFactory::CreateRsaOperation(std::move(key), begin_params, error)); if (op.get()) { switch (op->padding()) { case KM_PAD_NONE: @@ -240,7 +242,7 @@ RsaDigestingOperation::RsaDigestingOperation(AuthorizationSet&& hw_enforced, AuthorizationSet&& sw_enforced, keymaster_purpose_t purpose, keymaster_digest_t digest, keymaster_padding_t padding, EVP_PKEY* key) - : RsaOperation(move(hw_enforced), move(sw_enforced), purpose, digest, padding, key) { + : RsaOperation(std::move(hw_enforced), std::move(sw_enforced), purpose, digest, padding, key) { EVP_MD_CTX_init(&digest_ctx_); } RsaDigestingOperation::~RsaDigestingOperation() { diff --git a/km_openssl/symmetric_key.cpp b/km_openssl/symmetric_key.cpp index 1b89d66..d60d9f8 100644 --- a/km_openssl/symmetric_key.cpp +++ b/km_openssl/symmetric_key.cpp @@ -16,6 +16,8 @@ #include <keymaster/km_openssl/symmetric_key.h> +#include <utility> + #include <assert.h> #include <openssl/err.h> @@ -105,8 +107,8 @@ SymmetricKeyFactory::SupportedImportFormats(size_t* format_count) const { SymmetricKey::SymmetricKey(KeymasterKeyBlob&& key_material, AuthorizationSet&& hw_enforced, AuthorizationSet&& sw_enforced, const KeyFactory* key_factory) - : Key(move(hw_enforced), move(sw_enforced), key_factory) { - key_material_ = move(key_material); + : Key(std::move(hw_enforced), std::move(sw_enforced), key_factory) { + key_material_ = std::move(key_material); } SymmetricKey::~SymmetricKey() {} diff --git a/km_openssl/triple_des_key.cpp b/km_openssl/triple_des_key.cpp index 8c267e6..d60d204 100644 --- a/km_openssl/triple_des_key.cpp +++ b/km_openssl/triple_des_key.cpp @@ -16,6 +16,8 @@ #include <keymaster/km_openssl/triple_des_key.h> +#include <utility> + #include <assert.h> #include <openssl/err.h> @@ -48,7 +50,8 @@ keymaster_error_t TripleDesKeyFactory::LoadKey(KeymasterKeyBlob&& key_material, keymaster_error_t error = KM_ERROR_OK; key->reset(new (std::nothrow) - TripleDesKey(move(key_material), move(hw_enforced), move(sw_enforced), this)); + TripleDesKey(std::move(key_material), std::move(hw_enforced), + std::move(sw_enforced), this)); if (!key->get()) error = KM_ERROR_MEMORY_ALLOCATION_FAILED; return error; } diff --git a/legacy_support/ec_keymaster1_key.cpp b/legacy_support/ec_keymaster1_key.cpp index ddb3725..64c6916 100644 --- a/legacy_support/ec_keymaster1_key.cpp +++ b/legacy_support/ec_keymaster1_key.cpp @@ -17,6 +17,7 @@ #include <keymaster/legacy_support/ec_keymaster1_key.h> #include <memory> +#include <utility> #include <keymaster/km_openssl/ecdsa_operation.h> #include <keymaster/logger.h> @@ -112,10 +113,11 @@ keymaster_error_t EcdsaKeymaster1KeyFactory::LoadKey(KeymasterKeyBlob&& key_mate if (!ecdsa) return error; key->reset(new (std::nothrow) - EcdsaKeymaster1Key(ecdsa.release(), move(hw_enforced), move(sw_enforced), this)); + EcdsaKeymaster1Key(ecdsa.release(), std::move(hw_enforced), + std::move(sw_enforced), this)); if (!(*key)) return KM_ERROR_MEMORY_ALLOCATION_FAILED; - (*key)->key_material() = move(key_material); + (*key)->key_material() = std::move(key_material); return KM_ERROR_OK; } diff --git a/legacy_support/ecdsa_keymaster1_operation.h b/legacy_support/ecdsa_keymaster1_operation.h index e52deae..2b6d2b8 100644 --- a/legacy_support/ecdsa_keymaster1_operation.h +++ b/legacy_support/ecdsa_keymaster1_operation.h @@ -17,6 +17,8 @@ #ifndef SYSTEM_KEYMASTER_ECDSA_KEYMASTER1_OPERATION_H_ #define SYSTEM_KEYMASTER_ECDSA_KEYMASTER1_OPERATION_H_ +#include <utility> + #include <openssl/evp.h> #include <hardware/keymaster1.h> @@ -56,7 +58,7 @@ template <typename BaseOperation> class EcdsaKeymaster1Operation : public BaseOp EcdsaKeymaster1Operation(AuthorizationSet&& hw_enforced, AuthorizationSet&& sw_enforced, keymaster_digest_t digest, EVP_PKEY* key, const Keymaster1Engine* engine) - : BaseOperation(move(hw_enforced), move(sw_enforced), digest, key), + : BaseOperation(std::move(hw_enforced), std::move(sw_enforced), digest, key), wrapped_operation_(super::purpose(), engine) { // Shouldn't be instantiated for public key operations. assert(super::purpose() != KM_PURPOSE_VERIFY); diff --git a/legacy_support/keymaster1_legacy_support.cpp b/legacy_support/keymaster1_legacy_support.cpp index 3fd5cb4..b327ce3 100644 --- a/legacy_support/keymaster1_legacy_support.cpp +++ b/legacy_support/keymaster1_legacy_support.cpp @@ -23,6 +23,7 @@ #include <algorithm> #include <vector> +#include <utility> namespace keymaster { @@ -228,7 +229,7 @@ keymaster_error_t Keymaster1ArbitrationFactory<EcdsaKeymaster1KeyFactory>::Gener AuthorizationSet* sw_enforced, // CertificateChain* cert_chain) const { if (legacy_support_.RequiresSoftwareDigesting(key_description)) { - return software_digest_factory_.GenerateKey(key_description, move(attest_key), + return software_digest_factory_.GenerateKey(key_description, std::move(attest_key), issuer_subject, key_blob, hw_enforced, sw_enforced, cert_chain); } else { @@ -252,7 +253,7 @@ keymaster_error_t Keymaster1ArbitrationFactory<EcdsaKeymaster1KeyFactory>::Gener } } - return passthrough_factory_.GenerateKey(mutable_key_description, move(attest_key), + return passthrough_factory_.GenerateKey(mutable_key_description, std::move(attest_key), issuer_subject, key_blob, hw_enforced, sw_enforced, cert_chain); } @@ -268,8 +269,8 @@ keymaster_error_t Keymaster1ArbitrationFactory<EcdsaKeymaster1KeyFactory>::LoadK } bool requires_software_digesting = legacy_support_.RequiresSoftwareDigesting(digest, AuthProxy(hw_enforced, sw_enforced)); - auto rc = software_digest_factory_.LoadKey(move(key_material), additional_params, - move(hw_enforced), move(sw_enforced), key); + auto rc = software_digest_factory_.LoadKey(std::move(key_material), additional_params, + std::move(hw_enforced), std::move(sw_enforced), key); if (rc != KM_ERROR_OK) return rc; if (!requires_software_digesting) { (*key)->key_factory() = &passthrough_factory_; @@ -287,8 +288,8 @@ keymaster_error_t Keymaster1ArbitrationFactory<RsaKeymaster1KeyFactory>::LoadKey } bool requires_software_digesting = legacy_support_.RequiresSoftwareDigesting(digest, AuthProxy(hw_enforced, sw_enforced)); - auto rc = software_digest_factory_.LoadKey(move(key_material), additional_params, - move(hw_enforced), move(sw_enforced), key); + auto rc = software_digest_factory_.LoadKey(std::move(key_material), additional_params, + std::move(hw_enforced), std::move(sw_enforced), key); if (rc != KM_ERROR_OK) return rc; if (!requires_software_digesting) { (*key)->key_factory() = &passthrough_factory_; diff --git a/legacy_support/keymaster_passthrough_key.cpp b/legacy_support/keymaster_passthrough_key.cpp index 52b56e8..b649684 100644 --- a/legacy_support/keymaster_passthrough_key.cpp +++ b/legacy_support/keymaster_passthrough_key.cpp @@ -17,6 +17,8 @@ #include <keymaster/legacy_support/keymaster_passthrough_key.h> +#include <utility> + namespace keymaster { keymaster_error_t KeymasterPassthroughKeyFactory::LoadKey(KeymasterKeyBlob&& key_material, @@ -28,8 +30,9 @@ keymaster_error_t KeymasterPassthroughKeyFactory::LoadKey(KeymasterKeyBlob&& key if (!key) return KM_ERROR_OUTPUT_PARAMETER_NULL; key->reset(new (std::nothrow) - KeymasterPassthroughKey(move(key_material), move(hw_enforced), move(sw_enforced), - this, &error, additional_params, engine_)); + KeymasterPassthroughKey(std::move(key_material), std::move(hw_enforced), + std::move(sw_enforced), this, &error, additional_params, + engine_)); if (!key->get()) error = KM_ERROR_MEMORY_ALLOCATION_FAILED; return error; diff --git a/legacy_support/keymaster_passthrough_operation.cpp b/legacy_support/keymaster_passthrough_operation.cpp index 7b10722..c98449d 100644 --- a/legacy_support/keymaster_passthrough_operation.cpp +++ b/legacy_support/keymaster_passthrough_operation.cpp @@ -17,6 +17,7 @@ #include "keymaster_passthrough_operation.h" #include <keymaster/android_keymaster_utils.h> +#include <utility> #include <vector> namespace keymaster { @@ -85,7 +86,7 @@ keymaster_error_t KeymasterPassthroughOperation<keymaster1_device_t>::Finish( } accumulated_out_params.Deduplicate(); - if (output_params) *output_params = move(accumulated_out_params); + if (output_params) *output_params = std::move(accumulated_out_params); return KM_ERROR_OK; } diff --git a/legacy_support/rsa_keymaster1_key.cpp b/legacy_support/rsa_keymaster1_key.cpp index ff5576c..89ed859 100644 --- a/legacy_support/rsa_keymaster1_key.cpp +++ b/legacy_support/rsa_keymaster1_key.cpp @@ -14,9 +14,11 @@ * limitations under the License. */ -#include <keymaster/contexts/soft_keymaster_context.h> #include <keymaster/legacy_support/rsa_keymaster1_key.h> +#include <utility> + +#include <keymaster/contexts/soft_keymaster_context.h> #include <keymaster/km_openssl/openssl_utils.h> #include <keymaster/logger.h> @@ -121,10 +123,11 @@ keymaster_error_t RsaKeymaster1KeyFactory::LoadKey(KeymasterKeyBlob&& key_materi if (!rsa.get()) return error; key->reset(new (std::nothrow) - RsaKeymaster1Key(rsa.release(), move(hw_enforced), move(sw_enforced), this)); + RsaKeymaster1Key(rsa.release(), std::move(hw_enforced), std::move(sw_enforced), + this)); if (!(*key)) return KM_ERROR_MEMORY_ALLOCATION_FAILED; - (*key)->key_material() = move(key_material); + (*key)->key_material() = std::move(key_material); return KM_ERROR_OK; } diff --git a/legacy_support/rsa_keymaster1_operation.h b/legacy_support/rsa_keymaster1_operation.h index 124c4b7..fb0eda9 100644 --- a/legacy_support/rsa_keymaster1_operation.h +++ b/legacy_support/rsa_keymaster1_operation.h @@ -16,6 +16,8 @@ #pragma once +#include <utility> + #include <openssl/evp.h> #include <hardware/keymaster1.h> @@ -55,7 +57,7 @@ template <typename BaseOperation> class RsaKeymaster1Operation : public BaseOper RsaKeymaster1Operation(AuthorizationSet&& hw_enforced, AuthorizationSet&& sw_enforced, keymaster_digest_t digest, keymaster_padding_t padding, EVP_PKEY* key, const Keymaster1Engine* engine) - : BaseOperation(move(hw_enforced), move(sw_enforced), digest, padding, key), + : BaseOperation(std::move(hw_enforced), std::move(sw_enforced), digest, padding, key), wrapped_operation_(super::purpose(), engine) { // Shouldn't be instantiated for public key operations. assert(super::purpose() != KM_PURPOSE_VERIFY); diff --git a/tests/key_blob_test.cpp b/tests/key_blob_test.cpp index f69551b..2c751f1 100644 --- a/tests/key_blob_test.cpp +++ b/tests/key_blob_test.cpp @@ -15,6 +15,7 @@ */ #include <algorithm> +#include <utility> #include <gtest/gtest.h> @@ -79,7 +80,7 @@ class KeyBlobTest : public ::testing::TestWithParam<AuthEncryptedBlobFormat>, keymaster_error_t Decrypt() { auto result = - DecryptKey(move(deserialized_key_), hidden_, secure_deletion_data_, master_key_); + DecryptKey(std::move(deserialized_key_), hidden_, secure_deletion_data_, master_key_); if (!result) return result.error(); decrypted_plaintext_ = std::move(*result); return KM_ERROR_OK; |