aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorSylvain Munaut <tnt@246tNt.com>2014-06-16 14:59:30 +0200
committerSylvain Munaut <tnt@246tNt.com>2014-06-16 14:59:30 +0200
commit579a7103a1738df11009d75b7bf02559e711a1cb (patch)
tree186b527c1c18f02b52beb0f6876fb9afe98c834f /include
parente2c1390d1badbce07945d19ead64704ad4056309 (diff)
gsm: Add Kasumi cipher implementation
Submitted-by: Max <max.suraev@fairwaves.co> Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Diffstat (limited to 'include')
-rw-r--r--include/Makefile.am4
-rw-r--r--include/osmocom/gsm/kasumi.h48
2 files changed, 51 insertions, 1 deletions
diff --git a/include/Makefile.am b/include/Makefile.am
index 48ca7ea2..74396de0 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -108,7 +108,9 @@ nobase_include_HEADERS += \
osmocom/vty/vty.h
endif
-noinst_HEADERS = osmocom/core/timer_compat.h
+noinst_HEADERS = \
+ osmocom/core/timer_compat.h \
+ osmocom/gsm/kasumi.h
osmocom/core/bit%gen.h: osmocom/core/bitXXgen.h.tpl
$(AM_V_GEN)$(MKDIR_P) $(dir $@)
diff --git a/include/osmocom/gsm/kasumi.h b/include/osmocom/gsm/kasumi.h
new file mode 100644
index 00000000..8ecf65f6
--- /dev/null
+++ b/include/osmocom/gsm/kasumi.h
@@ -0,0 +1,48 @@
+/*
+ * KASUMI header
+ *
+ * See kasumi.c for details
+ * The parameters are described in TS 135 202.
+ */
+
+#pragma once
+
+#include <stdint.h>
+
+/*! \brief Single iteration of KASUMI cipher
+ * \param[in] P Block, 64 bits to be processed in this round
+ * \param[in] KLi1 Expanded subkeys
+ * \param[in] KLi2 Expanded subkeys
+ * \param[in] KOi1 Expanded subkeys
+ * \param[in] KOi2 Expanded subkeys
+ * \param[in] KOi3 Expanded subkeys
+ * \param[in] KIi1 Expanded subkeys
+ * \param[in] KIi2 Expanded subkeys
+ * \param[in] KIi3 Expanded subkeys
+ * \returns processed block of 64 bits
+ */
+uint64_t _kasumi(uint64_t P, const uint16_t *KLi1, const uint16_t *KLi2, const uint16_t *KOi1, const uint16_t *KOi2, const uint16_t *KOi3, const uint16_t *KIi1, const uint16_t *KIi2, const uint16_t *KIi3);
+
+/*! \brief Implementation of the KGCORE algorithm (used by A5/3, A5/4, GEA3, GEA4 and ECSD)
+ * \param[in] CA
+ * \param[in] cb
+ * \param[in] cc
+ * \param[in] cd
+ * \param[in] ck 8-bytes long key
+ * \param[out] co cl-dependent
+ * \param[in] cl
+ */
+void _kasumi_kgcore(uint8_t CA, uint8_t cb, uint32_t cc, uint8_t cd, const uint8_t *ck, uint8_t *co, uint16_t cl);
+
+/*! \brief Expand key into set of subkeys - see TS 135 202 for details
+ * \param[in] key (128 bits) as array of bytes
+ * \param[out] KLi1 Expanded subkeys
+ * \param[out] KLi2 Expanded subkeys
+ * \param[out] KOi1 Expanded subkeys
+ * \param[out] KOi2 Expanded subkeys
+ * \param[out] KOi3 Expanded subkeys
+ * \param[out] KIi1 Expanded subkeys
+ * \param[out] KIi2 Expanded subkeys
+ * \param[out] KIi3 Expanded subkeys
+ */
+void _kasumi_key_expand(const uint8_t *key, uint16_t *KLi1, uint16_t *KLi2, uint16_t *KOi1, uint16_t *KOi2, uint16_t *KOi3, uint16_t *KIi1, uint16_t *KIi2, uint16_t *KIi3);