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

Side by Side Diff: components/webcrypto/algorithms/aes.h

Issue 2163053002: [webcrypto] Check for empty key usages *after* key creation rather than before, to match the spec's… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 4 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
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 #ifndef COMPONENTS_WEBCRYPTO_ALGORITHMS_AES_H_ 5 #ifndef COMPONENTS_WEBCRYPTO_ALGORITHMS_AES_H_
6 #define COMPONENTS_WEBCRYPTO_ALGORITHMS_AES_H_ 6 #define COMPONENTS_WEBCRYPTO_ALGORITHMS_AES_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "components/webcrypto/algorithm_implementation.h" 10 #include "components/webcrypto/algorithm_implementation.h"
(...skipping 15 matching lines...) Expand all
26 // This is the same as the other AesAlgorithm constructor where 26 // This is the same as the other AesAlgorithm constructor where
27 // |all_key_usages| is pre-filled to values for encryption/decryption 27 // |all_key_usages| is pre-filled to values for encryption/decryption
28 // algorithms (supports usages for: encrypt, decrypt, wrap, unwrap). 28 // algorithms (supports usages for: encrypt, decrypt, wrap, unwrap).
29 explicit AesAlgorithm(const std::string& jwk_suffix); 29 explicit AesAlgorithm(const std::string& jwk_suffix);
30 30
31 Status GenerateKey(const blink::WebCryptoAlgorithm& algorithm, 31 Status GenerateKey(const blink::WebCryptoAlgorithm& algorithm,
32 bool extractable, 32 bool extractable,
33 blink::WebCryptoKeyUsageMask usages, 33 blink::WebCryptoKeyUsageMask usages,
34 GenerateKeyResult* result) const override; 34 GenerateKeyResult* result) const override;
35 35
36 Status VerifyKeyUsagesBeforeImportKey( 36 Status ImportKey(blink::WebCryptoKeyFormat format,
37 blink::WebCryptoKeyFormat format, 37 const CryptoData& key_data,
38 blink::WebCryptoKeyUsageMask usages) const override; 38 const blink::WebCryptoAlgorithm& algorithm,
39 bool extractable,
40 blink::WebCryptoKeyUsageMask usages,
41 blink::WebCryptoKey* key) const override;
39 42
40 Status ImportKeyRaw(const CryptoData& key_data, 43 Status ExportKey(blink::WebCryptoKeyFormat format,
41 const blink::WebCryptoAlgorithm& algorithm, 44 const blink::WebCryptoKey& key,
42 bool extractable, 45 std::vector<uint8_t>* buffer) const override;
43 blink::WebCryptoKeyUsageMask usages,
44 blink::WebCryptoKey* key) const override;
45
46 Status ImportKeyJwk(const CryptoData& key_data,
47 const blink::WebCryptoAlgorithm& algorithm,
48 bool extractable,
49 blink::WebCryptoKeyUsageMask usages,
50 blink::WebCryptoKey* key) const override;
51
52 Status ExportKeyRaw(const blink::WebCryptoKey& key,
53 std::vector<uint8_t>* buffer) const override;
54
55 Status ExportKeyJwk(const blink::WebCryptoKey& key,
56 std::vector<uint8_t>* buffer) const override;
57 46
58 Status DeserializeKeyForClone(const blink::WebCryptoKeyAlgorithm& algorithm, 47 Status DeserializeKeyForClone(const blink::WebCryptoKeyAlgorithm& algorithm,
59 blink::WebCryptoKeyType type, 48 blink::WebCryptoKeyType type,
60 bool extractable, 49 bool extractable,
61 blink::WebCryptoKeyUsageMask usages, 50 blink::WebCryptoKeyUsageMask usages,
62 const CryptoData& key_data, 51 const CryptoData& key_data,
63 blink::WebCryptoKey* key) const override; 52 blink::WebCryptoKey* key) const override;
64 53
65 Status GetKeyLength(const blink::WebCryptoAlgorithm& key_length_algorithm, 54 Status GetKeyLength(const blink::WebCryptoAlgorithm& key_length_algorithm,
66 bool* has_length_bits, 55 bool* has_length_bits,
67 unsigned int* length_bits) const override; 56 unsigned int* length_bits) const override;
68 57
69 private: 58 private:
59 Status ImportKeyRaw(const CryptoData& key_data,
60 const blink::WebCryptoAlgorithm& algorithm,
61 bool extractable,
62 blink::WebCryptoKeyUsageMask usages,
63 blink::WebCryptoKey* key) const;
64
65 Status ImportKeyJwk(const CryptoData& key_data,
66 const blink::WebCryptoAlgorithm& algorithm,
67 bool extractable,
68 blink::WebCryptoKeyUsageMask usages,
69 blink::WebCryptoKey* key) const;
70
71 Status ExportKeyRaw(const blink::WebCryptoKey& key,
72 std::vector<uint8_t>* buffer) const;
73
74 Status ExportKeyJwk(const blink::WebCryptoKey& key,
75 std::vector<uint8_t>* buffer) const;
76
70 const blink::WebCryptoKeyUsageMask all_key_usages_; 77 const blink::WebCryptoKeyUsageMask all_key_usages_;
71 const std::string jwk_suffix_; 78 const std::string jwk_suffix_;
72 }; 79 };
73 80
74 } // namespace webcrypto 81 } // namespace webcrypto
75 82
76 #endif // COMPONENTS_WEBCRYPTO_ALGORITHMS_AES_H_ 83 #endif // COMPONENTS_WEBCRYPTO_ALGORITHMS_AES_H_
OLDNEW
« no previous file with comments | « components/webcrypto/algorithm_implementation.cc ('k') | components/webcrypto/algorithms/aes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698