1 // Copyright 2015 The Chromium Authors 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 "net/cert/ct_log_verifier_util.h" 6 7 #include <memory> 8 9 #include "base/strings/string_util.h" 10 #include "crypto/secure_hash.h" 11 #include "crypto/sha2.h" 12 13 namespace net::ct::internal { 14 HashNodes(const std::string & lh,const std::string & rh)15std::string HashNodes(const std::string& lh, const std::string& rh) { 16 std::unique_ptr<crypto::SecureHash> hash( 17 crypto::SecureHash::Create(crypto::SecureHash::SHA256)); 18 19 hash->Update("\01", 1); 20 hash->Update(lh.data(), lh.size()); 21 hash->Update(rh.data(), rh.size()); 22 23 std::string result; 24 hash->Finish(base::WriteInto(&result, crypto::kSHA256Length + 1), 25 crypto::kSHA256Length); 26 return result; 27 } 28 29 } // namespace net::ct::internal 30