aboutsummaryrefslogtreecommitdiffstats
path: root/Source/lib/crypto
diff options
context:
space:
mode:
authorMartin Willi <martin@strongswan.org>2006-04-10 08:07:38 +0000
committerMartin Willi <martin@strongswan.org>2006-04-10 08:07:38 +0000
commit5113680f95e522c677cdd37072cfffbdca06831e (patch)
tree973ac57accbc66b042e5307942c6cbbbf4f19579 /Source/lib/crypto
parent6862128151fb78f63685a8da5575783c426d64a7 (diff)
downloadstrongswan-5113680f95e522c677cdd37072cfffbdca06831e.tar.bz2
strongswan-5113680f95e522c677cdd37072cfffbdca06831e.tar.xz
- split up in libstrong, charon, stroke, testing done
- new leak detective with malloc hook in library - useable, but needs improvements - logger_manager has now a single instance per library - allows use of loggers from any linking prog - a LOT of other things
Diffstat (limited to 'Source/lib/crypto')
-rwxr-xr-xSource/lib/crypto/certificate.c19
-rw-r--r--Source/lib/crypto/crypters/aes_cbc_crypter.c11
-rw-r--r--Source/lib/crypto/diffie_hellman.c13
-rw-r--r--Source/lib/crypto/hashers/md5_hasher.c9
-rw-r--r--Source/lib/crypto/hashers/sha1_hasher.c9
-rw-r--r--Source/lib/crypto/hmac.c19
-rw-r--r--Source/lib/crypto/prf_plus.c16
-rw-r--r--Source/lib/crypto/prfs/hmac_prf.c7
-rw-r--r--Source/lib/crypto/rsa/rsa_private_key.c38
-rw-r--r--Source/lib/crypto/rsa/rsa_public_key.c34
-rw-r--r--Source/lib/crypto/signers/hmac_signer.c11
11 files changed, 94 insertions, 92 deletions
diff --git a/Source/lib/crypto/certificate.c b/Source/lib/crypto/certificate.c
index 2c8f30bf3..34c82e853 100755
--- a/Source/lib/crypto/certificate.c
+++ b/Source/lib/crypto/certificate.c
@@ -27,7 +27,6 @@
#include "certificate.h"
#include <daemon.h>
-#include <utils/allocator.h>
#include <asn1/der_decoder.h>
@@ -151,10 +150,10 @@ static rsa_public_key_t *get_public_key(private_certificate_t *this)
static void destroy(private_certificate_t *this)
{
this->public_key->destroy(this->public_key);
- allocator_free(this->pubkey.ptr);
- allocator_free(this->signature.ptr);
- allocator_free(this->tbs_cert.ptr);
- allocator_free(this);
+ free(this->pubkey.ptr);
+ free(this->signature.ptr);
+ free(this->tbs_cert.ptr);
+ free(this);
}
/*
@@ -162,7 +161,7 @@ static void destroy(private_certificate_t *this)
*/
certificate_t *certificate_create_from_chunk(chunk_t chunk)
{
- private_certificate_t *this = allocator_alloc_thing(private_certificate_t);
+ private_certificate_t *this = malloc_thing(private_certificate_t);
der_decoder_t *dd;
/* public functions */
@@ -178,7 +177,7 @@ certificate_t *certificate_create_from_chunk(chunk_t chunk)
if (dd->decode(dd, chunk, this) != SUCCESS)
{
- allocator_free(this);
+ free(this);
dd->destroy(dd);
return NULL;
}
@@ -187,8 +186,8 @@ certificate_t *certificate_create_from_chunk(chunk_t chunk)
this->public_key = rsa_public_key_create_from_chunk(this->pubkey);
if (this->public_key == NULL)
{
- allocator_free(this->pubkey.ptr);
- allocator_free(this);
+ free(this->pubkey.ptr);
+ free(this);
return NULL;
}
@@ -220,8 +219,10 @@ certificate_t *certificate_create_from_file(char *filename)
if (fread(buffer, stb.st_size, 1, file) == -1)
{
+ fclose(file);
return NULL;
}
+ fclose(file);
chunk.ptr = buffer;
chunk.len = stb.st_size;
diff --git a/Source/lib/crypto/crypters/aes_cbc_crypter.c b/Source/lib/crypto/crypters/aes_cbc_crypter.c
index d5d0f9a60..9b7b07c62 100644
--- a/Source/lib/crypto/crypters/aes_cbc_crypter.c
+++ b/Source/lib/crypto/crypters/aes_cbc_crypter.c
@@ -23,7 +23,6 @@
#include "aes_cbc_crypter.h"
-#include <utils/allocator.h>
/*
@@ -1385,7 +1384,7 @@ static status_t decrypt (private_aes_cbc_crypter_t *this, chunk_t data, chunk_t
return INVALID_ARG;
}
- decrypted->ptr = allocator_alloc(data.len);
+ decrypted->ptr = malloc(data.len);
if (decrypted->ptr == NULL)
{
return OUT_OF_RES;
@@ -1433,7 +1432,7 @@ static status_t encrypt (private_aes_cbc_crypter_t *this, chunk_t data, chunk_t
return INVALID_ARG;
}
- encrypted->ptr = allocator_alloc(data.len);
+ encrypted->ptr = malloc(data.len);
if (encrypted->ptr == NULL)
{
return OUT_OF_RES;
@@ -1579,7 +1578,7 @@ static status_t set_key (private_aes_cbc_crypter_t *this, chunk_t key)
*/
static void destroy (private_aes_cbc_crypter_t *this)
{
- allocator_free(this);
+ free(this);
}
/*
@@ -1587,7 +1586,7 @@ static void destroy (private_aes_cbc_crypter_t *this)
*/
aes_cbc_crypter_t *aes_cbc_crypter_create(size_t key_size)
{
- private_aes_cbc_crypter_t *this = allocator_alloc_thing(private_aes_cbc_crypter_t);
+ private_aes_cbc_crypter_t *this = malloc_thing(private_aes_cbc_crypter_t);
#if !defined(FIXED_TABLES)
if(!tab_gen) { gen_tabs(); tab_gen = 1; }
@@ -1608,7 +1607,7 @@ aes_cbc_crypter_t *aes_cbc_crypter_create(size_t key_size)
this->aes_Nkey = 4;
break;
default:
- allocator_free(this);
+ free(this);
return NULL;
}
diff --git a/Source/lib/crypto/diffie_hellman.c b/Source/lib/crypto/diffie_hellman.c
index 84cf1e54a..e458fb80f 100644
--- a/Source/lib/crypto/diffie_hellman.c
+++ b/Source/lib/crypto/diffie_hellman.c
@@ -28,7 +28,6 @@
#include "diffie_hellman.h"
#include <daemon.h>
-#include <utils/allocator.h>
#include <utils/randomizer.h>
@@ -553,7 +552,7 @@ static void destroy(private_diffie_hellman_t *this)
/* other public value gets initialized together with shared secret */
mpz_clear(this->shared_secret);
}
- allocator_free(this);
+ free(this);
}
/*
@@ -561,7 +560,7 @@ static void destroy(private_diffie_hellman_t *this)
*/
diffie_hellman_t *diffie_hellman_create(diffie_hellman_group_t dh_group_number)
{
- private_diffie_hellman_t *this = allocator_alloc_thing(private_diffie_hellman_t);
+ private_diffie_hellman_t *this = malloc_thing(private_diffie_hellman_t);
randomizer_t *randomizer;
chunk_t random_bytes;
@@ -587,24 +586,24 @@ diffie_hellman_t *diffie_hellman_create(diffie_hellman_group_t dh_group_number)
/* set this->modulus */
if (this->set_modulus(this) != SUCCESS)
{
- allocator_free(this);
+ free(this);
return NULL;
}
randomizer = randomizer_create();
if (randomizer == NULL)
{
- allocator_free(this);
+ free(this);
return NULL;
}
if (randomizer->allocate_pseudo_random_bytes(randomizer, this->modulus_length, &random_bytes) != SUCCESS)
{
randomizer->destroy(randomizer);
- allocator_free(this);
+ free(this);
return NULL;
}
mpz_import(this->my_private_value, random_bytes.len, 1, 1, 1, 0, random_bytes.ptr);
- allocator_free_chunk(&random_bytes);
+ chunk_free(&random_bytes);
randomizer->destroy(randomizer);
diff --git a/Source/lib/crypto/hashers/md5_hasher.c b/Source/lib/crypto/hashers/md5_hasher.c
index cd883d92c..8d6361139 100644
--- a/Source/lib/crypto/hashers/md5_hasher.c
+++ b/Source/lib/crypto/hashers/md5_hasher.c
@@ -25,10 +25,11 @@
* for more details.
*/
+#include <string.h>
+
#include "md5_hasher.h"
#include <definitions.h>
-#include <utils/allocator.h>
#define BLOCK_SIZE_MD5 16
@@ -334,7 +335,7 @@ static void allocate_hash(private_md5_hasher_t *this, chunk_t chunk, chunk_t *ha
MD5Update(this, chunk.ptr, chunk.len);
if (hash != NULL)
{
- allocated_hash.ptr = allocator_alloc(BLOCK_SIZE_MD5);
+ allocated_hash.ptr = malloc(BLOCK_SIZE_MD5);
allocated_hash.len = BLOCK_SIZE_MD5;
MD5Final(this, allocated_hash.ptr);
@@ -370,7 +371,7 @@ static void reset(private_md5_hasher_t *this)
*/
static void destroy(private_md5_hasher_t *this)
{
- allocator_free(this);
+ free(this);
}
/*
@@ -378,7 +379,7 @@ static void destroy(private_md5_hasher_t *this)
*/
md5_hasher_t *md5_hasher_create()
{
- private_md5_hasher_t *this = allocator_alloc_thing(private_md5_hasher_t);
+ private_md5_hasher_t *this = malloc_thing(private_md5_hasher_t);
this->public.hasher_interface.get_hash = (void (*) (hasher_t*, chunk_t, u_int8_t*))get_hash;
this->public.hasher_interface.allocate_hash = (void (*) (hasher_t*, chunk_t, chunk_t*))allocate_hash;
diff --git a/Source/lib/crypto/hashers/sha1_hasher.c b/Source/lib/crypto/hashers/sha1_hasher.c
index 2fa659f74..b66e75ada 100644
--- a/Source/lib/crypto/hashers/sha1_hasher.c
+++ b/Source/lib/crypto/hashers/sha1_hasher.c
@@ -23,10 +23,11 @@
* for more details.
*/
+#include <string.h>
+
#include "sha1_hasher.h"
#include <definitions.h>
-#include <utils/allocator.h>
#define BLOCK_SIZE_SHA1 20
@@ -208,7 +209,7 @@ static void allocate_hash(private_sha1_hasher_t *this, chunk_t chunk, chunk_t *h
SHA1Update(this, chunk.ptr, chunk.len);
if (hash != NULL)
{
- allocated_hash.ptr = allocator_alloc(BLOCK_SIZE_SHA1);
+ allocated_hash.ptr = malloc(BLOCK_SIZE_SHA1);
allocated_hash.len = BLOCK_SIZE_SHA1;
SHA1Final(this, allocated_hash.ptr);
@@ -244,7 +245,7 @@ static void reset(private_sha1_hasher_t *this)
*/
static void destroy(private_sha1_hasher_t *this)
{
- allocator_free(this);
+ free(this);
}
@@ -253,7 +254,7 @@ static void destroy(private_sha1_hasher_t *this)
*/
sha1_hasher_t *sha1_hasher_create()
{
- private_sha1_hasher_t *this = allocator_alloc_thing(private_sha1_hasher_t);
+ private_sha1_hasher_t *this = malloc_thing(private_sha1_hasher_t);
this->public.hasher_interface.get_hash = (void (*) (hasher_t*, chunk_t, u_int8_t*))get_hash;
this->public.hasher_interface.allocate_hash = (void (*) (hasher_t*, chunk_t, chunk_t*))allocate_hash;
diff --git a/Source/lib/crypto/hmac.c b/Source/lib/crypto/hmac.c
index dc31af3eb..84d6044fd 100644
--- a/Source/lib/crypto/hmac.c
+++ b/Source/lib/crypto/hmac.c
@@ -19,11 +19,10 @@
* for more details.
*/
+#include <string.h>
#include "hmac.h"
-#include <utils/allocator.h>
-
typedef struct private_hmac_t private_hmac_t;
@@ -111,7 +110,7 @@ static void allocate_mac(private_hmac_t *this, chunk_t data, chunk_t *out)
else
{
out->len = this->h->get_block_size(this->h);
- out->ptr = allocator_alloc(out->len);
+ out->ptr = malloc(out->len);
this->hmac.get_mac(&(this->hmac), data, out->ptr);
}
}
@@ -163,9 +162,9 @@ static void set_key(private_hmac_t *this, chunk_t key)
static void destroy(private_hmac_t *this)
{
this->h->destroy(this->h);
- allocator_free(this->opaded_key.ptr);
- allocator_free(this->ipaded_key.ptr);
- allocator_free(this);
+ free(this->opaded_key.ptr);
+ free(this->ipaded_key.ptr);
+ free(this);
}
/*
@@ -175,7 +174,7 @@ hmac_t *hmac_create(hash_algorithm_t hash_algorithm)
{
private_hmac_t *this;
- this = allocator_alloc_thing(private_hmac_t);
+ this = malloc_thing(private_hmac_t);
/* set hmac_t methods */
this->hmac.get_mac = (void (*)(hmac_t *,chunk_t,u_int8_t*))get_mac;
@@ -192,7 +191,7 @@ hmac_t *hmac_create(hash_algorithm_t hash_algorithm)
this->b = 64;
break;
default:
- allocator_free(this);
+ free(this);
return NULL;
}
@@ -200,10 +199,10 @@ hmac_t *hmac_create(hash_algorithm_t hash_algorithm)
this->h = hasher_create(hash_algorithm);
/* build ipad and opad */
- this->opaded_key.ptr = allocator_alloc(this->b);
+ this->opaded_key.ptr = malloc(this->b);
this->opaded_key.len = this->b;
- this->ipaded_key.ptr = allocator_alloc(this->b);
+ this->ipaded_key.ptr = malloc(this->b);
this->ipaded_key.len = this->b;
return &(this->hmac);
diff --git a/Source/lib/crypto/prf_plus.c b/Source/lib/crypto/prf_plus.c
index f0f4a11c6..d408d0517 100644
--- a/Source/lib/crypto/prf_plus.c
+++ b/Source/lib/crypto/prf_plus.c
@@ -20,10 +20,10 @@
* for more details.
*/
+#include <string.h>
#include "prf_plus.h"
-#include <utils/allocator.h>
#include <definitions.h>
typedef struct private_prf_plus_t private_prf_plus_t;
@@ -102,7 +102,7 @@ static void get_bytes(private_prf_plus_t *this, size_t length, u_int8_t *buffer)
*/
static void allocate_bytes(private_prf_plus_t *this, size_t length, chunk_t *chunk)
{
- chunk->ptr = allocator_alloc(length);
+ chunk->ptr = malloc(length);
chunk->len = length;
this->public.get_bytes(&(this->public), length, chunk->ptr);
}
@@ -112,9 +112,9 @@ static void allocate_bytes(private_prf_plus_t *this, size_t length, chunk_t *chu
*/
static void destroy(private_prf_plus_t *this)
{
- allocator_free(this->buffer.ptr);
- allocator_free(this->seed.ptr);
- allocator_free(this);
+ free(this->buffer.ptr);
+ free(this->seed.ptr);
+ free(this);
}
/*
@@ -125,7 +125,7 @@ prf_plus_t *prf_plus_create(prf_t *prf, chunk_t seed)
private_prf_plus_t *this;
chunk_t appending_chunk;
- this = allocator_alloc_thing(private_prf_plus_t);
+ this = malloc_thing(private_prf_plus_t);
/* set public methods */
this->public.get_bytes = (void (*)(prf_plus_t *,size_t,u_int8_t*))get_bytes;
@@ -137,12 +137,12 @@ prf_plus_t *prf_plus_create(prf_t *prf, chunk_t seed)
/* allocate buffer for prf output */
this->buffer.len = prf->get_block_size(prf);
- this->buffer.ptr = allocator_alloc(this->buffer.len);
+ this->buffer.ptr = malloc(this->buffer.len);
this->appending_octet = 0x01;
/* clone seed */
- this->seed.ptr = allocator_clone_bytes(seed.ptr, seed.len);
+ this->seed.ptr = clalloc(seed.ptr, seed.len);
this->seed.len = seed.len;
/* do the first run */
diff --git a/Source/lib/crypto/prfs/hmac_prf.c b/Source/lib/crypto/prfs/hmac_prf.c
index 2ea0869f7..2a7d34a3a 100644
--- a/Source/lib/crypto/prfs/hmac_prf.c
+++ b/Source/lib/crypto/prfs/hmac_prf.c
@@ -22,7 +22,6 @@
#include "hmac_prf.h"
-#include <utils/allocator.h>
#include <crypto/hmac.h>
@@ -89,7 +88,7 @@ static void set_key(private_hmac_prf_t *this, chunk_t key)
*/
static void destroy(private_hmac_prf_t *this)
{
- allocator_free(this);
+ free(this);
this->hmac->destroy(this->hmac);
}
@@ -98,7 +97,7 @@ static void destroy(private_hmac_prf_t *this)
*/
hmac_prf_t *hmac_prf_create(hash_algorithm_t hash_algorithm)
{
- private_hmac_prf_t *this = allocator_alloc_thing(private_hmac_prf_t);
+ private_hmac_prf_t *this = malloc_thing(private_hmac_prf_t);
this->public.prf_interface.get_bytes = (void (*) (prf_t *,chunk_t,u_int8_t*))get_bytes;
this->public.prf_interface.allocate_bytes = (void (*) (prf_t*,chunk_t,chunk_t*))allocate_bytes;
@@ -110,7 +109,7 @@ hmac_prf_t *hmac_prf_create(hash_algorithm_t hash_algorithm)
this->hmac = hmac_create(hash_algorithm);
if (this->hmac == NULL)
{
- allocator_free(this);
+ free(this);
return NULL;
}
diff --git a/Source/lib/crypto/rsa/rsa_private_key.c b/Source/lib/crypto/rsa/rsa_private_key.c
index 0afadd179..879cade26 100644
--- a/Source/lib/crypto/rsa/rsa_private_key.c
+++ b/Source/lib/crypto/rsa/rsa_private_key.c
@@ -23,11 +23,11 @@
#include <gmp.h>
#include <sys/stat.h>
#include <unistd.h>
+#include <string.h>
#include "rsa_private_key.h"
#include <daemon.h>
-#include <utils/allocator.h>
#include <asn1/der_decoder.h>
@@ -188,7 +188,7 @@ static status_t compute_prime(private_rsa_private_key_t *this, size_t prime_size
/* get next prime */
mpz_nextprime (*prime, *prime);
- allocator_free(random_bytes.ptr);
+ free(random_bytes.ptr);
}
/* check if it isnt too large */
while (((mpz_sizeinbase(*prime, 2) + 7) / 8) > prime_size);
@@ -301,7 +301,7 @@ static status_t build_emsa_pkcs1_signature(private_rsa_private_key_t *this, hash
* T = oid || hash
*/
em.len = this->k;
- em.ptr = allocator_alloc(em.len);
+ em.ptr = malloc(em.len);
/* fill em with padding */
memset(em.ptr, 0xFF, em.len);
@@ -318,8 +318,8 @@ static status_t build_emsa_pkcs1_signature(private_rsa_private_key_t *this, hash
/* build signature */
*signature = this->rsasp1(this, em);
- allocator_free(hash.ptr);
- allocator_free(em.ptr);
+ free(hash.ptr);
+ free(em.ptr);
return SUCCESS;
}
@@ -349,7 +349,7 @@ static status_t get_key(private_rsa_private_key_t *this, chunk_t *key)
coeff.ptr = mpz_export(NULL, NULL, 1, coeff.len, 1, 0, this->coeff);
key->len = this->k * 8;
- key->ptr = allocator_alloc(key->len);
+ key->ptr = malloc(key->len);
memcpy(key->ptr + this->k * 0, n.ptr , n.len);
memcpy(key->ptr + this->k * 1, e.ptr, e.len);
memcpy(key->ptr + this->k * 2, p.ptr, p.len);
@@ -359,14 +359,14 @@ static status_t get_key(private_rsa_private_key_t *this, chunk_t *key)
memcpy(key->ptr + this->k * 6, exp2.ptr, exp2.len);
memcpy(key->ptr + this->k * 7, coeff.ptr, coeff.len);
- allocator_free(n.ptr);
- allocator_free(e.ptr);
- allocator_free(p.ptr);
- allocator_free(q.ptr);
- allocator_free(d.ptr);
- allocator_free(exp1.ptr);
- allocator_free(exp2.ptr);
- allocator_free(coeff.ptr);
+ free(n.ptr);
+ free(e.ptr);
+ free(p.ptr);
+ free(q.ptr);
+ free(d.ptr);
+ free(exp1.ptr);
+ free(exp2.ptr);
+ free(coeff.ptr);
return SUCCESS;
}
@@ -432,7 +432,7 @@ static void destroy(private_rsa_private_key_t *this)
mpz_clear(this->exp1);
mpz_clear(this->exp2);
mpz_clear(this->coeff);
- allocator_free(this);
+ free(this);
}
/**
@@ -440,7 +440,7 @@ static void destroy(private_rsa_private_key_t *this)
*/
static private_rsa_private_key_t *rsa_private_key_create_empty()
{
- private_rsa_private_key_t *this = allocator_alloc_thing(private_rsa_private_key_t);
+ private_rsa_private_key_t *this = malloc_thing(private_rsa_private_key_t);
/* public functions */
this->public.build_emsa_pkcs1_signature = (status_t (*) (rsa_private_key_t*,hash_algorithm_t,chunk_t,chunk_t*))build_emsa_pkcs1_signature;
@@ -474,13 +474,13 @@ rsa_private_key_t *rsa_private_key_create(size_t key_size)
/* Get values of primes p and q */
if (this->compute_prime(this, key_size/2, &p) != SUCCESS)
{
- allocator_free(this);
+ free(this);
return NULL;
}
if (this->compute_prime(this, key_size/2, &q) != SUCCESS)
{
mpz_clear(p);
- allocator_free(this);
+ free(this);
return NULL;
}
@@ -605,8 +605,10 @@ rsa_private_key_t *rsa_private_key_create_from_file(char *filename, char *passph
if (fread(buffer, stb.st_size, 1, file) != 1)
{
+ fclose(file);
return NULL;
}
+ fclose(file);
chunk.ptr = buffer;
chunk.len = stb.st_size;
diff --git a/Source/lib/crypto/rsa/rsa_public_key.c b/Source/lib/crypto/rsa/rsa_public_key.c
index 57ad10128..5b85f5256 100644
--- a/Source/lib/crypto/rsa/rsa_public_key.c
+++ b/Source/lib/crypto/rsa/rsa_public_key.c
@@ -23,11 +23,11 @@
#include <gmp.h>
#include <sys/stat.h>
#include <unistd.h>
+#include <string.h>
#include "rsa_public_key.h"
#include <daemon.h>
-#include <utils/allocator.h>
#include <crypto/hashers/hasher.h>
#include <asn1/der_decoder.h>
@@ -215,7 +215,7 @@ static status_t verify_emsa_pkcs1_signature(private_rsa_public_key_t *this, chun
if ((*(em.ptr) != 0x00) ||
(*(em.ptr+1) != 0x01))
{
- allocator_free(em.ptr);
+ free(em.ptr);
return FAILED;
}
@@ -232,7 +232,7 @@ static status_t verify_emsa_pkcs1_signature(private_rsa_public_key_t *this, chun
else if (*pos != 0xFF)
{
/* bad padding, decryption failed ?!*/
- allocator_free(em.ptr);
+ free(em.ptr);
return FAILED;
}
pos++;
@@ -241,7 +241,7 @@ static status_t verify_emsa_pkcs1_signature(private_rsa_public_key_t *this, chun
if (pos + 20 > em.ptr + em.len)
{
/* not enought room for oid compare */
- allocator_free(em.ptr);
+ free(em.ptr);
return FAILED;
}
@@ -279,14 +279,14 @@ static status_t verify_emsa_pkcs1_signature(private_rsa_public_key_t *this, chun
if (hasher == NULL)
{
/* not supported hash algorithm */
- allocator_free(em.ptr);
+ free(em.ptr);
return NOT_SUPPORTED;
}
if (pos + hasher->get_block_size(hasher) != em.ptr + em.len)
{
/* bad length */
- allocator_free(em.ptr);
+ free(em.ptr);
hasher->destroy(hasher);
return FAILED;
}
@@ -298,15 +298,15 @@ static status_t verify_emsa_pkcs1_signature(private_rsa_public_key_t *this, chun
if (memcmp(hash.ptr, pos, hash.len) != 0)
{
/* hash does not equal */
- allocator_free(hash.ptr);
- allocator_free(em.ptr);
+ free(hash.ptr);
+ free(em.ptr);
return FAILED;
}
/* seems good */
- allocator_free(hash.ptr);
- allocator_free(em.ptr);
+ free(hash.ptr);
+ free(em.ptr);
return SUCCESS;
}
@@ -323,11 +323,11 @@ static status_t get_key(private_rsa_public_key_t *this, chunk_t *key)
e.ptr = mpz_export(NULL, NULL, 1, e.len, 1, 0, this->e);
key->len = this->k * 2;
- key->ptr = allocator_alloc(key->len);
+ key->ptr = malloc(key->len);
memcpy(key->ptr, n.ptr, n.len);
memcpy(key->ptr + n.len, e.ptr, e.len);
- allocator_free(n.ptr);
- allocator_free(e.ptr);
+ free(n.ptr);
+ free(e.ptr);
return SUCCESS;
}
@@ -369,7 +369,7 @@ static void destroy(private_rsa_public_key_t *this)
{
mpz_clear(this->n);
mpz_clear(this->e);
- allocator_free(this);
+ free(this);
}
/**
@@ -377,7 +377,7 @@ static void destroy(private_rsa_public_key_t *this)
*/
private_rsa_public_key_t *rsa_public_key_create_empty()
{
- private_rsa_public_key_t *this = allocator_alloc_thing(private_rsa_public_key_t);
+ private_rsa_public_key_t *this = malloc_thing(private_rsa_public_key_t);
/* public functions */
this->public.verify_emsa_pkcs1_signature = (status_t (*) (rsa_public_key_t*,chunk_t,chunk_t))verify_emsa_pkcs1_signature;
@@ -458,11 +458,11 @@ rsa_public_key_t *rsa_public_key_create_from_file(char *filename)
dd = der_decoder_create(rsa_public_key_info_rules);
status = dd->decode(dd, chunk, &key_info);
dd->destroy(dd);
- allocator_free_chunk(&key_info.algorithm_oid);
+ chunk_free(&key_info.algorithm_oid);
if (status == SUCCESS)
{
public_key = rsa_public_key_create_from_chunk(chunk);
}
- allocator_free_chunk(&key_info.public_key);
+ chunk_free(&key_info.public_key);
return public_key;
}
diff --git a/Source/lib/crypto/signers/hmac_signer.c b/Source/lib/crypto/signers/hmac_signer.c
index e4311da1b..cb7d08244 100644
--- a/Source/lib/crypto/signers/hmac_signer.c
+++ b/Source/lib/crypto/signers/hmac_signer.c
@@ -20,9 +20,10 @@
* for more details.
*/
+#include <string.h>
+
#include "hmac_signer.h"
-#include <utils/allocator.h>
#include <crypto/prfs/hmac_prf.h>
/**
@@ -70,7 +71,7 @@ static void allocate_signature (private_hmac_signer_t *this, chunk_t data, chunk
this->hmac_prf->get_bytes(this->hmac_prf,data,full_mac);
- signature.ptr = allocator_alloc(BLOCK_SIZE);
+ signature.ptr = malloc(BLOCK_SIZE);
signature.len = BLOCK_SIZE;
/* copy signature */
@@ -135,7 +136,7 @@ static void set_key (private_hmac_signer_t *this, chunk_t key)
static status_t destroy(private_hmac_signer_t *this)
{
this->hmac_prf->destroy(this->hmac_prf);
- allocator_free(this);
+ free(this);
return SUCCESS;
}
@@ -144,14 +145,14 @@ static status_t destroy(private_hmac_signer_t *this)
*/
hmac_signer_t *hmac_signer_create(hash_algorithm_t hash_algoritm)
{
- private_hmac_signer_t *this = allocator_alloc_thing(private_hmac_signer_t);
+ private_hmac_signer_t *this = malloc_thing(private_hmac_signer_t);
this->hmac_prf = (prf_t *) hmac_prf_create(hash_algoritm);
if (this->hmac_prf == NULL)
{
/* algorithm not supported */
- allocator_free(this);
+ free(this);
return NULL;
}