Chromium Code Reviews| 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 EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_AUTH_UTIL_H_ | 5 #ifndef EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_AUTH_UTIL_H_ |
| 6 #define EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_AUTH_UTIL_H_ | 6 #define EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_AUTH_UTIL_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
|
Ryan Sleevi
2014/10/17 19:53:20
STYLE: Newline between lines 8 and 9
vadimgo
2014/10/20 23:35:27
Done.
| |
| 9 #include "crypto/scoped_nss_types.h" | |
|
Ryan Sleevi
2014/10/17 19:53:20
This is a non _nss.h file. Do not use NSS types di
vadimgo
2014/10/20 23:35:27
Done.
| |
| 10 #include "extensions/common/api/cast_channel/authority_keys.pb.h" | |
|
Ryan Sleevi
2014/10/17 19:53:21
STRONGLY discourage including .pb.h in .h files, e
vadimgo
2014/10/20 23:35:27
Done.
| |
| 11 #include "net/base/hash_value.h" | |
| 9 | 12 |
| 10 namespace extensions { | 13 namespace extensions { |
| 11 namespace core_api { | 14 namespace core_api { |
| 12 namespace cast_channel { | 15 namespace cast_channel { |
| 13 | 16 |
| 14 class CastMessage; | 17 class CastMessage; |
| 15 | 18 |
| 16 struct AuthResult { | 19 struct AuthResult { |
| 17 public: | 20 public: |
| 18 enum ErrorType { | 21 enum ErrorType { |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 45 std::string error_message; | 48 std::string error_message; |
| 46 ErrorType error_type; | 49 ErrorType error_type; |
| 47 int nss_error_code; | 50 int nss_error_code; |
| 48 | 51 |
| 49 private: | 52 private: |
| 50 AuthResult(const std::string& error_message, | 53 AuthResult(const std::string& error_message, |
| 51 ErrorType error_type, | 54 ErrorType error_type, |
| 52 int nss_error_code); | 55 int nss_error_code); |
| 53 }; | 56 }; |
| 54 | 57 |
| 58 // Helper class for intermediate certificate authority validation. | |
|
Ryan Sleevi
2014/10/17 19:53:21
DOCUMENTATION: This comment doesn't really provide
vadimgo
2014/10/20 23:35:27
Done.
| |
| 59 class AuthorityKeysStore { | |
| 60 public: | |
| 61 AuthorityKeysStore(); | |
| 62 ~AuthorityKeysStore(); | |
| 63 | |
| 64 // Returns the public key of the ICA whose fingerprint matches |fingerprint|. | |
| 65 // Returns NULL, if no such ICA is found. | |
| 66 const SECItem* GetICAPublicKeyFromFingerprint( | |
| 67 const net::SHA256HashValue& fingerprint); | |
| 68 | |
| 69 // Returns the public key of the first ICA in the list. | |
| 70 // Returns NULL if the authority keys store is empty. | |
| 71 const SECItem* GetDefaultICAPublicKey(); | |
|
Ryan Sleevi
2014/10/17 19:53:21
DOCUMENTATION: This documentation and method name
vadimgo
2014/10/20 23:35:27
Done.
| |
| 72 | |
| 73 // Loads authority keys from a serialized protobuf. | |
| 74 bool Load(std::string& keys); | |
|
Ryan Sleevi
2014/10/17 19:53:21
STYLE: Passing non-const references is forbidden
D
vadimgo
2014/10/20 23:35:27
Done.
| |
| 75 | |
| 76 private: | |
| 77 // Info for trusted ICA certs. | |
|
Ryan Sleevi
2014/10/17 19:53:21
DOCUMENTATION: I suspect you shouldn't have struct
vadimgo
2014/10/20 23:35:27
Done.
| |
| 78 struct ICACertInfo { | |
| 79 const net::SHA256HashValue* fingerprint; | |
| 80 SECItem public_key; | |
| 81 }; | |
| 82 | |
| 83 // The list of trusted certificate authorities, this points to either | |
| 84 // hard-coded constant data or to the data in the de-serialized protobuf. | |
| 85 std::vector<ICACertInfo> certificate_authorities_; | |
|
Ryan Sleevi
2014/10/17 19:53:21
DESIGN: You are effectively using a vector of tupl
vadimgo
2014/10/20 23:35:27
Done.
| |
| 86 | |
| 87 // Holds hard-coded constant ICA data. | |
| 88 static const ICACertInfo kAllowedICAs[]; | |
|
Ryan Sleevi
2014/10/17 19:53:21
STYLE: Don't ever declare private static class dat
vadimgo
2014/10/20 23:35:27
Done.
| |
| 89 | |
| 90 // Trusted certificate authorities data passed from the extension. | |
| 91 proto::AuthorityKeys authority_keys_; | |
| 92 }; | |
|
Ryan Sleevi
2014/10/17 19:53:21
STYLE: DISALLOW_COPY_AND_ASSIGN
vadimgo
2014/10/20 23:35:27
Done.
| |
| 93 | |
| 55 // Authenticates the given |challenge_reply|: | 94 // Authenticates the given |challenge_reply|: |
| 56 // 1. Signature contained in the reply is valid. | 95 // 1. Signature contained in the reply is valid. |
| 57 // 2. Certficate used to sign is rooted to a trusted CA. | 96 // 2. Certficate used to sign is rooted to a trusted CA. |
| 58 AuthResult AuthenticateChallengeReply(const CastMessage& challenge_reply, | 97 AuthResult AuthenticateChallengeReply(const CastMessage& challenge_reply, |
| 59 const std::string& peer_cert); | 98 const std::string& peer_cert); |
| 60 | 99 |
| 100 // Sets trusted certificate authorities. | |
| 101 bool SetTrustedCertificateAuthorities(const std::string& keys, | |
| 102 const std::string& signature); | |
| 103 | |
| 61 } // namespace cast_channel | 104 } // namespace cast_channel |
| 62 } // namespace core_api | 105 } // namespace core_api |
| 63 } // namespace extensions | 106 } // namespace extensions |
| 64 | 107 |
| 65 #endif // EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_AUTH_UTIL_H_ | 108 #endif // EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_AUTH_UTIL_H_ |
| OLD | NEW |