KM default implementations: Add vendor and boot patchlevels.

Default (software) implementations need to return vendor and boot patch
levels. This CL sets this information. Since software implementations
have no means of getting information from the bootloader, the os
patchlevel is used in its place.

Bug: 189973657
Test: keystore2_km_compat_test
Change-Id: I4f60caabf6459ecd9bdc15ed3aabd9f91a04b197
diff --git a/ng/AndroidKeymaster3Device.cpp b/ng/AndroidKeymaster3Device.cpp
index da00d96..7e56a0a 100644
--- a/ng/AndroidKeymaster3Device.cpp
+++ b/ng/AndroidKeymaster3Device.cpp
@@ -225,6 +225,12 @@
             [] () -> auto {
                 auto context = new PureSoftKeymasterContext();
                 context->SetSystemVersion(GetOsVersion(), GetOsPatchlevel());
+                context->SetVendorPatchlevel(GetVendorPatchlevel());
+                // Software devices cannot be configured by the boot loader but they have
+                // to return a boot patch level. So lets just return the OS patch level.
+                // The OS patch level only has a year and a month so we just add the 1st
+                // of the month as day field.
+                context->SetBootPatchlevel(GetOsPatchlevel() * 100 + 1);
                 return context;
             } (), kOperationTableSize)), profile_(KeymasterHardwareProfile::SW) {}
 
diff --git a/ng/AndroidKeymaster4Device.cpp b/ng/AndroidKeymaster4Device.cpp
index 9a71360..d773064 100644
--- a/ng/AndroidKeymaster4Device.cpp
+++ b/ng/AndroidKeymaster4Device.cpp
@@ -226,6 +226,12 @@
               auto context = new PureSoftKeymasterContext(
                   static_cast<keymaster_security_level_t>(securityLevel));
               context->SetSystemVersion(GetOsVersion(), GetOsPatchlevel());
+              context->SetVendorPatchlevel(GetVendorPatchlevel());
+              // Software devices cannot be configured by the boot loader but they have
+              // to return a boot patch level. So lets just return the OS patch level.
+              // The OS patch level only has a year and a month so we just add the 1st
+              // of the month as day field.
+              context->SetBootPatchlevel(GetOsPatchlevel() * 100 + 1);
               return context;
           }(),
           kOperationTableSize)),