diff options
author | Harald Welte <laforge@gnumonks.org> | 2010-06-30 20:55:56 +0200 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2010-06-30 20:55:56 +0200 |
commit | 3de78cd69c0594b0903e6cfffab7920c69e2d478 (patch) | |
tree | 1010a4035a0f78c43d8c11e2b0734bed773e9ff5 | |
parent | 6c0803938d9a2cd3e544f33ec3318372bd43744e (diff) |
Add integration with libosmocore gprs crypto support
-rw-r--r-- | src/Makefile.am | 3 | ||||
-rw-r--r-- | src/osmocom.c | 36 |
2 files changed, 38 insertions, 1 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 79da251..ece2fa0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -7,4 +7,5 @@ AM_CFLAGS = -fPIC -Wall lib_LTLIBRARIES = libosmo-crypto-a53.la -libosmo_crypto_a53_la_SOURCES = a53f.c kgcore.c kasumi.c +libosmo_crypto_a53_la_SOURCES = a53f.c kgcore.c kasumi.c osmocom.c +libosmo_crypto_a53_la_LDFLAGS = -shared diff --git a/src/osmocom.c b/src/osmocom.c new file mode 100644 index 0000000..e8c410e --- /dev/null +++ b/src/osmocom.c @@ -0,0 +1,36 @@ + +#include <stdint.h> + +#include <osmocom/crypt/gprs_cipher.h> + +#include "kasumi.h" +#include "a53f.h" + +static int gea3_run(uint8_t *out, uint16_t len, uint64_t kc, uint32_t iv, + enum gprs_cipher_direction direction) +{ + uint8_t dir; + + if (direction == GPRS_CIPH_MS2SGSN) + dir = 0; + else + dir = 1; + + GEA3((uint8_t *)&kc, sizeof(kc), iv, dir, out, len); + + return 0; +} + +static struct gprs_cipher_impl gea3_impl = { + .algo = GPRS_ALGO_GEA3, + .name = "3GPP Reference implementation of GEA3", + .priority = 1000, + .run = &gea3_run, +}; + +static void __attribute__((constructor)) osmo_crypt_a5_init(void) +{ + gprs_cipher_register(&gea3_impl); + + /* FIXME: A5/3 registration */ +} |