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