| 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> |
| 9 | 9 |
| 10 namespace extensions { | 10 namespace extensions { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 ERROR_MESSAGE_ERROR, | 26 ERROR_MESSAGE_ERROR, |
| 27 ERROR_NO_RESPONSE, | 27 ERROR_NO_RESPONSE, |
| 28 ERROR_FINGERPRINT_NOT_FOUND, | 28 ERROR_FINGERPRINT_NOT_FOUND, |
| 29 ERROR_CERT_PARSING_FAILED, | 29 ERROR_CERT_PARSING_FAILED, |
| 30 ERROR_CERT_NOT_SIGNED_BY_TRUSTED_CA, | 30 ERROR_CERT_NOT_SIGNED_BY_TRUSTED_CA, |
| 31 ERROR_CANNOT_EXTRACT_PUBLIC_KEY, | 31 ERROR_CANNOT_EXTRACT_PUBLIC_KEY, |
| 32 ERROR_SIGNED_BLOBS_MISMATCH, | 32 ERROR_SIGNED_BLOBS_MISMATCH, |
| 33 ERROR_UNEXPECTED_AUTH_LIBRARY_RESULT | 33 ERROR_UNEXPECTED_AUTH_LIBRARY_RESULT |
| 34 }; | 34 }; |
| 35 | 35 |
| 36 enum PolicyType { POLICY_NONE = 0, POLICY_AUDIO_ONLY = 1 << 0 }; |
| 37 |
| 36 // Constructs a AuthResult that corresponds to success. | 38 // Constructs a AuthResult that corresponds to success. |
| 37 AuthResult(); | 39 AuthResult(); |
| 38 ~AuthResult(); | 40 ~AuthResult(); |
| 39 | 41 |
| 40 static AuthResult CreateWithParseError(const std::string& error_message, | 42 static AuthResult CreateWithParseError(const std::string& error_message, |
| 41 ErrorType error_type); | 43 ErrorType error_type); |
| 42 static AuthResult CreateWithNSSError(const std::string& error_message, | 44 static AuthResult CreateWithNSSError(const std::string& error_message, |
| 43 ErrorType error_type, | 45 ErrorType error_type, |
| 44 int nss_error_code); | 46 int nss_error_code); |
| 45 | 47 |
| 46 bool success() const { return error_type == ERROR_NONE; } | 48 bool success() const { return error_type == ERROR_NONE; } |
| 47 | 49 |
| 48 std::string error_message; | 50 std::string error_message; |
| 49 ErrorType error_type; | 51 ErrorType error_type; |
| 50 int nss_error_code; | 52 int nss_error_code; |
| 53 unsigned int channel_policies; |
| 51 | 54 |
| 52 private: | 55 private: |
| 53 AuthResult(const std::string& error_message, | 56 AuthResult(const std::string& error_message, |
| 54 ErrorType error_type, | 57 ErrorType error_type, |
| 55 int nss_error_code); | 58 int nss_error_code); |
| 56 }; | 59 }; |
| 57 | 60 |
| 58 // Authenticates the given |challenge_reply|: | 61 // Authenticates the given |challenge_reply|: |
| 59 // 1. Signature contained in the reply is valid. | 62 // 1. Signature contained in the reply is valid. |
| 60 // 2. Certficate used to sign is rooted to a trusted CA. | 63 // 2. Certficate used to sign is rooted to a trusted CA. |
| 61 AuthResult AuthenticateChallengeReply(const CastMessage& challenge_reply, | 64 AuthResult AuthenticateChallengeReply(const CastMessage& challenge_reply, |
| 62 const std::string& peer_cert); | 65 const std::string& peer_cert); |
| 63 | 66 |
| 64 // Auth-library specific implementation of cryptographic signature | 67 // Auth-library specific implementation of cryptographic signature |
| 65 // verification routines. Verifies that |response| contains a | 68 // verification routines. Verifies that |response| contains a |
| 66 // valid signed form of |peer_cert|. | 69 // valid signed form of |peer_cert|. |
| 67 AuthResult VerifyCredentials(const AuthResponse& response, | 70 AuthResult VerifyCredentials(const AuthResponse& response, |
| 68 const std::string& peer_cert); | 71 const std::string& peer_cert); |
| 69 | 72 |
| 70 } // namespace cast_channel | 73 } // namespace cast_channel |
| 71 } // namespace core_api | 74 } // namespace core_api |
| 72 } // namespace extensions | 75 } // namespace extensions |
| 73 | 76 |
| 74 #endif // EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_AUTH_UTIL_H_ | 77 #endif // EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_AUTH_UTIL_H_ |
| OLD | NEW |