blob: f33cb50ab62370f013d77a6f04d8c7a1bbe761f6 [file] [log] [blame]
Harald Weltea3389832017-10-16 18:34:14 +02001/*! \defgroup oap Osmocom Authentication Protocol
2 * @{
3 *
4 * The Osmocom Authentication Protocol (OAP) is a way to use the 3GPP
5 * AKA (Authentication and Key Agreement) as cryptographic
6 * authentication mechanism in other protocols that don't provide
7 * cryptographic authentication.
8 *
9 * \file oap.h */
Neels Hofmeyr17518fe2017-06-20 04:35:06 +020010/*
Harald Weltee08da972017-11-13 01:00:26 +090011 * (C) 2015-2016 by sysmocom - s.f.m.c. GmbH
12 * Author: Neels Hofmeyr
Harald Weltec0f00072016-04-27 18:32:35 +020013 * All Rights Reserved
14 *
Harald Weltee08da972017-11-13 01:00:26 +090015 * SPDX-License-Identifier: GPL-2.0+
Harald Weltec0f00072016-04-27 18:32:35 +020016 *
17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation; either version 2 of the License, or
20 * (at your option) any later version.
21 *
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * You should have received a copy of the GNU General Public License
28 * along with this program. If not, see <http://www.gnu.org/licenses/>.
29 *
30 */
31
32#pragma once
33
34#include <stdint.h>
35#include <osmocom/core/msgb.h>
36#include <osmocom/gsm/protocol/gsm_04_08_gprs.h>
37
Neels Hofmeyr87e45502017-06-20 00:17:59 +020038/*! Information Element Identifiers for OAP IEs.
Harald Weltec0f00072016-04-27 18:32:35 +020039 * They match osmo_gsup_iei (so far). */
40enum osmo_oap_iei {
41 OAP_CAUSE_IE = 0x02,
42 OAP_RAND_IE = 0x20,
43 OAP_AUTN_IE = 0x23,
44 OAP_XRES_IE = 0x24,
45 OAP_AUTS_IE = 0x25,
46 OAP_CLIENT_ID_IE = 0x30,
47};
48
Neels Hofmeyr87e45502017-06-20 00:17:59 +020049/*! OAP message types */
Harald Weltec0f00072016-04-27 18:32:35 +020050enum osmo_oap_message_type {
51 OAP_MSGT_REGISTER_REQUEST = 0b00000100,
52 OAP_MSGT_REGISTER_ERROR = 0b00000101,
53 OAP_MSGT_REGISTER_RESULT = 0b00000110,
54
55 OAP_MSGT_CHALLENGE_REQUEST = 0b00001000,
56 OAP_MSGT_CHALLENGE_ERROR = 0b00001001,
57 OAP_MSGT_CHALLENGE_RESULT = 0b00001010,
58
59 OAP_MSGT_SYNC_REQUEST = 0b00001100,
60 OAP_MSGT_SYNC_ERROR = 0b00001101,
61 OAP_MSGT_SYNC_RESULT = 0b00001110,
62};
63
Neels Hofmeyr87e45502017-06-20 00:17:59 +020064/*! Parsed/decoded OAP protocol message */
Harald Weltec0f00072016-04-27 18:32:35 +020065struct osmo_oap_message {
66 enum osmo_oap_message_type message_type;
67 enum gsm48_gmm_cause cause;
68 uint16_t client_id;
69 int rand_present;
70 uint8_t rand[16];
71 int autn_present;
72 uint8_t autn[16];
73 int xres_present;
74 uint8_t xres[8];
75 int auts_present;
Neels Hofmeyr8352d312017-02-02 20:05:14 +010076 uint8_t auts[14];
Harald Weltec0f00072016-04-27 18:32:35 +020077};
78
79int osmo_oap_decode(struct osmo_oap_message *oap_msg, const uint8_t *data,
80 size_t data_len);
81void osmo_oap_encode(struct msgb *msg, const struct osmo_oap_message *oap_msg);
Harald Weltea3389832017-10-16 18:34:14 +020082
83/*! @} */