- implemented RSA, only signing and verifying esma_pkcs1 padded

- removed gmp-helper: chunk_to_mpz is now done with gmp functions, prime generation in prime-pool
- added prime-pool (needs priority fix)
- proof of concept RSA authentication
- mpz uses LEAK_DETECTIVE
- configuration-manager supports rsa keys
This commit is contained in:
Martin Willi
2005-12-04 01:30:35 +00:00
parent a374d1ee66
commit 8ff8c33d1d
29 changed files with 2311 additions and 289 deletions
+38 -13
View File
@@ -25,6 +25,7 @@
#include <string.h>
#include <assert.h>
#include <stdio.h>
#include <gmp.h>
#include "allocator.h"
@@ -213,26 +214,17 @@ static void * reallocate(allocator_t *allocator, void * old, size_t bytes, char
private_allocator_t *this = (private_allocator_t *) allocator;
memory_hdr_t *allocated_memory;
if (old == NULL)
{
return NULL;
}
pthread_mutex_lock( &(this->mutex));
allocated_memory = ((memory_hdr_t *)old) - 1;
void *new_space = this->allocate_special(this,bytes,file,line,FALSE);
if (new_space == NULL)
{
pthread_mutex_unlock(&(this->mutex));
this->public.free_pointer(&(this->public),old);
return NULL;
if (old != NULL)
{
/* the smaller size is copied to avoid overflows */
memcpy(new_space,old,(allocated_memory->info.size_of_memory < bytes) ? allocated_memory->info.size_of_memory : bytes);
}
/* the smaller size is copied to avoid overflows */
memcpy(new_space,old,(allocated_memory->info.size_of_memory < bytes) ? allocated_memory->info.size_of_memory : bytes);
pthread_mutex_unlock(&(this->mutex));
this->public.free_pointer(&(this->public),old);
@@ -331,7 +323,40 @@ static private_allocator_t allocator = {
mutex: PTHREAD_MUTEX_INITIALIZER
};
allocator_t *global_allocator = &(allocator.public);
/*
* alloc function for gmp
*/
void *gmp_alloc(size_t bytes)
{
return allocator.allocate_special(&allocator, bytes, "[ gmp internal ]", 0 , TRUE);
}
/*
* realloc function for gmp
*/
void *gmp_realloc(void *old, size_t old_bytes, size_t new_bytes)
{
return global_allocator->reallocate(global_allocator, old, new_bytes, "[ gmp internal ]", 0);
}
/*
* free function for gmp
*/
void gmp_free(void *ptr, size_t bytes)
{
free_pointer(global_allocator, ptr);
}
/*
* Described in header
*/
void allocator_init()
{
mp_set_memory_functions (gmp_alloc, gmp_realloc, gmp_free);
}
#else /* !LEAK_DETECTION */