CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
Path: blob/master/Common/Crypto/sha1.h
Views: 1401
/**1* \file sha1.h2*3* Copyright (C) 2006-2009, Paul Bakker <polarssl_maintainer at polarssl.org>4* All rights reserved.5*6* Joined copyright on original XySSL code with: Christophe Devine7*8* This program is free software; you can redistribute it and/or modify9* it under the terms of the GNU General Public License as published by10* the Free Software Foundation; either version 2 of the License, or11* (at your option) any later version.12*13* This program is distributed in the hope that it will be useful,14* but WITHOUT ANY WARRANTY; without even the implied warranty of15* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the16* GNU General Public License for more details.17*18* You should have received a copy of the GNU General Public License along19* with this program; if not, write to the Free Software Foundation, Inc.,20* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.21*/22#ifndef POLARSSL_SHA1_H23#define POLARSSL_SHA1_H2425/**26* \brief SHA-1 context structure27*/28typedef struct29{30unsigned long total[2]; /*!< number of bytes processed */31unsigned long state[5]; /*!< intermediate digest state */32unsigned char buffer[64]; /*!< data block being processed */3334unsigned char ipad[64]; /*!< HMAC: inner padding */35unsigned char opad[64]; /*!< HMAC: outer padding */36}37sha1_context;3839#ifdef __cplusplus40extern "C" {41#endif4243/**44* \brief SHA-1 context setup45*46* \param ctx context to be initialized47*/48void sha1_starts( sha1_context *ctx );4950/**51* \brief SHA-1 process buffer52*53* \param ctx SHA-1 context54* \param input buffer holding the data55* \param ilen length of the input data56*/57void sha1_update( sha1_context *ctx, unsigned char *input, int ilen );5859/**60* \brief SHA-1 final digest61*62* \param ctx SHA-1 context63* \param output SHA-1 checksum result64*/65void sha1_finish( sha1_context *ctx, unsigned char output[20] );6667/**68* \brief Output = SHA-1( input buffer )69*70* \param input buffer holding the data71* \param ilen length of the input data72* \param output SHA-1 checksum result73*/74void sha1( unsigned char *input, int ilen, unsigned char output[20] );7576/**77* \brief Output = SHA-1( file contents )78*79* \param path input file name80* \param output SHA-1 checksum result81*82* \return 0 if successful, 1 if fopen failed,83* or 2 if fread failed84*/85int sha1_file( char *path, unsigned char output[20] );8687/**88* \brief SHA-1 HMAC context setup89*90* \param ctx HMAC context to be initialized91* \param key HMAC secret key92* \param keylen length of the HMAC key93*/94void sha1_hmac_starts( sha1_context *ctx, unsigned char *key, int keylen );9596/**97* \brief SHA-1 HMAC process buffer98*99* \param ctx HMAC context100* \param input buffer holding the data101* \param ilen length of the input data102*/103void sha1_hmac_update( sha1_context *ctx, unsigned char *input, int ilen );104105/**106* \brief SHA-1 HMAC final digest107*108* \param ctx HMAC context109* \param output SHA-1 HMAC checksum result110*/111void sha1_hmac_finish( sha1_context *ctx, unsigned char output[20] );112113/**114* \brief Output = HMAC-SHA-1( hmac key, input buffer )115*116* \param key HMAC secret key117* \param keylen length of the HMAC key118* \param input buffer holding the data119* \param ilen length of the input data120* \param output HMAC-SHA-1 result121*/122void sha1_hmac( unsigned char *key, int keylen,123unsigned char *input, int ilen,124unsigned char output[20] );125126/**127* \brief Checkup routine128*129* \return 0 if successful, or 1 if the test failed130*/131int sha1_self_test( int verbose );132133#ifdef __cplusplus134}135#endif136137#endif /* sha1.h */138139140