Revert "Large refactor to move context out of AndroidKeymaster."
This reverts commit 8ba2a043f0d44ad3f58d4af518f9391c03eca9c3.
I need to update the Volantis non-secure code in sync. Reverting while I get that done.
Change-Id: I0fb9f928e7e624ad678050a04bb873b43b1c9a48
diff --git a/ec_key.h b/ec_key.h
index e3e15f6..1748fe0 100644
--- a/ec_key.h
+++ b/ec_key.h
@@ -25,20 +25,11 @@
class EcKeyFactory : public AsymmetricKeyFactory {
public:
- EcKeyFactory(const KeymasterContext* context) : AsymmetricKeyFactory(context) {}
-
- keymaster_error_t GenerateKey(const AuthorizationSet& key_description,
- KeymasterKeyBlob* key_blob, AuthorizationSet* hw_enforced,
- AuthorizationSet* sw_enforced) override;
- keymaster_error_t ImportKey(const AuthorizationSet& key_description,
- keymaster_key_format_t input_key_material_format,
- const KeymasterKeyBlob& input_key_material,
- KeymasterKeyBlob* output_key_blob, AuthorizationSet* hw_enforced,
- AuthorizationSet* sw_enforced) override;
-
- keymaster_error_t CreateEmptyKey(const AuthorizationSet& hw_enforced,
- const AuthorizationSet& sw_enforced,
- UniquePtr<AsymmetricKey>* key) override;
+ Key* GenerateKey(const AuthorizationSet& key_description, keymaster_error_t* error) override;
+ Key* ImportKey(const AuthorizationSet& key_description, keymaster_key_format_t key_format,
+ const uint8_t* key_data, size_t key_data_length,
+ keymaster_error_t* error) override;
+ Key* LoadKey(const UnencryptedKeyBlob& blob, keymaster_error_t* error) override;
private:
static EC_GROUP* choose_group(size_t key_size_bits);
@@ -51,22 +42,23 @@
class EcdsaKeyFactory : public EcKeyFactory {
public:
- EcdsaKeyFactory(const KeymasterContext* context) : EcKeyFactory(context) {}
-
- keymaster_algorithm_t registry_key() const override { return KM_ALGORITHM_EC; }
- int evp_key_type() override { return EVP_PKEY_EC; }
+ virtual keymaster_algorithm_t registry_key() const { return KM_ALGORITHM_EC; }
};
class EcdsaOperationFactory;
class EcKey : public AsymmetricKey {
- public:
- EcKey(const AuthorizationSet& hw_enforced, const AuthorizationSet& sw_enforced,
- keymaster_error_t* error)
- : AsymmetricKey(hw_enforced, sw_enforced, error) {}
+ private:
+ friend EcKeyFactory;
+ friend EcdsaKeyFactory;
+ friend EcdsaOperationFactory;
- bool InternalToEvp(EVP_PKEY* pkey) const override;
- bool EvpToInternal(const EVP_PKEY* pkey) override;
+ EcKey(const UnencryptedKeyBlob& blob, keymaster_error_t* error);
+ EcKey(EC_KEY* ec_key, const AuthorizationSet auths) : AsymmetricKey(auths), ec_key_(ec_key) {}
+
+ virtual int evp_key_type() { return EVP_PKEY_EC; }
+ virtual bool InternalToEvp(EVP_PKEY* pkey) const;
+ virtual bool EvpToInternal(const EVP_PKEY* pkey);
struct EC_Delete {
void operator()(EC_KEY* p) { EC_KEY_free(p); }