Compile-time flag for WITH_OPENSSL_SHA1
authoraland <aland>
Thu, 5 Jun 2008 12:07:22 +0000 (12:07 +0000)
committeraland <aland>
Thu, 5 Jun 2008 12:07:22 +0000 (12:07 +0000)
src/include/sha1.h
src/lib/sha1.c

index c3cec0c..a196840 100644 (file)
@@ -1,16 +1,7 @@
 #ifndef _FR_SHA1_H
 #define _FR_SHA1_H
 
-/*
- *  FreeRADIUS defines to ensure globally unique SHA1 function names,
- *  so that we don't pick up vendor-specific broken SHA1 libraries.
- */
-#define fr_SHA1_CTX            fr_SHA1_CTX
-#define fr_SHA1Transform               fr_SHA1Transform
-#define fr_SHA1Init            fr_SHA1Init
-#define fr_SHA1Update          fr_SHA1Update
-#define fr_SHA1Final           fr_SHA1Final
-
+#ifndef WITH_OPENSSL_SHA1
 typedef struct {
     uint32_t state[5];
     uint32_t count[2];
@@ -25,13 +16,28 @@ void fr_SHA1Final(uint8_t digest[20], fr_SHA1_CTX* context);
 /*
  * this version implements a raw SHA1 transform, no length is appended,
  * nor any 128s out to the block size.
+ *
+ *     Hmm... this function doesn't appear to be used anywhere.
  */
-void fr_fr_SHA1FinalNoLen(uint8_t digest[20], fr_SHA1_CTX* context);
+void fr_SHA1FinalNoLen(uint8_t digest[20], fr_SHA1_CTX* context);
+
+#else  /* WITH_OPENSSL_SHA1 */
+
+#include <openssl/sha.h>
+
+#define fr_SHA1_CTX    SHA_CTX
+#define fr_SHA1Init    SHA_Init
+#define fr_SHA1Update  SHA_Update
+#define fr_SHA1Final   SHA_Final
+#define fr_SHA1Transform SHA_Transform
+#endif
 
 /*
  * FIPS 186-2 PRF based upon SHA1.
+ *
+ *     Hmm... this is only used in src/modules/rlm_eap/libeap/
+ *     why is the prototype here?
  */
 extern void fips186_2prf(uint8_t mk[20], uint8_t finalkey[160]);
 
-
 #endif /* _FR_SHA1_H */
index 30dc024..c46ac20 100644 (file)
@@ -14,6 +14,7 @@ RCSID("$Id$")
 
 #include "../include/sha1.h"
 
+#ifndef WITH_OPENSSL_SHA1
 #define blk0(i) (block->l[i] = htonl(block->l[i]))
 
 #define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
@@ -153,7 +154,7 @@ uint8_t finalcount[8];
 #endif
 }
 
-void fr_fr_SHA1FinalNoLen(uint8_t digest[20], fr_SHA1_CTX* context)
+void fr_SHA1FinalNoLen(uint8_t digest[20], fr_SHA1_CTX* context)
 {
   uint32_t i, j;
 
@@ -172,4 +173,4 @@ void fr_fr_SHA1FinalNoLen(uint8_t digest[20], fr_SHA1_CTX* context)
     fr_SHA1Transform(context->state, context->buffer);
 #endif
 }
-
+#endif