aboutsummaryrefslogtreecommitdiffstats
path: root/include/osmocom
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2010-06-30 19:43:11 +0200
committerHarald Welte <laforge@gnumonks.org>2010-06-30 19:43:11 +0200
commitb9ce51c5fd9773694856802a175efdd9b37a2242 (patch)
tree5a920bcab6c518da0887500731380fdee325d195 /include/osmocom
parente34a94054227bb8b21a6082f7954fea980e2fead (diff)
Add support for plugins (and specifically GPRS encryption plugins)
Diffstat (limited to 'include/osmocom')
-rw-r--r--include/osmocom/Makefile.am4
-rw-r--r--include/osmocom/crypt/Makefile.am3
-rw-r--r--include/osmocom/crypt/gprs_cipher.h48
3 files changed, 54 insertions, 1 deletions
diff --git a/include/osmocom/Makefile.am b/include/osmocom/Makefile.am
index 71293d15..fd9074cd 100644
--- a/include/osmocom/Makefile.am
+++ b/include/osmocom/Makefile.am
@@ -1,3 +1,5 @@
if ENABLE_VTY
-SUBDIRS = vty
+SUBDIRS = vty crypt
+else
+SUBDIRS = crypt
endif
diff --git a/include/osmocom/crypt/Makefile.am b/include/osmocom/crypt/Makefile.am
new file mode 100644
index 00000000..7ce69fdd
--- /dev/null
+++ b/include/osmocom/crypt/Makefile.am
@@ -0,0 +1,3 @@
+osmocrypt_HEADERS = gprs_cipher.h
+
+osmocryptdir = $(includedir)/osmocom/crypt
diff --git a/include/osmocom/crypt/gprs_cipher.h b/include/osmocom/crypt/gprs_cipher.h
new file mode 100644
index 00000000..16560376
--- /dev/null
+++ b/include/osmocom/crypt/gprs_cipher.h
@@ -0,0 +1,48 @@
+#ifndef _GPRS_CIPHER_H
+#define _GPRS_CIPHER_H
+
+#include <osmocore/linuxlist.h>
+
+#define GSM0464_CIPH_MAX_BLOCK 1523
+
+enum gprs_ciph_algo {
+ GPRS_ALGO_GEA0,
+ GPRS_ALGO_GEA1,
+ GPRS_ALGO_GEA2,
+ GPRS_ALGO_GEA3,
+ _GPRS_ALGO_NUM
+};
+
+enum gprs_cipher_direction {
+ GPRS_CIPH_MS2SGSN,
+ GPRS_CIPH_SGSN2MS,
+};
+
+/* An implementation of a GPRS cipher */
+struct gprs_cipher_impl {
+ struct llist_head list;
+ enum gprs_ciph_algo algo;
+ const char *name;
+ unsigned int priority;
+
+ /* As specified in 04.64 Annex A. Uses Kc, IV and direction
+ * to generate the 1523 bytes cipher stream that need to be
+ * XORed wit the plaintext for encrypt / ciphertext for decrypt */
+ int (*run)(uint8_t *out, uint16_t len, uint64_t kc, uint32_t iv,
+ enum gprs_cipher_direction direction);
+};
+
+/* register a cipher with the core (from a plugin) */
+int gprs_cipher_register(struct gprs_cipher_impl *ciph);
+
+/* load all available GPRS cipher plugins */
+int gprs_cipher_load(const char *path);
+
+/* function to be called by core code */
+int gprs_cipher_run(uint8_t *out, uint16_t len, enum gprs_ciph_algo algo,
+ uint64_t kc, uint32_t iv, enum gprs_cipher_direction dir);
+
+/* Do we have an implementation for this cipher? */
+int gprs_cipher_supported(enum gprs_ciph_algo algo);
+
+#endif /* _GPRS_CIPHER_H */