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

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

Issue 2407633002: Use new BoringSSL scopers in //components. (Closed)
Patch Set: Created 4 years, 2 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_ASYMMETRIC_KEY_UTIL_ 5 #ifndef COMPONENTS_WEBCRYPTO_ALGORITHMS_ASYMMETRIC_KEY_UTIL_
6 #define COMPONENTS_WEBCRYPTO_ALGORITHMS_ASYMMETRIC_KEY_UTIL_ 6 #define COMPONENTS_WEBCRYPTO_ALGORITHMS_ASYMMETRIC_KEY_UTIL_
7 7
8 #include "crypto/scoped_openssl_types.h" 8 #include <openssl/base.h>
9
9 #include "third_party/WebKit/public/platform/WebCryptoAlgorithm.h" 10 #include "third_party/WebKit/public/platform/WebCryptoAlgorithm.h"
10 #include "third_party/WebKit/public/platform/WebCryptoKey.h" 11 #include "third_party/WebKit/public/platform/WebCryptoKey.h"
11 12
12 // This file contains functions shared by multiple asymmetric key algorithms. 13 // This file contains functions shared by multiple asymmetric key algorithms.
13 14
14 namespace webcrypto { 15 namespace webcrypto {
15 16
16 class CryptoData; 17 class CryptoData;
17 class Status; 18 class Status;
18 19
19 // Creates a WebCrypto public key given an EVP_PKEY. This step includes 20 // Creates a WebCrypto public key given an EVP_PKEY. This step includes
20 // exporting the key to SPKI format, for use by serialization later. 21 // exporting the key to SPKI format, for use by serialization later.
21 Status CreateWebCryptoPublicKey(crypto::ScopedEVP_PKEY public_key, 22 Status CreateWebCryptoPublicKey(bssl::UniquePtr<EVP_PKEY> public_key,
22 const blink::WebCryptoKeyAlgorithm& algorithm, 23 const blink::WebCryptoKeyAlgorithm& algorithm,
23 bool extractable, 24 bool extractable,
24 blink::WebCryptoKeyUsageMask usages, 25 blink::WebCryptoKeyUsageMask usages,
25 blink::WebCryptoKey* key); 26 blink::WebCryptoKey* key);
26 27
27 // Creates a WebCrypto private key given an EVP_PKEY. This step includes 28 // Creates a WebCrypto private key given an EVP_PKEY. This step includes
28 // exporting the key to PKCS8 format, for use by serialization later. 29 // exporting the key to PKCS8 format, for use by serialization later.
29 Status CreateWebCryptoPrivateKey(crypto::ScopedEVP_PKEY private_key, 30 Status CreateWebCryptoPrivateKey(bssl::UniquePtr<EVP_PKEY> private_key,
30 const blink::WebCryptoKeyAlgorithm& algorithm, 31 const blink::WebCryptoKeyAlgorithm& algorithm,
31 bool extractable, 32 bool extractable,
32 blink::WebCryptoKeyUsageMask usages, 33 blink::WebCryptoKeyUsageMask usages,
33 blink::WebCryptoKey* key); 34 blink::WebCryptoKey* key);
34 35
35 // Imports SPKI bytes to an EVP_PKEY for a public key. The resulting asymmetric 36 // Imports SPKI bytes to an EVP_PKEY for a public key. The resulting asymmetric
36 // key may be invalid, and should be verified using something like 37 // key may be invalid, and should be verified using something like
37 // RSA_check_key(). The only validation performed by this function is to ensure 38 // RSA_check_key(). The only validation performed by this function is to ensure
38 // the key type matched |expected_pkey_id|. 39 // the key type matched |expected_pkey_id|.
39 Status ImportUnverifiedPkeyFromSpki(const CryptoData& key_data, 40 Status ImportUnverifiedPkeyFromSpki(const CryptoData& key_data,
40 int expected_pkey_id, 41 int expected_pkey_id,
41 crypto::ScopedEVP_PKEY* pkey); 42 bssl::UniquePtr<EVP_PKEY>* pkey);
42 43
43 // Imports PKCS8 bytes to an EVP_PKEY for a private key. The resulting 44 // Imports PKCS8 bytes to an EVP_PKEY for a private key. The resulting
44 // asymmetric key may be invalid, and should be verified using something like 45 // asymmetric key may be invalid, and should be verified using something like
45 // RSA_check_key(). The only validation performed by this function is to ensure 46 // RSA_check_key(). The only validation performed by this function is to ensure
46 // the key type matched |expected_pkey_id|. 47 // the key type matched |expected_pkey_id|.
47 Status ImportUnverifiedPkeyFromPkcs8(const CryptoData& key_data, 48 Status ImportUnverifiedPkeyFromPkcs8(const CryptoData& key_data,
48 int expected_pkey_id, 49 int expected_pkey_id,
49 crypto::ScopedEVP_PKEY* pkey); 50 bssl::UniquePtr<EVP_PKEY>* pkey);
50 51
51 // Splits the combined usages given to GenerateKey() into the respective usages 52 // Splits the combined usages given to GenerateKey() into the respective usages
52 // for the public key and private key. Returns an error if the usages are 53 // for the public key and private key. Returns an error if the usages are
53 // invalid. 54 // invalid.
54 Status GetUsagesForGenerateAsymmetricKey( 55 Status GetUsagesForGenerateAsymmetricKey(
55 blink::WebCryptoKeyUsageMask combined_usages, 56 blink::WebCryptoKeyUsageMask combined_usages,
56 blink::WebCryptoKeyUsageMask all_public_usages, 57 blink::WebCryptoKeyUsageMask all_public_usages,
57 blink::WebCryptoKeyUsageMask all_private_usages, 58 blink::WebCryptoKeyUsageMask all_private_usages,
58 blink::WebCryptoKeyUsageMask* public_usages, 59 blink::WebCryptoKeyUsageMask* public_usages,
59 blink::WebCryptoKeyUsageMask* private_usages); 60 blink::WebCryptoKeyUsageMask* private_usages);
60 61
61 } // namespace webcrypto 62 } // namespace webcrypto
62 63
63 #endif // COMPONENTS_WEBCRYPTO_ALGORITHMS_ASYMMETRIC_KEY_UTIL_ 64 #endif // COMPONENTS_WEBCRYPTO_ALGORITHMS_ASYMMETRIC_KEY_UTIL_
OLDNEW
« no previous file with comments | « components/webcrypto/algorithms/aes_kw.cc ('k') | components/webcrypto/algorithms/asymmetric_key_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698