Home | History | Annotate | Download | only in debase
      1 #ifndef _DESHA1_H
      2 #define _DESHA1_H
      3 /*-------------------------------------------------------------------------
      4  * drawElements Base Portability Library
      5  * -------------------------------------
      6  *
      7  * Copyright 2015 The Android Open Source Project
      8  *
      9  * Licensed under the Apache License, Version 2.0 (the "License");
     10  * you may not use this file except in compliance with the License.
     11  * You may obtain a copy of the License at
     12  *
     13  *      http://www.apache.org/licenses/LICENSE-2.0
     14  *
     15  * Unless required by applicable law or agreed to in writing, software
     16  * distributed under the License is distributed on an "AS IS" BASIS,
     17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     18  * See the License for the specific language governing permissions and
     19  * limitations under the License.
     20  *
     21  *//*!
     22  * \file
     23  * \brief SHA1 hash functions.
     24  *//*--------------------------------------------------------------------*/
     25 
     26 #include "deDefs.h"
     27 
     28 DE_BEGIN_EXTERN_C
     29 
     30 typedef struct deSha1Stream_s
     31 {
     32 	deUint64	size;
     33 	deUint32	hash[5];
     34 
     35 	deUint32	data[80];
     36 } deSha1Stream;
     37 
     38 typedef struct deSha1_s
     39 {
     40 	deUint32	hash[5];
     41 } deSha1;
     42 
     43 /* Initialize sha1 stream. */
     44 void	deSha1Stream_init			(deSha1Stream* stream);
     45 
     46 /* Process single 512bit chunk. */
     47 void	deSha1Stream_process		(deSha1Stream* stream, size_t size, const void* data);
     48 
     49 /* Finalize the stream and output the hash. */
     50 void	deSha1Stream_finalize		(deSha1Stream* stream, deSha1* hash);
     51 
     52 /* Compute the sha1 hash from data. */
     53 void	deSha1_compute				(deSha1* hash, size_t size, const void* data);
     54 
     55 /* Render sha1 hash as 40 digit hex string. */
     56 void	deSha1_render				(const deSha1* hash, char* buffer);
     57 
     58 /* Parse sha1 from 40 digit hex string. */
     59 deBool	deSha1_parse				(deSha1* hash, const char* buffer);
     60 
     61 /* Compare hashes for equality. */
     62 deBool	deSha1_equal				(const deSha1* a, const deSha1* b);
     63 
     64 void	deSha1_selfTest				(void);
     65 
     66 DE_END_EXTERN_C
     67 
     68 #endif /* _DESHA1_H */
     69