Index: content/child/webcrypto/test/test_helpers.cc |
diff --git a/content/child/webcrypto/test/test_helpers.cc b/content/child/webcrypto/test/test_helpers.cc |
index e7f76ff3e532acf087d92a39c8fc01c8016288dc..ddabd7574c459a881144d253ad7ffed26e1c41d8 100644 |
--- a/content/child/webcrypto/test/test_helpers.cc |
+++ b/content/child/webcrypto/test/test_helpers.cc |
@@ -17,6 +17,7 @@ |
#include "base/values.h" |
#include "content/child/webcrypto/algorithm_dispatch.h" |
#include "content/child/webcrypto/crypto_data.h" |
+#include "content/child/webcrypto/generate_key_result.h" |
#include "content/child/webcrypto/jwk.h" |
#include "content/child/webcrypto/status.h" |
#include "content/child/webcrypto/webcrypto_util.h" |
@@ -580,6 +581,42 @@ void ImportExportJwkSymmetricKey( |
EXPECT_BYTES_EQ_HEX(key_hex, key_raw_out); |
} |
+Status GenerateSecretKey(const blink::WebCryptoAlgorithm& algorithm, |
+ bool extractable, |
+ blink::WebCryptoKeyUsageMask usage_mask, |
+ blink::WebCryptoKey* key) { |
+ GenerateKeyResult result; |
+ Status status = GenerateKey(algorithm, extractable, usage_mask, &result); |
+ if (status.IsError()) |
+ return status; |
+ |
+ if (result.type() != GenerateKeyResult::TYPE_SECRET_KEY) |
+ return Status::ErrorUnexpected(); |
+ |
+ *key = result.secret_key(); |
+ |
+ return Status::Success(); |
+} |
+ |
+Status GenerateKeyPair(const blink::WebCryptoAlgorithm& algorithm, |
+ bool extractable, |
+ blink::WebCryptoKeyUsageMask usage_mask, |
+ blink::WebCryptoKey* public_key, |
+ blink::WebCryptoKey* private_key) { |
+ GenerateKeyResult result; |
+ Status status = GenerateKey(algorithm, extractable, usage_mask, &result); |
+ if (status.IsError()) |
+ return status; |
+ |
+ if (result.type() != GenerateKeyResult::TYPE_PUBLIC_PRIVATE_KEY_PAIR) |
+ return Status::ErrorUnexpected(); |
+ |
+ *public_key = result.public_key(); |
+ *private_key = result.private_key(); |
+ |
+ return Status::Success(); |
+} |
+ |
} // namespace webcrypto |
} // namesapce content |