| OLD | NEW |
| 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 CONTENT_CHILD_WEBCRYPTO_OPENSSL_RSA_KEY_OPENSSL_H_ | 5 #ifndef CONTENT_CHILD_WEBCRYPTO_OPENSSL_EC_KEY_OPENSSL_H_ |
| 6 #define CONTENT_CHILD_WEBCRYPTO_OPENSSL_RSA_KEY_OPENSSL_H_ | 6 #define CONTENT_CHILD_WEBCRYPTO_OPENSSL_EC_KEY_OPENSSL_H_ |
| 7 | 7 |
| 8 #include "content/child/webcrypto/algorithm_implementation.h" | 8 #include "content/child/webcrypto/algorithm_implementation.h" |
| 9 | 9 |
| 10 namespace content { | 10 namespace content { |
| 11 | 11 |
| 12 namespace webcrypto { | 12 namespace webcrypto { |
| 13 | 13 |
| 14 // Base class for an RSA algorithm whose keys additionaly have a hash parameter | 14 // Base class for an EC algorithm. Provides functionality for generating, |
| 15 // bound to them. Provides functionality for generating, importing, and | 15 // importing, and exporting keys. |
| 16 // exporting keys. | 16 class EcAlgorithm : public AlgorithmImplementation { |
| 17 class RsaHashedAlgorithm : public AlgorithmImplementation { | |
| 18 public: | 17 public: |
| 19 // |all_public_key_usages| and |all_private_key_usages| are the set of | 18 // |all_public_key_usages| and |all_private_key_usages| are the set of |
| 20 // WebCrypto key usages that are valid for created keys (public and private | 19 // WebCrypto key usages that are valid for created keys (public and private |
| 21 // respectively). | 20 // respectively). |
| 22 // | 21 EcAlgorithm(blink::WebCryptoKeyUsageMask all_public_key_usages, |
| 23 // For instance if public keys support encryption and wrapping, and private | 22 blink::WebCryptoKeyUsageMask all_private_key_usages) |
| 24 // keys support decryption and unwrapping callers should set: | |
| 25 // all_public_key_usages = UsageEncrypt | UsageWrap | |
| 26 // all_private_key_usages = UsageDecrypt | UsageUnwrap | |
| 27 // This information is used when importing or generating keys, to enforce | |
| 28 // that valid key usages are allowed. | |
| 29 RsaHashedAlgorithm(blink::WebCryptoKeyUsageMask all_public_key_usages, | |
| 30 blink::WebCryptoKeyUsageMask all_private_key_usages) | |
| 31 : all_public_key_usages_(all_public_key_usages), | 23 : all_public_key_usages_(all_public_key_usages), |
| 32 all_private_key_usages_(all_private_key_usages) {} | 24 all_private_key_usages_(all_private_key_usages) {} |
| 33 | 25 |
| 34 // For instance "RSA-OAEP-256". | 26 // For instance "ES256". |
| 35 virtual const char* GetJwkAlgorithm( | 27 virtual const char* GetJwkAlgorithm( |
| 36 const blink::WebCryptoAlgorithmId hash) const = 0; | 28 const blink::WebCryptoNamedCurve curve) const = 0; |
| 37 | 29 |
| 38 Status GenerateKey(const blink::WebCryptoAlgorithm& algorithm, | 30 Status GenerateKey(const blink::WebCryptoAlgorithm& algorithm, |
| 39 bool extractable, | 31 bool extractable, |
| 40 blink::WebCryptoKeyUsageMask usages, | 32 blink::WebCryptoKeyUsageMask usages, |
| 41 GenerateKeyResult* result) const override; | 33 GenerateKeyResult* result) const override; |
| 42 | 34 |
| 43 Status VerifyKeyUsagesBeforeImportKey( | 35 Status VerifyKeyUsagesBeforeImportKey( |
| 44 blink::WebCryptoKeyFormat format, | 36 blink::WebCryptoKeyFormat format, |
| 45 blink::WebCryptoKeyUsageMask usages) const override; | 37 blink::WebCryptoKeyUsageMask usages) const override; |
| 46 | 38 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 65 Status ExportKeyPkcs8(const blink::WebCryptoKey& key, | 57 Status ExportKeyPkcs8(const blink::WebCryptoKey& key, |
| 66 std::vector<uint8_t>* buffer) const override; | 58 std::vector<uint8_t>* buffer) const override; |
| 67 | 59 |
| 68 Status ExportKeySpki(const blink::WebCryptoKey& key, | 60 Status ExportKeySpki(const blink::WebCryptoKey& key, |
| 69 std::vector<uint8_t>* buffer) const override; | 61 std::vector<uint8_t>* buffer) const override; |
| 70 | 62 |
| 71 Status ExportKeyJwk(const blink::WebCryptoKey& key, | 63 Status ExportKeyJwk(const blink::WebCryptoKey& key, |
| 72 std::vector<uint8_t>* buffer) const override; | 64 std::vector<uint8_t>* buffer) const override; |
| 73 | 65 |
| 74 private: | 66 private: |
| 75 blink::WebCryptoKeyUsageMask all_public_key_usages_; | 67 const blink::WebCryptoKeyUsageMask all_public_key_usages_; |
| 76 blink::WebCryptoKeyUsageMask all_private_key_usages_; | 68 const blink::WebCryptoKeyUsageMask all_private_key_usages_; |
| 77 }; | 69 }; |
| 78 | 70 |
| 79 } // namespace webcrypto | 71 } // namespace webcrypto |
| 80 | 72 |
| 81 } // namespace content | 73 } // namespace content |
| 82 | 74 |
| 83 #endif // CONTENT_CHILD_WEBCRYPTO_OPENSSL_RSA_KEY_OPENSSL_H_ | 75 #endif // CONTENT_CHILD_WEBCRYPTO_OPENSSL_EC_KEY_OPENSSL_H_ |
| OLD | NEW |