Back to index

openldap  2.4.31
lutil_sha1.h
Go to the documentation of this file.
00001 /* $OpenLDAP$ */
00002 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
00003  *
00004  * Copyright 1998-2012 The OpenLDAP Foundation.
00005  * All rights reserved.
00006  *
00007  * Redistribution and use in source and binary forms, with or without
00008  * modification, are permitted only as authorized by the OpenLDAP
00009  * Public License.
00010  *
00011  * A copy of this license is available in file LICENSE in the
00012  * top-level directory of the distribution or, alternatively, at
00013  * <http://www.OpenLDAP.org/license.html>.
00014  */
00015 
00016 /* This version is based on:
00017  *     $OpenBSD: sha1.h,v 1.8 1997/07/15 01:54:23 millert Exp $       */
00018 
00019 #ifndef _LUTIL_SHA1_H_
00020 #define _LUTIL_SHA1_H_
00021 
00022 #include <ldap_cdefs.h>
00023 #include <ac/bytes.h>
00024 
00025 #ifdef AC_INT4_TYPE
00026 
00027 LDAP_BEGIN_DECL
00028 
00029 
00030 /*
00031  * SHA-1 in C
00032  * By Steve Reid <steve@edmweb.com>
00033  */
00034 #define LUTIL_SHA1_BYTES 20
00035 
00036 /* This code assumes char are 8-bits and uint32 are 32-bits */
00037 typedef ac_uint4 uint32;
00038 
00039 typedef struct {
00040     uint32 state[5];
00041     uint32 count[2];
00042     unsigned char buffer[64];
00043 } lutil_SHA1_CTX;
00044 
00045 LDAP_LUTIL_F( void )
00046 lutil_SHA1Transform
00047        LDAP_P((uint32 state[5], const unsigned char buffer[64]));
00048 
00049 LDAP_LUTIL_F( void  )
00050 lutil_SHA1Init
00051        LDAP_P((lutil_SHA1_CTX *context));
00052 
00053 LDAP_LUTIL_F( void  )
00054 lutil_SHA1Update
00055        LDAP_P((lutil_SHA1_CTX *context, const unsigned char *data, uint32 len));
00056 
00057 LDAP_LUTIL_F( void  )
00058 lutil_SHA1Final
00059        LDAP_P((unsigned char digest[20], lutil_SHA1_CTX *context));
00060 
00061 LDAP_LUTIL_F( char * )
00062 lutil_SHA1End
00063        LDAP_P((lutil_SHA1_CTX *, char *));
00064 
00065 LDAP_LUTIL_F( char * )
00066 lutil_SHA1File
00067        LDAP_P((char *, char *));
00068 
00069 LDAP_LUTIL_F( char * )
00070 lutil_SHA1Data
00071        LDAP_P((const unsigned char *, size_t, char *));
00072 
00073 LDAP_END_DECL
00074 
00075 #endif /* AC_INT4_TYPE */
00076 
00077 #endif /* _LUTIL_SHA1_H_ */