Index: src/lib/libmd/Makefile =================================================================== RCS file: /home/ncvs/src/lib/libmd/Makefile,v retrieving revision 1.34 diff -u -I\$FreeBSD -r1.34 Makefile --- src/lib/libmd/Makefile 2000/01/14 07:57:34 1.34 +++ src/lib/libmd/Makefile 2001/03/18 13:55:10 @@ -3,23 +3,30 @@ LIB= md SRCS= md2c.c md4c.c md5c.c md2hl.c md4hl.c md5hl.c \ rmd160c.c rmd160hl.c \ - sha0c.c sha0hl.c sha1c.c sha1hl.c -INCS= md2.h md4.h md5.h ripemd.h sha.h + sha0c.c sha0hl.c sha1c.c sha1hl.c \ + mdhash.c +INCS= mdhash.h md2.h md4.h md5.h ripemd.h sha.h -MAN+= md2.3 md4.3 md5.3 ripemd.3 sha.3 +MAN+= md2.3 md4.3 md5.3 mdhash.3 ripemd.3 sha.3 MLINKS+=md2.3 MD2Init.3 md2.3 MD2Update.3 md2.3 MD2Final.3 -MLINKS+=md2.3 MD2End.3 md2.3 MD2File.3 md2.3 MD2Data.3 +MLINKS+=md2.3 MD2End.3 md2.3 MD2File.3 md2.3 MD2FileChunk.3 +MLINKS+=md2.3 MD2Data.3 MLINKS+=md4.3 MD4Init.3 md4.3 MD4Update.3 md4.3 MD4Final.3 -MLINKS+=md4.3 MD4End.3 md4.3 MD4File.3 md4.3 MD4Data.3 +MLINKS+=md4.3 MD4End.3 md4.3 MD4File.3 md4.3 MD4FileChunk.3 +MLINKS+=md4.3 MD4Data.3 MLINKS+=md5.3 MD5Init.3 md5.3 MD5Update.3 md5.3 MD5Final.3 -MLINKS+=md5.3 MD5End.3 md5.3 MD5File.3 md5.3 MD5Data.3 +MLINKS+=md5.3 MD5End.3 md5.3 MD5File.3 md5.3 MD5FileChunk.3 +MLINKS+=md5.3 MD5Data.3 MLINKS+=ripemd.3 RIPEMD160_Init.3 ripemd.3 RIPEMD160_Update.3 MLINKS+=ripemd.3 RIPEMD160_Final.3 ripemd.3 RIPEMD160_Data.3 MLINKS+=ripemd.3 RIPEMD160_End.3 ripemd.3 RIPEMD160_File.3 +MLINKS+=ripemd.3 RIPEMD160_FileChunk.3 MLINKS+=sha.3 SHA_Init.3 sha.3 SHA_Update.3 sha.3 SHA_Final.3 -MLINKS+=sha.3 SHA_End.3 sha.3 SHA_File.3 sha.3 SHA_Data.3 +MLINKS+=sha.3 SHA_End.3 sha.3 SHA_File.3 sha.3 SHA_FileChunk.3 +MLINKS+=sha.3 SHA_Data.3 MLINKS+=sha.3 SHA1_Init.3 sha.3 SHA1_Update.3 sha.3 SHA1_Final.3 -MLINKS+=sha.3 SHA1_End.3 sha.3 SHA1_File.3 sha.3 SHA1_Data.3 +MLINKS+=sha.3 SHA1_End.3 sha.3 SHA1_File.3 sha.3 SHA1_FileChunk.3 +MLINKS+=sha.3 SHA1_Data.3 CLEANFILES+= md[245]hl.c md[245].ref md[245].3 mddriver \ rmd160.ref rmd160hl.c rmddriver \ sha0.ref sha0hl.c sha1.ref sha1hl.c shadriver Index: src/lib/libmd/md2.h =================================================================== RCS file: /home/ncvs/src/lib/libmd/md2.h,v retrieving revision 1.8 retrieving revision 1.9 diff -u -I\$FreeBSD -r1.8 -r1.9 --- src/lib/libmd/md2.h 1999/08/28 00:05:04 1.8 +++ src/lib/libmd/md2.h 2001/03/17 10:00:50 1.9 @@ -39,6 +39,7 @@ void MD2Final(unsigned char [16], MD2_CTX *); char * MD2End(MD2_CTX *, char *); char * MD2File(const char *, char *); +char * MD2FileChunk(const char *, char *, off_t, off_t); char * MD2Data(const unsigned char *, unsigned int, char *); __END_DECLS Index: src/lib/libmd/md2c.c =================================================================== RCS file: /home/ncvs/src/lib/libmd/md2c.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -I\$FreeBSD -r1.7 -r1.8 --- src/lib/libmd/md2c.c 1999/08/28 00:05:05 1.7 +++ src/lib/libmd/md2c.c 2001/03/17 10:00:50 1.8 @@ -20,9 +20,9 @@ documentation and/or software. */ -#include "md2.h" -#include #include +#include +#include "md2.h" typedef unsigned char *POINTER; Index: src/lib/libmd/md4.h =================================================================== RCS file: /home/ncvs/src/lib/libmd/md4.h,v retrieving revision 1.9 retrieving revision 1.10 diff -u -I\$FreeBSD -r1.9 -r1.10 --- src/lib/libmd/md4.h 1999/08/28 00:05:05 1.9 +++ src/lib/libmd/md4.h 2001/03/17 10:00:50 1.10 @@ -41,6 +41,7 @@ void MD4Final(unsigned char [16], MD4_CTX *); char * MD4End(MD4_CTX *, char *); char * MD4File(const char *, char *); +char * MD4FileChunk(const char *, char *, off_t, off_t); char * MD4Data(const unsigned char *, unsigned int, char *); __END_DECLS Index: src/lib/libmd/mdX.3 =================================================================== RCS file: /home/ncvs/src/lib/libmd/mdX.3,v retrieving revision 1.16.2.2 diff -u -I\$FreeBSD -r1.16.2.2 mdX.3 --- src/lib/libmd/mdX.3 2000/12/14 12:10:04 1.16.2.2 +++ src/lib/libmd/mdX.3 2001/03/18 13:55:10 @@ -18,6 +18,7 @@ .Nm MDXFinal , .Nm MDXEnd , .Nm MDXFile , +.Nm MDXFileChunk , .Nm MDXData .Nd calculate the RSA Data Security, Inc., ``MDX'' message digest .Sh LIBRARY @@ -38,6 +39,8 @@ .Ft "char *" .Fn MDXFile "const char *filename" "char *buf" .Ft "char *" +.Fn MDXFileChunk "const char *filename" "char *buf" "off_t offset" "off_t length" +.Ft "char *" .Fn MDXData "const unsigned char *data" "unsigned int len" "char *buf" .Sh DESCRIPTION The MDX functions calculate a 128-bit cryptographic checksum (digest) @@ -88,6 +91,23 @@ .Fn MDXEnd to return the result. If the file cannot be opened, a null pointer is returned. +.Fn MDXFileChunk +is similar to +.Fn MDXFile , +but it only calculates the digest over a byte-range of the file specified, +starting at +.Ar offset +and spanning +.Ar length +bytes. +If the +.Ar length +parameter is specified as 0, or more than the length of the remaining part +of the file, +.Fn MDXFileChunk +calculates the digest from +.Ar offset +to the end of file. .Fn MDXData calculates the digest of a chunk of data in memory, and uses .Fn MDXEnd @@ -113,6 +133,8 @@ .Xr md2 3 , .Xr md4 3 , .Xr md5 3 , +.Xr mdhash 3 , +.Xr ripemd 3 , .Xr sha 3 .Rs .%A B. Kaliski @@ -158,7 +180,11 @@ Phk ristede runen. .Sh HISTORY These functions appeared in -.Fx 2.0 . +.Fx 2.0 , +except for +.Fn MDXFileChunk , +which appeared in +.Fx 5.0 . .Sh BUGS No method is known to exist which finds two files having the same hash value, nor to find a file with a specific hash value. Index: src/lib/libmd/mdXhl.c =================================================================== RCS file: /home/ncvs/src/lib/libmd/mdXhl.c,v retrieving revision 1.13 retrieving revision 1.14 diff -u -I\$FreeBSD -r1.13 -r1.14 --- src/lib/libmd/mdXhl.c 1999/08/28 00:05:07 1.13 +++ src/lib/libmd/mdXhl.c 2001/03/17 10:00:50 1.14 @@ -11,6 +11,7 @@ */ #include +#include #include #include @@ -43,19 +44,40 @@ char * MDXFile(const char *filename, char *buf) { + return MDXFileChunk(filename, buf, 0, 0); +} + +char * +MDXFileChunk(const char *filename, char *buf, off_t ofs, off_t len) +{ unsigned char buffer[BUFSIZ]; MDX_CTX ctx; - int f,i,j; + struct stat stbuf; + int f, i, e; + off_t n; MDXInit(&ctx); - f = open(filename,O_RDONLY); + f = open(filename, O_RDONLY); if (f < 0) return 0; - while ((i = read(f,buffer,sizeof buffer)) > 0) { - MDXUpdate(&ctx,buffer,i); - } - j = errno; + if (fstat(f, &stbuf) < 0) return 0; + if (ofs > stbuf.st_size) + ofs = stbuf.st_size; + if ((len == 0) || (len > stbuf.st_size - ofs)) + len = stbuf.st_size - ofs; + if (lseek(f, ofs, SEEK_SET) < 0) return 0; + n = len; + while (n > 0) { + if (n > sizeof(buffer)) + i = read(f, buffer, sizeof(buffer)); + else + i = read(f, buffer, n); + if (i < 0) break; + MDXUpdate(&ctx, buffer, i); + n -= i; + } + e = errno; close(f); - errno = j; + errno = e; if (i < 0) return 0; return MDXEnd(&ctx, buf); } Index: src/lib/libmd/mdhash.3 =================================================================== RCS file: mdhash.3 diff -N mdhash.3 --- /dev/null Sun Mar 18 05:50:21 2001 +++ src/lib/libmd/mdhash.3 Sun Mar 18 05:55:13 2001 @@ -0,0 +1,118 @@ +.\" +.\" ---------------------------------------------------------------------------- +.\" Some kind of license.. +.\" ---------------------------------------------------------------------------- +.\" +.\" $FreeBSD$ +.\" +.Dd March 18, 2001 +.Dt mdhash 3 +.Os FreeBSD +.Sh NAME +.Nm HashInit , +.Nm HashUpdate , +.Nm HashPad , +.Nm HashFinal , +.Nm HashEnd , +.Nm HashFile , +.Nm HashFileChunk , +.Nm HashData +.Nd wrapper functions for various hash algorithms +.Sh LIBRARY +.Lb libmd +.Sh SYNOPSIS +.Fd #include +.Fd #include +.Ft int +.Fn HashAlgByName "const char *algname" +.Ft void +.Fn HashInit "int alg" "HASH_CTX *context" +.Ft void +.Fn HashUpdate "int alg" "HASH_CTX *context" "const unsigned char *data" "unsigned int len" +.Ft void +.Fn HashPad "int alg" "HASH_CTX *context" +.Ft void +.Fn HashFinal "int alg" "unsigned char digest[16]" "HASH_CTX *context" +.Ft "char *" +.Fn HashEnd "int alg" "HASH_CTX *context" "char *buf" +.Ft "char *" +.Fn HashFile "int alg" "const char *filename" "char *buf" +.Ft "char *" +.Fn HashFileChunk "int alg" "const char *filename" "char *buf" "off_t offset" "off_t length" +.Ft "char *" +.Fn HashData "int alg" "const unsigned char *data" "unsigned int len" "char *buf" +.Sh DESCRIPTION +The +.Nm +functions serve as algorithm-independent wrappers for the various +cryptographic checksum (digest) calculation functions in the +.Lb libmd . +A cryptographic checksum is a one-way hash-function, that is, you cannot find +(except by exhaustive search) the input corresponding to a particular output. +This net result is a ``fingerprint'' of the input-data, which doesn't disclose +the actual input. +.Pp +The +.Fn HashAlgByName +takes an algorithm name as an argument, and returns an integer constant, +which is subsequently passed as the +.Ar alg +argument to the other +.Nm +functions. +The currently recognized (case-insensitive) algorithm names are: +.Bd -literal -offset indent -compact +md2 the RSA Corp. Message Digest 2 algorithm +md4 the RSA Corp. Message Digest 4 algorithm +md5 the RSA Corp. Message Digest 5 algorithm +sha the original FIPS-160 Secure Hash Algorithm +sha1 (XXX some description here) +ripemd the RIPEMD160 algorithm (XXX more description?) +.Ed +.Pp +The +.Fn HashInit , +.Fn HashUpdate , +.Fn HashFinal , +.Fn HashPad , +.Fn HashEnd , +.Fn HashFile , +.Fn HashFileChunk +and +.Fn HashData +function are the exact equivalents to the corresponding functions described +in the different algorithms' manpages. +.Sh RETURN VALUES +The +.Fn HashAlgByName +function returns a small non-negative integer, if +.Ar algname +is a recognized algorithm, and -1 on error. +The +.Fn HashInit , +.Fn HashUpdate , +.Fn HashFinal , +.Fn HashPad , +.Fn HashEnd , +.Fn HashFile , +.Fn HashFileChunk +and +.Fn HashData +functions have the same return types/values as the corresponding functions +described in the different algorithms' manpages. +.Sh SEE ALSO +.Xr md2 3 , +.Xr md4 3 , +.Xr md5 3 , +.Xr ripemd 3 , +.Xr sha 3 +.Sh HISTORY +These functions appeared in +.Fx 5.0 . +.Sh BUGS +No method is known to exist which finds two files having the same hash value, +nor to find a file with a specific hash value. +There is on the other hand no guarantee that such a method doesn't exist. +.Pp +MD2 has only been licensed for use in Privacy Enhanced Mail. +Use MD4 or MD5 if that isn't what you're doing. Index: src/lib/libmd/mdhash.c =================================================================== RCS file: mdhash.c diff -N mdhash.c --- /dev/null Sun Mar 18 05:50:21 2001 +++ src/lib/libmd/mdhash.c Sun Mar 18 05:55:13 2001 @@ -0,0 +1,158 @@ +/* mdhash.c + * Some kind of license.. + * + * $FreeBSD$ + * + */ + +#include + +#include +#include + +#include "mdhash.h" + +typedef void (*initfun)(void *); +typedef void (*updatefun)(void *, const unsigned char *, unsigned int); +typedef void (*padfun)(void *); +typedef void (*finalfun)(unsigned char [], void *); +typedef char * (*endfun)(void *, char *); + +typedef char * (*chunkfun)(const char *, char *, off_t, off_t); +typedef char * (*datafun)(const unsigned char *, unsigned int, char *); + +struct algdata { + const char *name; + + initfun init; + updatefun update; + padfun pad; + finalfun final; + endfun end; + + chunkfun chunk; + datafun data; +}; + +#define ALGDEF(name, pfx) { \ + name, \ + (initfun) pfx##Init, \ + (updatefun) pfx##Update, \ + (padfun) pfx##Pad, \ + (finalfun) pfx##Final, \ + (endfun) pfx##End, \ + (chunkfun) pfx##FileChunk, \ + (datafun) pfx##Data \ +} +#define ALGDEF_NOPAD(name, pfx) { \ + name, \ + (initfun) pfx##Init, \ + (updatefun) pfx##Update, \ + NULL, \ + (finalfun) pfx##Final, \ + (endfun) pfx##End, \ + (chunkfun) pfx##FileChunk, \ + (datafun) pfx##Data \ +} + +static struct algdata algorithms[] = { + ALGDEF("md2", MD2), + ALGDEF("md4", MD4), + ALGDEF("md5", MD5), + ALGDEF_NOPAD("sha", SHA_), + ALGDEF_NOPAD("sha1", SHA1_), + ALGDEF_NOPAD("ripemd", RIPEMD160_), + {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL} +}; + +int +HashAlgByName(const char *alg) { + int i; + + for (i = 0; algorithms[i].name; i++) + if (!strcasecmp(alg, algorithms[i].name)) + break; + if (algorithms[i].name == NULL) { + errno = EINVAL; + return (-1); + } + return (i); +} + +void +HashInit(int alg, HASH_CTX *ctx) { + struct algdata *ad; + + if ((alg < 0) || (alg >= HASH_INVALID)) { + errno = EINVAL; + return; + } + ad = &algorithms[alg]; + if (ad->init == NULL) + return; + ad->init(ctx); +} + +void +HashUpdate(int alg, HASH_CTX *ctx, const unsigned char *data, + unsigned int len) { + struct algdata *ad; + + if ((alg < 0) || (alg >= HASH_INVALID)) { + errno = EINVAL; + return; + } + ad = &algorithms[alg]; + if (ad->update == NULL) + return; + ad->update(ctx, data, len); +} + +char * +HashEnd(int alg, HASH_CTX *ctx, char *buf) { + struct algdata *ad; + + if ((alg < 0) || (alg >= HASH_INVALID)) { + errno = EINVAL; + return; + } + ad = &algorithms[alg]; + if (ad->end == NULL) + return (NULL); + return (ad->end(ctx, buf)); +} + +char * +HashFile(int alg, const char *filename, char *buf) { + return (HashFileChunk(alg, filename, buf, 0, 0)); +} + +char * +HashFileChunk(int alg, const char *filename, char *buf, + off_t offset, off_t length) { + struct algdata *ad; + + if ((alg < 0) || (alg >= HASH_INVALID)) { + errno = EINVAL; + return; + } + ad = &algorithms[alg]; + if (ad->chunk == NULL) + return (NULL); + return (ad->chunk(filename, buf, offset, length)); +} + +char * +HashData(int alg, const unsigned char *data, unsigned int len, + char *buf) { + struct algdata *ad; + + if ((alg < 0) || (alg >= HASH_INVALID)) { + errno = EINVAL; + return; + } + ad = &algorithms[alg]; + if (ad->data == NULL) + return (NULL); + return (ad->data(data, len, buf)); +} Index: src/lib/libmd/mdhash.h =================================================================== RCS file: mdhash.h diff -N mdhash.h --- /dev/null Sun Mar 18 05:50:21 2001 +++ src/lib/libmd/mdhash.h Sun Mar 18 05:55:13 2001 @@ -0,0 +1,41 @@ +#ifndef _MDHASH_H +#define _MDHASH_H + +/* Some kind of license should be slapped on here.. */ +/* $FreeBSD$ */ + +#include +#include +#include +#include +#include + +typedef union { + MD2_CTX md2; + MD4_CTX md4; + MD5_CTX md5; + RIPEMD160_CTX ripemd; + SHA_CTX sha; + SHA1_CTX sha1; +} HASH_CTX; + +enum { + HASH_MD2, HASH_MD4, HASH_MD5, + HASH_RIPEMD160, HASH_SHA, HASH_SHA1, + HASH_INVALID +}; + +int HashAlgByName(const char *); + +void HashInit(int, HASH_CTX *); +void HashUpdate(int, HASH_CTX *, const unsigned char *, + unsigned int); +void HashPad(int, HASH_CTX *); +void HashFinal(int, unsigned char [], HASH_CTX *); +char * HashEnd(int, HASH_CTX *, char *); + +char * HashFile(int, const char *, char *); +char * HashFileChunk(int, const char *, char *, off_t, off_t); +char * HashData(int, const unsigned char *, unsigned int, char *); + +#endif /* _MDHASH_H */ Index: src/lib/libmd/ripemd.3 =================================================================== RCS file: /home/ncvs/src/lib/libmd/ripemd.3,v retrieving revision 1.2.2.2 diff -u -I\$FreeBSD -r1.2.2.2 ripemd.3 --- src/lib/libmd/ripemd.3 2000/12/14 12:10:04 1.2.2.2 +++ src/lib/libmd/ripemd.3 2001/03/18 13:55:21 @@ -18,6 +18,7 @@ .Nm RIPEMD160_Final , .Nm RIPEMD160_End , .Nm RIPEMD160_File , +.Nm RIPEMD160_FileChunk , .Nm RIPEMD160_Data .Nd calculate the RIPEMD160 message digest .Sh LIBRARY @@ -36,6 +37,8 @@ .Ft "char *" .Fn RIPEMD160_File "const char *filename" "char *buf" .Ft "char *" +.Fn RIPEMD160_FileChunk "const char *filename" "char *buf" "off_t offset" "off_t length" +.Ft "char *" .Fn RIPEMD160_Data "const unsigned char *data" "unsigned int len" "char *buf" .Sh DESCRIPTION The @@ -72,6 +75,23 @@ .Fn RIPEMD160_End to return the result. If the file cannot be opened, a null pointer is returned. +.Fn RIPEMD160_FileChunk +is similar to +.Fn RIPEMD160_File , +but it only calculates the digest over a byte-range of the file specified, +starting at +.Ar offset +and spanning +.Ar length +bytes. +If the +.Ar length +parameter is specified as 0, or more than the length of the remaining part +of the file, +.Fn RIPEMD160_FileChunk +calculates the digest from +.Ar offset +to the end of file. .Fn RIPEMD160_Data calculates the digest of a chunk of data in memory, and uses .Fn RIPEMD160_End @@ -97,6 +117,7 @@ .Xr md2 3 , .Xr md4 3 , .Xr md5 3 , +.Xr mdhash 3 , .Xr sha 3 .Sh AUTHORS The core hash routines were implemented by Eric Young based on the @@ -105,7 +126,11 @@ specification. .Sh HISTORY These functions appeared in -.Fx 4.0 . +.Fx 4.0 , +except for +.Fn RIPEMD160_FileChunk , +which appeared in +.Fx 5.0 . .Sh BUGS No method is known to exist which finds two files having the same hash value, nor to find a file with a specific hash value. Index: src/lib/libmd/ripemd.h =================================================================== RCS file: /home/ncvs/src/lib/libmd/ripemd.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -I\$FreeBSD -r1.1 -r1.2 --- src/lib/libmd/ripemd.h 1999/02/26 18:41:45 1.1 +++ src/lib/libmd/ripemd.h 2001/03/17 10:00:50 1.2 @@ -83,6 +87,7 @@ void RIPEMD160_Final(unsigned char *md, RIPEMD160_CTX *c); char *RIPEMD160_End(RIPEMD160_CTX *, char *); char *RIPEMD160_File(const char *, char *); +char *RIPEMD160_FileChunk(const char *, char *, off_t, off_t); char *RIPEMD160_Data(const unsigned char *, unsigned int, char *); __END_DECLS Index: src/lib/libmd/sha.3 =================================================================== RCS file: /home/ncvs/src/lib/libmd/sha.3,v retrieving revision 1.4.2.2 diff -u -I\$FreeBSD -r1.4.2.2 sha.3 --- src/lib/libmd/sha.3 2000/12/14 12:10:04 1.4.2.2 +++ src/lib/libmd/sha.3 2001/03/18 13:55:21 @@ -18,12 +18,14 @@ .Nm SHA_Final , .Nm SHA_End , .Nm SHA_File , +.Nm SHA_FileChunk , .Nm SHA_Data , .Nm SHA1_Init , .Nm SHA1_Update , .Nm SHA1_Final , .Nm SHA1_End , .Nm SHA1_File , +.Nm SHA1_FileChunk , .Nm SHA1_Data .Nd calculate the FIPS 160 and 160-1 ``SHA'' message digests .Sh LIBRARY @@ -42,6 +44,8 @@ .Ft "char *" .Fn SHA_File "const char *filename" "char *buf" .Ft "char *" +.Fn SHA_FileChunk "const char *filename" "char *buf" "off_t offset" "off_t length" +.Ft "char *" .Fn SHA_Data "const unsigned char *data" "unsigned int len" "char *buf" .Ft void .Fn SHA1_Init "SHA_CTX *context" @@ -54,6 +58,8 @@ .Ft "char *" .Fn SHA1_File "const char *filename" "char *buf" .Ft "char *" +.Fn SHA1_FileChunk "const char *filename" "char *buf" "off_t offset" "off_t length" +.Ft "char *" .Fn SHA1_Data "const unsigned char *data" "unsigned int len" "char *buf" .Sh DESCRIPTION The @@ -101,6 +107,23 @@ .Fn SHA1_End to return the result. If the file cannot be opened, a null pointer is returned. +.Fn SHA1_FileChunk +is similar to +.Fn SHA1_File , +but it only calculates the digest over a byte-range of the file specified, +starting at +.Ar offset +and spanning +.Ar length +bytes. +If the +.Ar length +parameter is specified as 0, or more than the length of the remaining part +of the file, +.Fn SHA1_FileChunk +calculates the digest from +.Ar offset +to the end of file. .Fn SHA1_Data calculates the digest of a chunk of data in memory, and uses .Fn SHA1_End @@ -126,6 +149,7 @@ .Xr md2 3 , .Xr md4 3 , .Xr md5 3 , +.Xr mdhash 3 , .Xr ripemd 3 .Sh AUTHORS The core hash routines were implemented by Eric Young based on the @@ -134,7 +158,13 @@ standards. .Sh HISTORY These functions appeared in -.Fx 4.0 . +.Fx 4.0 , +except for +.Fn SHA_FileChunk +and +.Fn SHA1_FileChunk , +which appeared in +.Fx 5.0 . .Sh BUGS No method is known to exist which finds two files having the same hash value, nor to find a file with a specific hash value. Index: src/lib/libmd/sha.h =================================================================== RCS file: /home/ncvs/src/lib/libmd/sha.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -I\$FreeBSD -r1.3 -r1.4 --- src/lib/libmd/sha.h 1999/08/28 00:05:08 1.3 +++ src/lib/libmd/sha.h 2001/03/17 10:00:50 1.4 @@ -84,12 +84,14 @@ void SHA_Final(unsigned char *md, SHA_CTX *c); char *SHA_End(SHA_CTX *, char *); char *SHA_File(const char *, char *); +char *SHA_FileChunk(const char *, char *, off_t, off_t); char *SHA_Data(const unsigned char *, unsigned int, char *); void SHA1_Init(SHA_CTX *c); void SHA1_Update(SHA_CTX *c, const unsigned char *data, size_t len); void SHA1_Final(unsigned char *md, SHA_CTX *c); char *SHA1_End(SHA_CTX *, char *); char *SHA1_File(const char *, char *); +char *SHA1_FileChunk(const char *, char *, off_t, off_t); char *SHA1_Data(const unsigned char *, unsigned int, char *); __END_DECLS Index: src/sys/sys/md5.h =================================================================== RCS file: /home/ncvs/src/sys/sys/md5.h,v retrieving revision 1.13 diff -u -r1.13 md5.h --- src/sys/sys/md5.h 1999/12/29 04:24:44 1.13 +++ src/sys/sys/md5.h 2001/03/30 07:59:11 @@ -42,6 +42,7 @@ void MD5Final (unsigned char [16], MD5_CTX *); char * MD5End(MD5_CTX *, char *); char * MD5File(const char *, char *); +char * MD5FileChunk(const char *, char *, off_t, off_t); char * MD5Data(const unsigned char *, unsigned int, char *); #ifdef _KERNEL void MD5Transform __P((u_int32_t [4], const unsigned char [64]));