forked from facebook/redex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSha1.h
44 lines (38 loc) · 1.2 KB
/
Sha1.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/**
* Copyright (c) 2016-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#pragma once
/*
* This implementation of SHA1 is taken from HHVM with minor style edits:
* https://github.com/facebook/hhvm
*/
/*
* State used for SHA1 algorithm.
*/
struct Sha1Context {
unsigned int state[5]; /* state (ABCD) */
unsigned int count[2]; /* number of bits, modulo 2^64 */
unsigned char buffer[64]; /* input buffer */
};
/*
* SHA1 initialization. Begins an SHA1 operation, writing a new context.
*/
void sha1_init(Sha1Context* context);
/*
* SHA1 block update operation. Continues an SHA1 message-digest operation,
* processing another message block, and updating the context.
*/
void sha1_update(
Sha1Context* context,
const unsigned char* input,
unsigned int inputLen);
/*
* SHA1 finalization. Ends an SHA1 message-digest operation, writing the
* message digest and zeroizing the context.
*/
void sha1_final(unsigned char* digest, Sha1Context* context);