Make keymaster's version configurable.

Test: Keystore CTS tests and Keymaster/KeyMint VTS tests on cuttlefish
Bug: b/173577355
Change-Id: Ie7dda2c09b9d0b8e5b5b69ba4056ac40af67c870
diff --git a/ng/AndroidKeymaster3Device.cpp b/ng/AndroidKeymaster3Device.cpp
index da00d96..b621ba8 100644
--- a/ng/AndroidKeymaster3Device.cpp
+++ b/ng/AndroidKeymaster3Device.cpp
@@ -222,12 +222,13 @@
 
 AndroidKeymaster3Device::AndroidKeymaster3Device()
     : impl_(new ::keymaster::AndroidKeymaster(
-            [] () -> auto {
-                auto context = new PureSoftKeymasterContext();
-                context->SetSystemVersion(GetOsVersion(), GetOsPatchlevel());
-                return context;
-            } (), kOperationTableSize)), profile_(KeymasterHardwareProfile::SW) {}
-
+          []() -> auto {
+              auto context = new PureSoftKeymasterContext(KmVersion::KEYMASTER_3);
+              context->SetSystemVersion(GetOsVersion(), GetOsPatchlevel());
+              return context;
+          }(),
+          kOperationTableSize)),
+      profile_(KeymasterHardwareProfile::SW) {}
 
 AndroidKeymaster3Device::AndroidKeymaster3Device(KeymasterContext* context, KeymasterHardwareProfile profile)
     : impl_(new ::keymaster::AndroidKeymaster(context, kOperationTableSize)), profile_(profile) {}
@@ -496,19 +497,22 @@
 IKeymasterDevice* CreateKeymasterDevice() {
     return new AndroidKeymaster3Device();
 }
+
 IKeymasterDevice* CreateKeymasterDevice(keymaster2_device_t* km2_device) {
     if (ConfigureDevice(km2_device) != KM_ERROR_OK) return nullptr;
     auto context = new Keymaster2PassthroughContext(km2_device);
     context->SetSystemVersion(GetOsVersion(), GetOsPatchlevel());
     return new AndroidKeymaster3Device(context, KeymasterHardwareProfile::KM2);
 }
+
 IKeymasterDevice* CreateKeymasterDevice(keymaster1_device_t* km1_device) {
-    auto context = new Keymaster1PassthroughContext(km1_device);
+    auto context = new Keymaster1PassthroughContext(KmVersion::KEYMASTER_3, km1_device);
     context->SetSystemVersion(GetOsVersion(), GetOsPatchlevel());
     return new AndroidKeymaster3Device(context, KeymasterHardwareProfile::KM1);
 }
+
 IKeymasterDevice* CreateKeymasterDevice(keymaster0_device_t* km0_device) {
-    auto context = new Keymaster0PassthroughContext(km0_device);
+    auto context = new Keymaster0PassthroughContext(KmVersion::KEYMASTER_3, km0_device);
     context->SetSystemVersion(GetOsVersion(), GetOsPatchlevel());
     return new AndroidKeymaster3Device(context, KeymasterHardwareProfile::KM0);
 }