aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2017-01-05 11:42:47 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2017-01-05 11:47:21 +0000
commite64406407c4392f2c750d14139e46484309a2ebc (patch)
treef33d450aae225c4937b8fd7d9b4e9ceb1d5bee9b
parent9a70779d68a5f9ab211d97b69a932a1043052ff6 (diff)
md5 had to move too.
-rw-r--r--configd/src/apps/sentinel/CMakeLists.txt1
-rw-r--r--slobrok/CMakeLists.txt1
-rw-r--r--staging_vespalib/CMakeLists.txt1
-rw-r--r--staging_vespalib/src/vespa/vespalib/util/CMakeLists.txt1
-rw-r--r--vespalib/src/vespa/vespalib/util/CMakeLists.txt1
-rw-r--r--vespalib/src/vespa/vespalib/util/md5.c (renamed from staging_vespalib/src/vespa/vespalib/util/md5.c)69
-rw-r--r--vespalib/src/vespa/vespalib/util/md5.h (renamed from staging_vespalib/src/vespa/vespalib/util/md5.h)7
7 files changed, 34 insertions, 47 deletions
diff --git a/configd/src/apps/sentinel/CMakeLists.txt b/configd/src/apps/sentinel/CMakeLists.txt
index 27a5d052d72..5f20042c021 100644
--- a/configd/src/apps/sentinel/CMakeLists.txt
+++ b/configd/src/apps/sentinel/CMakeLists.txt
@@ -13,4 +13,5 @@ vespa_add_executable(configd_config-sentinel_app
INSTALL sbin
DEPENDS
configdefinitions
+ staging_vespalib
)
diff --git a/slobrok/CMakeLists.txt b/slobrok/CMakeLists.txt
index 4c78f331492..a860d00729b 100644
--- a/slobrok/CMakeLists.txt
+++ b/slobrok/CMakeLists.txt
@@ -5,6 +5,7 @@ vespa_define_module(
vespalib
fnet
configdefinitions
+ staging_vespalib
LIBS
src/vespa/slobrok
diff --git a/staging_vespalib/CMakeLists.txt b/staging_vespalib/CMakeLists.txt
index 65cd8bb8630..3f447c3ac57 100644
--- a/staging_vespalib/CMakeLists.txt
+++ b/staging_vespalib/CMakeLists.txt
@@ -32,7 +32,6 @@ vespa_define_module(
src/tests/state_server
src/tests/stllike
src/tests/timer
- src/tests/trace
src/tests/util/process_memory_stats
src/tests/xmlserializable
diff --git a/staging_vespalib/src/vespa/vespalib/util/CMakeLists.txt b/staging_vespalib/src/vespa/vespalib/util/CMakeLists.txt
index fd2c12abbd0..ca440428e0a 100644
--- a/staging_vespalib/src/vespa/vespalib/util/CMakeLists.txt
+++ b/staging_vespalib/src/vespa/vespalib/util/CMakeLists.txt
@@ -10,7 +10,6 @@ vespa_add_library(staging_vespalib_vespalib_util OBJECT
jsonstream.cpp
jsonwriter.cpp
librarypool.cpp
- md5.c
process_memory_stats.cpp
programoptions.cpp
programoptions_testutils.cpp
diff --git a/vespalib/src/vespa/vespalib/util/CMakeLists.txt b/vespalib/src/vespa/vespalib/util/CMakeLists.txt
index 6fb3626a3a1..fb6634b13f2 100644
--- a/vespalib/src/vespa/vespalib/util/CMakeLists.txt
+++ b/vespalib/src/vespa/vespalib/util/CMakeLists.txt
@@ -25,6 +25,7 @@ vespa_add_library(vespalib_vespalib_util OBJECT
host_name.cpp
joinable.cpp
left_right_heap.cpp
+ md5.c
printable.cpp
priority_queue.cpp
random.cpp
diff --git a/staging_vespalib/src/vespa/vespalib/util/md5.c b/vespalib/src/vespa/vespalib/util/md5.c
index 0d287fb3c45..0800b101335 100644
--- a/staging_vespalib/src/vespa/vespalib/util/md5.c
+++ b/vespalib/src/vespa/vespalib/util/md5.c
@@ -1,5 +1,5 @@
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-/* $Id$
+/*
*
* Generic hash functions to ensure the same hash values are used everywhere.
*/
@@ -33,20 +33,9 @@
*
*/
-#include <sys/types.h>
+#include "md5.h"
#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-/*
-#include <debugmalloc.h>
-#include <hash.h>
-#include <fileutil.h>
-#include <poolmalloc.h>
-#include <workarounds.h>
-*/
-
-#include <vespa/vespalib/util/md5.h>
+#include <inttypes.h>
/* --- START OF MD5 CODE --- */
@@ -70,17 +59,17 @@
/* MD5 context. */
typedef struct
{
- uint state[4]; /* state (ABCD) */
- uint count[2]; /* number of bits, modulo 2^64 (lsb first) */
+ uint32_t state[4]; /* state (ABCD) */
+ uint32_t count[2]; /* number of bits, modulo 2^64 (lsb first) */
unsigned char buffer[64]; /* input buffer */
} MD5_CTX;
static void MD5Init (MD5_CTX *);
-static void MD5Update (MD5_CTX *, const unsigned char *, uint);
+static void MD5Update (MD5_CTX *, const unsigned char *, uint32_t);
static void MD5Final (unsigned char [16], MD5_CTX *);
-static void MD5Transform (uint [4], const unsigned char [64]);
-static void Encode (unsigned char *, uint *, uint);
-static void Decode (uint *, const unsigned char *, uint);
+static void MD5Transform (uint32_t [4], const unsigned char [64]);
+static void Encode (unsigned char *, uint32_t *, uint32_t);
+static void Decode (uint32_t *, const unsigned char *, uint32_t);
static unsigned char PADDING[64] = {
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -103,22 +92,22 @@ static unsigned char PADDING[64] = {
Rotation is separate from addition to prevent recomputation.
*/
#define FF(a, b, c, d, x, s, ac) { \
- (a) += F ((b), (c), (d)) + (x) + (uint)(ac); \
+ (a) += F ((b), (c), (d)) + (x) + (uint32_t)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define GG(a, b, c, d, x, s, ac) { \
- (a) += G ((b), (c), (d)) + (x) + (uint)(ac); \
+ (a) += G ((b), (c), (d)) + (x) + (uint32_t)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define HH(a, b, c, d, x, s, ac) { \
- (a) += H ((b), (c), (d)) + (x) + (uint)(ac); \
+ (a) += H ((b), (c), (d)) + (x) + (uint32_t)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define II(a, b, c, d, x, s, ac) { \
- (a) += I ((b), (c), (d)) + (x) + (uint)(ac); \
+ (a) += I ((b), (c), (d)) + (x) + (uint32_t)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
@@ -142,18 +131,18 @@ MD5Init (MD5_CTX *context)
context.
*/
static void
-MD5Update (MD5_CTX *context, const unsigned char *input, uint inputLen)
+MD5Update (MD5_CTX *context, const unsigned char *input, uint32_t inputLen)
{
- uint i, idx, partLen;
+ uint32_t i, idx, partLen;
/* Compute number of bytes mod 64 */
- idx = (uint)((context->count[0] >> 3) & 0x3F);
+ idx = (uint32_t)((context->count[0] >> 3) & 0x3F);
/* Update number of bits */
- if ((context->count[0] += ((uint)inputLen << 3)) < ((uint)inputLen << 3)) {
+ if ((context->count[0] += ((uint32_t)inputLen << 3)) < ((uint32_t)inputLen << 3)) {
context->count[1]++;
}
- context->count[1] += ((uint)inputLen >> 29);
+ context->count[1] += ((uint32_t)inputLen >> 29);
partLen = 64 - idx;
@@ -182,14 +171,14 @@ static void
MD5Final (unsigned char digest[16], MD5_CTX *context)
{
unsigned char bits[8];
- uint idx, padLen;
+ uint32_t idx, padLen;
/* Save number of bits */
Encode (bits, context->count, 8);
/* Pad out to 56 mod 64.
*/
- idx = (uint)((context->count[0] >> 3) & 0x3f);
+ idx = (uint32_t)((context->count[0] >> 3) & 0x3f);
padLen = (idx < 56) ? (56 - idx) : (120 - idx);
MD5Update (context, PADDING, padLen);
@@ -206,9 +195,9 @@ MD5Final (unsigned char digest[16], MD5_CTX *context)
/* MD5 basic transformation. Transforms state based on block.
*/
static void
-MD5Transform (uint state[4], const unsigned char dblock[64])
+MD5Transform (uint32_t state[4], const unsigned char dblock[64])
{
- uint a = state[0], b = state[1], c = state[2], d = state[3], x[16];
+ uint32_t a = state[0], b = state[1], c = state[2], d = state[3], x[16];
Decode (x, dblock, 64);
@@ -295,9 +284,9 @@ MD5Transform (uint state[4], const unsigned char dblock[64])
}
static void
-Encode (unsigned char *output, uint *input, uint len)
+Encode (unsigned char *output, uint32_t *input, uint32_t len)
{
- uint i, j;
+ uint32_t i, j;
for (i = 0, j = 0; j < len; i++, j += 4) {
output[j] = (unsigned char)(input[i] & 0xff);
@@ -307,18 +296,18 @@ Encode (unsigned char *output, uint *input, uint len)
}
}
-/* Decodes input (unsigned char) into output (uint). Assumes len is
+/* Decodes input (unsigned char) into output (uint32_t). Assumes len is
a multiple of 4.
*/
static void
-Decode (uint *output, const unsigned char *input, uint len)
+Decode (uint32_t *output, const unsigned char *input, uint32_t len)
{
- uint i, j;
+ uint32_t i, j;
for (i = 0, j = 0; j < len; i++, j += 4)
- output[i] = ((uint)input[j]) | (((uint)input[j+1]) << 8) |
- (((uint)input[j+2]) << 16) | (((uint)input[j+3]) << 24);
+ output[i] = ((uint32_t)input[j]) | (((uint32_t)input[j+1]) << 8) |
+ (((uint32_t)input[j+2]) << 16) | (((uint32_t)input[j+3]) << 24);
}
diff --git a/staging_vespalib/src/vespa/vespalib/util/md5.h b/vespalib/src/vespa/vespalib/util/md5.h
index edb54d56d6f..e9a3acc0668 100644
--- a/staging_vespalib/src/vespa/vespalib/util/md5.h
+++ b/vespalib/src/vespa/vespalib/util/md5.h
@@ -1,12 +1,9 @@
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-/**
- @author Thomas F. Gundersen
- @version $Id$
- @date 2004-03-15
-*/
#pragma once
+#include <stddef.h>
+
/* Returns pointer to a key in compacted format, ie 16 unsigned chars */
#ifdef __cplusplus