blob: d95c03e893f7be4f1c3144c34a178d2b54299297 [file] [log] [blame]
Neels Hofmeyr17518fe2017-06-20 04:35:06 +02001/*! \file gea.c
2 * Implementation of GEA3 and GEA4. */
Max4f169502016-06-30 10:39:00 +02003/*
Max4f169502016-06-30 10:39:00 +02004 * 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 Welte96e2a002017-06-12 21:44:18 +020031/*! \addtogroup crypto
32 * @{
Neels Hofmeyr17518fe2017-06-20 04:35:06 +020033 * \file gsm/gea.c */
Harald Welte96e2a002017-06-12 21:44:18 +020034
Neels Hofmeyr87e45502017-06-20 00:17:59 +020035/*! Performs the GEA4 algorithm as in 3GPP TS 55.226 V9.0.0
Max4f169502016-06-30 10:39:00 +020036 * \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 */
42int 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 Hofmeyr87e45502017-06-20 00:17:59 +020049/*! Performs the GEA3 algorithm as in 3GPP TS 55.216 V6.2.0
Max4f169502016-06-30 10:39:00 +020050 * \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 */
56int 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 Welte96e2a002017-06-12 21:44:18 +020063
64/*! @} */