summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorRob Landley2006-02-21 06:44:43 +0000
committerRob Landley2006-02-21 06:44:43 +0000
commit5cf7c2df668d25c41a05670edd08558226f0bfdf (patch)
tree3c3a7b2aa31dd4105f15f435a5894c91c941686e /include
parenta7e3d0520856db27744b4a33e786123d44bf5b2a (diff)
downloadbusybox-5cf7c2df668d25c41a05670edd08558226f0bfdf.zip
busybox-5cf7c2df668d25c41a05670edd08558226f0bfdf.tar.gz
Patch from Devin Bayer to split up hash_fd.c into md5.c and sha1.c. (I tweaked
md5_sha1_sum.c to convert some #ifdef CONFIG to if(ENABLE).)
Diffstat (limited to 'include')
-rw-r--r--include/libbb.h26
-rw-r--r--include/platform.h15
2 files changed, 38 insertions, 3 deletions
diff --git a/include/libbb.h b/include/libbb.h
index 9f0c85b..0ede812 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -464,9 +464,29 @@ extern void vfork_daemon_rexec(int nochdir, int noclose,
extern int get_terminal_width_height(int fd, int *width, int *height);
extern unsigned long get_ug_id(const char *s, long (*__bb_getxxnam)(const char *));
-#define HASH_SHA1 1
-#define HASH_MD5 2
-extern int hash_fd(int fd, const size_t size, const uint8_t hash_algo, uint8_t *hashval);
+typedef struct _sha1_ctx_t_ {
+ uint32_t count[2];
+ uint32_t hash[5];
+ uint32_t wbuf[16];
+} sha1_ctx_t;
+
+void sha1_begin(sha1_ctx_t *ctx);
+void sha1_hash(const void *data, size_t length, sha1_ctx_t *ctx);
+void *sha1_end(void *resbuf, sha1_ctx_t *ctx);
+
+typedef struct _md5_ctx_t_ {
+ uint32_t A;
+ uint32_t B;
+ uint32_t C;
+ uint32_t D;
+ uint32_t total[2];
+ uint32_t buflen;
+ char buffer[128];
+} md5_ctx_t;
+
+void md5_begin(md5_ctx_t *ctx);
+void md5_hash(const void *data, size_t length, md5_ctx_t *ctx);
+void *md5_end(void *resbuf, md5_ctx_t *ctx);
/* busybox.h will include dmalloc later for us, else include it here. */
#if !defined _BB_INTERNAL_H_ && defined DMALLOC
diff --git a/include/platform.h b/include/platform.h
index 68c7abb..b19621a 100644
--- a/include/platform.h
+++ b/include/platform.h
@@ -78,4 +78,19 @@
# endif
#endif
+/* ---- Endian Detection ------------------------------------ */
+#ifndef __APPLE__
+ #include <byteswap.h>
+ #include <endian.h>
+#endif
+
+#ifdef __BIG_ENDIAN__
+ #define BB_BIG_ENDIAN 1
+#elif __BYTE_ORDER == __BIG_ENDIAN
+ #define BB_BIG_ENDIAN 1
+#else
+ #define BB_BIG_ENDIAN 0
+#endif
+
+
#endif /* platform.h */