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

Side by Side Diff: extensions/browser/api/cast_channel/cast_auth_ica.cc

Issue 687733004: Implement crypto signature verification routines using OpenSSL. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Broke off error reporting into separate branch, made unit tests security lib agnostic Created 6 years, 1 month 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 "extensions/browser/api/cast_channel/cast_auth_ica.h" 5 #include "extensions/browser/api/cast_channel/cast_auth_ica.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "crypto/signature_verifier.h" 9 #include "crypto/signature_verifier.h"
10 #include "extensions/browser/api/cast_channel/cast_auth_util.h" 10 #include "extensions/browser/api/cast_channel/cast_auth_util.h"
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 if (!VerifySignature(decoded_signature, decoded_keys)) 679 if (!VerifySignature(decoded_signature, decoded_keys))
680 return false; 680 return false;
681 681
682 return g_authority_keys_store.Get().Load(decoded_keys); 682 return g_authority_keys_store.Get().Load(decoded_keys);
683 } 683 }
684 684
685 base::StringPiece GetTrustedICAPublicKey(const base::StringPiece& data) { 685 base::StringPiece GetTrustedICAPublicKey(const base::StringPiece& data) {
686 AuthorityKeyStore& authority_keys_store = g_authority_keys_store.Get(); 686 AuthorityKeyStore& authority_keys_store = g_authority_keys_store.Get();
687 scoped_refptr<net::X509Certificate> ica_cert = 687 scoped_refptr<net::X509Certificate> ica_cert =
688 net::X509Certificate::CreateFromBytes(data.data(), data.size()); 688 net::X509Certificate::CreateFromBytes(data.data(), data.size());
689 if (!ica_cert.get()) {
690 LOG(ERROR) << "Invalid ICA certificate.";
691 return "";
692 }
689 return authority_keys_store.GetICAPublicKeyFromFingerprint( 693 return authority_keys_store.GetICAPublicKeyFromFingerprint(
690 net::X509Certificate::CalculateFingerprint256( 694 net::X509Certificate::CalculateFingerprint256(
691 ica_cert->os_cert_handle())); 695 ica_cert->os_cert_handle()));
692 } 696 }
693 697
694 base::StringPiece GetDefaultTrustedICAPublicKey() { 698 base::StringPiece GetDefaultTrustedICAPublicKey() {
695 AuthorityKeyStore& authority_keys_store = g_authority_keys_store.Get(); 699 AuthorityKeyStore& authority_keys_store = g_authority_keys_store.Get();
696 return authority_keys_store.GetDefaultICAPublicKey(); 700 return authority_keys_store.GetDefaultICAPublicKey();
697 } 701 }
698 702
699 } // namespace cast_channel 703 } // namespace cast_channel
700 } // namespace core_api 704 } // namespace core_api
701 } // namespace extensions 705 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698