| 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 { |
| 11 namespace core_api { | 11 namespace core_api { |
| 12 namespace cast_channel { | 12 namespace cast_channel { |
| 13 | 13 |
| 14 class AuthResponse; |
| 14 class CastMessage; | 15 class CastMessage; |
| 15 class DeviceAuthMessage; | 16 class DeviceAuthMessage; |
| 16 | 17 |
| 17 struct AuthResult { | 18 struct AuthResult { |
| 18 public: | 19 public: |
| 19 enum ErrorType { | 20 enum ErrorType { |
| 20 ERROR_NONE, | 21 ERROR_NONE, |
| 21 ERROR_PEER_CERT_EMPTY, | 22 ERROR_PEER_CERT_EMPTY, |
| 22 ERROR_WRONG_PAYLOAD_TYPE, | 23 ERROR_WRONG_PAYLOAD_TYPE, |
| 23 ERROR_NO_PAYLOAD, | 24 ERROR_NO_PAYLOAD, |
| 24 ERROR_PAYLOAD_PARSING_FAILED, | 25 ERROR_PAYLOAD_PARSING_FAILED, |
| 25 ERROR_MESSAGE_ERROR, | 26 ERROR_MESSAGE_ERROR, |
| 26 ERROR_NO_RESPONSE, | 27 ERROR_NO_RESPONSE, |
| 27 ERROR_FINGERPRINT_NOT_FOUND, | 28 ERROR_FINGERPRINT_NOT_FOUND, |
| 28 ERROR_NSS_CERT_PARSING_FAILED, | 29 ERROR_CERT_PARSING_FAILED, |
| 29 ERROR_NSS_CERT_NOT_SIGNED_BY_TRUSTED_CA, | 30 ERROR_CERT_NOT_SIGNED_BY_TRUSTED_CA, |
| 30 ERROR_NSS_CANNOT_EXTRACT_PUBLIC_KEY, | 31 ERROR_CANNOT_EXTRACT_PUBLIC_KEY, |
| 31 ERROR_NSS_SIGNED_BLOBS_MISMATCH | 32 ERROR_SIGNED_BLOBS_MISMATCH, |
| 33 ERROR_UNEXPECTED_AUTH_LIBRARY_RESULT |
| 32 }; | 34 }; |
| 33 | 35 |
| 34 // Constructs a AuthResult that corresponds to success. | 36 // Constructs a AuthResult that corresponds to success. |
| 35 AuthResult(); | 37 AuthResult(); |
| 36 ~AuthResult(); | 38 ~AuthResult(); |
| 37 | 39 |
| 38 static AuthResult CreateWithParseError(const std::string& error_message, | 40 static AuthResult CreateWithParseError(const std::string& error_message, |
| 39 ErrorType error_type); | 41 ErrorType error_type); |
| 40 static AuthResult CreateWithNSSError(const std::string& error_message, | 42 static AuthResult CreateWithNSSError(const std::string& error_message, |
| 41 ErrorType error_type, | 43 ErrorType error_type, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 52 ErrorType error_type, | 54 ErrorType error_type, |
| 53 int nss_error_code); | 55 int nss_error_code); |
| 54 }; | 56 }; |
| 55 | 57 |
| 56 // Authenticates the given |challenge_reply|: | 58 // Authenticates the given |challenge_reply|: |
| 57 // 1. Signature contained in the reply is valid. | 59 // 1. Signature contained in the reply is valid. |
| 58 // 2. Certficate used to sign is rooted to a trusted CA. | 60 // 2. Certficate used to sign is rooted to a trusted CA. |
| 59 AuthResult AuthenticateChallengeReply(const CastMessage& challenge_reply, | 61 AuthResult AuthenticateChallengeReply(const CastMessage& challenge_reply, |
| 60 const std::string& peer_cert); | 62 const std::string& peer_cert); |
| 61 | 63 |
| 62 // Parses a DeviceAuthMessage payload from a challenge reply. | 64 // Auth-library specific implementation of cryptographic signature |
| 63 // Returns an AuthResult to indicate success or failure. | 65 // verification routines. Verifies that |response| contains a |
| 64 AuthResult ParseAuthMessage(const CastMessage& challenge_reply, | 66 // valid signed form of |peer_cert|. |
| 65 DeviceAuthMessage* auth_message); | 67 AuthResult VerifyCredentials(const AuthResponse& response, |
| 68 const std::string& peer_cert); |
| 66 | 69 |
| 67 } // namespace cast_channel | 70 } // namespace cast_channel |
| 68 } // namespace core_api | 71 } // namespace core_api |
| 69 } // namespace extensions | 72 } // namespace extensions |
| 70 | 73 |
| 71 #endif // EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_AUTH_UTIL_H_ | 74 #endif // EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_AUTH_UTIL_H_ |
| OLD | NEW |