blob: ce1e151305e7b5c08ae0dce80bbe3acff1c0af7a [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/*
11 * (C) 2015-2016 by sysmocom s.f.m.c. GmbH
Harald Weltec0f00072016-04-27 18:32:35 +020012 * All Rights Reserved
13 *
14 * Author: Neels Hofmeyr
15 *
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program. If not, see <http://www.gnu.org/licenses/>.
28 *
29 */
30
31#pragma once
32
33#include <stdint.h>
34#include <osmocom/core/msgb.h>
35#include <osmocom/gsm/protocol/gsm_04_08_gprs.h>
36
Neels Hofmeyr87e45502017-06-20 00:17:59 +020037/*! Information Element Identifiers for OAP IEs.
Harald Weltec0f00072016-04-27 18:32:35 +020038 * They match osmo_gsup_iei (so far). */
39enum osmo_oap_iei {
40 OAP_CAUSE_IE = 0x02,
41 OAP_RAND_IE = 0x20,
42 OAP_AUTN_IE = 0x23,
43 OAP_XRES_IE = 0x24,
44 OAP_AUTS_IE = 0x25,
45 OAP_CLIENT_ID_IE = 0x30,
46};
47
Neels Hofmeyr87e45502017-06-20 00:17:59 +020048/*! OAP message types */
Harald Weltec0f00072016-04-27 18:32:35 +020049enum osmo_oap_message_type {
50 OAP_MSGT_REGISTER_REQUEST = 0b00000100,
51 OAP_MSGT_REGISTER_ERROR = 0b00000101,
52 OAP_MSGT_REGISTER_RESULT = 0b00000110,
53
54 OAP_MSGT_CHALLENGE_REQUEST = 0b00001000,
55 OAP_MSGT_CHALLENGE_ERROR = 0b00001001,
56 OAP_MSGT_CHALLENGE_RESULT = 0b00001010,
57
58 OAP_MSGT_SYNC_REQUEST = 0b00001100,
59 OAP_MSGT_SYNC_ERROR = 0b00001101,
60 OAP_MSGT_SYNC_RESULT = 0b00001110,
61};
62
Neels Hofmeyr87e45502017-06-20 00:17:59 +020063/*! Parsed/decoded OAP protocol message */
Harald Weltec0f00072016-04-27 18:32:35 +020064struct osmo_oap_message {
65 enum osmo_oap_message_type message_type;
66 enum gsm48_gmm_cause cause;
67 uint16_t client_id;
68 int rand_present;
69 uint8_t rand[16];
70 int autn_present;
71 uint8_t autn[16];
72 int xres_present;
73 uint8_t xres[8];
74 int auts_present;
Neels Hofmeyr8352d312017-02-02 20:05:14 +010075 uint8_t auts[14];
Harald Weltec0f00072016-04-27 18:32:35 +020076};
77
78int osmo_oap_decode(struct osmo_oap_message *oap_msg, const uint8_t *data,
79 size_t data_len);
80void osmo_oap_encode(struct msgb *msg, const struct osmo_oap_message *oap_msg);
Harald Weltea3389832017-10-16 18:34:14 +020081
82/*! @} */