| // Copyright 2017 The Fuchsia Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| #ifndef COBALT_SRC_LIB_CRYPTO_UTIL_HASH_H_ |
| #define COBALT_SRC_LIB_CRYPTO_UTIL_HASH_H_ |
| |
| #include <cstddef> |
| |
| #include "src/lib/crypto_util/types.h" |
| |
| namespace cobalt { |
| |
| namespace crypto { |
| |
| namespace hash { |
| |
| static const size_t DIGEST_SIZE = 32; // SHA-256 outputs 32 bytes. |
| |
| // Computes the SHA256 digest of |data_len| bytes from |data| and writes the |
| // result to |out| which must have length |DIGEST_SIZE|. |
| // |
| // Returns true for success or false for failure. |
| bool Hash(const byte *data, size_t data_len, byte out[DIGEST_SIZE]); |
| |
| } // namespace hash |
| |
| } // namespace crypto |
| |
| } // namespace cobalt |
| #endif // COBALT_SRC_LIB_CRYPTO_UTIL_HASH_H_ |