summaryrefslogtreecommitdiffstats
path: root/src/crypto/cipher/salsa2012
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/crypto/cipher/salsa2012
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/crypto/cipher/salsa2012')
-rw-r--r--src/crypto/cipher/salsa2012/nacl/salsa2012_nacl.c3
-rw-r--r--src/crypto/cipher/salsa2012/xmm/salsa2012_xmm.c3
2 files changed, 4 insertions, 2 deletions
diff --git a/src/crypto/cipher/salsa2012/nacl/salsa2012_nacl.c b/src/crypto/cipher/salsa2012/nacl/salsa2012_nacl.c
index 18ec502..24450dc 100644
--- a/src/crypto/cipher/salsa2012/nacl/salsa2012_nacl.c
+++ b/src/crypto/cipher/salsa2012/nacl/salsa2012_nacl.c
@@ -30,6 +30,7 @@
*/
+#include "../../../../alloc.h"
#include "../../../../crypto.h"
#include <crypto_stream_salsa2012.h>
@@ -43,7 +44,7 @@ struct fastd_cipher_state {
/** Initializes the cipher state */
static fastd_cipher_state_t* salsa2012_init(const uint8_t *key) {
- fastd_cipher_state_t *state = malloc(sizeof(fastd_cipher_state_t));
+ fastd_cipher_state_t *state = fastd_new(fastd_cipher_state_t);
memcpy(state->key, key, crypto_stream_salsa2012_KEYBYTES);
return state;
diff --git a/src/crypto/cipher/salsa2012/xmm/salsa2012_xmm.c b/src/crypto/cipher/salsa2012/xmm/salsa2012_xmm.c
index 7e6fe80..6180702 100644
--- a/src/crypto/cipher/salsa2012/xmm/salsa2012_xmm.c
+++ b/src/crypto/cipher/salsa2012/xmm/salsa2012_xmm.c
@@ -33,6 +33,7 @@
*/
+#include "../../../../alloc.h"
#include "../../../../crypto.h"
#include "../../../../cpuid.h"
@@ -67,7 +68,7 @@ static bool salsa2012_available(void) {
/** Initializes the cipher state */
static fastd_cipher_state_t* salsa2012_init(const uint8_t *key) {
- fastd_cipher_state_t *state = malloc(sizeof(fastd_cipher_state_t));
+ fastd_cipher_state_t *state = fastd_new(fastd_cipher_state_t);
memcpy(state->key, key, KEYBYTES);
return state;