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

Side by Side Diff: content/child/webcrypto/shared_crypto_unittest.cc

Issue 267323009: [webcrypto] Add deriveBits key_op to JWK import/export. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months 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 | Annotate | Revision Log
« no previous file with comments | « content/child/webcrypto/jwk.cc ('k') | content/child/webcrypto/webcrypto_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "content/child/webcrypto/shared_crypto.h" 5 #include "content/child/webcrypto/shared_crypto.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 1167 matching lines...) Expand 10 before | Expand all | Expand 10 after
1178 ImportKeyJwkFromDict(dict, aes_cbc_algorithm, false, 0, &key)); 1178 ImportKeyJwkFromDict(dict, aes_cbc_algorithm, false, 0, &key));
1179 EXPECT_EQ(0, key.usages()); 1179 EXPECT_EQ(0, key.usages());
1180 1180
1181 // Test each key_ops value translates to the correct Web Crypto value. 1181 // Test each key_ops value translates to the correct Web Crypto value.
1182 struct TestCase { 1182 struct TestCase {
1183 const char* jwk_key_op; 1183 const char* jwk_key_op;
1184 const char* jwk_alg; 1184 const char* jwk_alg;
1185 const blink::WebCryptoAlgorithm algorithm; 1185 const blink::WebCryptoAlgorithm algorithm;
1186 const blink::WebCryptoKeyUsage usage; 1186 const blink::WebCryptoKeyUsage usage;
1187 }; 1187 };
1188 // TODO(padolph): Add 'deriveBits' key_ops value once it is supported.
1189 const TestCase test_case[] = { 1188 const TestCase test_case[] = {
1190 {"encrypt", "A128CBC", aes_cbc_algorithm, 1189 {"encrypt", "A128CBC", aes_cbc_algorithm,
1191 blink::WebCryptoKeyUsageEncrypt}, 1190 blink::WebCryptoKeyUsageEncrypt},
1192 {"decrypt", "A128CBC", aes_cbc_algorithm, 1191 {"decrypt", "A128CBC", aes_cbc_algorithm,
1193 blink::WebCryptoKeyUsageDecrypt}, 1192 blink::WebCryptoKeyUsageDecrypt},
1194 {"sign", "HS256", hmac_algorithm, blink::WebCryptoKeyUsageSign}, 1193 {"sign", "HS256", hmac_algorithm, blink::WebCryptoKeyUsageSign},
1195 {"verify", "HS256", hmac_algorithm, blink::WebCryptoKeyUsageVerify}, 1194 {"verify", "HS256", hmac_algorithm, blink::WebCryptoKeyUsageVerify},
1196 {"wrapKey", "A128KW", aes_kw_algorithm, blink::WebCryptoKeyUsageWrapKey}, 1195 {"wrapKey", "A128KW", aes_kw_algorithm, blink::WebCryptoKeyUsageWrapKey},
1197 {"unwrapKey", "A128KW", aes_kw_algorithm, 1196 {"unwrapKey", "A128KW", aes_kw_algorithm,
1198 blink::WebCryptoKeyUsageUnwrapKey}, 1197 blink::WebCryptoKeyUsageUnwrapKey},
1199 {"deriveKey", "HS256", hmac_algorithm, 1198 {"deriveKey", "HS256", hmac_algorithm,
1200 blink::WebCryptoKeyUsageDeriveKey}}; 1199 blink::WebCryptoKeyUsageDeriveKey},
1200 {"deriveBits", "HS256", hmac_algorithm,
1201 blink::WebCryptoKeyUsageDeriveBits}};
Ryan Sleevi 2014/05/09 00:06:03 Hrm. Not sure if a spec bug or not that you can im
eroman 2014/05/09 00:36:49 It is not a spec bug, it is an implementation bug.
1201 for (size_t test_index = 0; test_index < ARRAYSIZE_UNSAFE(test_case); 1202 for (size_t test_index = 0; test_index < ARRAYSIZE_UNSAFE(test_case);
1202 ++test_index) { 1203 ++test_index) {
1203 SCOPED_TRACE(test_index); 1204 SCOPED_TRACE(test_index);
1204 dict.SetString("alg", test_case[test_index].jwk_alg); 1205 dict.SetString("alg", test_case[test_index].jwk_alg);
1205 key_ops->Clear(); 1206 key_ops->Clear();
1206 key_ops->AppendString(test_case[test_index].jwk_key_op); 1207 key_ops->AppendString(test_case[test_index].jwk_key_op);
1207 EXPECT_EQ(Status::Success(), 1208 EXPECT_EQ(Status::Success(),
1208 ImportKeyJwkFromDict(dict, 1209 ImportKeyJwkFromDict(dict,
1209 test_case[test_index].algorithm, 1210 test_case[test_index].algorithm,
1210 false, 1211 false,
(...skipping 2208 matching lines...) Expand 10 before | Expand all | Expand 10 after
3419 algorithm, 3420 algorithm,
3420 CreateAesCbcAlgorithm(std::vector<uint8>(0, 16)), 3421 CreateAesCbcAlgorithm(std::vector<uint8>(0, 16)),
3421 true, 3422 true,
3422 blink::WebCryptoKeyUsageEncrypt, 3423 blink::WebCryptoKeyUsageEncrypt,
3423 &unwrapped_key)); 3424 &unwrapped_key));
3424 } 3425 }
3425 3426
3426 } // namespace webcrypto 3427 } // namespace webcrypto
3427 3428
3428 } // namespace content 3429 } // namespace content
OLDNEW
« no previous file with comments | « content/child/webcrypto/jwk.cc ('k') | content/child/webcrypto/webcrypto_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698