1 // Copyright 2018 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "mojo/public/cpp/base/unguessable_token_mojom_traits.h" 6 7 namespace mojo { 8 9 // static 10 bool StructTraits<mojo_base::mojom::UnguessableTokenDataView, 11 base::UnguessableToken>:: Read(mojo_base::mojom::UnguessableTokenDataView data,base::UnguessableToken * out)12 Read(mojo_base::mojom::UnguessableTokenDataView data, 13 base::UnguessableToken* out) { 14 uint64_t high = data.high(); 15 uint64_t low = data.low(); 16 17 // Receiving a zeroed UnguessableToken is a security issue. 18 if (high == 0 && low == 0) 19 return false; 20 21 *out = base::UnguessableToken::Deserialize(high, low); 22 return true; 23 } 24 25 } // namespace mojo