Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(669)

Side by Side Diff: content/renderer/webcrypto/webcrypto_impl.h

Issue 25906002: [webcrypto] Add JWK import for HMAC and AES-CBC key. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixes for eroman plus more tests Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_RENDERER_WEBCRYPTO_WEBCRYPTO_IMPL_H_ 5 #ifndef CONTENT_RENDERER_WEBCRYPTO_WEBCRYPTO_IMPL_H_
6 #define CONTENT_RENDERER_WEBCRYPTO_WEBCRYPTO_IMPL_H_ 6 #define CONTENT_RENDERER_WEBCRYPTO_WEBCRYPTO_IMPL_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "content/common/content_export.h" 11 #include "content/common/content_export.h"
12 #include "third_party/WebKit/public/platform/WebCrypto.h" 12 #include "third_party/WebKit/public/platform/WebCrypto.h"
13 13
14 namespace content { 14 namespace content {
15 15
16 class CONTENT_EXPORT WebCryptoImpl 16 class CONTENT_EXPORT WebCryptoImpl
17 : NON_EXPORTED_BASE(public WebKit::WebCrypto) { 17 : NON_EXPORTED_BASE(public WebKit::WebCrypto) {
18 public: 18 public:
19 WebCryptoImpl(); 19 WebCryptoImpl();
20 virtual ~WebCryptoImpl();
20 21
21 virtual void encrypt( 22 virtual void encrypt(
22 const WebKit::WebCryptoAlgorithm& algorithm, 23 const WebKit::WebCryptoAlgorithm& algorithm,
23 const WebKit::WebCryptoKey& key, 24 const WebKit::WebCryptoKey& key,
24 const unsigned char* data, 25 const unsigned char* data,
25 unsigned data_size, 26 unsigned data_size,
26 WebKit::WebCryptoResult result); 27 WebKit::WebCryptoResult result);
27 virtual void decrypt( 28 virtual void decrypt(
28 const WebKit::WebCryptoAlgorithm& algorithm, 29 const WebKit::WebCryptoAlgorithm& algorithm,
29 const WebKit::WebCryptoKey& key, 30 const WebKit::WebCryptoKey& key,
(...skipping 26 matching lines...) Expand all
56 WebKit::WebCryptoResult result); 57 WebKit::WebCryptoResult result);
57 virtual void verifySignature( 58 virtual void verifySignature(
58 const WebKit::WebCryptoAlgorithm& algorithm, 59 const WebKit::WebCryptoAlgorithm& algorithm,
59 const WebKit::WebCryptoKey& key, 60 const WebKit::WebCryptoKey& key,
60 const unsigned char* signature, 61 const unsigned char* signature,
61 unsigned signature_size, 62 unsigned signature_size,
62 const unsigned char* data, 63 const unsigned char* data,
63 unsigned data_size, 64 unsigned data_size,
64 WebKit::WebCryptoResult result); 65 WebKit::WebCryptoResult result);
65 66
66 static void ShrinkBuffer(WebKit::WebArrayBuffer* buffer, unsigned new_size);
67
68 protected: 67 protected:
69 friend class WebCryptoImplTest; 68 friend class WebCryptoImplTest;
70 69
71 void Init(); 70 void Init();
72 71
73 bool EncryptInternal( 72 bool EncryptInternal(
74 const WebKit::WebCryptoAlgorithm& algorithm, 73 const WebKit::WebCryptoAlgorithm& algorithm,
75 const WebKit::WebCryptoKey& key, 74 const WebKit::WebCryptoKey& key,
76 const unsigned char* data, 75 const unsigned char* data,
77 unsigned data_size, 76 unsigned data_size,
(...skipping 29 matching lines...) Expand all
107 WebKit::WebArrayBuffer* buffer); 106 WebKit::WebArrayBuffer* buffer);
108 bool VerifySignatureInternal( 107 bool VerifySignatureInternal(
109 const WebKit::WebCryptoAlgorithm& algorithm, 108 const WebKit::WebCryptoAlgorithm& algorithm,
110 const WebKit::WebCryptoKey& key, 109 const WebKit::WebCryptoKey& key,
111 const unsigned char* signature, 110 const unsigned char* signature,
112 unsigned signature_size, 111 unsigned signature_size,
113 const unsigned char* data, 112 const unsigned char* data,
114 unsigned data_size, 113 unsigned data_size,
115 bool* signature_match); 114 bool* signature_match);
116 115
116 bool ImportKeyJwk(
117 const unsigned char* key_data,
118 unsigned key_data_size,
119 bool extractable,
120 const WebKit::WebCryptoAlgorithm& algorithm,
121 WebKit::WebCryptoKeyUsageMask usage_mask,
122 scoped_ptr<WebKit::WebCryptoKeyHandle>* handle,
123 WebKit::WebCryptoKeyType* type);
124
117 private: 125 private:
118 DISALLOW_COPY_AND_ASSIGN(WebCryptoImpl); 126 DISALLOW_COPY_AND_ASSIGN(WebCryptoImpl);
119 }; 127 };
120 128
121 } // namespace content 129 } // namespace content
122 130
123 #endif // CONTENT_RENDERER_WEBCRYPTO_WEBCRYPTO_IMPL_H_ 131 #endif // CONTENT_RENDERER_WEBCRYPTO_WEBCRYPTO_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698