xref: /aosp_15_r20/external/cronet/net/cert/ct_log_verifier_util.cc (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
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)15 std::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(crypto::kSHA256Length, '\0');
24   hash->Finish(result.data(), result.size());
25   return result;
26 }
27 
28 }  // namespace net::ct::internal
29