summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorShawn Willden <swillden@google.com>2015-05-25 23:12:48 -0600
committerShawn Willden <swillden@google.com>2015-05-31 09:28:56 -0600
commit0629810b145187575bc26c910dded0d24c64569d (patch)
tree5c1309696f2205777f6aad1c1b5b65aeaa64c9b7 /include
parent6270aca8571399aca8ea538acd7386ddecdcc112 (diff)
downloadandroid_system_keymaster-0629810b145187575bc26c910dded0d24c64569d.tar.gz
android_system_keymaster-0629810b145187575bc26c910dded0d24c64569d.tar.bz2
android_system_keymaster-0629810b145187575bc26c910dded0d24c64569d.zip
Another refactor, deleting AbstractFactoryRegistry.
I should have known better than to make these singletons to begin with. Globals create problems. This undoes that mistake. Change-Id: Idf61d5f72e3c34b5c4ddb27cc94b05f506561743
Diffstat (limited to 'include')
-rw-r--r--include/keymaster/android_keymaster.h3
-rw-r--r--include/keymaster/keymaster_context.h15
-rw-r--r--include/keymaster/soft_keymaster_context.h9
3 files changed, 22 insertions, 5 deletions
diff --git a/include/keymaster/android_keymaster.h b/include/keymaster/android_keymaster.h
index db74b97..c9de8ee 100644
--- a/include/keymaster/android_keymaster.h
+++ b/include/keymaster/android_keymaster.h
@@ -23,6 +23,7 @@
namespace keymaster {
class Key;
+class KeyFactory;
class KeymasterContext;
class OperationTable;
@@ -79,7 +80,7 @@ class AndroidKeymaster {
keymaster_error_t LoadKey(const keymaster_key_blob_t& key_blob,
const AuthorizationSet& additional_params,
AuthorizationSet* hw_enforced, AuthorizationSet* sw_enforced,
- keymaster_algorithm_t* algorithm, UniquePtr<Key>* key);
+ const KeyFactory** factory, UniquePtr<Key>* key);
UniquePtr<KeymasterContext> context_;
UniquePtr<OperationTable> operation_table_;
diff --git a/include/keymaster/keymaster_context.h b/include/keymaster/keymaster_context.h
index 0b9b62b..be4f8d7 100644
--- a/include/keymaster/keymaster_context.h
+++ b/include/keymaster/keymaster_context.h
@@ -19,11 +19,15 @@
#include <assert.h>
-#include <keymaster/authorization_set.h>
-#include <keymaster/android_keymaster_utils.h>
+#include <hardware/keymaster_defs.h>
namespace keymaster {
+class AuthorizationSet;
+class KeyFactory;
+class OperationFactory;
+struct KeymasterKeyBlob;
+
/**
* KeymasterContext provides a singleton abstract interface that encapsulates various
* environment-dependent elements of AndroidKeymaster.
@@ -58,12 +62,17 @@ class KeymasterContext {
KeymasterContext() {}
virtual ~KeymasterContext(){};
+ virtual KeyFactory* GetKeyFactory(keymaster_algorithm_t algorithm) const = 0;
+ virtual OperationFactory* GetOperationFactory(keymaster_algorithm_t algorithm,
+ keymaster_purpose_t purpose) const = 0;
+ virtual keymaster_algorithm_t* GetSupportedAlgorithms(size_t* algorithms_count) const = 0;
+
/**
* CreateKeyBlob takes authorization sets and key material and produces a key blob and hardware
* and software authorization lists ready to be returned to the AndroidKeymaster client
* (Keystore, generally). The blob is integrity-checked and may be encrypted, depending on the
* needs of the context.
- *
+ *
* This method is generally called only by KeyFactory subclassses.
*/
virtual keymaster_error_t CreateKeyBlob(const AuthorizationSet& key_description,
diff --git a/include/keymaster/soft_keymaster_context.h b/include/keymaster/soft_keymaster_context.h
index 33afe3d..7cf3703 100644
--- a/include/keymaster/soft_keymaster_context.h
+++ b/include/keymaster/soft_keymaster_context.h
@@ -34,6 +34,10 @@ class SoftKeymasterContext : public KeymasterContext {
public:
SoftKeymasterContext(keymaster0_device_t* keymaster0_device);
+ KeyFactory* GetKeyFactory(keymaster_algorithm_t algorithm) const override;
+ OperationFactory* GetOperationFactory(keymaster_algorithm_t algorithm,
+ keymaster_purpose_t purpose) const override;
+ keymaster_algorithm_t* GetSupportedAlgorithms(size_t* algorithms_count) const override;
keymaster_error_t CreateKeyBlob(const AuthorizationSet& auths, keymaster_key_origin_t origin,
const KeymasterKeyBlob& key_material, KeymasterKeyBlob* blob,
AuthorizationSet* hw_enforced,
@@ -48,7 +52,10 @@ class SoftKeymasterContext : public KeymasterContext {
private:
std::unique_ptr<Keymaster0Engine> engine_;
- std::unique_ptr<SoftKeymasterKeyRegistrations> registrations_;
+ std::unique_ptr<KeyFactory> rsa_factory_;
+ std::unique_ptr<KeyFactory> ec_factory_;
+ std::unique_ptr<KeyFactory> aes_factory_;
+ std::unique_ptr<KeyFactory> hmac_factory_;
};
} // namespace keymaster