OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_CHILD_WEBCRYPTO_NSS_AES_NSS_H_ |
| 6 #define CONTENT_CHILD_WEBCRYPTO_NSS_AES_NSS_H_ |
| 7 |
| 8 #include <pkcs11t.h> |
| 9 |
| 10 #include "content/child/webcrypto/algorithm.h" |
| 11 |
| 12 namespace content { |
| 13 |
| 14 namespace webcrypto { |
| 15 |
| 16 // Base class for AES algorithms that provides the implementation for key |
| 17 // creation and export. |
| 18 class AesAlgorithm : public AlgorithmImplementation { |
| 19 public: |
| 20 AesAlgorithm(CK_MECHANISM_TYPE import_mechanism, |
| 21 CK_FLAGS import_flags, |
| 22 blink::WebCryptoKeyUsageMask all_key_usages, |
| 23 const char* jwk_suffix); |
| 24 |
| 25 // Shortcut for creating an encryption algorithm, with support for encrypt, |
| 26 // decrypt, wrap, unwrap. |
| 27 AesAlgorithm(CK_MECHANISM_TYPE import_mechanism, const char* jwk_suffix); |
| 28 |
| 29 virtual Status GenerateSecretKey(const blink::WebCryptoAlgorithm& algorithm, |
| 30 bool extractable, |
| 31 blink::WebCryptoKeyUsageMask usage_mask, |
| 32 blink::WebCryptoKey* key) const OVERRIDE; |
| 33 |
| 34 virtual Status VerifyKeyUsagesBeforeImportKey( |
| 35 blink::WebCryptoKeyFormat format, |
| 36 blink::WebCryptoKeyUsageMask usage_mask) const OVERRIDE; |
| 37 |
| 38 virtual Status VerifyKeyUsagesBeforeGenerateKey( |
| 39 blink::WebCryptoKeyUsageMask usage_mask) const OVERRIDE; |
| 40 |
| 41 virtual Status ImportKeyRaw(const CryptoData& key_data, |
| 42 const blink::WebCryptoAlgorithm& algorithm, |
| 43 bool extractable, |
| 44 blink::WebCryptoKeyUsageMask usage_mask, |
| 45 blink::WebCryptoKey* key) const OVERRIDE; |
| 46 |
| 47 virtual Status ImportKeyJwk(const CryptoData& key_data, |
| 48 const blink::WebCryptoAlgorithm& algorithm, |
| 49 bool extractable, |
| 50 blink::WebCryptoKeyUsageMask usage_mask, |
| 51 blink::WebCryptoKey* key) const OVERRIDE; |
| 52 |
| 53 virtual Status ExportKeyRaw(const blink::WebCryptoKey& key, |
| 54 std::vector<uint8>* buffer) const OVERRIDE; |
| 55 |
| 56 virtual Status ExportKeyJwk(const blink::WebCryptoKey& key, |
| 57 std::vector<uint8>* buffer) const OVERRIDE; |
| 58 |
| 59 private: |
| 60 std::string GetJwkAlgorithmName(unsigned int keylen_bytes) const; |
| 61 |
| 62 const CK_MECHANISM_TYPE import_mechanism_; |
| 63 const CK_FLAGS import_flags_; |
| 64 const blink::WebCryptoKeyUsageMask all_key_usages_; |
| 65 const char* const jwk_suffix_; |
| 66 }; |
| 67 |
| 68 } // namespace webcrypto |
| 69 |
| 70 } // namespace content |
| 71 |
| 72 #endif // CONTENT_CHILD_WEBCRYPTO_NSS_AES_NSS_H_ |
OLD | NEW |