diff options
author | Shawn Willden <swillden@google.com> | 2018-01-08 00:48:10 -0700 |
---|---|---|
committer | Shawn Willden <swillden@google.com> | 2018-01-16 09:46:34 -0700 |
commit | 0797016108191fcf54bec412702d13f1646da041 (patch) | |
tree | 4e245a9eab855bbcd1b13c0138986a5360f42dea /include/keymaster | |
parent | deffcb7efaac94b2c674247cb9888a0af3d7e256 (diff) | |
download | android_system_keymaster-0797016108191fcf54bec412702d13f1646da041.tar.gz android_system_keymaster-0797016108191fcf54bec412702d13f1646da041.tar.bz2 android_system_keymaster-0797016108191fcf54bec412702d13f1646da041.zip |
Refactor AES operations to generalize block cipher operations.
In preparation for adding 3DES support, this CL moves the code that
does all the block cipher work from AesOperation to
EvpBlockCipherOperation (and associated classes). To make it easier
to see what was changed, the block cipher code was left in
aes_operation.{cpp|h}. The next CL will move it to separate files.
Test: make (local unit tests), CTS & VTS
Change-Id: Ibbf870c351425ea8d990218aa0ae089d0b2ada4b
Diffstat (limited to 'include/keymaster')
-rw-r--r-- | include/keymaster/km_openssl/symmetric_key.h | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/include/keymaster/km_openssl/symmetric_key.h b/include/keymaster/km_openssl/symmetric_key.h index 89afd0e..e8a0c12 100644 --- a/include/keymaster/km_openssl/symmetric_key.h +++ b/include/keymaster/km_openssl/symmetric_key.h @@ -18,8 +18,8 @@ #define SYSTEM_KEYMASTER_SYMMETRIC_KEY_H_ #include <keymaster/key_factory.h> -#include <keymaster/soft_key_factory.h> #include <keymaster/random_source.h> +#include <keymaster/soft_key_factory.h> #include <keymaster/key.h> @@ -43,13 +43,19 @@ class SymmetricKeyFactory : public KeyFactory, public SoftKeyFactoryMixin { KeymasterKeyBlob* output_key_blob, AuthorizationSet* hw_enforced, AuthorizationSet* sw_enforced) const override; - virtual const keymaster_key_format_t* SupportedImportFormats(size_t* format_count) const override; - virtual const keymaster_key_format_t* SupportedExportFormats(size_t* format_count) const override { - return NoFormats(format_count); + virtual const keymaster_key_format_t* SupportedImportFormats(size_t* count) const override; + virtual const keymaster_key_format_t* SupportedExportFormats(size_t* count) const override { + return NoFormats(count); }; private: virtual bool key_size_supported(size_t key_size_bits) const = 0; + + // These methods translate between key size in bits and bytes. Normally it's just 8 bits to the + // byte, but DES is different. + virtual size_t key_size_bytes(size_t key_size_bits) const { return key_size_bits / 8; } + virtual size_t key_size_bits(size_t key_size_bytes) const { return key_size_bytes * 8; } + virtual keymaster_error_t validate_algorithm_specific_new_key_params(const AuthorizationSet& key_description) const = 0; |