Changeset 12502
- Timestamp:
- Mar 19, 2007, 3:13:54 PM (19 years ago)
- Location:
- trunk/psLib
- Files:
-
- 2 added
- 3 edited
-
configure.ac (modified) (2 diffs)
-
src/math/Makefile.am (modified) (2 diffs)
-
src/math/md5.c (added)
-
src/math/md5.h (added)
-
src/math/psMD5.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/configure.ac
r12498 r12502 84 84 dnl check the systems endianness 85 85 AC_C_BIGENDIAN 86 87 dnl set NO_STRCASESTR if we can't find strcasestr 88 AC_CHECK_FUNC([strcasestr], [], [AC_SUBST(NO_STRCASESTR, [1])]) 86 89 87 90 AC_PREFIX_DEFAULT([/usr/local]) … … 409 412 LDFLAGS=${TMP_LDFLAGS} 410 413 CPPFLAGS=${TMP_CPPFLAGS} 411 412 dnl ------- openssl ---------413 414 dnl save LIBS/CFLAGS/LDFLAGS415 TMP_LIBS=${LIBS}416 TMP_CFLAGS=${CFLAGS}417 TMP_LDFLAGS=${LDFLAGS}418 TMP_CPPFLAGS=${CPPFLAGS}419 420 AC_ARG_WITH(ssl,421 [AS_HELP_STRING(--with-ssl=DIR,Specify location of SSL.)],422 [SSL_CFLAGS="-I$withval/include"423 SSL_LDFLAGS="-L$withval/lib"])424 AC_ARG_WITH(ssl-include,425 [AS_HELP_STRING(--with-ssl-include=DIR,Specify SSL include directory.)],426 [SSL_CFLAGS="-I$withval"])427 AC_ARG_WITH(ssl-lib,428 [AS_HELP_STRING(--with-ssl-lib=DIR,Specify SSL library directory.)],429 [SSL_LDFLAGS="-L$withval"])430 431 CFLAGS="${CFLAGS} ${SSL_CFLAGS}"432 CPPFLAGS=${CFLAGS}433 LDFLAGS="${LDFLAGS} ${SSL_LIBS}"434 435 AC_CHECK_HEADERS([openssl/md5.h],[],436 [AC_CHECK_HEADERS([sys/md5.h],[],437 [AC_MSG_ERROR([SSL headers not found. Obtain it at http://www.openssl.org/ or use --with-ssl to specify location.])]438 )]439 )440 AC_CHECK_LIB(crypto,MD5,[],441 [AC_MSG_ERROR([SSL library not found. Obtain it at http://www.openssl.org/ or use --with-ssl to specify location.])]442 )443 444 PSLIB_CFLAGS="${PSLIB_CFLAGS=} ${SSL_CFLAGS}"445 PSLIB_LIBS="${PSLIB_LIBS=} ${SSL_LDFLAGS=} ${LIBS}"446 447 AC_SUBST([SSL_CFLAGS])448 AC_SUBST([SSL_LDFLAGS])449 450 dnl restore the CFLAGS/LDFLAGS451 LIBS=${TMP_LIBS}452 CFLAGS=${TMP_CFLAGS}453 LDFLAGS=${TMP_LDFLAGS}454 CPPFLAGS=${TMP_CPPFLAGS}455 456 dnl set NO_STRCASESTR if we can't find strcasestr457 AC_CHECK_FUNC([strcasestr], [], [AC_SUBST(NO_STRCASESTR, [1])])458 414 459 415 dnl ------- enable -Werror after all of the probes have run --------- -
trunk/psLib/src/math/Makefile.am
r11669 r12502 26 26 psStats.c \ 27 27 psHistogram.c \ 28 psVectorSmooth.c 28 psVectorSmooth.c \ 29 md5.c 29 30 30 31 EXTRA_DIST = math.i … … 55 56 psVectorSmooth.h 56 57 58 noinst_HEADERS = \ 59 md5.h 60 57 61 CLEANFILES = *~ *.bb *.bbg *.da -
trunk/psLib/src/math/psMD5.c
r12430 r12502 6 6 #include <string.h> 7 7 8 #ifdef HAVE_SYS_MD5_H 9 // Seems to be the case for Solaris 10 #include <sys/md5.h> 11 #else 12 // Seems to be the case for most others 13 #include <openssl/md5.h> 14 #endif // HAVE_SYS_MD5_H 15 8 #include "md5.h" 16 9 17 10 #include "psAssert.h" … … 24 17 25 18 19 #define MD5_DIGEST_LENGTH 16 // Length of an MD5 digest, in bytes 20 26 21 psVector *psStringMD5(const char *string) 27 22 { 28 23 psVector *hash = psVectorAlloc(MD5_DIGEST_LENGTH, PS_TYPE_U8); // The resultant MD5 hash 29 if (!MD5((const unsigned char *)string, strlen(string), &hash->data.U8[0])) { 30 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to generate md5 hash.\n"); 31 psFree(hash); 32 return NULL; 33 } 24 md5_state_t buffer; // Calculation buffer 25 md5_init(&buffer); 26 md5_append(&buffer, (psU8*)string, strlen(string)); 27 md5_finish(&buffer, &hash->data.U8[0]); 34 28 return hash; 35 29 } … … 40 34 41 35 psVector *hash = psVectorAlloc(MD5_DIGEST_LENGTH, PS_TYPE_U8); // The resultant MD5 hash 42 if (!MD5(vector->data.U8, vector->n * PSELEMTYPE_SIZEOF(vector->type.type), &hash->data.U8[0])) { 43 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to generate md5 hash.\n"); 44 psFree(hash); 45 return NULL; 46 } 36 md5_state_t buffer; // Calculation buffer 37 md5_init(&buffer); 38 md5_append(&buffer, vector->data.U8, vector->n * PSELEMTYPE_SIZEOF(vector->type.type)); 39 md5_finish(&buffer, &hash->data.U8[0]); 47 40 return hash; 48 41 } … … 54 47 55 48 psVector *hash = psVectorAlloc(MD5_DIGEST_LENGTH, PS_TYPE_U8); // The resultant MD5 hash 49 md5_state_t buffer; // Calculation buffer 50 md5_init(&buffer); 56 51 if (!image->parent) { 57 52 // No parent means image is contiguous 58 if (!MD5(&image->data.U8[0][0], image->numCols * image->numRows * PSELEMTYPE_SIZEOF(image->type.type), 59 &hash->data.U8[0])) { 60 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to generate md5 hash.\n"); 61 psFree(hash); 62 return NULL; 53 md5_append(&buffer, image->data.U8[0], 54 image->numCols * image->numRows * PSELEMTYPE_SIZEOF(image->type.type)); 55 } else { 56 for (int row = 0; row < image->numRows; row++) { 57 md5_append(&buffer, image->data.U8[row], 58 image->numCols * PSELEMTYPE_SIZEOF(image->type.type)); 63 59 } 64 } else {65 MD5_CTX ctx; // MD5 calculator66 MD5_Init(&ctx);67 for (int row = 0; row < image->numRows; row++) {68 MD5_Update(&ctx, image->data.U8[row], image->numCols * PSELEMTYPE_SIZEOF(image->type.type));69 }70 MD5_Final(&hash->data.U8[0], &ctx);71 60 } 61 md5_finish(&buffer, &hash->data.U8[0]); 72 62 73 63 return hash;
Note:
See TracChangeset
for help on using the changeset viewer.
