Bug 785860 - fix sts preload list tests to skip private mode tests if private browsin...
[gecko.git] / mfbt / SHA1.h
blobfdb2150dc212056f8c91e3f33e423da761bb6243
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 /* Simple class for computing SHA1. */
8 /*
9 * To compute the SHA1 of a buffer using this class you should write something
10 * like:
11 * void SHA1(const uint8_t* buf, unsigned size, uint8_t hash[20])
12 * {
13 * SHA1Sum S;
14 * S.update(buf, size);
15 * S.finish(hash);
16 * }
17 * If there are multiple buffers or chunks, the update method can be called
18 * multiple times and the SHA1 is computed on the concatenation of all the
19 * buffers passed to it.
20 * The finish method may only be called once and cannot be followed by calls
21 * to update.
24 #ifndef mozilla_SHA1_h_
25 #define mozilla_SHA1_h_
27 #include "mozilla/StandardInteger.h"
28 namespace mozilla {
29 class SHA1Sum {
30 union {
31 uint32_t w[16]; /* input buffer */
32 uint8_t b[64];
33 } u;
34 uint64_t size; /* count of hashed bytes. */
35 unsigned H[22]; /* 5 state variables, 16 tmp values, 1 extra */
36 bool mDone;
38 public:
39 static const unsigned int HashSize = 20;
40 SHA1Sum();
41 void update(const uint8_t *dataIn, uint32_t len);
42 void finish(uint8_t hashout[20]);
46 #endif /* mozilla_SHA1_h_ */