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

Side by Side Diff: chrome/common/extensions/api/networking_private/networking_private_crypto.cc

Issue 1924323002: Move Cast certificate verification code from extensions to components. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Simplified OWNERS files Created 4 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
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 "chrome/common/extensions/api/networking_private/networking_private_cry pto.h" 5 #include "chrome/common/extensions/api/networking_private/networking_private_cry pto.h"
6 6
7 #include <openssl/digest.h> 7 #include <openssl/digest.h>
8 #include <openssl/evp.h> 8 #include <openssl/evp.h>
9 #include <openssl/rsa.h> 9 #include <openssl/rsa.h>
10 #include <openssl/x509.h> 10 #include <openssl/x509.h>
11 #include <stddef.h> 11 #include <stddef.h>
12 12
13 #include <memory> 13 #include <memory>
14 14
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/strings/string_util.h" 16 #include "base/strings/string_util.h"
17 #include "components/cast_certificate/cast_cert_validator.h"
17 #include "crypto/openssl_util.h" 18 #include "crypto/openssl_util.h"
18 #include "crypto/rsa_private_key.h" 19 #include "crypto/rsa_private_key.h"
19 #include "crypto/scoped_openssl_types.h" 20 #include "crypto/scoped_openssl_types.h"
20 #include "extensions/common/cast/cast_cert_validator.h"
21 #include "net/cert/pem_tokenizer.h" 21 #include "net/cert/pem_tokenizer.h"
22 22
23 namespace { 23 namespace {
24 24
25 namespace cast_crypto = ::extensions::api::cast_crypto; 25 namespace cast_crypto = ::cast_certificate;
26 26
27 // Parses |pem_data| for a PEM block of |pem_type|. 27 // Parses |pem_data| for a PEM block of |pem_type|.
28 // Returns true if a |pem_type| block is found, storing the decoded result in 28 // Returns true if a |pem_type| block is found, storing the decoded result in
29 // |der_output|. 29 // |der_output|.
30 bool GetDERFromPEM(const std::string& pem_data, 30 bool GetDERFromPEM(const std::string& pem_data,
31 const std::string& pem_type, 31 const std::string& pem_type,
32 std::vector<uint8_t>* der_output) { 32 std::vector<uint8_t>* der_output) {
33 std::vector<std::string> headers; 33 std::vector<std::string> headers;
34 headers.push_back(pem_type); 34 headers.push_back(pem_type);
35 net::PEMTokenizer pem_tokenizer(pem_data, headers); 35 net::PEMTokenizer pem_tokenizer(pem_data, headers);
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 rsa.get(), RSA_PKCS1_PADDING); 179 rsa.get(), RSA_PKCS1_PADDING);
180 if (output_length < 0) { 180 if (output_length < 0) {
181 LOG(ERROR) << "Error during decryption."; 181 LOG(ERROR) << "Error during decryption.";
182 return false; 182 return false;
183 } 183 }
184 decrypted_output->resize(output_length); 184 decrypted_output->resize(output_length);
185 return true; 185 return true;
186 } 186 }
187 187
188 } // namespace networking_private_crypto 188 } // namespace networking_private_crypto
OLDNEW
« no previous file with comments | « chrome/common/DEPS ('k') | chrome/common/extensions/api/networking_private/networking_private_crypto_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698