2 * Copyright 2013 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
15 //The following macros can be defined to affect the SHA1 code generated.
16 //SK_SHA1_CLEAR_DATA causes all intermediate state to be overwritten with 0's.
17 //SK_CPU_BENDIAN allows 32 bit <=> 8 bit conversions without copies (if alligned).
18 //SK_CPU_FAST_UNALIGNED_ACCESS allows 32 bit <=> 8 bit conversions without copies if SK_CPU_BENDIAN.
20 class SkSHA1 : public SkWStream {
24 /** Processes input, adding it to the digest.
25 * Note that this treats the buffer as a series of uint8_t values.
27 bool write(const void* buffer, size_t size) SK_OVERRIDE {
28 update(reinterpret_cast<const uint8_t*>(buffer), size);
32 size_t bytesWritten() const SK_OVERRIDE { return SkToSizeT(this->byteCount); }
34 /** Processes input, adding it to the digest. Calling this after finish is undefined. */
35 void update(const uint8_t* input, size_t length);
41 /** Computes and returns the digest. */
42 void finish(Digest& digest);
45 // number of bytes, modulo 2^64