4
* interface to the Secure Hash Algorithm v.1 (SHA-1), specified in
13
* Copyright (c) 2001-2006, Cisco Systems, Inc.
14
* All rights reserved.
16
* Redistribution and use in source and binary forms, with or without
17
* modification, are permitted provided that the following conditions
20
* Redistributions of source code must retain the above copyright
21
* notice, this list of conditions and the following disclaimer.
23
* Redistributions in binary form must reproduce the above
24
* copyright notice, this list of conditions and the following
25
* disclaimer in the documentation and/or other materials provided
26
* with the distribution.
28
* Neither the name of the Cisco Systems, Inc. nor the names of its
29
* contributors may be used to endorse or promote products derived
30
* from this software without specific prior written permission.
32
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
35
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
36
* COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
37
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
38
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
39
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
40
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
41
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
42
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
43
* OF THE POSSIBILITY OF SUCH DAMAGE.
51
#include "datatypes.h"
54
uint32_t H[5]; /* state vector */
55
uint32_t M[16]; /* message buffer */
56
int octets_in_buffer; /* octets of message in buffer */
57
uint32_t num_bits_in_msg; /* total number of bits in message */
61
* sha1(&ctx, msg, len, output) hashes the len octets starting at msg
62
* into the SHA1 context, then writes the result to the 20 octets at
68
sha1(const uint8_t *message, int octets_in_msg, uint32_t output[5]);
71
* sha1_init(&ctx) initializes the SHA1 context ctx
73
* sha1_update(&ctx, msg, len) hashes the len octets starting at msg
74
* into the SHA1 context
76
* sha1_final(&ctx, output) performs the final processing of the SHA1
77
* context and writes the result to the 20 octets at output
82
sha1_init(sha1_ctx_t *ctx);
85
sha1_update(sha1_ctx_t *ctx, const uint8_t *M, int octets_in_msg);
88
sha1_final(sha1_ctx_t *ctx, uint32_t output[5]);
91
* The sha1_core function is INTERNAL to SHA-1, but it is declared
92
* here because it is also used by the cipher SEAL 3.0 in its key
97
* sha1_core(M, H) computes the core sha1 compression function, where M is
98
* the next part of the message and H is the intermediate state {H0,
101
* this function does not do any of the padding required in the
102
* complete sha1 function
106
sha1_core(const uint32_t M[16], uint32_t hash_value[5]);