Harald Welte | c0f0007 | 2016-04-27 18:32:35 +0200 | [diff] [blame] | 1 | /* Osmocom Authentication Protocol message encoder/decoder */ |
| 2 | |
| 3 | /* (C) 2015-2016 by sysmocom s.f.m.c. GmbH |
| 4 | * All Rights Reserved |
| 5 | * |
| 6 | * Author: Neels Hofmeyr |
| 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 2 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 |
| 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 20 | * |
| 21 | */ |
| 22 | |
| 23 | #pragma once |
| 24 | |
| 25 | #include <stdint.h> |
| 26 | #include <osmocom/core/msgb.h> |
| 27 | #include <osmocom/gsm/protocol/gsm_04_08_gprs.h> |
| 28 | |
| 29 | /*! \brief Information Element Identifiers for OAP IEs. |
| 30 | * They match osmo_gsup_iei (so far). */ |
| 31 | enum osmo_oap_iei { |
| 32 | OAP_CAUSE_IE = 0x02, |
| 33 | OAP_RAND_IE = 0x20, |
| 34 | OAP_AUTN_IE = 0x23, |
| 35 | OAP_XRES_IE = 0x24, |
| 36 | OAP_AUTS_IE = 0x25, |
| 37 | OAP_CLIENT_ID_IE = 0x30, |
| 38 | }; |
| 39 | |
| 40 | /*! \brief OAP message types */ |
| 41 | enum osmo_oap_message_type { |
| 42 | OAP_MSGT_REGISTER_REQUEST = 0b00000100, |
| 43 | OAP_MSGT_REGISTER_ERROR = 0b00000101, |
| 44 | OAP_MSGT_REGISTER_RESULT = 0b00000110, |
| 45 | |
| 46 | OAP_MSGT_CHALLENGE_REQUEST = 0b00001000, |
| 47 | OAP_MSGT_CHALLENGE_ERROR = 0b00001001, |
| 48 | OAP_MSGT_CHALLENGE_RESULT = 0b00001010, |
| 49 | |
| 50 | OAP_MSGT_SYNC_REQUEST = 0b00001100, |
| 51 | OAP_MSGT_SYNC_ERROR = 0b00001101, |
| 52 | OAP_MSGT_SYNC_RESULT = 0b00001110, |
| 53 | }; |
| 54 | |
| 55 | /*! \brief Parsed/decoded OAP protocol message */ |
| 56 | struct osmo_oap_message { |
| 57 | enum osmo_oap_message_type message_type; |
| 58 | enum gsm48_gmm_cause cause; |
| 59 | uint16_t client_id; |
| 60 | int rand_present; |
| 61 | uint8_t rand[16]; |
| 62 | int autn_present; |
| 63 | uint8_t autn[16]; |
| 64 | int xres_present; |
| 65 | uint8_t xres[8]; |
| 66 | int auts_present; |
Neels Hofmeyr | 8352d31 | 2017-02-02 20:05:14 +0100 | [diff] [blame] | 67 | uint8_t auts[14]; |
Harald Welte | c0f0007 | 2016-04-27 18:32:35 +0200 | [diff] [blame] | 68 | }; |
| 69 | |
| 70 | int osmo_oap_decode(struct osmo_oap_message *oap_msg, const uint8_t *data, |
| 71 | size_t data_len); |
| 72 | void osmo_oap_encode(struct msgb *msg, const struct osmo_oap_message *oap_msg); |