Browse files

Whirlpool: renamed functions and structs

  • Loading branch information...
1 parent 6fe2a7e commit e8654c70b9f795f7148a76a29bb7406cdb14f9bc Stijn van Drongelen committed Aug 11, 2012
Showing with 43 additions and 51 deletions.
  1. +6 −6 cbits/whirlpool.c
  2. +37 −5 cbits/whirlpool.h
  3. +0 −40 cbits/whirlpool_nessie.h
View
12 cbits/whirlpool.c
@@ -62,7 +62,7 @@
#include <string.h>
#include "bitfn.h"
-#include "whirlpool_nessie.h"
+#include "whirlpool.h"
/* #define TRACE_INTERMEDIATE_VALUES */
@@ -721,7 +721,7 @@ static void inplaceXor(uint64_t dst[8], uint64_t src[8]) {
/**
* The core Whirlpool transform.
*/
-static void processBuffer(struct NESSIEstruct * const structpointer) {
+static void processBuffer(whirlpool_ctx * const structpointer) {
int i, r;
uint64_t K[8]; /* the round key */
uint64_t block[8]; /* mu(buffer) */
@@ -777,7 +777,7 @@ static void processBuffer(struct NESSIEstruct * const structpointer) {
/**
* Initialize the hashing state.
*/
-void NESSIEinit(struct NESSIEstruct * const structpointer) {
+void whirlpool_init(struct whirlpool_ctx * const structpointer) {
int i;
memset(structpointer->bitLength, 0, 32);
@@ -796,9 +796,9 @@ void NESSIEinit(struct NESSIEstruct * const structpointer) {
*
* This method maintains the invariant: bufferBits < DIGESTBITS
*/
-void NESSIEadd(const unsigned char * const source,
+void whirlpool_add(const unsigned char * const source,
unsigned long sourceBits,
- struct NESSIEstruct * const structpointer) {
+ struct whirlpool_ctx * const structpointer) {
/*
sourcePos
|
@@ -914,7 +914,7 @@ void NESSIEadd(const unsigned char * const source,
*
* This method uses the invariant: bufferBits < DIGESTBITS
*/
-void NESSIEfinalize(struct NESSIEstruct * const structpointer,
+void whirlpool_finalize(struct whirlpool_ctx * const structpointer,
unsigned char * const result) {
int i;
uint8_t *buffer = structpointer->buffer;
View
42 cbits/whirlpool.h
@@ -1,13 +1,45 @@
#ifndef CRYPTOHASH_WHIRLPOOL_H
#define CRYPTOHASH_WHIRLPOOL_H
-#include "whirlpool_nessie.h"
+#ifdef _MSC_VER
+typedef signed char int8_t;
+typedef unsigned char uint8_t;
+typedef __int32 int32_t;
+typedef unsigned __int32 uint32_t;
+typedef __int64 int64_t;
+typedef unsigned __int64 uint64_t;
+#define LL(v) (v##i64)
+#else
+#include <stdint.h>
+#define LL(v) (v##ULL)
+#endif
+
+/*
+ * Whirlpool-specific definitions.
+ */
+
+#define DIGESTBYTES 64
+#define DIGESTBITS (8*DIGESTBYTES) /* 512 */
+
+#define WBLOCKBYTES 64
+#define WBLOCKBITS (8*WBLOCKBYTES) /* 512 */
+
+#define LENGTHBYTES 32
+#define LENGTHBITS (8*LENGTHBYTES) /* 256 */
+
+typedef struct whirlpool_ctx {
+ uint8_t bitLength[LENGTHBYTES]; /* global number of hashed bits (256-bit counter) */
+ uint8_t buffer[WBLOCKBYTES]; /* buffer of data to hash */
+ uint32_t bufferBits; /* current number of bits on the buffer */
+ uint32_t bufferPos; /* current (possibly incomplete) byte slot on the buffer */
+ uint64_t hash[DIGESTBYTES/8]; /* the hashing state */
+} whirlpool_ctx;
-void NESSIEinit(struct NESSIEstruct * const structpointer);
-void NESSIEadd(const unsigned char * const source,
+void whirlpool_init(struct whirlpool_ctx * const structpointer);
+void whirlpool_add(const unsigned char * const source,
unsigned long sourceBits,
- struct NESSIEstruct * const structpointer);
-void NESSIEfinalize(struct NESSIEstruct * const structpointer,
+ struct whirlpool_ctx * const structpointer);
+void whirlpool_finalize(struct whirlpool_ctx * const structpointer,
unsigned char * const result);
#endif
View
40 cbits/whirlpool_nessie.h
@@ -1,40 +0,0 @@
-
-#ifndef PORTABLE_C__
-#define PORTABLE_C__
-
-#ifdef _MSC_VER
-typedef signed char int8_t;
-typedef unsigned char uint8_t;
-typedef __int32 int32_t;
-typedef unsigned __int32 uint32_t;
-typedef __int64 int64_t;
-typedef unsigned __int64 uint64_t;
-#define LL(v) (v##i64)
-#else
-#include <stdint.h>
-#define LL(v) (v##ULL)
-#endif
-
-/*
- * Whirlpool-specific definitions.
- */
-
-#define DIGESTBYTES 64
-#define DIGESTBITS (8*DIGESTBYTES) /* 512 */
-
-#define WBLOCKBYTES 64
-#define WBLOCKBITS (8*WBLOCKBYTES) /* 512 */
-
-#define LENGTHBYTES 32
-#define LENGTHBITS (8*LENGTHBYTES) /* 256 */
-
-typedef struct NESSIEstruct {
- uint8_t bitLength[LENGTHBYTES]; /* global number of hashed bits (256-bit counter) */
- uint8_t buffer[WBLOCKBYTES]; /* buffer of data to hash */
- uint32_t bufferBits; /* current number of bits on the buffer */
- uint32_t bufferPos; /* current (possibly incomplete) byte slot on the buffer */
- uint64_t hash[DIGESTBYTES/8]; /* the hashing state */
-} NESSIEstruct;
-
-#endif /* PORTABLE_C__ */
-

0 comments on commit e8654c7

Please sign in to comment.