diff --git a/lib/libmd/Symbol.map b/lib/libmd/Symbol.map index 86523a5933a1..f0a1192af352 100644 --- a/lib/libmd/Symbol.map +++ b/lib/libmd/Symbol.map @@ -1,261 +1,256 @@ FBSD_1.7 { MD4Data; MD4End; MD4Fd; MD4FdChunk; MD4File; MD4FileChunk; MD4Final; MD4Init; MD4Pad; MD4Update; MD5Data; MD5End; MD5Fd; MD5FdChunk; MD5File; MD5FileChunk; MD5Final; MD5Init; MD5Update; RIPEMD160_Data; RIPEMD160_End; RIPEMD160_Fd; RIPEMD160_FdChunk; RIPEMD160_File; RIPEMD160_FileChunk; RIPEMD160_Final; RIPEMD160_Init; RIPEMD160_Update; - RMD160_version; SHA1_Data; SHA1_End; SHA1_Fd; SHA1_FdChunk; SHA1_File; SHA1_FileChunk; SHA1_Final; SHA1_Init; SHA1_Update; - SHA1_version; SHA224_Data; SHA224_End; SHA224_Fd; SHA224_FdChunk; SHA224_File; SHA224_FileChunk; SHA224_Final; SHA224_Init; SHA224_Update; SHA256_Data; SHA256_End; SHA256_Fd; SHA256_FdChunk; SHA256_File; SHA256_FileChunk; SHA256_Final; SHA256_Init; SHA256_Update; SHA384_Data; SHA384_End; SHA384_Fd; SHA384_FdChunk; SHA384_File; SHA384_FileChunk; SHA384_Final; SHA384_Init; SHA384_Update; SHA512_224_Data; SHA512_224_End; SHA512_224_Fd; SHA512_224_FdChunk; SHA512_224_File; SHA512_224_FileChunk; SHA512_224_Final; SHA512_224_Init; SHA512_224_Update; SHA512_256_Data; SHA512_256_End; SHA512_256_Fd; SHA512_256_FdChunk; SHA512_256_File; SHA512_256_FileChunk; SHA512_256_Final; SHA512_256_Init; SHA512_256_Update; SHA512_Data; SHA512_End; SHA512_Fd; SHA512_FdChunk; SHA512_File; SHA512_FileChunk; SHA512_Final; SHA512_Init; SHA512_Update; SHA_Data; SHA_End; SHA_Fd; SHA_FdChunk; SHA_File; SHA_FileChunk; SKEIN1024_Data; SKEIN1024_End; SKEIN1024_Fd; SKEIN1024_FdChunk; SKEIN1024_File; SKEIN1024_FileChunk; SKEIN1024_Final; SKEIN1024_Init; SKEIN1024_Update; SKEIN256_Data; SKEIN256_End; SKEIN256_Fd; SKEIN256_FdChunk; SKEIN256_File; SKEIN256_FileChunk; SKEIN256_Final; SKEIN256_Init; SKEIN256_Update; SKEIN512_Data; SKEIN512_End; SKEIN512_Fd; SKEIN512_FdChunk; SKEIN512_File; SKEIN512_FileChunk; SKEIN512_Final; SKEIN512_Init; SKEIN512_Update; }; FBSDprivate_1.0 { _libmd_MD4Data; _libmd_MD4End; _libmd_MD4Fd; _libmd_MD4FdChunk; _libmd_MD4File; _libmd_MD4FileChunk; _libmd_MD4Final; _libmd_MD4Init; _libmd_MD4Pad; _libmd_MD4Update; _libmd_MD5Data; _libmd_MD5End; _libmd_MD5Fd; _libmd_MD5FdChunk; _libmd_MD5File; _libmd_MD5FileChunk; _libmd_MD5Final; _libmd_MD5Init; _libmd_MD5Update; _libmd_RIPEMD160_Data; _libmd_RIPEMD160_End; _libmd_RIPEMD160_Fd; _libmd_RIPEMD160_FdChunk; _libmd_RIPEMD160_File; _libmd_RIPEMD160_FileChunk; _libmd_RIPEMD160_Final; _libmd_RIPEMD160_Init; _libmd_RIPEMD160_Update; - _libmd_RMD160_version; _libmd_SHA1_Data; _libmd_SHA1_End; _libmd_SHA1_Fd; _libmd_SHA1_FdChunk; _libmd_SHA1_File; _libmd_SHA1_FileChunk; _libmd_SHA1_Final; _libmd_SHA1_Init; _libmd_SHA1_Update; - _libmd_SHA1_version; _libmd_SHA224_Data; _libmd_SHA224_End; _libmd_SHA224_Fd; _libmd_SHA224_FdChunk; _libmd_SHA224_File; _libmd_SHA224_FileChunk; _libmd_SHA224_Final; _libmd_SHA224_Init; _libmd_SHA224_Update; _libmd_SHA256_Data; _libmd_SHA256_End; _libmd_SHA256_Fd; _libmd_SHA256_FdChunk; _libmd_SHA256_File; _libmd_SHA256_FileChunk; _libmd_SHA256_Final; _libmd_SHA256_Init; _libmd_SHA256_Update; _libmd_SHA384_Data; _libmd_SHA384_End; _libmd_SHA384_Fd; _libmd_SHA384_FdChunk; _libmd_SHA384_File; _libmd_SHA384_FileChunk; _libmd_SHA384_Final; _libmd_SHA384_Init; _libmd_SHA384_Update; _libmd_SHA512_224_Data; _libmd_SHA512_224_End; _libmd_SHA512_224_Fd; _libmd_SHA512_224_FdChunk; _libmd_SHA512_224_File; _libmd_SHA512_224_FileChunk; _libmd_SHA512_224_Final; _libmd_SHA512_224_Init; _libmd_SHA512_224_Update; _libmd_SHA512_256_Data; _libmd_SHA512_256_End; _libmd_SHA512_256_Fd; _libmd_SHA512_256_FdChunk; _libmd_SHA512_256_File; _libmd_SHA512_256_FileChunk; _libmd_SHA512_256_Final; _libmd_SHA512_256_Init; _libmd_SHA512_256_Update; _libmd_SHA512_Data; _libmd_SHA512_End; _libmd_SHA512_Fd; _libmd_SHA512_FdChunk; _libmd_SHA512_File; _libmd_SHA512_FileChunk; _libmd_SHA512_Final; _libmd_SHA512_Init; _libmd_SHA512_Update; _libmd_SHA_Data; _libmd_SHA_End; _libmd_SHA_Fd; _libmd_SHA_FdChunk; _libmd_SHA_File; _libmd_SHA_FileChunk; _libmd_SHA_Final; _libmd_SHA_Init; _libmd_SHA_Update; - _libmd_SHA_version; _libmd_SKEIN1024_Data; _libmd_SKEIN1024_End; _libmd_SKEIN1024_Fd; _libmd_SKEIN1024_FdChunk; _libmd_SKEIN1024_File; _libmd_SKEIN1024_FileChunk; _libmd_SKEIN1024_Final; _libmd_SKEIN1024_Init; _libmd_SKEIN1024_Update; _libmd_SKEIN256_Data; _libmd_SKEIN256_End; _libmd_SKEIN256_Fd; _libmd_SKEIN256_FdChunk; _libmd_SKEIN256_File; _libmd_SKEIN256_FileChunk; _libmd_SKEIN256_Final; _libmd_SKEIN256_Init; _libmd_SKEIN256_Update; _libmd_SKEIN512_Data; _libmd_SKEIN512_End; _libmd_SKEIN512_Fd; _libmd_SKEIN512_FdChunk; _libmd_SKEIN512_File; _libmd_SKEIN512_FileChunk; _libmd_SKEIN512_Final; _libmd_SKEIN512_Init; _libmd_SKEIN512_Update; }; diff --git a/lib/libmd/ripemd.h b/lib/libmd/ripemd.h index 7f82a54a5176..07293dad0e5f 100644 --- a/lib/libmd/ripemd.h +++ b/lib/libmd/ripemd.h @@ -1,132 +1,129 @@ /* crypto/ripemd/ripemd.h */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the routines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* */ #ifndef HEADER_RIPEMD_H #define HEADER_RIPEMD_H #include /* XXX switch to machine/ansi.h and __ types */ #define RIPEMD160_CBLOCK 64 #define RIPEMD160_LBLOCK 16 #define RIPEMD160_BLOCK 16 #define RIPEMD160_LAST_BLOCK 56 #define RIPEMD160_LENGTH_BLOCK 8 #define RIPEMD160_DIGEST_LENGTH 20 typedef struct RIPEMD160state_st { u_int32_t A,B,C,D,E; u_int32_t Nl,Nh; u_int32_t data[RIPEMD160_LBLOCK]; int num; } RIPEMD160_CTX; __BEGIN_DECLS /* Ensure libmd symbols do not clash with libcrypto */ #ifndef RIPEMD160_Init #define RIPEMD160_Init _libmd_RIPEMD160_Init #endif #ifndef RIPEMD160_Update #define RIPEMD160_Update _libmd_RIPEMD160_Update #endif #ifndef RIPEMD160_Final #define RIPEMD160_Final _libmd_RIPEMD160_Final #endif #ifndef RIPEMD160_End #define RIPEMD160_End _libmd_RIPEMD160_End #endif #ifndef RIPEMD160_Fd #define RIPEMD160_Fd _libmd_RIPEMD160_Fd #endif #ifndef RIPEMD160_FdChunk #define RIPEMD160_FdChunk _libmd_RIPEMD160_FdChunk #endif #ifndef RIPEMD160_File #define RIPEMD160_File _libmd_RIPEMD160_File #endif #ifndef RIPEMD160_FileChunk #define RIPEMD160_FileChunk _libmd_RIPEMD160_FileChunk #endif #ifndef RIPEMD160_Data #define RIPEMD160_Data _libmd_RIPEMD160_Data #endif -#ifndef RMD160_version -#define RMD160_version _libmd_RMD160_version -#endif #ifndef ripemd160_block #define ripemd160_block _libmd_ripemd160_block #endif void RIPEMD160_Init(RIPEMD160_CTX *c); void RIPEMD160_Update(RIPEMD160_CTX *c, const void *data, size_t len); void RIPEMD160_Final(unsigned char *md, RIPEMD160_CTX *c); char *RIPEMD160_End(RIPEMD160_CTX *, char *); char *RIPEMD160_Fd(int, char *); char *RIPEMD160_FdChunk(int, char *, off_t, off_t); char *RIPEMD160_File(const char *, char *); char *RIPEMD160_FileChunk(const char *, char *, off_t, off_t); char *RIPEMD160_Data(const void *, unsigned int, char *); __END_DECLS #endif diff --git a/lib/libmd/rmd160c.c b/lib/libmd/rmd160c.c index 5642a9a29a1c..92d6524b25b4 100644 --- a/lib/libmd/rmd160c.c +++ b/lib/libmd/rmd160c.c @@ -1,545 +1,543 @@ /* crypto/ripemd/rmd_dgst.c */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the routines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #if 0 #include /* we use the __ variants of bit-sized types */ #endif #include #include "rmd_locl.h" /* * The assembly-language code is not position-independent, so don't * try to use it in a shared library. */ #ifdef PIC #undef RMD160_ASM #endif -char *RMD160_version="RIPEMD160 part of SSLeay 0.9.0b 11-Oct-1998"; +static char *RMD160_version="RIPEMD160 part of SSLeay 0.9.0b 11-Oct-1998"; #ifdef RMD160_ASM void ripemd160_block_x86(RIPEMD160_CTX *c, const u_int32_t *p,int num); #define ripemd160_block ripemd160_block_x86 #else void ripemd160_block(RIPEMD160_CTX *c, const u_int32_t *p,int num); #endif void RIPEMD160_Init(RIPEMD160_CTX *c) { c->A=RIPEMD160_A; c->B=RIPEMD160_B; c->C=RIPEMD160_C; c->D=RIPEMD160_D; c->E=RIPEMD160_E; c->Nl=0; c->Nh=0; c->num=0; } void RIPEMD160_Update(RIPEMD160_CTX *c, const void *in, size_t len) { u_int32_t *p; int sw,sc; u_int32_t l; const unsigned char *data = in; if (len == 0) return; l=(c->Nl+(len<<3))&0xffffffffL; if (l < c->Nl) /* overflow */ c->Nh++; c->Nh+=(len>>29); c->Nl=l; if (c->num != 0) { p=c->data; sw=c->num>>2; sc=c->num&0x03; if ((c->num+len) >= RIPEMD160_CBLOCK) { l= p[sw]; p_c2l(data,l,sc); p[sw++]=l; for (; swnum); ripemd160_block(c,p,64); c->num=0; /* drop through and do the rest */ } else { int ew,ec; c->num+=(int)len; if ((sc+len) < 4) /* ugly, add char's to a word */ { l= p[sw]; p_c2l_p(data,l,sc,len); p[sw]=l; } else { ew=(c->num>>2); ec=(c->num&0x03); l= p[sw]; p_c2l(data,l,sc); p[sw++]=l; for (; sw < ew; sw++) { c2l(data,l); p[sw]=l; } if (ec) { c2l_p(data,l,ec); p[sw]=l; } } return; } } /* we now can process the input data in blocks of RIPEMD160_CBLOCK * chars and save the leftovers to c->data. */ #if BYTE_ORDER == LITTLE_ENDIAN if ((((unsigned long)data)%sizeof(u_int32_t)) == 0) { sw=(int)len/RIPEMD160_CBLOCK; if (sw > 0) { sw*=RIPEMD160_CBLOCK; ripemd160_block(c,(u_int32_t *)data,sw); data+=sw; len-=sw; } } #endif p=c->data; while (len >= RIPEMD160_CBLOCK) { #if BYTE_ORDER == LITTLE_ENDIAN || BYTE_ORDER == BIG_ENDIAN if (p != (u_int32_t *)data) memcpy(p,data,RIPEMD160_CBLOCK); data+=RIPEMD160_CBLOCK; #if BYTE_ORDER == BIG_ENDIAN for (sw=(RIPEMD160_LBLOCK/4); sw; sw--) { Endian_Reverse32(p[0]); Endian_Reverse32(p[1]); Endian_Reverse32(p[2]); Endian_Reverse32(p[3]); p+=4; } #endif #else for (sw=(RIPEMD160_LBLOCK/4); sw; sw--) { c2l(data,l); *(p++)=l; c2l(data,l); *(p++)=l; c2l(data,l); *(p++)=l; c2l(data,l); *(p++)=l; } #endif p=c->data; ripemd160_block(c,p,64); len-=RIPEMD160_CBLOCK; } sc=(int)len; c->num=sc; if (sc) { sw=sc>>2; /* words to copy */ #if BYTE_ORDER == LITTLE_ENDIAN p[sw]=0; memcpy(p,data,sc); #else sc&=0x03; for ( ; sw; sw--) { c2l(data,l); *(p++)=l; } c2l_p(data,l,sc); *p=l; #endif } } static void RIPEMD160_Transform(RIPEMD160_CTX *c, unsigned char *b) { u_int32_t p[16]; #if BYTE_ORDER != LITTLE_ENDIAN u_int32_t *q; int i; #endif #if BYTE_ORDER == BIG_ENDIAN || BYTE_ORDER == LITTLE_ENDIAN memcpy(p,b,64); #if BYTE_ORDER == BIG_ENDIAN q=p; for (i=(RIPEMD160_LBLOCK/4); i; i--) { Endian_Reverse32(q[0]); Endian_Reverse32(q[1]); Endian_Reverse32(q[2]); Endian_Reverse32(q[3]); q+=4; } #endif #else q=p; for (i=(RIPEMD160_LBLOCK/4); i; i--) { u_int32_t l; c2l(b,l); *(q++)=l; c2l(b,l); *(q++)=l; c2l(b,l); *(q++)=l; c2l(b,l); *(q++)=l; } #endif ripemd160_block(c,p,64); } #ifndef RMD160_ASM void ripemd160_block(RIPEMD160_CTX *ctx, const u_int32_t *X, int num) { u_int32_t A,B,C,D,E; u_int32_t a,b,c,d,e; for (;;) { A=ctx->A; B=ctx->B; C=ctx->C; D=ctx->D; E=ctx->E; RIP1(A,B,C,D,E,WL00,SL00); RIP1(E,A,B,C,D,WL01,SL01); RIP1(D,E,A,B,C,WL02,SL02); RIP1(C,D,E,A,B,WL03,SL03); RIP1(B,C,D,E,A,WL04,SL04); RIP1(A,B,C,D,E,WL05,SL05); RIP1(E,A,B,C,D,WL06,SL06); RIP1(D,E,A,B,C,WL07,SL07); RIP1(C,D,E,A,B,WL08,SL08); RIP1(B,C,D,E,A,WL09,SL09); RIP1(A,B,C,D,E,WL10,SL10); RIP1(E,A,B,C,D,WL11,SL11); RIP1(D,E,A,B,C,WL12,SL12); RIP1(C,D,E,A,B,WL13,SL13); RIP1(B,C,D,E,A,WL14,SL14); RIP1(A,B,C,D,E,WL15,SL15); RIP2(E,A,B,C,D,WL16,SL16,KL1); RIP2(D,E,A,B,C,WL17,SL17,KL1); RIP2(C,D,E,A,B,WL18,SL18,KL1); RIP2(B,C,D,E,A,WL19,SL19,KL1); RIP2(A,B,C,D,E,WL20,SL20,KL1); RIP2(E,A,B,C,D,WL21,SL21,KL1); RIP2(D,E,A,B,C,WL22,SL22,KL1); RIP2(C,D,E,A,B,WL23,SL23,KL1); RIP2(B,C,D,E,A,WL24,SL24,KL1); RIP2(A,B,C,D,E,WL25,SL25,KL1); RIP2(E,A,B,C,D,WL26,SL26,KL1); RIP2(D,E,A,B,C,WL27,SL27,KL1); RIP2(C,D,E,A,B,WL28,SL28,KL1); RIP2(B,C,D,E,A,WL29,SL29,KL1); RIP2(A,B,C,D,E,WL30,SL30,KL1); RIP2(E,A,B,C,D,WL31,SL31,KL1); RIP3(D,E,A,B,C,WL32,SL32,KL2); RIP3(C,D,E,A,B,WL33,SL33,KL2); RIP3(B,C,D,E,A,WL34,SL34,KL2); RIP3(A,B,C,D,E,WL35,SL35,KL2); RIP3(E,A,B,C,D,WL36,SL36,KL2); RIP3(D,E,A,B,C,WL37,SL37,KL2); RIP3(C,D,E,A,B,WL38,SL38,KL2); RIP3(B,C,D,E,A,WL39,SL39,KL2); RIP3(A,B,C,D,E,WL40,SL40,KL2); RIP3(E,A,B,C,D,WL41,SL41,KL2); RIP3(D,E,A,B,C,WL42,SL42,KL2); RIP3(C,D,E,A,B,WL43,SL43,KL2); RIP3(B,C,D,E,A,WL44,SL44,KL2); RIP3(A,B,C,D,E,WL45,SL45,KL2); RIP3(E,A,B,C,D,WL46,SL46,KL2); RIP3(D,E,A,B,C,WL47,SL47,KL2); RIP4(C,D,E,A,B,WL48,SL48,KL3); RIP4(B,C,D,E,A,WL49,SL49,KL3); RIP4(A,B,C,D,E,WL50,SL50,KL3); RIP4(E,A,B,C,D,WL51,SL51,KL3); RIP4(D,E,A,B,C,WL52,SL52,KL3); RIP4(C,D,E,A,B,WL53,SL53,KL3); RIP4(B,C,D,E,A,WL54,SL54,KL3); RIP4(A,B,C,D,E,WL55,SL55,KL3); RIP4(E,A,B,C,D,WL56,SL56,KL3); RIP4(D,E,A,B,C,WL57,SL57,KL3); RIP4(C,D,E,A,B,WL58,SL58,KL3); RIP4(B,C,D,E,A,WL59,SL59,KL3); RIP4(A,B,C,D,E,WL60,SL60,KL3); RIP4(E,A,B,C,D,WL61,SL61,KL3); RIP4(D,E,A,B,C,WL62,SL62,KL3); RIP4(C,D,E,A,B,WL63,SL63,KL3); RIP5(B,C,D,E,A,WL64,SL64,KL4); RIP5(A,B,C,D,E,WL65,SL65,KL4); RIP5(E,A,B,C,D,WL66,SL66,KL4); RIP5(D,E,A,B,C,WL67,SL67,KL4); RIP5(C,D,E,A,B,WL68,SL68,KL4); RIP5(B,C,D,E,A,WL69,SL69,KL4); RIP5(A,B,C,D,E,WL70,SL70,KL4); RIP5(E,A,B,C,D,WL71,SL71,KL4); RIP5(D,E,A,B,C,WL72,SL72,KL4); RIP5(C,D,E,A,B,WL73,SL73,KL4); RIP5(B,C,D,E,A,WL74,SL74,KL4); RIP5(A,B,C,D,E,WL75,SL75,KL4); RIP5(E,A,B,C,D,WL76,SL76,KL4); RIP5(D,E,A,B,C,WL77,SL77,KL4); RIP5(C,D,E,A,B,WL78,SL78,KL4); RIP5(B,C,D,E,A,WL79,SL79,KL4); a=A; b=B; c=C; d=D; e=E; /* Do other half */ A=ctx->A; B=ctx->B; C=ctx->C; D=ctx->D; E=ctx->E; RIP5(A,B,C,D,E,WR00,SR00,KR0); RIP5(E,A,B,C,D,WR01,SR01,KR0); RIP5(D,E,A,B,C,WR02,SR02,KR0); RIP5(C,D,E,A,B,WR03,SR03,KR0); RIP5(B,C,D,E,A,WR04,SR04,KR0); RIP5(A,B,C,D,E,WR05,SR05,KR0); RIP5(E,A,B,C,D,WR06,SR06,KR0); RIP5(D,E,A,B,C,WR07,SR07,KR0); RIP5(C,D,E,A,B,WR08,SR08,KR0); RIP5(B,C,D,E,A,WR09,SR09,KR0); RIP5(A,B,C,D,E,WR10,SR10,KR0); RIP5(E,A,B,C,D,WR11,SR11,KR0); RIP5(D,E,A,B,C,WR12,SR12,KR0); RIP5(C,D,E,A,B,WR13,SR13,KR0); RIP5(B,C,D,E,A,WR14,SR14,KR0); RIP5(A,B,C,D,E,WR15,SR15,KR0); RIP4(E,A,B,C,D,WR16,SR16,KR1); RIP4(D,E,A,B,C,WR17,SR17,KR1); RIP4(C,D,E,A,B,WR18,SR18,KR1); RIP4(B,C,D,E,A,WR19,SR19,KR1); RIP4(A,B,C,D,E,WR20,SR20,KR1); RIP4(E,A,B,C,D,WR21,SR21,KR1); RIP4(D,E,A,B,C,WR22,SR22,KR1); RIP4(C,D,E,A,B,WR23,SR23,KR1); RIP4(B,C,D,E,A,WR24,SR24,KR1); RIP4(A,B,C,D,E,WR25,SR25,KR1); RIP4(E,A,B,C,D,WR26,SR26,KR1); RIP4(D,E,A,B,C,WR27,SR27,KR1); RIP4(C,D,E,A,B,WR28,SR28,KR1); RIP4(B,C,D,E,A,WR29,SR29,KR1); RIP4(A,B,C,D,E,WR30,SR30,KR1); RIP4(E,A,B,C,D,WR31,SR31,KR1); RIP3(D,E,A,B,C,WR32,SR32,KR2); RIP3(C,D,E,A,B,WR33,SR33,KR2); RIP3(B,C,D,E,A,WR34,SR34,KR2); RIP3(A,B,C,D,E,WR35,SR35,KR2); RIP3(E,A,B,C,D,WR36,SR36,KR2); RIP3(D,E,A,B,C,WR37,SR37,KR2); RIP3(C,D,E,A,B,WR38,SR38,KR2); RIP3(B,C,D,E,A,WR39,SR39,KR2); RIP3(A,B,C,D,E,WR40,SR40,KR2); RIP3(E,A,B,C,D,WR41,SR41,KR2); RIP3(D,E,A,B,C,WR42,SR42,KR2); RIP3(C,D,E,A,B,WR43,SR43,KR2); RIP3(B,C,D,E,A,WR44,SR44,KR2); RIP3(A,B,C,D,E,WR45,SR45,KR2); RIP3(E,A,B,C,D,WR46,SR46,KR2); RIP3(D,E,A,B,C,WR47,SR47,KR2); RIP2(C,D,E,A,B,WR48,SR48,KR3); RIP2(B,C,D,E,A,WR49,SR49,KR3); RIP2(A,B,C,D,E,WR50,SR50,KR3); RIP2(E,A,B,C,D,WR51,SR51,KR3); RIP2(D,E,A,B,C,WR52,SR52,KR3); RIP2(C,D,E,A,B,WR53,SR53,KR3); RIP2(B,C,D,E,A,WR54,SR54,KR3); RIP2(A,B,C,D,E,WR55,SR55,KR3); RIP2(E,A,B,C,D,WR56,SR56,KR3); RIP2(D,E,A,B,C,WR57,SR57,KR3); RIP2(C,D,E,A,B,WR58,SR58,KR3); RIP2(B,C,D,E,A,WR59,SR59,KR3); RIP2(A,B,C,D,E,WR60,SR60,KR3); RIP2(E,A,B,C,D,WR61,SR61,KR3); RIP2(D,E,A,B,C,WR62,SR62,KR3); RIP2(C,D,E,A,B,WR63,SR63,KR3); RIP1(B,C,D,E,A,WR64,SR64); RIP1(A,B,C,D,E,WR65,SR65); RIP1(E,A,B,C,D,WR66,SR66); RIP1(D,E,A,B,C,WR67,SR67); RIP1(C,D,E,A,B,WR68,SR68); RIP1(B,C,D,E,A,WR69,SR69); RIP1(A,B,C,D,E,WR70,SR70); RIP1(E,A,B,C,D,WR71,SR71); RIP1(D,E,A,B,C,WR72,SR72); RIP1(C,D,E,A,B,WR73,SR73); RIP1(B,C,D,E,A,WR74,SR74); RIP1(A,B,C,D,E,WR75,SR75); RIP1(E,A,B,C,D,WR76,SR76); RIP1(D,E,A,B,C,WR77,SR77); RIP1(C,D,E,A,B,WR78,SR78); RIP1(B,C,D,E,A,WR79,SR79); D =ctx->B+c+D; ctx->B=ctx->C+d+E; ctx->C=ctx->D+e+A; ctx->D=ctx->E+a+B; ctx->E=ctx->A+b+C; ctx->A=D; X+=16; num-=64; if (num <= 0) break; } } #endif void RIPEMD160_Final(unsigned char *md, RIPEMD160_CTX *c) { int i,j; u_int32_t l; u_int32_t *p; static unsigned char end[4]={0x80,0x00,0x00,0x00}; unsigned char *cp=end; /* c->num should definitly have room for at least one more byte. */ p=c->data; j=c->num; i=j>>2; /* purify often complains about the following line as an * Uninitialized Memory Read. While this can be true, the * following p_c2l macro will reset l when that case is true. * This is because j&0x03 contains the number of 'valid' bytes * already in p[i]. If and only if j&0x03 == 0, the UMR will * occur but this is also the only time p_c2l will do * l= *(cp++) instead of l|= *(cp++) * Many thanks to Alex Tang for pickup this * 'potential bug' */ #ifdef PURIFY if ((j&0x03) == 0) p[i]=0; #endif l=p[i]; p_c2l(cp,l,j&0x03); p[i]=l; i++; /* i is the next 'undefined word' */ if (c->num >= RIPEMD160_LAST_BLOCK) { for (; iNl; p[RIPEMD160_LBLOCK-1]=c->Nh; ripemd160_block(c,p,64); cp=md; l=c->A; l2c(l,cp); l=c->B; l2c(l,cp); l=c->C; l2c(l,cp); l=c->D; l2c(l,cp); l=c->E; l2c(l,cp); /* Clear the context state */ explicit_bzero(&c, sizeof(c)); } #ifdef undef int printit(unsigned long *l) { int i,ii; for (i=0; i<2; i++) { for (ii=0; ii<8; ii++) { fprintf(stderr,"%08lx ",l[i*8+ii]); } fprintf(stderr,"\n"); } } #endif #ifdef WEAK_REFS /* When building libmd, provide weak references. Note: this is not activated in the context of compiling these sources for internal use in libcrypt. */ #undef RIPEMD160_Init __weak_reference(_libmd_RIPEMD160_Init, RIPEMD160_Init); #undef RIPEMD160_Update __weak_reference(_libmd_RIPEMD160_Update, RIPEMD160_Update); #undef RIPEMD160_Final __weak_reference(_libmd_RIPEMD160_Final, RIPEMD160_Final); -#undef RMD160_version -__weak_reference(_libmd_RMD160_version, RMD160_version); #endif diff --git a/lib/libmd/sha.h b/lib/libmd/sha.h index 49f65d91bfda..cd4a899bee49 100644 --- a/lib/libmd/sha.h +++ b/lib/libmd/sha.h @@ -1,173 +1,167 @@ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the routines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #ifndef _SHA_H_ #define _SHA_H_ 1 #include /* XXX switch to machine/ansi.h and __ types */ #define SHA_CBLOCK 64 #define SHA_LBLOCK 16 #define SHA_BLOCK 16 #define SHA_LAST_BLOCK 56 #define SHA_LENGTH_BLOCK 8 #define SHA_DIGEST_LENGTH 20 typedef struct SHAstate_st { u_int32_t h0, h1, h2, h3, h4; u_int32_t Nl, Nh; u_int32_t data[SHA_LBLOCK]; int num; } SHA_CTX; #define SHA1_CTX SHA_CTX __BEGIN_DECLS /* Ensure libmd symbols do not clash with libcrypto */ #ifndef SHA_Init #define SHA_Init _libmd_SHA_Init #endif #ifndef SHA_Update #define SHA_Update _libmd_SHA_Update #endif #ifndef SHA_Final #define SHA_Final _libmd_SHA_Final #endif #ifndef SHA_End #define SHA_End _libmd_SHA_End #endif #ifndef SHA_Fd #define SHA_Fd _libmd_SHA_Fd #endif #ifndef SHA_FdChunk #define SHA_FdChunk _libmd_SHA_FdChunk #endif #ifndef SHA_File #define SHA_File _libmd_SHA_File #endif #ifndef SHA_FileChunk #define SHA_FileChunk _libmd_SHA_FileChunk #endif #ifndef SHA_Data #define SHA_Data _libmd_SHA_Data #endif -#ifndef SHA_version -#define SHA_version _libmd_SHA_version -#endif #ifndef sha_block #define sha_block _libmd_sha_block #endif #ifndef SHA1_Init #define SHA1_Init _libmd_SHA1_Init #endif #ifndef SHA1_Update #define SHA1_Update _libmd_SHA1_Update #endif #ifndef SHA1_Final #define SHA1_Final _libmd_SHA1_Final #endif #ifndef SHA1_End #define SHA1_End _libmd_SHA1_End #endif #ifndef SHA1_Fd #define SHA1_Fd _libmd_SHA1_Fd #endif #ifndef SHA1_FdChunk #define SHA1_FdChunk _libmd_SHA1_FdChunk #endif #ifndef SHA1_File #define SHA1_File _libmd_SHA1_File #endif #ifndef SHA1_FileChunk #define SHA1_FileChunk _libmd_SHA1_FileChunk #endif #ifndef SHA1_Data #define SHA1_Data _libmd_SHA1_Data #endif -#ifndef SHA1_version -#define SHA1_version _libmd_SHA1_version -#endif #ifndef sha1_block #define sha1_block _libmd_sha1_block #endif void SHA_Init(SHA_CTX *c); void SHA_Update(SHA_CTX *c, const void *data, size_t len); void SHA_Final(unsigned char *md, SHA_CTX *c); char *SHA_End(SHA_CTX *, char *); char *SHA_Fd(int, char *); char *SHA_FdChunk(int, char *, off_t, off_t); char *SHA_File(const char *, char *); char *SHA_FileChunk(const char *, char *, off_t, off_t); char *SHA_Data(const void *, unsigned int, char *); void SHA1_Init(SHA_CTX *c); void SHA1_Update(SHA_CTX *c, const void *data, size_t len); void SHA1_Final(unsigned char *md, SHA_CTX *c); char *SHA1_End(SHA_CTX *, char *); char *SHA1_Fd(int, char *); char *SHA1_FdChunk(int, char *, off_t, off_t); char *SHA1_File(const char *, char *); char *SHA1_FileChunk(const char *, char *, off_t, off_t); char *SHA1_Data(const void *, unsigned int, char *); __END_DECLS #endif /* !_SHA_H_ */ diff --git a/lib/libmd/sha1c.c b/lib/libmd/sha1c.c index 6e80407e4ec0..83e402e132e7 100644 --- a/lib/libmd/sha1c.c +++ b/lib/libmd/sha1c.c @@ -1,496 +1,492 @@ /* crypto/sha/sha1dgst.c */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the routines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #if 0 #include /* we use the __ variants of bit-sized types */ #endif #include #undef SHA_0 #define SHA_1 #include "sha.h" #include "sha_locl.h" /* * The assembly-language code is not position-independent, so don't * try to use it in a shared library. */ #ifdef PIC #undef SHA1_ASM #endif -char *SHA1_version="SHA1 part of SSLeay 0.9.0b 11-Oct-1998"; +static char *SHA1_version="SHA1 part of SSLeay 0.9.0b 11-Oct-1998"; /* Implemented from SHA-1 document - The Secure Hash Algorithm */ #define INIT_DATA_h0 (unsigned long)0x67452301L #define INIT_DATA_h1 (unsigned long)0xefcdab89L #define INIT_DATA_h2 (unsigned long)0x98badcfeL #define INIT_DATA_h3 (unsigned long)0x10325476L #define INIT_DATA_h4 (unsigned long)0xc3d2e1f0L #define K_00_19 0x5a827999L #define K_20_39 0x6ed9eba1L #define K_40_59 0x8f1bbcdcL #define K_60_79 0xca62c1d6L #ifndef NOPROTO # ifdef SHA1_ASM void sha1_block_x86(SHA_CTX *c, const u_int32_t *p, int num); # define sha1_block sha1_block_x86 # else void sha1_block(SHA_CTX *c, const u_int32_t *p, int num); # endif #else # ifdef SHA1_ASM void sha1_block_x86(); # define sha1_block sha1_block_x86 # else void sha1_block(); # endif #endif #if BYTE_ORDER == LITTLE_ENDIAN && defined(SHA1_ASM) # define M_c2nl c2l # define M_p_c2nl p_c2l # define M_c2nl_p c2l_p # define M_p_c2nl_p p_c2l_p # define M_nl2c l2c #else # define M_c2nl c2nl # define M_p_c2nl p_c2nl # define M_c2nl_p c2nl_p # define M_p_c2nl_p p_c2nl_p # define M_nl2c nl2c #endif void SHA1_Init(SHA_CTX *c) { c->h0=INIT_DATA_h0; c->h1=INIT_DATA_h1; c->h2=INIT_DATA_h2; c->h3=INIT_DATA_h3; c->h4=INIT_DATA_h4; c->Nl=0; c->Nh=0; c->num=0; } void SHA1_Update(SHA_CTX *c, const void *in, size_t len) { u_int32_t *p; int ew,ec,sw,sc; u_int32_t l; const unsigned char *data = in; if (len == 0) return; l=(c->Nl+(len<<3))&0xffffffffL; if (l < c->Nl) /* overflow */ c->Nh++; c->Nh+=(len>>29); c->Nl=l; if (c->num != 0) { p=c->data; sw=c->num>>2; sc=c->num&0x03; if ((c->num+len) >= SHA_CBLOCK) { l= p[sw]; M_p_c2nl(data,l,sc); p[sw++]=l; for (; swnum); sha1_block(c,p,64); c->num=0; /* drop through and do the rest */ } else { c->num+=(int)len; if ((sc+len) < 4) /* ugly, add char's to a word */ { l= p[sw]; M_p_c2nl_p(data,l,sc,len); p[sw]=l; } else { ew=(c->num>>2); ec=(c->num&0x03); l= p[sw]; M_p_c2nl(data,l,sc); p[sw++]=l; for (; sw < ew; sw++) { M_c2nl(data,l); p[sw]=l; } if (ec) { M_c2nl_p(data,l,ec); p[sw]=l; } } return; } } /* We can only do the following code for assember, the reason * being that the sha1_block 'C' version changes the values * in the 'data' array. The assember code avoids this and * copies it to a local array. I should be able to do this for * the C version as well.... */ #if 1 #if BYTE_ORDER == BIG_ENDIAN || defined(SHA1_ASM) if ((((unsigned int)data)%sizeof(u_int32_t)) == 0) { sw=len/SHA_CBLOCK; if (sw) { sw*=SHA_CBLOCK; sha1_block(c,(u_int32_t *)data,sw); data+=sw; len-=sw; } } #endif #endif /* we now can process the input data in blocks of SHA_CBLOCK * chars and save the leftovers to c->data. */ p=c->data; while (len >= SHA_CBLOCK) { #if BYTE_ORDER == BIG_ENDIAN || BYTE_ORDER == LITTLE_ENDIAN if (p != (u_int32_t *)data) memcpy(p,data,SHA_CBLOCK); data+=SHA_CBLOCK; # if BYTE_ORDER == LITTLE_ENDIAN # ifndef SHA1_ASM /* Will not happen */ for (sw=(SHA_LBLOCK/4); sw; sw--) { Endian_Reverse32(p[0]); Endian_Reverse32(p[1]); Endian_Reverse32(p[2]); Endian_Reverse32(p[3]); p+=4; } p=c->data; # endif # endif #else for (sw=(SHA_BLOCK/4); sw; sw--) { M_c2nl(data,l); *(p++)=l; M_c2nl(data,l); *(p++)=l; M_c2nl(data,l); *(p++)=l; M_c2nl(data,l); *(p++)=l; } p=c->data; #endif sha1_block(c,p,64); len-=SHA_CBLOCK; } ec=(int)len; c->num=ec; ew=(ec>>2); ec&=0x03; for (sw=0; sw < ew; sw++) { M_c2nl(data,l); p[sw]=l; } M_c2nl_p(data,l,ec); p[sw]=l; } static void SHA1_Transform(SHA_CTX *c, unsigned char *b) { u_int32_t p[16]; #if BYTE_ORDER != BIG_ENDIAN u_int32_t *q; int i; #endif #if BYTE_ORDER == BIG_ENDIAN || BYTE_ORDER == LITTLE_ENDIAN memcpy(p,b,64); #if BYTE_ORDER == LITTLE_ENDIAN q=p; for (i=(SHA_LBLOCK/4); i; i--) { Endian_Reverse32(q[0]); Endian_Reverse32(q[1]); Endian_Reverse32(q[2]); Endian_Reverse32(q[3]); q+=4; } #endif #else q=p; for (i=(SHA_LBLOCK/4); i; i--) { u_int32_t l; c2nl(b,l); *(q++)=l; c2nl(b,l); *(q++)=l; c2nl(b,l); *(q++)=l; c2nl(b,l); *(q++)=l; } #endif sha1_block(c,p,64); } #ifndef SHA1_ASM void sha1_block(SHA_CTX *c, const u_int32_t *W, int num) { u_int32_t A,B,C,D,E,T; u_int32_t X[16]; A=c->h0; B=c->h1; C=c->h2; D=c->h3; E=c->h4; for (;;) { BODY_00_15( 0,A,B,C,D,E,T,W); BODY_00_15( 1,T,A,B,C,D,E,W); BODY_00_15( 2,E,T,A,B,C,D,W); BODY_00_15( 3,D,E,T,A,B,C,W); BODY_00_15( 4,C,D,E,T,A,B,W); BODY_00_15( 5,B,C,D,E,T,A,W); BODY_00_15( 6,A,B,C,D,E,T,W); BODY_00_15( 7,T,A,B,C,D,E,W); BODY_00_15( 8,E,T,A,B,C,D,W); BODY_00_15( 9,D,E,T,A,B,C,W); BODY_00_15(10,C,D,E,T,A,B,W); BODY_00_15(11,B,C,D,E,T,A,W); BODY_00_15(12,A,B,C,D,E,T,W); BODY_00_15(13,T,A,B,C,D,E,W); BODY_00_15(14,E,T,A,B,C,D,W); BODY_00_15(15,D,E,T,A,B,C,W); BODY_16_19(16,C,D,E,T,A,B,W,W,W,W); BODY_16_19(17,B,C,D,E,T,A,W,W,W,W); BODY_16_19(18,A,B,C,D,E,T,W,W,W,W); BODY_16_19(19,T,A,B,C,D,E,W,W,W,X); BODY_20_31(20,E,T,A,B,C,D,W,W,W,X); BODY_20_31(21,D,E,T,A,B,C,W,W,W,X); BODY_20_31(22,C,D,E,T,A,B,W,W,W,X); BODY_20_31(23,B,C,D,E,T,A,W,W,W,X); BODY_20_31(24,A,B,C,D,E,T,W,W,X,X); BODY_20_31(25,T,A,B,C,D,E,W,W,X,X); BODY_20_31(26,E,T,A,B,C,D,W,W,X,X); BODY_20_31(27,D,E,T,A,B,C,W,W,X,X); BODY_20_31(28,C,D,E,T,A,B,W,W,X,X); BODY_20_31(29,B,C,D,E,T,A,W,W,X,X); BODY_20_31(30,A,B,C,D,E,T,W,X,X,X); BODY_20_31(31,T,A,B,C,D,E,W,X,X,X); BODY_32_39(32,E,T,A,B,C,D,X); BODY_32_39(33,D,E,T,A,B,C,X); BODY_32_39(34,C,D,E,T,A,B,X); BODY_32_39(35,B,C,D,E,T,A,X); BODY_32_39(36,A,B,C,D,E,T,X); BODY_32_39(37,T,A,B,C,D,E,X); BODY_32_39(38,E,T,A,B,C,D,X); BODY_32_39(39,D,E,T,A,B,C,X); BODY_40_59(40,C,D,E,T,A,B,X); BODY_40_59(41,B,C,D,E,T,A,X); BODY_40_59(42,A,B,C,D,E,T,X); BODY_40_59(43,T,A,B,C,D,E,X); BODY_40_59(44,E,T,A,B,C,D,X); BODY_40_59(45,D,E,T,A,B,C,X); BODY_40_59(46,C,D,E,T,A,B,X); BODY_40_59(47,B,C,D,E,T,A,X); BODY_40_59(48,A,B,C,D,E,T,X); BODY_40_59(49,T,A,B,C,D,E,X); BODY_40_59(50,E,T,A,B,C,D,X); BODY_40_59(51,D,E,T,A,B,C,X); BODY_40_59(52,C,D,E,T,A,B,X); BODY_40_59(53,B,C,D,E,T,A,X); BODY_40_59(54,A,B,C,D,E,T,X); BODY_40_59(55,T,A,B,C,D,E,X); BODY_40_59(56,E,T,A,B,C,D,X); BODY_40_59(57,D,E,T,A,B,C,X); BODY_40_59(58,C,D,E,T,A,B,X); BODY_40_59(59,B,C,D,E,T,A,X); BODY_60_79(60,A,B,C,D,E,T,X); BODY_60_79(61,T,A,B,C,D,E,X); BODY_60_79(62,E,T,A,B,C,D,X); BODY_60_79(63,D,E,T,A,B,C,X); BODY_60_79(64,C,D,E,T,A,B,X); BODY_60_79(65,B,C,D,E,T,A,X); BODY_60_79(66,A,B,C,D,E,T,X); BODY_60_79(67,T,A,B,C,D,E,X); BODY_60_79(68,E,T,A,B,C,D,X); BODY_60_79(69,D,E,T,A,B,C,X); BODY_60_79(70,C,D,E,T,A,B,X); BODY_60_79(71,B,C,D,E,T,A,X); BODY_60_79(72,A,B,C,D,E,T,X); BODY_60_79(73,T,A,B,C,D,E,X); BODY_60_79(74,E,T,A,B,C,D,X); BODY_60_79(75,D,E,T,A,B,C,X); BODY_60_79(76,C,D,E,T,A,B,X); BODY_60_79(77,B,C,D,E,T,A,X); BODY_60_79(78,A,B,C,D,E,T,X); BODY_60_79(79,T,A,B,C,D,E,X); c->h0=(c->h0+E)&0xffffffffL; c->h1=(c->h1+T)&0xffffffffL; c->h2=(c->h2+A)&0xffffffffL; c->h3=(c->h3+B)&0xffffffffL; c->h4=(c->h4+C)&0xffffffffL; num-=64; if (num <= 0) break; A=c->h0; B=c->h1; C=c->h2; D=c->h3; E=c->h4; W+=16; } } #endif void SHA1_Final(unsigned char *md, SHA_CTX *c) { int i,j; u_int32_t l; u_int32_t *p; static unsigned char end[4]={0x80,0x00,0x00,0x00}; unsigned char *cp=end; /* c->num should definitly have room for at least one more byte. */ p=c->data; j=c->num; i=j>>2; #ifdef PURIFY if ((j&0x03) == 0) p[i]=0; #endif l=p[i]; M_p_c2nl(cp,l,j&0x03); p[i]=l; i++; /* i is the next 'undefined word' */ if (c->num >= SHA_LAST_BLOCK) { for (; iNh; p[SHA_LBLOCK-1]=c->Nl; #if BYTE_ORDER == LITTLE_ENDIAN && defined(SHA1_ASM) Endian_Reverse32(p[SHA_LBLOCK-2]); Endian_Reverse32(p[SHA_LBLOCK-1]); #endif sha1_block(c,p,64); cp=md; l=c->h0; nl2c(l,cp); l=c->h1; nl2c(l,cp); l=c->h2; nl2c(l,cp); l=c->h3; nl2c(l,cp); l=c->h4; nl2c(l,cp); /* Clear the context state */ explicit_bzero(&c, sizeof(c)); } #ifdef WEAK_REFS /* When building libmd, provide weak references. Note: this is not activated in the context of compiling these sources for internal use in libcrypt. */ #undef SHA_Init __weak_reference(_libmd_SHA_Init, SHA_Init); #undef SHA_Update __weak_reference(_libmd_SHA_Update, SHA_Update); #undef SHA_Final __weak_reference(_libmd_SHA_Final, SHA_Final); -#undef SHA_version -__weak_reference(_libmd_SHA_version, SHA_version); #undef SHA1_Init __weak_reference(_libmd_SHA1_Init, SHA1_Init); #undef SHA1_Update __weak_reference(_libmd_SHA1_Update, SHA1_Update); #undef SHA1_Final __weak_reference(_libmd_SHA1_Final, SHA1_Final); -#undef SHA1_version -__weak_reference(_libmd_SHA1_version, SHA1_version); #endif diff --git a/sys/crypto/sha2/sha224.h b/sys/crypto/sha2/sha224.h index 8286a31fdec2..b54f418ae594 100644 --- a/sys/crypto/sha2/sha224.h +++ b/sys/crypto/sha2/sha224.h @@ -1,94 +1,90 @@ /*- * Copyright 2005 Colin Percival * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #ifndef _SHA224_H_ #define _SHA224_H_ #ifndef _KERNEL #include #endif #define SHA224_BLOCK_LENGTH 64 #define SHA224_DIGEST_LENGTH 28 #define SHA224_DIGEST_STRING_LENGTH (SHA224_DIGEST_LENGTH * 2 + 1) typedef struct SHA224Context { uint32_t state[8]; uint64_t count; uint8_t buf[SHA224_BLOCK_LENGTH]; } SHA224_CTX; __BEGIN_DECLS /* Ensure libmd symbols do not clash with libcrypto */ #ifndef SHA224_Init #define SHA224_Init _libmd_SHA224_Init #endif #ifndef SHA224_Update #define SHA224_Update _libmd_SHA224_Update #endif #ifndef SHA224_Final #define SHA224_Final _libmd_SHA224_Final #endif #ifndef SHA224_End #define SHA224_End _libmd_SHA224_End #endif #ifndef SHA224_Fd #define SHA224_Fd _libmd_SHA224_Fd #endif #ifndef SHA224_FdChunk #define SHA224_FdChunk _libmd_SHA224_FdChunk #endif #ifndef SHA224_File #define SHA224_File _libmd_SHA224_File #endif #ifndef SHA224_FileChunk #define SHA224_FileChunk _libmd_SHA224_FileChunk #endif #ifndef SHA224_Data #define SHA224_Data _libmd_SHA224_Data #endif -#ifndef SHA224_version -#define SHA224_version _libmd_SHA224_version -#endif - void SHA224_Init(SHA224_CTX *); void SHA224_Update(SHA224_CTX *, const void *, size_t); void SHA224_Final(unsigned char [__min_size(SHA224_DIGEST_LENGTH)], SHA224_CTX *); #ifndef _KERNEL char *SHA224_End(SHA224_CTX *, char *); char *SHA224_Data(const void *, unsigned int, char *); char *SHA224_Fd(int, char *); char *SHA224_FdChunk(int, char *, off_t, off_t); char *SHA224_File(const char *, char *); char *SHA224_FileChunk(const char *, char *, off_t, off_t); #endif __END_DECLS #endif /* !_SHA224_H_ */ diff --git a/sys/crypto/sha2/sha256.h b/sys/crypto/sha2/sha256.h index 7bee1002c25c..77237c466bd9 100644 --- a/sys/crypto/sha2/sha256.h +++ b/sys/crypto/sha2/sha256.h @@ -1,94 +1,90 @@ /*- * Copyright 2005 Colin Percival * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #ifndef _SHA256_H_ #define _SHA256_H_ #ifndef _KERNEL #include #endif #define SHA256_BLOCK_LENGTH 64 #define SHA256_DIGEST_LENGTH 32 #define SHA256_DIGEST_STRING_LENGTH (SHA256_DIGEST_LENGTH * 2 + 1) typedef struct SHA256Context { uint32_t state[8]; uint64_t count; uint8_t buf[SHA256_BLOCK_LENGTH]; } SHA256_CTX; __BEGIN_DECLS /* Ensure libmd symbols do not clash with libcrypto */ #ifndef SHA256_Init #define SHA256_Init _libmd_SHA256_Init #endif #ifndef SHA256_Update #define SHA256_Update _libmd_SHA256_Update #endif #ifndef SHA256_Final #define SHA256_Final _libmd_SHA256_Final #endif #ifndef SHA256_End #define SHA256_End _libmd_SHA256_End #endif #ifndef SHA256_Fd #define SHA256_Fd _libmd_SHA256_Fd #endif #ifndef SHA256_FdChunk #define SHA256_FdChunk _libmd_SHA256_FdChunk #endif #ifndef SHA256_File #define SHA256_File _libmd_SHA256_File #endif #ifndef SHA256_FileChunk #define SHA256_FileChunk _libmd_SHA256_FileChunk #endif #ifndef SHA256_Data #define SHA256_Data _libmd_SHA256_Data #endif -#ifndef SHA256_version -#define SHA256_version _libmd_SHA256_version -#endif - void SHA256_Init(SHA256_CTX *); void SHA256_Update(SHA256_CTX *, const void *, size_t); void SHA256_Final(unsigned char [__min_size(SHA256_DIGEST_LENGTH)], SHA256_CTX *); #ifndef _KERNEL char *SHA256_End(SHA256_CTX *, char *); char *SHA256_Data(const void *, unsigned int, char *); char *SHA256_Fd(int, char *); char *SHA256_FdChunk(int, char *, off_t, off_t); char *SHA256_File(const char *, char *); char *SHA256_FileChunk(const char *, char *, off_t, off_t); #endif __END_DECLS #endif /* !_SHA256_H_ */ diff --git a/sys/crypto/sha2/sha384.h b/sys/crypto/sha2/sha384.h index 17d99f6901b7..83ffb8b1ebf1 100644 --- a/sys/crypto/sha2/sha384.h +++ b/sys/crypto/sha2/sha384.h @@ -1,94 +1,90 @@ /*- * Copyright 2005 Colin Percival * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #ifndef _SHA384_H_ #define _SHA384_H_ #ifndef _KERNEL #include #endif #define SHA384_BLOCK_LENGTH 128 #define SHA384_DIGEST_LENGTH 48 #define SHA384_DIGEST_STRING_LENGTH (SHA384_DIGEST_LENGTH * 2 + 1) typedef struct SHA384Context { uint64_t state[8]; uint64_t count[2]; uint8_t buf[SHA384_BLOCK_LENGTH]; } SHA384_CTX; __BEGIN_DECLS /* Ensure libmd symbols do not clash with libcrypto */ #ifndef SHA384_Init #define SHA384_Init _libmd_SHA384_Init #endif #ifndef SHA384_Update #define SHA384_Update _libmd_SHA384_Update #endif #ifndef SHA384_Final #define SHA384_Final _libmd_SHA384_Final #endif #ifndef SHA384_End #define SHA384_End _libmd_SHA384_End #endif #ifndef SHA384_Fd #define SHA384_Fd _libmd_SHA384_Fd #endif #ifndef SHA384_FdChunk #define SHA384_FdChunk _libmd_SHA384_FdChunk #endif #ifndef SHA384_File #define SHA384_File _libmd_SHA384_File #endif #ifndef SHA384_FileChunk #define SHA384_FileChunk _libmd_SHA384_FileChunk #endif #ifndef SHA384_Data #define SHA384_Data _libmd_SHA384_Data #endif -#ifndef SHA384_version -#define SHA384_version _libmd_SHA384_version -#endif - void SHA384_Init(SHA384_CTX *); void SHA384_Update(SHA384_CTX *, const void *, size_t); void SHA384_Final(unsigned char [__min_size(SHA384_DIGEST_LENGTH)], SHA384_CTX *); #ifndef _KERNEL char *SHA384_End(SHA384_CTX *, char *); char *SHA384_Data(const void *, unsigned int, char *); char *SHA384_Fd(int, char *); char *SHA384_FdChunk(int, char *, off_t, off_t); char *SHA384_File(const char *, char *); char *SHA384_FileChunk(const char *, char *, off_t, off_t); #endif __END_DECLS #endif /* !_SHA384_H_ */ diff --git a/sys/crypto/sha2/sha512.h b/sys/crypto/sha2/sha512.h index 4a3e2cadf022..b78fde7dc22f 100644 --- a/sys/crypto/sha2/sha512.h +++ b/sys/crypto/sha2/sha512.h @@ -1,94 +1,90 @@ /*- * Copyright 2005 Colin Percival * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #ifndef _SHA512_H_ #define _SHA512_H_ #ifndef _KERNEL #include #endif #define SHA512_BLOCK_LENGTH 128 #define SHA512_DIGEST_LENGTH 64 #define SHA512_DIGEST_STRING_LENGTH (SHA512_DIGEST_LENGTH * 2 + 1) typedef struct SHA512Context { uint64_t state[8]; uint64_t count[2]; uint8_t buf[SHA512_BLOCK_LENGTH]; } SHA512_CTX; __BEGIN_DECLS /* Ensure libmd symbols do not clash with libcrypto */ #ifndef SHA512_Init #define SHA512_Init _libmd_SHA512_Init #endif #ifndef SHA512_Update #define SHA512_Update _libmd_SHA512_Update #endif #ifndef SHA512_Final #define SHA512_Final _libmd_SHA512_Final #endif #ifndef SHA512_End #define SHA512_End _libmd_SHA512_End #endif #ifndef SHA512_Fd #define SHA512_Fd _libmd_SHA512_Fd #endif #ifndef SHA512_FdChunk #define SHA512_FdChunk _libmd_SHA512_FdChunk #endif #ifndef SHA512_File #define SHA512_File _libmd_SHA512_File #endif #ifndef SHA512_FileChunk #define SHA512_FileChunk _libmd_SHA512_FileChunk #endif #ifndef SHA512_Data #define SHA512_Data _libmd_SHA512_Data #endif -#ifndef SHA512_version -#define SHA512_version _libmd_SHA512_version -#endif - void SHA512_Init(SHA512_CTX *); void SHA512_Update(SHA512_CTX *, const void *, size_t); void SHA512_Final(unsigned char [__min_size(SHA512_DIGEST_LENGTH)], SHA512_CTX *); #ifndef _KERNEL char *SHA512_End(SHA512_CTX *, char *); char *SHA512_Data(const void *, unsigned int, char *); char *SHA512_Fd(int, char *); char *SHA512_FdChunk(int, char *, off_t, off_t); char *SHA512_File(const char *, char *); char *SHA512_FileChunk(const char *, char *, off_t, off_t); #endif __END_DECLS #endif /* !_SHA512_H_ */ diff --git a/sys/crypto/sha2/sha512t.h b/sys/crypto/sha2/sha512t.h index 2274fa2704b9..dc8025e4a74f 100644 --- a/sys/crypto/sha2/sha512t.h +++ b/sys/crypto/sha2/sha512t.h @@ -1,135 +1,127 @@ /*- * Copyright (c) 2015 Allan Jude * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #ifndef _SHA512T_H_ #define _SHA512T_H_ #include "sha512.h" #ifndef _KERNEL #include #endif #define SHA512_224_DIGEST_LENGTH 28 #define SHA512_224_DIGEST_STRING_LENGTH (SHA512_224_DIGEST_LENGTH * 2 + 1) #define SHA512_256_DIGEST_LENGTH 32 #define SHA512_256_DIGEST_STRING_LENGTH (SHA512_256_DIGEST_LENGTH * 2 + 1) __BEGIN_DECLS /* Ensure libmd symbols do not clash with libcrypto */ #ifndef SHA512_224_Init #define SHA512_224_Init _libmd_SHA512_224_Init #endif #ifndef SHA512_224_Update #define SHA512_224_Update _libmd_SHA512_224_Update #endif #ifndef SHA512_224_Final #define SHA512_224_Final _libmd_SHA512_224_Final #endif #ifndef SHA512_224_End #define SHA512_224_End _libmd_SHA512_224_End #endif #ifndef SHA512_224_Fd #define SHA512_224_Fd _libmd_SHA512_224_Fd #endif #ifndef SHA512_224_FdChunk #define SHA512_224_FdChunk _libmd_SHA512_224_FdChunk #endif #ifndef SHA512_224_File #define SHA512_224_File _libmd_SHA512_224_File #endif #ifndef SHA512_224_FileChunk #define SHA512_224_FileChunk _libmd_SHA512_224_FileChunk #endif #ifndef SHA512_224_Data #define SHA512_224_Data _libmd_SHA512_224_Data #endif -#ifndef SHA512_224_version -#define SHA512_224_version _libmd_SHA512_224_version -#endif - #ifndef SHA512_256_Init #define SHA512_256_Init _libmd_SHA512_256_Init #endif #ifndef SHA512_256_Update #define SHA512_256_Update _libmd_SHA512_256_Update #endif #ifndef SHA512_256_Final #define SHA512_256_Final _libmd_SHA512_256_Final #endif #ifndef SHA512_256_End #define SHA512_256_End _libmd_SHA512_256_End #endif #ifndef SHA512_256_Fd #define SHA512_256_Fd _libmd_SHA512_256_Fd #endif #ifndef SHA512_256_FdChunk #define SHA512_256_FdChunk _libmd_SHA512_256_FdChunk #endif #ifndef SHA512_256_File #define SHA512_256_File _libmd_SHA512_256_File #endif #ifndef SHA512_256_FileChunk #define SHA512_256_FileChunk _libmd_SHA512_256_FileChunk #endif #ifndef SHA512_256_Data #define SHA512_256_Data _libmd_SHA512_256_Data #endif -#ifndef SHA512_256_version -#define SHA512_256_version _libmd_SHA512_256_version -#endif - void SHA512_224_Init(SHA512_CTX *); void SHA512_224_Update(SHA512_CTX *, const void *, size_t); void SHA512_224_Final(unsigned char [__min_size(SHA512_224_DIGEST_LENGTH)], SHA512_CTX *); #ifndef _KERNEL char *SHA512_224_End(SHA512_CTX *, char *); char *SHA512_224_Data(const void *, unsigned int, char *); char *SHA512_224_Fd(int, char *); char *SHA512_224_FdChunk(int, char *, off_t, off_t); char *SHA512_224_File(const char *, char *); char *SHA512_224_FileChunk(const char *, char *, off_t, off_t); #endif void SHA512_256_Init(SHA512_CTX *); void SHA512_256_Update(SHA512_CTX *, const void *, size_t); void SHA512_256_Final(unsigned char [__min_size(SHA512_256_DIGEST_LENGTH)], SHA512_CTX *); #ifndef _KERNEL char *SHA512_256_End(SHA512_CTX *, char *); char *SHA512_256_Data(const void *, unsigned int, char *); char *SHA512_256_Fd(int, char *); char *SHA512_256_FdChunk(int, char *, off_t, off_t); char *SHA512_256_File(const char *, char *); char *SHA512_256_FileChunk(const char *, char *, off_t, off_t); #endif __END_DECLS #endif /* !_SHA512T_H_ */