netwerk/srtp/src/crypto/include/sha1.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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  */
    11 /*
    12  *	
    13  * Copyright (c) 2001-2006, 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  */
    47 #ifndef SHA1_H
    48 #define SHA1_H
    50 #include "err.h"
    51 #include "datatypes.h"
    53 typedef struct {
    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 */
    58 } sha1_ctx_t;
    60 /*
    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
    63  * output
    64  * 
    65  */
    67 void
    68 sha1(const uint8_t *message,  int octets_in_msg, uint32_t output[5]);
    70 /*
    71  * sha1_init(&ctx) initializes the SHA1 context ctx
    72  * 
    73  * sha1_update(&ctx, msg, len) hashes the len octets starting at msg
    74  * into the SHA1 context
    75  * 
    76  * sha1_final(&ctx, output) performs the final processing of the SHA1
    77  * context and writes the result to the 20 octets at output
    78  *
    79  */
    81 void
    82 sha1_init(sha1_ctx_t *ctx);
    84 void
    85 sha1_update(sha1_ctx_t *ctx, const uint8_t *M, int octets_in_msg);
    87 void
    88 sha1_final(sha1_ctx_t *ctx, uint32_t output[5]);
    90 /*
    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
    93  * setup algorithm.  
    94  */
    96 /*
    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,
    99  *  H1, ...}
   100  *
   101  *  this function does not do any of the padding required in the
   102  *  complete sha1 function
   103  */
   105 void
   106 sha1_core(const uint32_t M[16], uint32_t hash_value[5]);
   108 #endif /* SHA1_H */

mercurial