Neels Hofmeyr | 17518fe | 2017-06-20 04:35:06 +0200 | [diff] [blame] | 1 | /*! \file gea.c |
| 2 | * Implementation of GEA3 and GEA4. */ |
Max | 4f16950 | 2016-06-30 10:39:00 +0200 | [diff] [blame] | 3 | /* |
Max | 4f16950 | 2016-06-30 10:39:00 +0200 | [diff] [blame] | 4 | * Copyright (C) 2016 by Sysmocom s.f.m.c. GmbH |
| 5 | * |
| 6 | * All Rights Reserved |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; either version 3 of the License, or |
| 11 | * (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License along |
| 19 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 21 | */ |
| 22 | |
| 23 | #include <osmocom/core/bits.h> |
| 24 | #include <osmocom/crypt/gprs_cipher.h> |
| 25 | #include <osmocom/crypt/auth.h> |
| 26 | #include <osmocom/gsm/kasumi.h> |
| 27 | |
| 28 | #include <stdint.h> |
| 29 | #include <string.h> |
| 30 | |
Harald Welte | 96e2a00 | 2017-06-12 21:44:18 +0200 | [diff] [blame] | 31 | /*! \addtogroup crypto |
| 32 | * @{ |
Neels Hofmeyr | 17518fe | 2017-06-20 04:35:06 +0200 | [diff] [blame] | 33 | * \file gsm/gea.c */ |
Harald Welte | 96e2a00 | 2017-06-12 21:44:18 +0200 | [diff] [blame] | 34 | |
Neels Hofmeyr | 87e4550 | 2017-06-20 00:17:59 +0200 | [diff] [blame] | 35 | /*! Performs the GEA4 algorithm as in 3GPP TS 55.226 V9.0.0 |
Max | 4f16950 | 2016-06-30 10:39:00 +0200 | [diff] [blame] | 36 | * \param[in,out] out Buffer for gamma for encrypted/decrypted |
| 37 | * \param[in] len Length of out, in bytes |
| 38 | * \param[in] kc Buffer with the ciphering key |
| 39 | * \param[in] iv Init vector |
| 40 | * \param[in] direct Direction: 0 (MS -> SGSN) or 1 (SGSN -> MS) |
| 41 | */ |
| 42 | int gea4(uint8_t *out, uint16_t len, uint8_t *kc, uint32_t iv, |
| 43 | enum gprs_cipher_direction direction) |
| 44 | { |
| 45 | _kasumi_kgcore(0xFF, 0, iv, direction, kc, out, len * 8); |
| 46 | return 0; |
| 47 | } |
| 48 | |
Neels Hofmeyr | 87e4550 | 2017-06-20 00:17:59 +0200 | [diff] [blame] | 49 | /*! Performs the GEA3 algorithm as in 3GPP TS 55.216 V6.2.0 |
Max | 4f16950 | 2016-06-30 10:39:00 +0200 | [diff] [blame] | 50 | * \param[in,out] out Buffer for gamma for encrypted/decrypted |
| 51 | * \param[in] len Length of out, in bytes |
| 52 | * \param[in] kc Buffer with the ciphering key |
| 53 | * \param[in] iv Init vector |
| 54 | * \param[in] direct Direction: 0 (MS -> SGSN) or 1 (SGSN -> MS) |
| 55 | */ |
| 56 | int gea3(uint8_t *out, uint16_t len, uint8_t *kc, uint32_t iv, |
| 57 | enum gprs_cipher_direction direction) |
| 58 | { |
| 59 | uint8_t ck[gprs_cipher_key_length(GPRS_ALGO_GEA4)]; |
| 60 | osmo_c4(ck, kc); |
| 61 | return gea4(out, len, ck, iv, direction); |
| 62 | } |
Harald Welte | 96e2a00 | 2017-06-12 21:44:18 +0200 | [diff] [blame] | 63 | |
| 64 | /*! @} */ |