2016-04-27 16:32:35 +00:00
|
|
|
/* Osmocom Authentication Protocol message encoder/decoder */
|
|
|
|
|
|
|
|
/* (C) 2015-2016 by sysmocom s.f.m.c. GmbH
|
|
|
|
* All Rights Reserved
|
|
|
|
*
|
|
|
|
* Author: Neels Hofmeyr
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <osmocom/core/msgb.h>
|
|
|
|
#include <osmocom/gsm/protocol/gsm_04_08_gprs.h>
|
|
|
|
|
|
|
|
/*! \brief Information Element Identifiers for OAP IEs.
|
|
|
|
* They match osmo_gsup_iei (so far). */
|
|
|
|
enum osmo_oap_iei {
|
|
|
|
OAP_CAUSE_IE = 0x02,
|
|
|
|
OAP_RAND_IE = 0x20,
|
|
|
|
OAP_AUTN_IE = 0x23,
|
|
|
|
OAP_XRES_IE = 0x24,
|
|
|
|
OAP_AUTS_IE = 0x25,
|
|
|
|
OAP_CLIENT_ID_IE = 0x30,
|
|
|
|
};
|
|
|
|
|
|
|
|
/*! \brief OAP message types */
|
|
|
|
enum osmo_oap_message_type {
|
|
|
|
OAP_MSGT_REGISTER_REQUEST = 0b00000100,
|
|
|
|
OAP_MSGT_REGISTER_ERROR = 0b00000101,
|
|
|
|
OAP_MSGT_REGISTER_RESULT = 0b00000110,
|
|
|
|
|
|
|
|
OAP_MSGT_CHALLENGE_REQUEST = 0b00001000,
|
|
|
|
OAP_MSGT_CHALLENGE_ERROR = 0b00001001,
|
|
|
|
OAP_MSGT_CHALLENGE_RESULT = 0b00001010,
|
|
|
|
|
|
|
|
OAP_MSGT_SYNC_REQUEST = 0b00001100,
|
|
|
|
OAP_MSGT_SYNC_ERROR = 0b00001101,
|
|
|
|
OAP_MSGT_SYNC_RESULT = 0b00001110,
|
|
|
|
};
|
|
|
|
|
|
|
|
/*! \brief Parsed/decoded OAP protocol message */
|
|
|
|
struct osmo_oap_message {
|
|
|
|
enum osmo_oap_message_type message_type;
|
|
|
|
enum gsm48_gmm_cause cause;
|
|
|
|
uint16_t client_id;
|
|
|
|
int rand_present;
|
|
|
|
uint8_t rand[16];
|
|
|
|
int autn_present;
|
|
|
|
uint8_t autn[16];
|
|
|
|
int xres_present;
|
|
|
|
uint8_t xres[8];
|
|
|
|
int auts_present;
|
GSUP, OAP, osmo-gen-vec: fix AUTS length to 14, not 16
GSUP transmits AUTS for UMTS authentication procedures, and OAP uses the same
procedures to authenticate. osmo-gen-vec is a utility program that passes AUTS
to our osmo_auth_gen_vec_auts() API.
According to 3GPP 33.102 6.3.3, AUTS = SQN^AK || MAC-S, which are 6 || 8 == 14
bytes. This is confirmed by 24.008 9.2.3a where the TLV has 16 bytes, TL = 2
and AUTS being the V = 14.
It is not harmful for milenage_gen_vec_auts() to pass two more AUTS bytes. But
writing 16 bytes to a GSUP struct is a potential problem when passing in a 14
byte long AUTS buffer to the GSUP API, which then reads past the AUTS buffer.
The API implies the length, so far to be 16, so passing in a 14 byte buffer to
GSUP would require copying to a larger buffer first.
Fix this by using a length of 14 for AUTS everywhere instead.
This constitues an ABI breakage, we may handle it as a "fix before an official
release", otherwise we need a version bump.
The OAP protocol document has also been updated, needs an update in the
osmo-gsm-manuals as well.
Change-Id: If25b173d9ec57ea4c504d860954912b7d82af455
2017-02-02 19:05:14 +00:00
|
|
|
uint8_t auts[14];
|
2016-04-27 16:32:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
int osmo_oap_decode(struct osmo_oap_message *oap_msg, const uint8_t *data,
|
|
|
|
size_t data_len);
|
|
|
|
void osmo_oap_encode(struct msgb *msg, const struct osmo_oap_message *oap_msg);
|