summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-11-25 21:30:36 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-11-25 21:30:36 +0100
commit60c2c11de820687887a643344fc1b0a91fd45226 (patch)
tree5dde7180b5d28ed21af2528a74ecf8e0193c626b /src
parentc58ad422281f6d6f747aa31177cdc93ae63b4f64 (diff)
downloadfastd-60c2c11de820687887a643344fc1b0a91fd45226.tar
fastd-60c2c11de820687887a643344fc1b0a91fd45226.zip
Move cipher and mac structures to a new header
Diffstat (limited to 'src')
-rw-r--r--src/crypto.h60
-rw-r--r--src/crypto/cipher/aes128_ctr/nacl/cipher_aes128_ctr_nacl.c2
-rw-r--r--src/crypto/cipher/blowfish_ctr/builtin/blowfish_ctr.c2
-rw-r--r--src/crypto/cipher/ciphers.c.in2
-rw-r--r--src/crypto/cipher/null/memcpy/null_memcpy.c2
-rw-r--r--src/crypto/cipher/salsa20/nacl/salsa20_nacl.c2
-rw-r--r--src/crypto/cipher/salsa2012/nacl/salsa2012_nacl.c2
-rw-r--r--src/crypto/mac/ghash/builtin/ghash_builtin.c2
-rw-r--r--src/crypto/mac/macs.c.in2
-rw-r--r--src/fastd.h27
-rw-r--r--src/methods/cipher_test/cipher_test.c2
-rw-r--r--src/methods/composed_gmac/composed_gmac.c2
-rw-r--r--src/methods/generic_gcm/generic_gcm.c2
-rw-r--r--src/methods/generic_gmac/generic_gmac.c2
-rw-r--r--src/methods/generic_poly1305/generic_poly1305.c2
15 files changed, 73 insertions, 40 deletions
diff --git a/src/crypto.h b/src/crypto.h
new file mode 100644
index 0000000..e7d011b
--- /dev/null
+++ b/src/crypto.h
@@ -0,0 +1,60 @@
+/*
+ Copyright (c) 2012-2013, Matthias Schiffer <mschiffer@universe-factory.net>
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+
+#ifndef _FASTD_CRYPTO_H_
+#define _FASTD_CRYPTO_H_
+
+#include "fastd.h"
+
+
+struct fastd_cipher {
+ const char *name;
+ size_t key_length;
+ size_t iv_length;
+
+ fastd_cipher_context_t* (*initialize)(fastd_context_t *ctx);
+ fastd_cipher_state_t* (*init_state)(fastd_context_t *ctx, const fastd_cipher_context_t *cctx, const uint8_t *key);
+
+ bool (*crypt)(fastd_context_t *ctx, const fastd_cipher_state_t *state, fastd_block128_t *out, const fastd_block128_t *in, size_t len, const uint8_t *iv);
+
+ void (*free_state)(fastd_context_t *ctx, fastd_cipher_state_t *state);
+ void (*free)(fastd_context_t *ctx, fastd_cipher_context_t *cctx);
+};
+
+struct fastd_mac {
+ const char *name;
+ size_t key_length;
+
+ fastd_mac_context_t* (*initialize)(fastd_context_t *ctx);
+ fastd_mac_state_t* (*init_state)(fastd_context_t *ctx, const fastd_mac_context_t *mctx, const uint8_t *key);
+
+ bool (*hash)(fastd_context_t *ctx, const fastd_mac_state_t *state, fastd_block128_t *out, const fastd_block128_t *in, size_t n_blocks);
+
+ void (*free_state)(fastd_context_t *ctx, fastd_mac_state_t *state);
+ void (*free)(fastd_context_t *ctx, fastd_mac_context_t *mctx);
+};
+
+#endif /* _FASTD_CRYPTO_H_ */
diff --git a/src/crypto/cipher/aes128_ctr/nacl/cipher_aes128_ctr_nacl.c b/src/crypto/cipher/aes128_ctr/nacl/cipher_aes128_ctr_nacl.c
index 7c75b7d..a520732 100644
--- a/src/crypto/cipher/aes128_ctr/nacl/cipher_aes128_ctr_nacl.c
+++ b/src/crypto/cipher/aes128_ctr/nacl/cipher_aes128_ctr_nacl.c
@@ -24,7 +24,7 @@
*/
-#include "../../../../fastd.h"
+#include "../../../../crypto.h"
#include <crypto_stream_aes128ctr.h>
diff --git a/src/crypto/cipher/blowfish_ctr/builtin/blowfish_ctr.c b/src/crypto/cipher/blowfish_ctr/builtin/blowfish_ctr.c
index d657694..0ca8d2d 100644
--- a/src/crypto/cipher/blowfish_ctr/builtin/blowfish_ctr.c
+++ b/src/crypto/cipher/blowfish_ctr/builtin/blowfish_ctr.c
@@ -24,7 +24,7 @@
*/
-#include "../../../../fastd.h"
+#include "../../../../crypto.h"
static const uint32_t Sdefault[4][256] = {
{
diff --git a/src/crypto/cipher/ciphers.c.in b/src/crypto/cipher/ciphers.c.in
index 667cfac..c912e60 100644
--- a/src/crypto/cipher/ciphers.c.in
+++ b/src/crypto/cipher/ciphers.c.in
@@ -24,8 +24,8 @@
*/
-#include <src/fastd.h>
#include <src/config.h>
+#include <src/crypto.h>
@CIPHER_DEFINITIONS@
diff --git a/src/crypto/cipher/null/memcpy/null_memcpy.c b/src/crypto/cipher/null/memcpy/null_memcpy.c
index c260ffb..45ad297 100644
--- a/src/crypto/cipher/null/memcpy/null_memcpy.c
+++ b/src/crypto/cipher/null/memcpy/null_memcpy.c
@@ -24,7 +24,7 @@
*/
-#include "../../../../fastd.h"
+#include "../../../../crypto.h"
static fastd_cipher_context_t* null_initialize(fastd_context_t *ctx UNUSED) {
diff --git a/src/crypto/cipher/salsa20/nacl/salsa20_nacl.c b/src/crypto/cipher/salsa20/nacl/salsa20_nacl.c
index cb78afc..93daad3 100644
--- a/src/crypto/cipher/salsa20/nacl/salsa20_nacl.c
+++ b/src/crypto/cipher/salsa20/nacl/salsa20_nacl.c
@@ -24,7 +24,7 @@
*/
-#include "../../../../fastd.h"
+#include "../../../../crypto.h"
#include <crypto_stream_salsa20.h>
diff --git a/src/crypto/cipher/salsa2012/nacl/salsa2012_nacl.c b/src/crypto/cipher/salsa2012/nacl/salsa2012_nacl.c
index edf5843..2703f0e 100644
--- a/src/crypto/cipher/salsa2012/nacl/salsa2012_nacl.c
+++ b/src/crypto/cipher/salsa2012/nacl/salsa2012_nacl.c
@@ -24,7 +24,7 @@
*/
-#include "../../../../fastd.h"
+#include "../../../../crypto.h"
#include <crypto_stream_salsa2012.h>
diff --git a/src/crypto/mac/ghash/builtin/ghash_builtin.c b/src/crypto/mac/ghash/builtin/ghash_builtin.c
index 8793627..0af30ed 100644
--- a/src/crypto/mac/ghash/builtin/ghash_builtin.c
+++ b/src/crypto/mac/ghash/builtin/ghash_builtin.c
@@ -24,7 +24,7 @@
*/
-#include "../../../../fastd.h"
+#include "../../../../crypto.h"
struct fastd_mac_state {
diff --git a/src/crypto/mac/macs.c.in b/src/crypto/mac/macs.c.in
index 5adca10..43031ee 100644
--- a/src/crypto/mac/macs.c.in
+++ b/src/crypto/mac/macs.c.in
@@ -24,8 +24,8 @@
*/
-#include <src/fastd.h>
#include <src/config.h>
+#include <src/crypto.h>
@MAC_DEFINITIONS@
diff --git a/src/fastd.h b/src/fastd.h
index 66dd06f..c253a97 100644
--- a/src/fastd.h
+++ b/src/fastd.h
@@ -100,33 +100,6 @@ struct fastd_method {
bool (*decrypt)(fastd_context_t *ctx, fastd_peer_t *peer, fastd_method_session_state_t *session, fastd_buffer_t *out, fastd_buffer_t in);
};
-struct fastd_cipher {
- const char *name;
- size_t key_length;
- size_t iv_length;
-
- fastd_cipher_context_t* (*initialize)(fastd_context_t *ctx);
- fastd_cipher_state_t* (*init_state)(fastd_context_t *ctx, const fastd_cipher_context_t *cctx, const uint8_t *key);
-
- bool (*crypt)(fastd_context_t *ctx, const fastd_cipher_state_t *state, fastd_block128_t *out, const fastd_block128_t *in, size_t len, const uint8_t *iv);
-
- void (*free_state)(fastd_context_t *ctx, fastd_cipher_state_t *state);
- void (*free)(fastd_context_t *ctx, fastd_cipher_context_t *cctx);
-};
-
-struct fastd_mac {
- const char *name;
- size_t key_length;
-
- fastd_mac_context_t* (*initialize)(fastd_context_t *ctx);
- fastd_mac_state_t* (*init_state)(fastd_context_t *ctx, const fastd_mac_context_t *mctx, const uint8_t *key);
-
- bool (*hash)(fastd_context_t *ctx, const fastd_mac_state_t *state, fastd_block128_t *out, const fastd_block128_t *in, size_t n_blocks);
-
- void (*free_state)(fastd_context_t *ctx, fastd_mac_state_t *state);
- void (*free)(fastd_context_t *ctx, fastd_mac_context_t *mctx);
-};
-
union fastd_peer_address {
struct sockaddr sa;
struct sockaddr_in in;
diff --git a/src/methods/cipher_test/cipher_test.c b/src/methods/cipher_test/cipher_test.c
index 4891781..b9a7881 100644
--- a/src/methods/cipher_test/cipher_test.c
+++ b/src/methods/cipher_test/cipher_test.c
@@ -24,7 +24,7 @@
*/
-#include "../../fastd.h"
+#include "../../crypto.h"
#include "../common.h"
diff --git a/src/methods/composed_gmac/composed_gmac.c b/src/methods/composed_gmac/composed_gmac.c
index b63089f..eae27db 100644
--- a/src/methods/composed_gmac/composed_gmac.c
+++ b/src/methods/composed_gmac/composed_gmac.c
@@ -24,7 +24,7 @@
*/
-#include "../../fastd.h"
+#include "../../crypto.h"
#include "../common.h"
diff --git a/src/methods/generic_gcm/generic_gcm.c b/src/methods/generic_gcm/generic_gcm.c
index 9738a2d..5d3f6c4 100644
--- a/src/methods/generic_gcm/generic_gcm.c
+++ b/src/methods/generic_gcm/generic_gcm.c
@@ -24,7 +24,7 @@
*/
-#include "../../fastd.h"
+#include "../../crypto.h"
#include "../common.h"
diff --git a/src/methods/generic_gmac/generic_gmac.c b/src/methods/generic_gmac/generic_gmac.c
index 7030304..03377c5 100644
--- a/src/methods/generic_gmac/generic_gmac.c
+++ b/src/methods/generic_gmac/generic_gmac.c
@@ -24,7 +24,7 @@
*/
-#include "../../fastd.h"
+#include "../../crypto.h"
#include "../common.h"
diff --git a/src/methods/generic_poly1305/generic_poly1305.c b/src/methods/generic_poly1305/generic_poly1305.c
index f3d630a..84f9f9a 100644
--- a/src/methods/generic_poly1305/generic_poly1305.c
+++ b/src/methods/generic_poly1305/generic_poly1305.c
@@ -24,7 +24,7 @@
*/
-#include "../../fastd.h"
+#include "../../crypto.h"
#include "../common.h"
#include <crypto_onetimeauth_poly1305.h>