summaryrefslogtreecommitdiffstats
path: root/src/methods
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2014-08-02 00:53:47 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2014-08-02 00:53:47 +0200
commit546ac7936340312cf272969ff83317ae4d50d2b4 (patch)
tree7ecadca11430c8624d9f80aae7c348fa4d65b969 /src/methods
parentb22364f4af3564f0dd9a5f4e150bb09747bd5c4e (diff)
downloadfastd-546ac7936340312cf272969ff83317ae4d50d2b4.tar
fastd-546ac7936340312cf272969ff83317ae4d50d2b4.zip
Introduce and use alloc helpers
These new helpers will terminate fastd on allocation failures and add some additional convenience (allow strdup with NULL; typesafe new(type) macros).
Diffstat (limited to 'src/methods')
-rw-r--r--src/methods/cipher_test/cipher_test.c4
-rw-r--r--src/methods/composed_gmac/composed_gmac.c4
-rw-r--r--src/methods/generic_gmac/generic_gmac.c4
-rw-r--r--src/methods/generic_poly1305/generic_poly1305.c4
-rw-r--r--src/methods/null/null.c2
-rw-r--r--src/methods/xsalsa20_poly1305/xsalsa20_poly1305.c2
6 files changed, 10 insertions, 10 deletions
diff --git a/src/methods/cipher_test/cipher_test.c b/src/methods/cipher_test/cipher_test.c
index 7e064ba..277671a 100644
--- a/src/methods/cipher_test/cipher_test.c
+++ b/src/methods/cipher_test/cipher_test.c
@@ -72,7 +72,7 @@ static bool method_create_by_name(const char *name, fastd_method_t **method) {
if (!m.cipher_info)
return false;
- *method = malloc(sizeof(fastd_method_t));
+ *method = fastd_new(fastd_method_t);
**method = m;
return true;
@@ -90,7 +90,7 @@ static size_t method_key_length(const fastd_method_t *method) {
/** Initializes a session */
static fastd_method_session_state_t* method_session_init(const fastd_method_t *method, const uint8_t *secret, bool initiator) {
- fastd_method_session_state_t *session = malloc(sizeof(fastd_method_session_state_t));
+ fastd_method_session_state_t *session = fastd_new(fastd_method_session_state_t);
fastd_method_common_init(&session->common, initiator);
session->method = method;
diff --git a/src/methods/composed_gmac/composed_gmac.c b/src/methods/composed_gmac/composed_gmac.c
index 6636e49..ead3cb0 100644
--- a/src/methods/composed_gmac/composed_gmac.c
+++ b/src/methods/composed_gmac/composed_gmac.c
@@ -115,7 +115,7 @@ static bool method_create_by_name(const char *name, fastd_method_t **method) {
if (m.gmac_cipher_info->iv_length <= COMMON_NONCEBYTES)
return false;
- *method = malloc(sizeof(fastd_method_t));
+ *method = fastd_new(fastd_method_t);
**method = m;
return true;
@@ -133,7 +133,7 @@ static size_t method_key_length(const fastd_method_t *method) {
/** Initializes a session */
static fastd_method_session_state_t* method_session_init(const fastd_method_t *method, const uint8_t *secret, bool initiator) {
- fastd_method_session_state_t *session = malloc(sizeof(fastd_method_session_state_t));
+ fastd_method_session_state_t *session = fastd_new(fastd_method_session_state_t);
fastd_method_common_init(&session->common, initiator);
session->method = method;
diff --git a/src/methods/generic_gmac/generic_gmac.c b/src/methods/generic_gmac/generic_gmac.c
index 546cd50..930e52d 100644
--- a/src/methods/generic_gmac/generic_gmac.c
+++ b/src/methods/generic_gmac/generic_gmac.c
@@ -90,7 +90,7 @@ static bool method_create_by_name(const char *name, fastd_method_t **method) {
if (m.cipher_info->iv_length <= COMMON_NONCEBYTES)
return false;
- *method = malloc(sizeof(fastd_method_t));
+ *method = fastd_new(fastd_method_t);
**method = m;
return true;
@@ -108,7 +108,7 @@ static size_t method_key_length(const fastd_method_t *method) {
/** Initializes a session */
static fastd_method_session_state_t* method_session_init(const fastd_method_t *method, const uint8_t *secret, bool initiator) {
- fastd_method_session_state_t *session = malloc(sizeof(fastd_method_session_state_t));
+ fastd_method_session_state_t *session = fastd_new(fastd_method_session_state_t);
fastd_method_common_init(&session->common, initiator);
session->method = method;
diff --git a/src/methods/generic_poly1305/generic_poly1305.c b/src/methods/generic_poly1305/generic_poly1305.c
index 142b50e..f804ba3 100644
--- a/src/methods/generic_poly1305/generic_poly1305.c
+++ b/src/methods/generic_poly1305/generic_poly1305.c
@@ -84,7 +84,7 @@ static bool method_create_by_name(const char *name, fastd_method_t **method) {
if (m.cipher_info->iv_length <= COMMON_NONCEBYTES)
return false;
- *method = malloc(sizeof(fastd_method_t));
+ *method = fastd_new(fastd_method_t);
**method = m;
return true;
@@ -102,7 +102,7 @@ static size_t method_key_length(const fastd_method_t *method) {
/** Initializes a session */
static fastd_method_session_state_t* method_session_init(const fastd_method_t *method, const uint8_t *secret, bool initiator) {
- fastd_method_session_state_t *session = malloc(sizeof(fastd_method_session_state_t));
+ fastd_method_session_state_t *session = fastd_new(fastd_method_session_state_t);
fastd_method_common_init(&session->common, initiator);
session->method = method;
diff --git a/src/methods/null/null.c b/src/methods/null/null.c
index 3062fcf..71191de 100644
--- a/src/methods/null/null.c
+++ b/src/methods/null/null.c
@@ -55,7 +55,7 @@ static size_t method_key_length(const fastd_method_t *method UNUSED) {
/** Initiates a new null session */
static fastd_method_session_state_t* method_session_init(const fastd_method_t *method UNUSED, const uint8_t *secret UNUSED, bool initiator) {
- fastd_method_session_state_t *session = malloc(sizeof(fastd_method_session_state_t));
+ fastd_method_session_state_t *session = fastd_new(fastd_method_session_state_t);
session->valid = true;
session->initiator = initiator;
diff --git a/src/methods/xsalsa20_poly1305/xsalsa20_poly1305.c b/src/methods/xsalsa20_poly1305/xsalsa20_poly1305.c
index 9f2d61c..5a4966e 100644
--- a/src/methods/xsalsa20_poly1305/xsalsa20_poly1305.c
+++ b/src/methods/xsalsa20_poly1305/xsalsa20_poly1305.c
@@ -65,7 +65,7 @@ static size_t method_key_length(const fastd_method_t *method UNUSED) {
/** Initializes the session state */
static fastd_method_session_state_t* method_session_init(const fastd_method_t *method UNUSED, const uint8_t *secret, bool initiator) {
- fastd_method_session_state_t *session = malloc(sizeof(fastd_method_session_state_t));
+ fastd_method_session_state_t *session = fastd_new(fastd_method_session_state_t);
fastd_method_common_init(&session->common, initiator);