Rename alloc functions to comply with library name.
diff --git a/crypto/cipher/aes_gcm_ossl.c b/crypto/cipher/aes_gcm_ossl.c
index b4009f6..c352563 100644
--- a/crypto/cipher/aes_gcm_ossl.c
+++ b/crypto/cipher/aes_gcm_ossl.c
@@ -106,7 +106,7 @@
/* allocate memory a cipher of type aes_gcm */
tmp = sizeof(cipher_t) + sizeof(srtp_aes_gcm_ctx_t);
- allptr = crypto_alloc(tmp);
+ allptr = srtp_crypto_alloc(tmp);
if (allptr == NULL) {
return (srtp_err_status_alloc_fail);
}
@@ -156,7 +156,7 @@
octet_string_set_to_zero((uint8_t*)c, sizeof(cipher_t) + sizeof(srtp_aes_gcm_ctx_t));
/* free memory */
- crypto_free(c);
+ srtp_crypto_free(c);
return (srtp_err_status_ok);
}
diff --git a/crypto/cipher/aes_icm.c b/crypto/cipher/aes_icm.c
index 79d59ae..c05e53b 100644
--- a/crypto/cipher/aes_icm.c
+++ b/crypto/cipher/aes_icm.c
@@ -116,7 +116,7 @@
/* allocate memory a cipher of type aes_icm */
tmp = (sizeof(aes_icm_ctx_t) + sizeof(cipher_t));
- pointer = (uint8_t*)crypto_alloc(tmp);
+ pointer = (uint8_t*)srtp_crypto_alloc(tmp);
if (pointer == NULL) {
return srtp_err_status_alloc_fail;
}
@@ -155,7 +155,7 @@
sizeof(aes_icm_ctx_t) + sizeof(cipher_t));
/* free memory */
- crypto_free(c);
+ srtp_crypto_free(c);
return srtp_err_status_ok;
}
diff --git a/crypto/cipher/aes_icm_ossl.c b/crypto/cipher/aes_icm_ossl.c
index c32b1a4..990bdc4 100644
--- a/crypto/cipher/aes_icm_ossl.c
+++ b/crypto/cipher/aes_icm_ossl.c
@@ -128,7 +128,7 @@
/* allocate memory a cipher of type aes_icm */
tmp = sizeof(cipher_t) + sizeof(srtp_aes_icm_ctx_t);
- allptr = (uint8_t*)crypto_alloc(tmp);
+ allptr = (uint8_t*)srtp_crypto_alloc(tmp);
if (allptr == NULL) {
return srtp_err_status_alloc_fail;
}
@@ -189,7 +189,7 @@
sizeof(cipher_t) + sizeof(srtp_aes_icm_ctx_t));
/* free memory */
- crypto_free(c);
+ srtp_crypto_free(c);
return srtp_err_status_ok;
}
diff --git a/crypto/cipher/cipher.c b/crypto/cipher/cipher.c
index 9f533ac..84325d2 100644
--- a/crypto/cipher/cipher.c
+++ b/crypto/cipher/cipher.c
@@ -488,7 +488,7 @@
unsigned char *enc_buf;
unsigned int len = octets_in_buffer;
- enc_buf = (unsigned char*) crypto_alloc(octets_in_buffer);
+ enc_buf = (unsigned char*) srtp_crypto_alloc(octets_in_buffer);
if (enc_buf == NULL)
return 0; /* indicate bad parameters by returning null */
@@ -501,7 +501,7 @@
}
timer = clock() - timer;
- crypto_free(enc_buf);
+ srtp_crypto_free(enc_buf);
if (timer == 0) {
/* Too fast! */
diff --git a/crypto/cipher/null_cipher.c b/crypto/cipher/null_cipher.c
index 6fcb365..065f924 100644
--- a/crypto/cipher/null_cipher.c
+++ b/crypto/cipher/null_cipher.c
@@ -65,7 +65,7 @@
"allocating cipher with key length %d", key_len);
/* allocate memory a cipher of type null_cipher */
- pointer = (uint8_t*)crypto_alloc(sizeof(null_cipher_ctx_t) + sizeof(cipher_t));
+ pointer = (uint8_t*)srtp_crypto_alloc(sizeof(null_cipher_ctx_t) + sizeof(cipher_t));
if (pointer == NULL)
return srtp_err_status_alloc_fail;
@@ -91,7 +91,7 @@
sizeof(null_cipher_ctx_t) + sizeof(cipher_t));
/* free memory of type null_cipher */
- crypto_free(c);
+ srtp_crypto_free(c);
return srtp_err_status_ok;
diff --git a/crypto/hash/hmac.c b/crypto/hash/hmac.c
index 8946f7f..51f6a50 100644
--- a/crypto/hash/hmac.c
+++ b/crypto/hash/hmac.c
@@ -77,7 +77,7 @@
return srtp_err_status_bad_param;
/* allocate memory for auth and hmac_ctx_t structures */
- pointer = (uint8_t*)crypto_alloc(sizeof(hmac_ctx_t) + sizeof(auth_t));
+ pointer = (uint8_t*)srtp_crypto_alloc(sizeof(hmac_ctx_t) + sizeof(auth_t));
if (pointer == NULL)
return srtp_err_status_alloc_fail;
@@ -101,7 +101,7 @@
sizeof(hmac_ctx_t) + sizeof(auth_t));
/* free memory */
- crypto_free(a);
+ srtp_crypto_free(a);
return srtp_err_status_ok;
}
diff --git a/crypto/hash/hmac_ossl.c b/crypto/hash/hmac_ossl.c
index 72b9d81..d599301 100644
--- a/crypto/hash/hmac_ossl.c
+++ b/crypto/hash/hmac_ossl.c
@@ -84,7 +84,7 @@
}
/* allocate memory for auth and hmac_ctx_t structures */
- pointer = (uint8_t*)crypto_alloc(sizeof(hmac_ctx_t) + sizeof(auth_t));
+ pointer = (uint8_t*)srtp_crypto_alloc(sizeof(hmac_ctx_t) + sizeof(auth_t));
if (pointer == NULL) {
return srtp_err_status_alloc_fail;
}
@@ -121,7 +121,7 @@
sizeof(hmac_ctx_t) + sizeof(auth_t));
/* free memory */
- crypto_free(a);
+ srtp_crypto_free(a);
return srtp_err_status_ok;
}
diff --git a/crypto/hash/null_auth.c b/crypto/hash/null_auth.c
index 26032d7..cb9e05c 100644
--- a/crypto/hash/null_auth.c
+++ b/crypto/hash/null_auth.c
@@ -64,7 +64,7 @@
debug_print(mod_auth, " tag length %d", out_len);
/* allocate memory for auth and null_auth_ctx_t structures */
- pointer = (uint8_t*)crypto_alloc(sizeof(null_auth_ctx_t) + sizeof(auth_t));
+ pointer = (uint8_t*)srtp_crypto_alloc(sizeof(null_auth_ctx_t) + sizeof(auth_t));
if (pointer == NULL)
return srtp_err_status_alloc_fail;
@@ -88,7 +88,7 @@
sizeof(null_auth_ctx_t) + sizeof(auth_t));
/* free memory */
- crypto_free(a);
+ srtp_crypto_free(a);
return srtp_err_status_ok;
}
diff --git a/crypto/include/alloc.h b/crypto/include/alloc.h
index 5980eed..7190e1e 100644
--- a/crypto/include/alloc.h
+++ b/crypto/include/alloc.h
@@ -48,10 +48,8 @@
#include "datatypes.h"
-void *
-crypto_alloc(size_t size);
+void * srtp_crypto_alloc(size_t size);
-void
-crypto_free(void *ptr);
+void srtp_crypto_free(void *ptr);
#endif /* CRYPTO_ALLOC_H */
diff --git a/crypto/kernel/alloc.c b/crypto/kernel/alloc.c
index e728798..623b212 100644
--- a/crypto/kernel/alloc.c
+++ b/crypto/kernel/alloc.c
@@ -57,8 +57,8 @@
};
/*
- * Nota bene: the debugging statements for crypto_alloc() and
- * crypto_free() have identical prefixes, which include the addresses
+ * Nota bene: the debugging statements for srtp_crypto_alloc() and
+ * srtp_crypto_free() have identical prefixes, which include the addresses
* of the memory locations on which they are operating. This fact can
* be used to locate memory leaks, by turning on memory debugging,
* grepping for 'alloc', then matching alloc and free calls by
@@ -69,8 +69,7 @@
#include <linux/interrupt.h>
-void *
-crypto_alloc(size_t size) {
+void * srtp_crypto_alloc(size_t size) {
void *ptr;
ptr = kmalloc(size, in_interrupt() ? GFP_ATOMIC : GFP_KERNEL);
@@ -84,8 +83,7 @@
return ptr;
}
-void
-crypto_free(void *ptr) {
+void srtp_crypto_free(void *ptr) {
debug_print(mod_alloc, "(location: %p) freed", ptr);
@@ -95,8 +93,7 @@
#elif defined(HAVE_STDLIB_H)
-void *
-crypto_alloc(size_t size) {
+void * srtp_crypto_alloc(size_t size) {
void *ptr;
ptr = malloc(size);
@@ -110,8 +107,7 @@
return ptr;
}
-void
-crypto_free(void *ptr) {
+void srtp_crypto_free(void *ptr) {
debug_print(mod_alloc, "(location: %p) freed", ptr);
diff --git a/crypto/kernel/crypto_kernel.c b/crypto/kernel/crypto_kernel.c
index 72979b5..7e85819 100644
--- a/crypto/kernel/crypto_kernel.c
+++ b/crypto/kernel/crypto_kernel.c
@@ -266,7 +266,7 @@
debug_print(mod_crypto_kernel,
"freeing memory for cipher %s",
ctype->cipher_type->description);
- crypto_free(ctype);
+ srtp_crypto_free(ctype);
}
/* walk down authetication module list, freeing memory */
@@ -276,7 +276,7 @@
debug_print(mod_crypto_kernel,
"freeing memory for authentication %s",
atype->auth_type->description);
- crypto_free(atype);
+ srtp_crypto_free(atype);
}
/* walk down debug module list, freeing memory */
@@ -286,7 +286,7 @@
debug_print(mod_crypto_kernel,
"freeing memory for debug module %s",
kdm->mod->name);
- crypto_free(kdm);
+ srtp_crypto_free(kdm);
}
/* de-initialize random number generator */ status = rand_source_deinit();
@@ -338,7 +338,7 @@
/* if not found, put new_ct at the head of the list */
if (ctype == NULL) {
/* allocate memory */
- new_ctype = (kernel_cipher_type_t *) crypto_alloc(sizeof(kernel_cipher_type_t));
+ new_ctype = (kernel_cipher_type_t *) srtp_crypto_alloc(sizeof(kernel_cipher_type_t));
if (new_ctype == NULL)
return srtp_err_status_alloc_fail;
new_ctype->next = crypto_kernel.cipher_type_list;
@@ -408,7 +408,7 @@
/* if not found, put new_at at the head of the list */
if (atype == NULL) {
/* allocate memory */
- new_atype = (kernel_auth_type_t *)crypto_alloc(sizeof(kernel_auth_type_t));
+ new_atype = (kernel_auth_type_t *)srtp_crypto_alloc(sizeof(kernel_auth_type_t));
if (new_atype == NULL)
return srtp_err_status_alloc_fail;
@@ -536,7 +536,7 @@
/* put new_dm at the head of the list */
/* allocate memory */
- new = (kernel_debug_module_t *)crypto_alloc(sizeof(kernel_debug_module_t));
+ new = (kernel_debug_module_t *)srtp_crypto_alloc(sizeof(kernel_debug_module_t));
if (new == NULL)
return srtp_err_status_alloc_fail;
diff --git a/crypto/math/datatypes.c b/crypto/math/datatypes.c
index cbe8f69..2ec1a71 100644
--- a/crypto/math/datatypes.c
+++ b/crypto/math/datatypes.c
@@ -360,7 +360,7 @@
if (l == 0)
v->word = NULL;
else {
- v->word = (uint32_t*)crypto_alloc(l);
+ v->word = (uint32_t*)srtp_crypto_alloc(l);
if (v->word == NULL) {
v->word = NULL;
v->length = 0;
@@ -379,7 +379,7 @@
void
bitvector_dealloc(bitvector_t *v) {
if (v->word != NULL)
- crypto_free(v->word);
+ srtp_crypto_free(v->word);
v->word = NULL;
v->length = 0;
}
diff --git a/crypto/test/auth_driver.c b/crypto/test/auth_driver.c
index cd8a75d..37833ce 100644
--- a/crypto/test/auth_driver.c
+++ b/crypto/test/auth_driver.c
@@ -163,8 +163,7 @@
#include <time.h>
-double
-auth_bits_per_second(auth_t *a, int msg_len_octets) {
+double auth_bits_per_second(auth_t *a, int msg_len_octets) {
int i;
clock_t timer;
uint8_t *result;
@@ -172,16 +171,16 @@
uint16_t *msg_string;
/* create random message */
- msg_string = (uint16_t *) crypto_alloc(msg_len_octets);
+ msg_string = (uint16_t *) srtp_crypto_alloc(msg_len_octets);
if (msg_string == NULL)
return 0.0; /* indicate failure */
for (i=0; i < msg_len; i++)
msg_string[i] = (uint16_t) random();
/* allocate temporary storage for authentication tag */
- result = crypto_alloc(auth_get_tag_length(a));
+ result = srtp_crypto_alloc(auth_get_tag_length(a));
if (result == NULL) {
- free(msg_string);
+ srtp_crypto_free(msg_string);
return 0.0; /* indicate failure */
}
@@ -191,8 +190,8 @@
}
timer = clock() - timer;
- free(msg_string);
- free(result);
+ srtp_crypto_free(msg_string);
+ srtp_crypto_free(result);
return (double) NUM_TRIALS * 8 * msg_len_octets * CLOCKS_PER_SEC / timer;
}
diff --git a/crypto/test/cipher_driver.c b/crypto/test/cipher_driver.c
index 90646e6..5c9decd 100644
--- a/crypto/test/cipher_driver.c
+++ b/crypto/test/cipher_driver.c
@@ -463,7 +463,7 @@
*ca = cipher_array;
/* allocate key */
- key = crypto_alloc(klen_pad);
+ key = srtp_crypto_alloc(klen_pad);
if (key == NULL) {
free(cipher_array);
return srtp_err_status_alloc_fail;
@@ -494,7 +494,7 @@
cipher_array++;
}
- crypto_free(key);
+ srtp_crypto_free(key);
return srtp_err_status_ok;
}
@@ -535,7 +535,7 @@
int cipher_index = rand() % num_cipher;
/* Over-alloc, for NIST CBC padding */
- enc_buf = crypto_alloc(octets_in_buffer+17);
+ enc_buf = srtp_crypto_alloc(octets_in_buffer+17);
if (enc_buf == NULL)
return 0; /* indicate bad parameters by returning null */
memset(enc_buf, 0, octets_in_buffer);
diff --git a/srtp/srtp.c b/srtp/srtp.c
index aebd5e4..94bd3b6 100644
--- a/srtp/srtp.c
+++ b/srtp/srtp.c
@@ -47,7 +47,7 @@
#include "crypto_types.h"
#include "err.h"
#include "ekt.h" /* for SRTP Encrypted Key Transport */
-#include "alloc.h" /* for crypto_alloc() */
+#include "alloc.h" /* for srtp_crypto_alloc() */
#ifdef OPENSSL
#include "aes_gcm_ossl.h" /* for AES GCM mode */
#endif
@@ -128,7 +128,7 @@
*/
/* allocate srtp stream and set str_ptr */
- str = (srtp_stream_ctx_t *) crypto_alloc(sizeof(srtp_stream_ctx_t));
+ str = (srtp_stream_ctx_t *) srtp_crypto_alloc(sizeof(srtp_stream_ctx_t));
if (str == NULL)
return srtp_err_status_alloc_fail;
*str_ptr = str;
@@ -139,7 +139,7 @@
p->rtp.cipher_key_len,
p->rtp.auth_tag_len);
if (stat) {
- crypto_free(str);
+ srtp_crypto_free(str);
return stat;
}
@@ -150,16 +150,16 @@
p->rtp.auth_tag_len);
if (stat) {
cipher_dealloc(str->rtp_cipher);
- crypto_free(str);
+ srtp_crypto_free(str);
return stat;
}
/* allocate key limit structure */
- str->limit = (key_limit_ctx_t*) crypto_alloc(sizeof(key_limit_ctx_t));
+ str->limit = (key_limit_ctx_t*) srtp_crypto_alloc(sizeof(key_limit_ctx_t));
if (str->limit == NULL) {
auth_dealloc(str->rtp_auth);
cipher_dealloc(str->rtp_cipher);
- crypto_free(str);
+ srtp_crypto_free(str);
return srtp_err_status_alloc_fail;
}
@@ -174,8 +174,8 @@
if (stat) {
auth_dealloc(str->rtp_auth);
cipher_dealloc(str->rtp_cipher);
- crypto_free(str->limit);
- crypto_free(str);
+ srtp_crypto_free(str->limit);
+ srtp_crypto_free(str);
return stat;
}
@@ -188,8 +188,8 @@
cipher_dealloc(str->rtcp_cipher);
auth_dealloc(str->rtp_auth);
cipher_dealloc(str->rtp_cipher);
- crypto_free(str->limit);
- crypto_free(str);
+ srtp_crypto_free(str->limit);
+ srtp_crypto_free(str);
return stat;
}
@@ -200,8 +200,8 @@
cipher_dealloc(str->rtcp_cipher);
auth_dealloc(str->rtp_auth);
cipher_dealloc(str->rtp_cipher);
- crypto_free(str->limit);
- crypto_free(str);
+ srtp_crypto_free(str->limit);
+ srtp_crypto_free(str);
return stat;
}
@@ -243,7 +243,7 @@
&& stream->limit == session->stream_template->limit) {
/* do nothing */
} else {
- crypto_free(stream->limit);
+ srtp_crypto_free(stream->limit);
}
/*
@@ -286,7 +286,7 @@
/* deallocate srtp stream context */
- crypto_free(stream);
+ srtp_crypto_free(stream);
return srtp_err_status_ok;
}
@@ -310,7 +310,7 @@
debug_print(mod_srtp, "cloning stream (SSRC: 0x%08x)", ssrc);
/* allocate srtp stream and set str_ptr */
- str = (srtp_stream_ctx_t *) crypto_alloc(sizeof(srtp_stream_ctx_t));
+ str = (srtp_stream_ctx_t *) srtp_crypto_alloc(sizeof(srtp_stream_ctx_t));
if (str == NULL)
return srtp_err_status_alloc_fail;
*str_ptr = str;
@@ -324,7 +324,7 @@
/* set key limit to point to that of the template */
status = key_limit_clone(stream_template->limit, &str->limit);
if (status) {
- crypto_free(*str_ptr);
+ srtp_crypto_free(*str_ptr);
*str_ptr = NULL;
return status;
}
@@ -333,7 +333,7 @@
status = rdbx_init(&str->rtp_rdbx,
rdbx_get_window_size(&stream_template->rtp_rdbx));
if (status) {
- crypto_free(*str_ptr);
+ srtp_crypto_free(*str_ptr);
*str_ptr = NULL;
return status;
}
@@ -1813,7 +1813,7 @@
status = cipher_dealloc(session->stream_template->rtcp_cipher);
if (status)
return status;
- crypto_free(session->stream_template->limit);
+ srtp_crypto_free(session->stream_template->limit);
status = cipher_dealloc(session->stream_template->rtp_cipher);
if (status)
return status;
@@ -1823,11 +1823,11 @@
status = rdbx_dealloc(&session->stream_template->rtp_rdbx);
if (status)
return status;
- crypto_free(session->stream_template);
+ srtp_crypto_free(session->stream_template);
}
/* deallocate session context */
- crypto_free(session);
+ srtp_crypto_free(session);
return srtp_err_status_ok;
}
@@ -1852,7 +1852,7 @@
/* initialize stream */
status = srtp_stream_init(tmp, policy);
if (status) {
- crypto_free(tmp);
+ srtp_crypto_free(tmp);
return status;
}
@@ -1885,7 +1885,7 @@
break;
case (ssrc_undefined):
default:
- crypto_free(tmp);
+ srtp_crypto_free(tmp);
return srtp_err_status_bad_param;
}
@@ -1904,7 +1904,7 @@
return srtp_err_status_bad_param;
/* allocate srtp context and set ctx_ptr */
- ctx = (srtp_ctx_t *) crypto_alloc(sizeof(srtp_ctx_t));
+ ctx = (srtp_ctx_t *) srtp_crypto_alloc(sizeof(srtp_ctx_t));
if (ctx == NULL)
return srtp_err_status_alloc_fail;
*session = ctx;