diff options
author | Shawn Willden <swillden@google.com> | 2018-01-08 22:00:12 -0700 |
---|---|---|
committer | Shawn Willden <swillden@google.com> | 2018-01-17 14:26:08 -0700 |
commit | 7efc77216ead495bcfe4504be9040cb8a8b284ca (patch) | |
tree | 56135057227c4f245cd8be40ffb9b3a6def8cd46 /contexts | |
parent | dd7e8a099bdc6310c066d7b99f29faa8d0932c86 (diff) | |
download | android_system_keymaster-7efc77216ead495bcfe4504be9040cb8a8b284ca.tar.gz android_system_keymaster-7efc77216ead495bcfe4504be9040cb8a8b284ca.tar.bz2 android_system_keymaster-7efc77216ead495bcfe4504be9040cb8a8b284ca.zip |
Add Triple DES support
Bug: 31675676
Test: make (will run local unit tests)
Change-Id: I4ed2ebcb087ccf6b9976c8899fc795c09dfad408
Diffstat (limited to 'contexts')
-rw-r--r-- | contexts/keymaster1_passthrough_context.cpp | 3 | ||||
-rw-r--r-- | contexts/pure_soft_keymaster_context.cpp | 8 | ||||
-rw-r--r-- | contexts/soft_keymaster_context.cpp | 19 | ||||
-rw-r--r-- | contexts/soft_keymaster_device.cpp | 3 |
4 files changed, 23 insertions, 10 deletions
diff --git a/contexts/keymaster1_passthrough_context.cpp b/contexts/keymaster1_passthrough_context.cpp index 3f3c371..dab8f37 100644 --- a/contexts/keymaster1_passthrough_context.cpp +++ b/contexts/keymaster1_passthrough_context.cpp @@ -72,6 +72,9 @@ KeyFactory* Keymaster1PassthroughContext::GetKeyFactory(keymaster_algorithm_t al result.reset(new Keymaster1ArbitrationFactory<HmacKeyFactory>(pt_engine_.get(), KM_ALGORITHM_HMAC, device_, this, this)); break; + case KM_ALGORITHM_TRIPLE_DES: + // Not supported by KM1. + return nullptr; } } return result.get(); diff --git a/contexts/pure_soft_keymaster_context.cpp b/contexts/pure_soft_keymaster_context.cpp index 71622a9..b4d1fb7 100644 --- a/contexts/pure_soft_keymaster_context.cpp +++ b/contexts/pure_soft_keymaster_context.cpp @@ -39,6 +39,7 @@ #include <keymaster/km_openssl/openssl_utils.h> #include <keymaster/km_openssl/rsa_key_factory.h> #include <keymaster/km_openssl/soft_keymaster_enforcement.h> +#include <keymaster/km_openssl/triple_des_key.h> #include <keymaster/logger.h> #include <keymaster/operation.h> #include <keymaster/wrapped_key.h> @@ -51,8 +52,9 @@ namespace keymaster { PureSoftKeymasterContext::PureSoftKeymasterContext() : rsa_factory_(new RsaKeyFactory(this)), ec_factory_(new EcKeyFactory(this)), - aes_factory_(new AesKeyFactory(this, this)), hmac_factory_(new HmacKeyFactory(this, this)), - os_version_(0), os_patchlevel_(0), + aes_factory_(new AesKeyFactory(this, this)), + tdes_factory_(new TripleDesKeyFactory(this, this)), + hmac_factory_(new HmacKeyFactory(this, this)), os_version_(0), os_patchlevel_(0), soft_keymaster_enforcement_(64, 64) {} PureSoftKeymasterContext::~PureSoftKeymasterContext() {} @@ -77,6 +79,8 @@ KeyFactory* PureSoftKeymasterContext::GetKeyFactory(keymaster_algorithm_t algori return ec_factory_.get(); case KM_ALGORITHM_AES: return aes_factory_.get(); + case KM_ALGORITHM_TRIPLE_DES: + return tdes_factory_.get(); case KM_ALGORITHM_HMAC: return hmac_factory_.get(); default: diff --git a/contexts/soft_keymaster_context.cpp b/contexts/soft_keymaster_context.cpp index dc9dcd5..7c28bdc 100644 --- a/contexts/soft_keymaster_context.cpp +++ b/contexts/soft_keymaster_context.cpp @@ -25,16 +25,17 @@ #include <keymaster/key_blob_utils/integrity_assured_key_blob.h> #include <keymaster/key_blob_utils/ocb_utils.h> #include <keymaster/key_blob_utils/software_keyblobs.h> -#include <keymaster/legacy_support/ec_keymaster0_key.h> -#include <keymaster/legacy_support/ec_keymaster1_key.h> -#include <keymaster/legacy_support/keymaster0_engine.h> -#include <keymaster/legacy_support/rsa_keymaster0_key.h> -#include <keymaster/legacy_support/rsa_keymaster1_key.h> #include <keymaster/km_openssl/aes_key.h> #include <keymaster/km_openssl/asymmetric_key.h> #include <keymaster/km_openssl/attestation_utils.h> #include <keymaster/km_openssl/hmac_key.h> #include <keymaster/km_openssl/openssl_err.h> +#include <keymaster/km_openssl/triple_des_key.h> +#include <keymaster/legacy_support/ec_keymaster0_key.h> +#include <keymaster/legacy_support/ec_keymaster1_key.h> +#include <keymaster/legacy_support/keymaster0_engine.h> +#include <keymaster/legacy_support/rsa_keymaster0_key.h> +#include <keymaster/legacy_support/rsa_keymaster1_key.h> #include <keymaster/logger.h> #include "soft_attestation_cert.h" @@ -53,8 +54,10 @@ KeymasterBlob string2Blob(const std::string& str) { SoftKeymasterContext::SoftKeymasterContext(const std::string& root_of_trust) : rsa_factory_(new RsaKeyFactory(this)), ec_factory_(new EcKeyFactory(this)), - aes_factory_(new AesKeyFactory(this, this)), hmac_factory_(new HmacKeyFactory(this, this)), - km1_dev_(nullptr), root_of_trust_(string2Blob(root_of_trust)), os_version_(0), os_patchlevel_(0) {} + aes_factory_(new AesKeyFactory(this, this)), + tdes_factory_(new TripleDesKeyFactory(this, this)), + hmac_factory_(new HmacKeyFactory(this, this)), km1_dev_(nullptr), + root_of_trust_(string2Blob(root_of_trust)), os_version_(0), os_patchlevel_(0) {} SoftKeymasterContext::~SoftKeymasterContext() {} @@ -111,6 +114,8 @@ KeyFactory* SoftKeymasterContext::GetKeyFactory(keymaster_algorithm_t algorithm) return ec_factory_.get(); case KM_ALGORITHM_AES: return aes_factory_.get(); + case KM_ALGORITHM_TRIPLE_DES: + return tdes_factory_.get(); case KM_ALGORITHM_HMAC: return hmac_factory_.get(); default: diff --git a/contexts/soft_keymaster_device.cpp b/contexts/soft_keymaster_device.cpp index 6864151..c3c7af5 100644 --- a/contexts/soft_keymaster_device.cpp +++ b/contexts/soft_keymaster_device.cpp @@ -694,7 +694,8 @@ bool SoftKeymasterDevice::RequiresSoftwareDigesting(keymaster_algorithm_t algori switch (algorithm) { case KM_ALGORITHM_AES: - LOG_D("Not performing software digesting for AES keys", algorithm); + case KM_ALGORITHM_TRIPLE_DES: + LOG_D("Not performing software digesting for algorithm %d", algorithm); return false; case KM_ALGORITHM_HMAC: case KM_ALGORITHM_RSA: |