Chromium Code Reviews| Index: content/renderer/webcrypto_impl.cc |
| diff --git a/content/renderer/webcrypto_impl.cc b/content/renderer/webcrypto_impl.cc |
| index ad37457ece6a474927f71c578d8daa5c864a89d5..789c9bfa6f0e3db2cf74ab8ae5a63553f8d9fffd 100644 |
| --- a/content/renderer/webcrypto_impl.cc |
| +++ b/content/renderer/webcrypto_impl.cc |
| @@ -5,6 +5,8 @@ |
| #include "content/renderer/webcrypto_impl.h" |
| #include "third_party/WebKit/public/platform/WebArrayBuffer.h" |
| +#include "third_party/WebKit/public/platform/WebCryptoAlgorithm.h" |
| +#include "third_party/WebKit/public/platform/WebCryptoKey.h" |
| namespace content { |
| @@ -21,4 +23,54 @@ void WebCryptoImpl::digest( |
| } |
| } |
| +void WebCryptoImpl::importKey( |
| + WebKit::WebCryptoKeyFormat format, |
| + const unsigned char* key_data, |
| + size_t key_data_size, |
| + const WebKit::WebCryptoAlgorithm& algorithm, |
| + bool extractable, |
| + WebKit::WebCryptoKeyUsageMask usage_mask, |
| + WebKit::WebCryptoResult result) { |
| + WebKit::WebCryptoKeyType type; |
| + switch (algorithm.id()) { |
| + case WebKit::WebCryptoAlgorithmIdHmac: |
| + type = WebKit::WebCryptoKeyTypeSecret; |
|
eroman
2013/09/05 01:57:51
For the future, we are better off having the "type
Bryan Eyler
2013/09/06 01:27:51
Done.
|
| + break; |
| + default: |
| + result.completeWithError(); |
| + return; |
| + } |
| + |
| + WebKit::WebCryptoKeyHandle* handle; |
| + if (!importKeyInternal(format, |
| + key_data, |
| + key_data_size, |
| + algorithm, |
| + extractable, |
| + usage_mask, |
| + &handle)) { |
| + result.completeWithError(); |
|
eroman
2013/09/05 01:57:51
You need a return statement after this
Bryan Eyler
2013/09/06 01:27:51
Done.
|
| + } |
| + |
| + WebKit::WebCryptoKey key( |
| + WebKit::WebCryptoKey::create( |
| + handle, type, extractable, algorithm, usage_mask)); |
| + |
| + result.completeWithKey(key); |
| +} |
| + |
| +void WebCryptoImpl::sign( |
| + const WebKit::WebCryptoAlgorithm& algorithm, |
| + const WebKit::WebCryptoKey& key, |
| + const unsigned char* data, |
| + size_t data_size, |
| + WebKit::WebCryptoResult result) { |
| + WebKit::WebArrayBuffer buffer; |
| + if (!signInternal(algorithm, key.handle(), data, data_size, &buffer)) { |
| + result.completeWithError(); |
| + } else { |
| + result.completeWithBuffer(buffer); |
| + } |
| +} |
| + |
| } // namespace content |