(root)/
Linux-PAM-1.5.3/
modules/
pam_timestamp/
sha1.h
       1  /* Yet another SHA-1 implementation.
       2   *
       3   * Copyright (c) 2003 Red Hat, Inc.
       4   * Written by Nalin Dahyabhai <nalin@redhat.com>
       5   *
       6   * Redistribution and use in source and binary forms, with or without
       7   * modification, are permitted provided that the following conditions
       8   * are met:
       9   * 1. Redistributions of source code must retain the above copyright
      10   *    notice, and the entire permission notice in its entirety,
      11   *    including the disclaimer of warranties.
      12   * 2. Redistributions in binary form must reproduce the above copyright
      13   *    notice, this list of conditions and the following disclaimer in the
      14   *    documentation and/or other materials provided with the distribution.
      15   * 3. The name of the author may not be used to endorse or promote
      16   *    products derived from this software without specific prior
      17   *    written permission.
      18   *
      19   * ALTERNATIVELY, this product may be distributed under the terms of
      20   * the GNU Public License, in which case the provisions of the GPL are
      21   * required INSTEAD OF the above restrictions.  (This clause is
      22   * necessary due to a potential bad interaction between the GPL and
      23   * the restrictions contained in a BSD-style copyright.)
      24   *
      25   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
      26   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
      27   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
      28   * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
      29   * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
      30   * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
      31   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
      32   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
      33   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
      34   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
      35   * OF THE POSSIBILITY OF SUCH DAMAGE.
      36   *
      37   */
      38  #ifndef pam_timestamp_sha1_h
      39  #define pam_timestamp_sha1_h
      40  
      41  #include <stdint.h>
      42  #include <sys/types.h>
      43  #include "pam_cc_compat.h"
      44  
      45  #define SHA1_BLOCK_SIZE 64
      46  
      47  struct sha1_context {
      48  	size_t count;
      49  	union {
      50  		unsigned char c[SHA1_BLOCK_SIZE];
      51  		uint32_t i[SHA1_BLOCK_SIZE / sizeof(uint32_t)];
      52  	} pending;
      53  	uint32_t counts[2];
      54  	size_t pending_count;
      55  	uint32_t a, b, c, d, e;
      56  };
      57  
      58  #define SHA1_OUTPUT_SIZE 20
      59  
      60  void sha1_init(struct sha1_context *ctx);
      61  void sha1_update(struct sha1_context *ctx,
      62  		 const unsigned char *data, size_t length);
      63  size_t sha1_output(struct sha1_context *ctx, unsigned char *out);
      64  
      65  #endif