- moved hasher_*_t to *_hasher_t

- some logging improvements
This commit is contained in:
Martin Willi
2005-11-27 14:04:16 +00:00
parent 9d086b79f6
commit b241048084
18 changed files with 180 additions and 238 deletions
+1 -1
View File
@@ -337,7 +337,7 @@ static status_t get_transforms_for_host_and_proposals (private_configuration_man
iterator_t *transforms;
status_t status;
this->logger->log(this->logger,ERROR, "Going to get transforms for given proposal");
this->logger->log(this->logger,CONTROL|MORE, "Going to get transforms for given proposal");
if (!proposals->has_next(proposals))
{
-1
View File
@@ -849,7 +849,6 @@ static status_t parse_payload(private_parser_t *this, payload_type_t payload_typ
*payload = pld;
this->logger->log(this->logger, CONTROL, "parsing %s successful", mapping_find(payload_type_m, payload_type));
return SUCCESS;
}
+2 -2
View File
@@ -220,7 +220,7 @@ static status_t process_message (private_ike_sa_t *this, message_t *message)
is_request = message->get_request(message);
exchange_type = message->get_exchange_type(message);
this->logger->log(this->logger, CONTROL|MORE, "Process %s message of exchange type %s",(is_request) ? "REQUEST" : "RESPONSE",mapping_find(exchange_type_m,exchange_type));
this->logger->log(this->logger, CONTROL, "Process %s message of exchange type %s",(is_request) ? "REQUEST" : "RESPONSE",mapping_find(exchange_type_m,exchange_type));
message_id = message->get_message_id(message);
@@ -270,7 +270,7 @@ static status_t build_message(private_ike_sa_t *this, exchange_type_t type, bool
message_t *new_message;
host_t *source, *destination;
this ->logger->log(this->logger, CONTROL|MORE, "build empty message");
this->logger->log(this->logger, CONTROL|MORE, "build empty message");
new_message = message_create();
if (new_message == NULL)
{
+5 -5
View File
@@ -238,7 +238,7 @@ static status_t initiate_connection (private_initiator_init_t *this, char *name)
}
/* generate packet */
this ->logger->log(this->logger, CONTROL|MOST, "generate packet from message");
this->logger->log(this->logger, CONTROL|MOST, "generate packet from message");
status = message->generate(message, &packet);
if (status != SUCCESS)
{
@@ -247,7 +247,7 @@ static status_t initiate_connection (private_initiator_init_t *this, char *name)
return status;
}
this ->logger->log(this->logger, CONTROL|MOST, "Add packet to global send queue");
this->logger->log(this->logger, CONTROL|MOST, "Add packet to global send queue");
status = global_send_queue->add(global_send_queue, packet);
if (status != SUCCESS)
{
@@ -258,7 +258,7 @@ static status_t initiate_connection (private_initiator_init_t *this, char *name)
}
/* state can now be changed */
this ->logger->log(this->logger, CONTROL|MOST, "Create next state object");
this->logger->log(this->logger, CONTROL|MOST, "Create next state object");
next_state = ike_sa_init_requested_create(this->ike_sa, this->dh_group_number, this->diffie_hellman, this->sent_nonce);
if (next_state == NULL)
{
@@ -282,9 +282,9 @@ static status_t initiate_connection (private_initiator_init_t *this, char *name)
this->ike_sa->set_new_state(this->ike_sa,(state_t *) next_state);
/* state has NOW changed :-) */
this ->logger->log(this->logger, CONTROL|MORE, "Changed state of IKE_SA from %s to %s",mapping_find(ike_sa_state_m,INITIATOR_INIT),mapping_find(ike_sa_state_m,IKE_SA_INIT_REQUESTED) );
this->logger->log(this->logger, CONTROL|MORE, "Changed state of IKE_SA from %s to %s",mapping_find(ike_sa_state_m,INITIATOR_INIT),mapping_find(ike_sa_state_m,IKE_SA_INIT_REQUESTED) );
this ->logger->log(this->logger, CONTROL|MOST, "Destroy old sate object");
this->logger->log(this->logger, CONTROL|MOST, "Destroy old sate object");
this->destroy_after_state_change(this);
return SUCCESS;
+2 -6
View File
@@ -19,10 +19,6 @@ TEST_OBJS+= $(BUILD_DIR)diffie_hellman_test.o
$(BUILD_DIR)diffie_hellman_test.o : $(TESTCASES_DIR)diffie_hellman_test.c $(TESTCASES_DIR)diffie_hellman_test.h
$(CC) $(CFLAGS) -c -o $@ $<
TEST_OBJS+= $(BUILD_DIR)hasher_md5_test.o
$(BUILD_DIR)hasher_md5_test.o : $(TESTCASES_DIR)hasher_md5_test.c $(TESTCASES_DIR)hasher_md5_test.h
$(CC) $(CFLAGS) -c -o $@ $<
TEST_OBJS+= $(BUILD_DIR)event_queue_test.o
$(BUILD_DIR)event_queue_test.o : $(TESTCASES_DIR)event_queue_test.c $(TESTCASES_DIR)event_queue_test.h
$(CC) $(CFLAGS) -c -o $@ $<
@@ -43,8 +39,8 @@ TEST_OBJS+= $(BUILD_DIR)parser_test.o
$(BUILD_DIR)parser_test.o : $(TESTCASES_DIR)parser_test.c $(TESTCASES_DIR)parser_test.h
$(CC) $(CFLAGS) -c -o $@ $<
TEST_OBJS+= $(BUILD_DIR)hasher_sha1_test.o
$(BUILD_DIR)hasher_sha1_test.o : $(TESTCASES_DIR)hasher_sha1_test.c $(TESTCASES_DIR)hasher_sha1_test.h
TEST_OBJS+= $(BUILD_DIR)hasher_test.o
$(BUILD_DIR)hasher_test.o : $(TESTCASES_DIR)hasher_test.c $(TESTCASES_DIR)hasher_test.h
$(CC) $(CFLAGS) -c -o $@ $<
TEST_OBJS+= $(BUILD_DIR)ike_sa_manager_test.o
-37
View File
@@ -1,37 +0,0 @@
/**
* @file hasher_md5_test.h
*
* @brief Tests the md5 hasher
*
*/
/*
* Copyright (C) 2005 Jan Hutter, Martin Willi
* Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
#ifndef HASHER_MD5_TEST_H_
#define HASHER_MD5_TEST_H_
#include <transforms/hashers/hasher.h>
#include <transforms/hashers/hasher_md5.h>
#include <utils/tester.h>
/**
* @brief Test function used to test the md5-hasher functionality
*
* @param tester associated tester object
*/
void test_hasher_md5(tester_t *tester);
#endif /*HASHER_MD5_TEST_H_*/
-106
View File
@@ -1,106 +0,0 @@
/**
* @file hasher_sha1_test.h
*
* @brief Tests the sha1 hasher
*
*/
/*
* Copyright (C) 2005 Jan Hutter, Martin Willi
* Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
#include <string.h>
#include "hasher_sha1_test.h"
#include <utils/allocator.h>
/*
* described in Header-File
*/
void test_hasher_sha1(tester_t *tester)
{
/*
* Test Vectors (from FIPS PUB 180-1)
* "abc"
* A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D
* "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
* 84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1
* A million repetitions of "a"
* 34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F
*/
hasher_t *hasher = hasher_create(HASH_SHA1);
u_int8_t hash_buffer[20];
chunk_t abc, abcdb, aaa, hash_chunk;
u_int32_t i;
u_int8_t hash_abc[] = {
0xA9,0x99,0x3E,0x36,
0x47,0x06,0x81,0x6A,
0xBA,0x3E,0x25,0x71,
0x78,0x50,0xC2,0x6C,
0x9C,0xD0,0xD8,0x9D
};
u_int8_t hash_abcdb[] = {
0x84,0x98,0x3E,0x44,
0x1C,0x3B,0xD2,0x6E,
0xBA,0xAE,0x4A,0xA1,
0xF9,0x51,0x29,0xE5,
0xE5,0x46,0x70,0xF1
};
u_int8_t hash_aaa[] = {
0x34,0xAA,0x97,0x3C,
0xD4,0xC4,0xDA,0xA4,
0xF6,0x1E,0xEB,0x2B,
0xDB,0xAD,0x27,0x31,
0x65,0x34,0x01,0x6F
};
abc.ptr = "abc";
abc.len = 3;
abcdb.ptr = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq";
abcdb.len = strlen(abcdb.ptr);
aaa.ptr = "aaaaaaaaaa"; /* 10 a's */
aaa.len = 10;
tester->assert_true(tester, hasher->get_block_size(hasher) == 20, "block size");
/* simple hashing, using "abc" */
hasher->get_hash(hasher, abc, hash_buffer);
tester->assert_false(tester, memcmp(hash_buffer, hash_abc, 20), "hash for abc");
/* with allocation, using "abcdb..." */
hasher->reset(hasher);
hasher->allocate_hash(hasher, abcdb, &hash_chunk);
tester->assert_true(tester, hash_chunk.len == 20, "chunk len");
tester->assert_false(tester, memcmp(hash_chunk.ptr, hash_abcdb, hash_chunk.len), "hash for abcdb...");
allocator_free(hash_chunk.ptr);
/* updating, using "aaaaaaa..." */
hasher->reset(hasher);
for(i=0; i<100000; i++)
{
if (i != 99999)
{
hasher->get_hash(hasher, aaa, NULL);
}
else
{
hasher->get_hash(hasher, aaa, hash_buffer);
}
}
tester->assert_false(tester, memcmp(hash_buffer, hash_aaa, 20), "hash for aaa...");
tester->assert_true(tester, (hasher->destroy(hasher) == SUCCESS), "destroy call test");
}
@@ -1,5 +1,5 @@
/**
* @file hasher_md5_test.h
* @file md5_hasher_test.h
*
* @brief Tests the md5 hasher
*
@@ -22,7 +22,7 @@
#include <string.h>
#include "hasher_md5_test.h"
#include "hasher_test.h"
#include <utils/allocator.h>
@@ -30,7 +30,7 @@
/*
* described in Header-File
*/
void test_hasher_md5(tester_t *tester)
void test_md5_hasher(tester_t *tester)
{
/*
* Test vectors from RFC1321:
@@ -92,3 +92,81 @@ void test_hasher_md5(tester_t *tester)
allocator_free(hash_chunk.ptr);
tester->assert_true(tester, (hasher->destroy(hasher) == SUCCESS), "destroy call test");
}
/*
* described in Header-File
*/
void test_sha1_hasher(tester_t *tester)
{
/*
* Test Vectors (from FIPS PUB 180-1)
* "abc"
* A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D
* "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
* 84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1
* A million repetitions of "a"
* 34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F
*/
hasher_t *hasher = hasher_create(HASH_SHA1);
u_int8_t hash_buffer[20];
chunk_t abc, abcdb, aaa, hash_chunk;
u_int32_t i;
u_int8_t hash_abc[] = {
0xA9,0x99,0x3E,0x36,
0x47,0x06,0x81,0x6A,
0xBA,0x3E,0x25,0x71,
0x78,0x50,0xC2,0x6C,
0x9C,0xD0,0xD8,0x9D
};
u_int8_t hash_abcdb[] = {
0x84,0x98,0x3E,0x44,
0x1C,0x3B,0xD2,0x6E,
0xBA,0xAE,0x4A,0xA1,
0xF9,0x51,0x29,0xE5,
0xE5,0x46,0x70,0xF1
};
u_int8_t hash_aaa[] = {
0x34,0xAA,0x97,0x3C,
0xD4,0xC4,0xDA,0xA4,
0xF6,0x1E,0xEB,0x2B,
0xDB,0xAD,0x27,0x31,
0x65,0x34,0x01,0x6F
};
abc.ptr = "abc";
abc.len = 3;
abcdb.ptr = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq";
abcdb.len = strlen(abcdb.ptr);
aaa.ptr = "aaaaaaaaaa"; /* 10 a's */
aaa.len = 10;
tester->assert_true(tester, hasher->get_block_size(hasher) == 20, "block size");
/* simple hashing, using "abc" */
hasher->get_hash(hasher, abc, hash_buffer);
tester->assert_false(tester, memcmp(hash_buffer, hash_abc, 20), "hash for abc");
/* with allocation, using "abcdb..." */
hasher->reset(hasher);
hasher->allocate_hash(hasher, abcdb, &hash_chunk);
tester->assert_true(tester, hash_chunk.len == 20, "chunk len");
tester->assert_false(tester, memcmp(hash_chunk.ptr, hash_abcdb, hash_chunk.len), "hash for abcdb...");
allocator_free(hash_chunk.ptr);
/* updating, using "aaaaaaa..." */
hasher->reset(hasher);
for(i=0; i<100000; i++)
{
if (i != 99999)
{
hasher->get_hash(hasher, aaa, NULL);
}
else
{
hasher->get_hash(hasher, aaa, hash_buffer);
}
}
tester->assert_false(tester, memcmp(hash_buffer, hash_aaa, 20), "hash for aaa...");
tester->assert_true(tester, (hasher->destroy(hasher) == SUCCESS), "destroy call test");
}
@@ -1,7 +1,7 @@
/**
* @file hasher_sha1_test.h
* @file hasher_test.h
*
* @brief Tests the sha1 hasher
* @brief Tests the hashers
*
*/
@@ -20,11 +20,12 @@
* for more details.
*/
#ifndef HASHER_SHA1_TEST_H_
#define HASHER_SHA1_TEST_H_
#ifndef HASHER_TEST_H_
#define HASHER_TEST_H_
#include <transforms/hashers/hasher.h>
#include <transforms/hashers/hasher_sha1.h>
#include <transforms/hashers/md5_hasher.h>
#include <transforms/hashers/sha1_hasher.h>
#include <utils/tester.h>
/**
@@ -32,6 +33,13 @@
*
* @param tester associated tester object
*/
void test_hasher_sha1(tester_t *tester);
void test_sha1_hasher(tester_t *tester);
#endif /*HASHER_SHA1_TEST_H_*/
/**
* @brief Test function used to test the md5-hasher functionality
*
* @param tester associated tester object
*/
void test_md5_hasher(tester_t *tester);
#endif /*HASHER_TEST_H_*/
+7 -8
View File
@@ -48,8 +48,7 @@
#include <testcases/parser_test.h>
#include <testcases/packet_test.h>
#include <testcases/diffie_hellman_test.h>
#include <testcases/hasher_sha1_test.h>
#include <testcases/hasher_md5_test.h>
#include <testcases/hasher_test.h>
#include <testcases/hmac_test.h>
#include <testcases/prf_plus_test.h>
@@ -179,12 +178,12 @@ test_t diffie_hellman_test = {test_diffie_hellman,"Diffie Hellman"};
/**
* Test for sha1 hasher
*/
test_t hasher_sha1_test = {test_hasher_sha1,"SHA1 hasher"};
test_t sha1_hasher_test = {test_sha1_hasher,"SHA1 hasher"};
/**
* Test for md5 hasher
*/
test_t hasher_md5_test = {test_hasher_md5,"MD5 hasher"};
test_t md5_hasher_test = {test_md5_hasher,"MD5 hasher"};
/**
* Test for hmac
@@ -271,14 +270,14 @@ logger_manager_t *global_logger_manager;
&ike_sa_manager_test,
&packet_test,
&diffie_hellman_test,
&hasher_sha1_test,
&hasher_md5_test,
&sha1_hasher_test,
&md5_hasher_test,
&hmac_test1,
&hmac_test2,
&prf_plus_test,
NULL
};
global_logger_manager = logger_manager_create(FULL);
global_logger_manager = logger_manager_create(0);
global_socket = socket_create(4600);
@@ -294,7 +293,7 @@ logger_manager_t *global_logger_manager;
tester->perform_tests(tester,all_tests);
// tester->perform_test(tester,&hasher_sha1_test);
// tester->perform_test(tester,&sha1_hasher_test);
+4
View File
@@ -348,6 +348,10 @@ thread_pool_t *thread_pool_create(size_t pool_size)
int current;
private_thread_pool_t *this = allocator_alloc_thing(private_thread_pool_t);
if (this == NULL)
{
return NULL;
}
/* fill in public fields */
this->public.destroy = (status_t(*)(thread_pool_t*))destroy;
@@ -18,10 +18,10 @@ OBJS+= $(BUILD_DIR)hasher.o
$(BUILD_DIR)hasher.o : $(HASHERS_DIR)hasher.c $(HASHERS_DIR)hasher.h
$(CC) $(CFLAGS) -c -o $@ $<
OBJS+= $(BUILD_DIR)hasher_sha1.o
$(BUILD_DIR)hasher_sha1.o : $(HASHERS_DIR)hasher_sha1.c $(HASHERS_DIR)hasher_sha1.h
OBJS+= $(BUILD_DIR)sha1_hasher.o
$(BUILD_DIR)sha1_hasher.o : $(HASHERS_DIR)sha1_hasher.c $(HASHERS_DIR)sha1_hasher.h
$(CC) $(CFLAGS) -c -o $@ $<
OBJS+= $(BUILD_DIR)hasher_md5.o
$(BUILD_DIR)hasher_md5.o : $(HASHERS_DIR)hasher_md5.c $(HASHERS_DIR)hasher_md5.h
OBJS+= $(BUILD_DIR)md5_hasher.o
$(BUILD_DIR)md5_hasher.o : $(HASHERS_DIR)md5_hasher.c $(HASHERS_DIR)md5_hasher.h
$(CC) $(CFLAGS) -c -o $@ $<
+4 -4
View File
@@ -23,8 +23,8 @@
#include "hasher.h"
#include <transforms/hashers/hasher_sha1.h>
#include <transforms/hashers/hasher_md5.h>
#include <transforms/hashers/sha1_hasher.h>
#include <transforms/hashers/md5_hasher.h>
/**
* mappings for hash_algorithm_t
@@ -44,11 +44,11 @@ hasher_t *hasher_create(hash_algorithm_t hash_algorithm)
{
case HASH_SHA1:
{
return (hasher_t*)hasher_sha1_create();
return (hasher_t*)sha1_hasher_create();
}
case HASH_MD5:
{
return (hasher_t*)hasher_md5_create();
return (hasher_t*)md5_hasher_create();
}
default:
return NULL;
@@ -1,7 +1,7 @@
/**
* @file hasher_md5.c
* @file md5_hasher.c
*
* @brief Implementation of hasher_md5_t.
* @brief Implementation of md5_hasher_t.
*
*/
@@ -25,7 +25,7 @@
* for more details.
*/
#include "hasher_md5.h"
#include "md5_hasher.h"
#include <definitions.h>
#include <utils/allocator.h>
@@ -97,16 +97,16 @@ Rotation is separate from addition to prevent recomputation.
typedef struct private_hasher_md5_t private_hasher_md5_t;
typedef struct private_md5_hasher_t private_md5_hasher_t;
/**
* private data structure with hasing context
*/
struct private_hasher_md5_t {
struct private_md5_hasher_t {
/**
* public interface for this hasher
*/
hasher_md5_t public;
md5_hasher_t public;
/*
* state of the hasher
@@ -244,7 +244,7 @@ static void MD5Transform(u_int32_t state[4], u_int8_t block[64])
* operation, processing another message block, and updating the
* context.
*/
void MD5Update(private_hasher_md5_t *this, u_int8_t *input, size_t inputLen)
void MD5Update(private_md5_hasher_t *this, u_int8_t *input, size_t inputLen)
{
u_int32_t i;
size_t index, partLen;
@@ -285,7 +285,7 @@ void MD5Update(private_hasher_md5_t *this, u_int8_t *input, size_t inputLen)
/* MD5 finalization. Ends an MD5 message-digest operation, writing the
* the message digest and zeroizing the context.
*/
void MD5Final (private_hasher_md5_t *this, u_int8_t digest[16])
void MD5Final (private_md5_hasher_t *this, u_int8_t digest[16])
{
u_int8_t bits[8];
size_t index, padLen;
@@ -313,7 +313,7 @@ void MD5Final (private_hasher_md5_t *this, u_int8_t digest[16])
/**
* implementation of hasher_t.get_hash for md5
*/
static status_t get_hash(private_hasher_md5_t *this, chunk_t chunk, u_int8_t *buffer)
static status_t get_hash(private_md5_hasher_t *this, chunk_t chunk, u_int8_t *buffer)
{
MD5Update(this, chunk.ptr, chunk.len);
if (buffer != NULL)
@@ -328,7 +328,7 @@ static status_t get_hash(private_hasher_md5_t *this, chunk_t chunk, u_int8_t *bu
/**
* implementation of hasher_t.allocate_hash for md5
*/
static status_t allocate_hash(private_hasher_md5_t *this, chunk_t chunk, chunk_t *hash)
static status_t allocate_hash(private_md5_hasher_t *this, chunk_t chunk, chunk_t *hash)
{
chunk_t allocated_hash;
@@ -353,7 +353,7 @@ static status_t allocate_hash(private_hasher_md5_t *this, chunk_t chunk, chunk_t
/**
* implementation of hasher_t.get_block_size for md5
*/
static size_t get_block_size(private_hasher_md5_t *this)
static size_t get_block_size(private_md5_hasher_t *this)
{
return BLOCK_SIZE_MD5;
}
@@ -361,7 +361,7 @@ static size_t get_block_size(private_hasher_md5_t *this)
/**
* implementation of hasher_t.reset for md5
*/
static status_t reset(private_hasher_md5_t *this)
static status_t reset(private_md5_hasher_t *this)
{
this->state[0] = 0x67452301;
this->state[1] = 0xefcdab89;
@@ -374,7 +374,7 @@ static status_t reset(private_hasher_md5_t *this)
/**
* implementation of hasher_t.destroy for md5
*/
static status_t destroy(private_hasher_md5_t *this)
static status_t destroy(private_md5_hasher_t *this)
{
allocator_free(this);
return SUCCESS;
@@ -384,9 +384,9 @@ static status_t destroy(private_hasher_md5_t *this)
/*
* Described in header
*/
hasher_md5_t *hasher_md5_create()
md5_hasher_t *md5_hasher_create()
{
private_hasher_md5_t *this = allocator_alloc_thing(private_hasher_md5_t);
private_md5_hasher_t *this = allocator_alloc_thing(private_md5_hasher_t);
if (this == NULL)
{
return NULL;
@@ -1,7 +1,7 @@
/**
* @file hasher_md5.h
* @file md5_hasher.h
*
* @brief Interface for hasher_md5_t.
* @brief Interface for md5_hasher_t.
*
*/
@@ -20,13 +20,13 @@
* for more details.
*/
#ifndef HASHER_MD5_H_
#define HASHER_MD5_H_
#ifndef MD5_HASHER_H_
#define MD5_HASHER_H_
#include <transforms/hashers/hasher.h>
typedef struct hasher_md5_t hasher_md5_t;
typedef struct md5_hasher_t md5_hasher_t;
/**
* @brief Implementation of hasher_t interface using the
@@ -34,7 +34,7 @@ typedef struct hasher_md5_t hasher_md5_t;
*
* @ingroup hashers
*/
struct hasher_md5_t {
struct md5_hasher_t {
/**
* generic hasher_t interface for this hasher
@@ -43,14 +43,14 @@ struct hasher_md5_t {
};
/**
* @brief Creates a new hasher_md5_t.
* @brief Creates a new md5_hasher_t.
*
* @return
* - hasher_md5_t if successfully
* - md5_hasher_t if successfully
* - NULL if out of ressources
*
* @ingroup hashers
*/
hasher_md5_t *hasher_md5_create();
md5_hasher_t *md5_hasher_create();
#endif /*HASHER_md5_H_*/
#endif /*MD5_HASHER_H_*/
@@ -1,5 +1,5 @@
/**
* @file hasher_sha1.c
* @file sha1_hasher.c
*
* @brief Implementation of hasher_sha_t.
*
@@ -23,7 +23,7 @@
* for more details.
*/
#include "hasher_sha1.h"
#include "sha1_hasher.h"
#include <definitions.h>
#include <utils/allocator.h>
@@ -52,16 +52,16 @@
#define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
typedef struct private_hasher_sha1_t private_hasher_sha1_t;
typedef struct private_sha1_hasher_t private_sha1_hasher_t;
/**
* private data structure with hasing context
*/
struct private_hasher_sha1_t {
struct private_sha1_hasher_t {
/**
* public interface for this hasher
*/
hasher_sha1_t public;
sha1_hasher_t public;
/*
* state of the hasher
@@ -125,7 +125,7 @@ void SHA1Transform(u_int32_t state[5], const unsigned char buffer[64])
/*
* Run your data through this.
*/
void SHA1Update(private_hasher_sha1_t* this, u_int8_t *data, u_int32_t len)
void SHA1Update(private_sha1_hasher_t* this, u_int8_t *data, u_int32_t len)
{
u_int32_t i;
u_int32_t j;
@@ -158,7 +158,7 @@ void SHA1Update(private_hasher_sha1_t* this, u_int8_t *data, u_int32_t len)
/*
* Add padding and return the message digest.
*/
void SHA1Final(private_hasher_sha1_t *this, u_int8_t *digest)
void SHA1Final(private_sha1_hasher_t *this, u_int8_t *digest)
{
u_int32_t i;
u_int8_t finalcount[8];
@@ -187,7 +187,7 @@ void SHA1Final(private_hasher_sha1_t *this, u_int8_t *digest)
/**
* implementation of hasher_t.get_hash for sha1
*/
static status_t get_hash(private_hasher_sha1_t *this, chunk_t chunk, u_int8_t *buffer)
static status_t get_hash(private_sha1_hasher_t *this, chunk_t chunk, u_int8_t *buffer)
{
SHA1Update(this, chunk.ptr, chunk.len);
if (buffer != NULL)
@@ -202,7 +202,7 @@ static status_t get_hash(private_hasher_sha1_t *this, chunk_t chunk, u_int8_t *b
/**
* implementation of hasher_t.allocate_hash for sha1
*/
static status_t allocate_hash(private_hasher_sha1_t *this, chunk_t chunk, chunk_t *hash)
static status_t allocate_hash(private_sha1_hasher_t *this, chunk_t chunk, chunk_t *hash)
{
chunk_t allocated_hash;
@@ -227,7 +227,7 @@ static status_t allocate_hash(private_hasher_sha1_t *this, chunk_t chunk, chunk_
/**
* implementation of hasher_t.get_block_size for sha1
*/
static size_t get_block_size(private_hasher_sha1_t *this)
static size_t get_block_size(private_sha1_hasher_t *this)
{
return BLOCK_SIZE_SHA1;
}
@@ -235,7 +235,7 @@ static size_t get_block_size(private_hasher_sha1_t *this)
/**
* implementation of hasher_t.reset for sha1
*/
static status_t reset(private_hasher_sha1_t *this)
static status_t reset(private_sha1_hasher_t *this)
{
this->state[0] = 0x67452301;
this->state[1] = 0xEFCDAB89;
@@ -249,7 +249,7 @@ static status_t reset(private_hasher_sha1_t *this)
/**
* implementation of hasher_t.destroy for sha1
*/
static status_t destroy(private_hasher_sha1_t *this)
static status_t destroy(private_sha1_hasher_t *this)
{
allocator_free(this);
return SUCCESS;
@@ -259,9 +259,9 @@ static status_t destroy(private_hasher_sha1_t *this)
/*
* Described in header
*/
hasher_sha1_t *hasher_sha1_create()
sha1_hasher_t *sha1_hasher_create()
{
private_hasher_sha1_t *this = allocator_alloc_thing(private_hasher_sha1_t);
private_sha1_hasher_t *this = allocator_alloc_thing(private_sha1_hasher_t);
if (this == NULL)
{
return NULL;
@@ -1,7 +1,7 @@
/**
* @file hasher_sha1.h
* @file sha1_hasher.h
*
* @brief Interface of hasher_sha1_t
* @brief Interface of sha1_hasher_t
*
*/
@@ -20,13 +20,13 @@
* for more details.
*/
#ifndef HASHER_SHA1_H_
#define HASHER_SHA1_H_
#ifndef SHA1_HASHER_H_
#define SHA1_HASHER_H_
#include <transforms/hashers/hasher.h>
typedef struct hasher_sha1_t hasher_sha1_t;
typedef struct sha1_hasher_t sha1_hasher_t;
/**
* @brief Implementation of hasher_t interface using the
@@ -34,7 +34,7 @@ typedef struct hasher_sha1_t hasher_sha1_t;
*
* @ingroup hashers
*/
struct hasher_sha1_t {
struct sha1_hasher_t {
/**
* generic hasher_t interface for this hasher
@@ -43,14 +43,14 @@ struct hasher_sha1_t {
};
/**
* @brief Creates a new hasher_sha1_t.
* @brief Creates a new sha1_hasher_t.
*
* @return
* - hasher_sha1_t if successfully
* - sha1_hasher_t if successfully
* - NULL if out of ressources
*
* @ingroup hashers
*/
hasher_sha1_t *hasher_sha1_create();
sha1_hasher_t *sha1_hasher_create();
#endif /*HASHER_SHA1_H_*/
#endif /*SHA1_HASHER_H_*/
+6 -5
View File
@@ -133,7 +133,7 @@ static logger_t *create_logger(private_logger_manager_t *this, logger_context_t
char buffer[MAX_LOGGER_NAME];
loggers_entry_t *entry;
logger_t *logger;
logger_level_t logger_level;
logger_level_t logger_level = 0;
context_name = mapping_find(logger_context_t_mappings,context);
@@ -145,13 +145,14 @@ static logger_t *create_logger(private_logger_manager_t *this, logger_context_t
case TESTER:
log_thread_ids = FALSE;
output = stdout;
logger_level = FULL;
logger_level = 0;
break;
case PARSER:
case GENERATOR:
case IKE_SA:
case IKE_SA_MANAGER:
case MESSAGE:
logger_level |= ALL;
case PARSER:
case GENERATOR:
case THREAD_POOL:
case WORKER:
case SCHEDULER:
@@ -161,7 +162,7 @@ static logger_t *create_logger(private_logger_manager_t *this, logger_context_t
case DAEMON:
case CONFIGURATION_MANAGER:
log_thread_ids = FALSE;
logger_level = ERROR|CONTROL;
logger_level |= ERROR|CONTROL;
break;
}