| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/proximity_auth/device_to_device_initiator_operations.h" | 5 #include "components/proximity_auth/device_to_device_initiator_operations.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "components/proximity_auth/cryptauth/proto/cryptauth_api.pb.h" | 9 #include "components/proximity_auth/cryptauth/proto/cryptauth_api.pb.h" |
| 10 #include "components/proximity_auth/cryptauth/proto/securemessage.pb.h" | 10 #include "components/proximity_auth/cryptauth/proto/securemessage.pb.h" |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 | 208 |
| 209 // Called after the inner-most layer of [Responder Auth] is unwrapped. | 209 // Called after the inner-most layer of [Responder Auth] is unwrapped. |
| 210 void OnInnerMessageUnwrappedForResponderAuth( | 210 void OnInnerMessageUnwrappedForResponderAuth( |
| 211 const ValidateResponderAuthMessageContext& context, | 211 const ValidateResponderAuthMessageContext& context, |
| 212 bool verified, | 212 bool verified, |
| 213 const std::string& payload, | 213 const std::string& payload, |
| 214 const securemessage::Header& header) { | 214 const securemessage::Header& header) { |
| 215 if (!verified) | 215 if (!verified) |
| 216 PA_LOG(INFO) << "Failed to unwrap inner [Responder Auth] message."; | 216 PA_LOG(INFO) << "Failed to unwrap inner [Responder Auth] message."; |
| 217 | 217 |
| 218 // Note: The GMS Core implementation does not properly set the metadata |
| 219 // version, so we only check that the type is UNLOCK_KEY_SIGNED_CHALLENGE. |
| 218 cryptauth::GcmMetadata gcm_metadata; | 220 cryptauth::GcmMetadata gcm_metadata; |
| 219 if (!gcm_metadata.ParseFromString(header.public_metadata()) || | 221 if (!gcm_metadata.ParseFromString(header.public_metadata()) || |
| 220 gcm_metadata.type() != cryptauth::UNLOCK_KEY_SIGNED_CHALLENGE || | 222 gcm_metadata.type() != cryptauth::UNLOCK_KEY_SIGNED_CHALLENGE) { |
| 221 gcm_metadata.version() != kGcmMetadataVersion) { | |
| 222 PA_LOG(WARNING) << "Failed to validate GcmMetadata in inner-most " | 223 PA_LOG(WARNING) << "Failed to validate GcmMetadata in inner-most " |
| 223 << "[Responder Auth] message."; | 224 << "[Responder Auth] message."; |
| 224 context.callback.Run(false, std::string()); | 225 context.callback.Run(false, std::string()); |
| 225 return; | 226 return; |
| 226 } | 227 } |
| 227 | 228 |
| 228 context.callback.Run(verified, context.session_symmetric_key); | 229 context.callback.Run(verified, context.session_symmetric_key); |
| 229 } | 230 } |
| 230 | 231 |
| 231 } // namespace | 232 } // namespace |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 create_options.encryption_scheme = securemessage::AES_256_CBC; | 320 create_options.encryption_scheme = securemessage::AES_256_CBC; |
| 320 create_options.signature_scheme = securemessage::HMAC_SHA256; | 321 create_options.signature_scheme = securemessage::HMAC_SHA256; |
| 321 create_options.associated_data = responder_auth_message; | 322 create_options.associated_data = responder_auth_message; |
| 322 secure_message_delegate->CreateSecureMessage( | 323 secure_message_delegate->CreateSecureMessage( |
| 323 kPayloadFiller, persistent_symmetric_key, create_options, | 324 kPayloadFiller, persistent_symmetric_key, create_options, |
| 324 base::Bind(&OnInnerMessageCreatedForInitiatorAuth, session_symmetric_key, | 325 base::Bind(&OnInnerMessageCreatedForInitiatorAuth, session_symmetric_key, |
| 325 secure_message_delegate, callback)); | 326 secure_message_delegate, callback)); |
| 326 } | 327 } |
| 327 | 328 |
| 328 } // proximity_auth | 329 } // proximity_auth |
| OLD | NEW |