aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstrongswan/math/libnttfft/ntt_fft.h
diff options
context:
space:
mode:
authorAndreas Steffen <andreas.steffen@strongswan.org>2016-07-24 19:57:54 +0200
committerAndreas Steffen <andreas.steffen@strongswan.org>2016-07-29 12:36:15 +0200
commitd305f251a53520db97c899ba1c1f40e239fb68fa (patch)
tree99c8096c3338f56c1220fca3c2953420e4f8badb /src/libstrongswan/math/libnttfft/ntt_fft.h
parent65f2ecb86ddb4fab2cdbc7ac4e9416ff4c26222c (diff)
downloadstrongswan-d305f251a53520db97c899ba1c1f40e239fb68fa.tar.bz2
strongswan-d305f251a53520db97c899ba1c1f40e239fb68fa.tar.xz
Created libnttfft
This makes Number Theoretic Transforms (NTT) based on the efficient Fast-Fourier-Transform (FFT) available to multiple plugins.
Diffstat (limited to 'src/libstrongswan/math/libnttfft/ntt_fft.h')
-rw-r--r--src/libstrongswan/math/libnttfft/ntt_fft.h71
1 files changed, 71 insertions, 0 deletions
diff --git a/src/libstrongswan/math/libnttfft/ntt_fft.h b/src/libstrongswan/math/libnttfft/ntt_fft.h
new file mode 100644
index 000000000..0054a6c4e
--- /dev/null
+++ b/src/libstrongswan/math/libnttfft/ntt_fft.h
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2014 Andreas Steffen
+ * HSR Hochschule fuer Technik Rapperswil
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ */
+
+/**
+ * @defgroup ntt_fft ntt_fft
+ * @{ @ingroup bliss_p
+ */
+
+#ifndef NTT_FFT_H_
+#define NTT_FFT_H_
+
+#include "ntt_fft_params.h"
+
+#include <library.h>
+
+typedef struct ntt_fft_t ntt_fft_t;
+
+/**
+ * Implements a Number Theoretic Transform (NTT) via the FFT algorithm
+ */
+struct ntt_fft_t {
+
+ /**
+ * Get the size of the Number Theoretic Transform
+ *
+ * @result Transform size
+ */
+ uint16_t (*get_size)(ntt_fft_t *this);
+
+ /**
+ * Get the prime modulus of the Number Theoretic Transform
+ *
+ * @result Prime modulus
+ */
+ uint16_t (*get_modulus)(ntt_fft_t *this);
+
+ /**
+ * Compute the [inverse] NTT of a polynomial
+ *
+ * @param a Coefficient of input polynomial
+ * @param b Coefficient of output polynomial
+ * @param inverse TRUE if the inverse NTT has to be computed
+ */
+ void (*transform)(ntt_fft_t *this, uint32_t *a, uint32_t *b, bool inverse);
+
+ /**
+ * Destroy ntt_fft_t object
+ */
+ void (*destroy)(ntt_fft_t *this);
+};
+
+/**
+ * Create a ntt_fft_t object for a given FFT parameter set
+ *
+ * @param params FFT parameters
+ */
+ntt_fft_t *ntt_fft_create(ntt_fft_params_t *params);
+
+#endif /** NTT_FFT_H_ @}*/