Add key export, RSA only. (rileyspahn@google.com implemented).
Change-Id: I55c3497a1dc5360bfc8518a388b73776388a47e4
diff --git a/google_keymaster_test.cpp b/google_keymaster_test.cpp
index 38eb164..8507924 100644
--- a/google_keymaster_test.cpp
+++ b/google_keymaster_test.cpp
@@ -487,6 +487,7 @@
TEST_F(SigningOperationsTest, RsaSuccess) {
GenerateKey(KM_ALGORITHM_RSA, KM_DIGEST_NONE, KM_PAD_NONE, 256 /* key size */);
+ const char message[] = "12345678901234567890123456789012";
BeginOperationRequest begin_request;
BeginOperationResponse begin_response;
@@ -500,8 +501,8 @@
UpdateOperationRequest update_request;
UpdateOperationResponse update_response;
update_request.op_handle = begin_response.op_handle;
- update_request.input.Reinitialize("012345678901234567890123456789012", 32);
- EXPECT_EQ(32U, update_request.input.available_read());
+ update_request.input.Reinitialize(message, array_size(message) - 1);
+ EXPECT_EQ(array_size(message) - 1, update_request.input.available_read());
device.UpdateOperation(update_request, &update_response);
ASSERT_EQ(KM_ERROR_OK, update_response.error);
@@ -802,5 +803,21 @@
EXPECT_EQ(KM_ERROR_INVALID_OPERATION_HANDLE, device.AbortOperation(begin_response.op_handle));
}
+typedef SigningOperationsTest ExportKeyTest;
+TEST_F(ExportKeyTest, RsaSuccess) {
+ GenerateKey(KM_ALGORITHM_RSA, KM_DIGEST_NONE, KM_PAD_NONE, 256 /* key size */);
+ ASSERT_TRUE(signature() != NULL);
+
+ ExportKeyRequest request;
+ ExportKeyResponse response;
+ AddClientParams(&request.additional_params);
+ request.key_format = KM_KEY_FORMAT_X509;
+ request.SetKeyMaterial(key_blob());
+
+ device.ExportKey(request, &response);
+ ASSERT_EQ(KM_ERROR_OK, response.error);
+ EXPECT_TRUE(response.key_data != NULL);
+}
+
} // namespace test
} // namespace keymaster