sha1.h (2820B)
1 /* 2 * sha1.h 3 * 4 * interface to the Secure Hash Algorithm v.1 (SHA-1), specified in 5 * FIPS 180-1 6 * 7 * David A. McGrew 8 * Cisco Systems, Inc. 9 */ 10 11 /* 12 * 13 * Copyright (c) 2001-2017, Cisco Systems, Inc. 14 * All rights reserved. 15 * 16 * Redistribution and use in source and binary forms, with or without 17 * modification, are permitted provided that the following conditions 18 * are met: 19 * 20 * Redistributions of source code must retain the above copyright 21 * notice, this list of conditions and the following disclaimer. 22 * 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. 27 * 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. 31 * 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. 44 * 45 */ 46 47 #ifndef SHA1_H 48 #define SHA1_H 49 50 #ifdef HAVE_CONFIG_H 51 #include <config.h> 52 #endif 53 54 #include "err.h" 55 #include "datatypes.h" 56 57 #ifdef __cplusplus 58 extern "C" { 59 #endif 60 61 typedef struct { 62 uint32_t H[5]; /* state vector */ 63 uint32_t M[16]; /* message buffer */ 64 int octets_in_buffer; /* octets of message in buffer */ 65 uint32_t num_bits_in_msg; /* total number of bits in message */ 66 } srtp_sha1_ctx_t; 67 68 /* 69 * srtp_sha1_init(&ctx) initializes the SHA1 context ctx 70 * 71 * srtp_sha1_update(&ctx, msg, len) hashes the len octets starting at msg 72 * into the SHA1 context 73 * 74 * srtp_sha1_final(&ctx, output) performs the final processing of the SHA1 75 * context and writes the result to the 20 octets at output 76 * 77 */ 78 void srtp_sha1_init(srtp_sha1_ctx_t *ctx); 79 80 void srtp_sha1_update(srtp_sha1_ctx_t *ctx, 81 const uint8_t *M, 82 int octets_in_msg); 83 84 void srtp_sha1_final(srtp_sha1_ctx_t *ctx, uint32_t output[5]); 85 86 #ifdef __cplusplus 87 } 88 #endif 89 90 #endif /* SHA1_H */