Commit f557e8a6 authored by Anton Kozhemiachenko's avatar Anton Kozhemiachenko

nrUE: add EAP-AKA' support

parent affb4dc8
......@@ -1794,6 +1794,7 @@ set(libnas_ies_OBJS
${NAS_SRC}COMMON/IES/AuthenticationParameterAutn.c
${NAS_SRC}COMMON/IES/AuthenticationParameterRand.c
${NAS_SRC}COMMON/IES/AuthenticationResponseParameter.c
${NAS_SRC}COMMON/IES/EapMessage.c
${NAS_SRC}COMMON/IES/CipheringKeySequenceNumber.c
${NAS_SRC}COMMON/IES/Cli.c
${NAS_SRC}COMMON/IES/CsfbResponse.c
......
......@@ -1758,6 +1758,7 @@ INPUT = \
@CMAKE_CURRENT_SOURCE_DIR@/../openair3/NAS/COMMON/IES/TimeZoneAndTime.c \
@CMAKE_CURRENT_SOURCE_DIR@/../openair3/NAS/COMMON/IES/Cli.c \
@CMAKE_CURRENT_SOURCE_DIR@/../openair3/NAS/COMMON/IES/AuthenticationResponseParameter.c \
@CMAKE_CURRENT_SOURCE_DIR@/../openair3/NAS/COMMON/IES/EapMessage.c \
@CMAKE_CURRENT_SOURCE_DIR@/../openair3/NAS/COMMON/IES/SORTransparentContainer.h \
@CMAKE_CURRENT_SOURCE_DIR@/../openair3/NAS/COMMON/IES/FGSRegistrationType.h \
@CMAKE_CURRENT_SOURCE_DIR@/../openair3/NAS/COMMON/IES/NasRequestType.h \
......@@ -1857,6 +1858,7 @@ INPUT = \
@CMAKE_CURRENT_SOURCE_DIR@/../openair3/NAS/COMMON/IES/ProtocolConfigurationOptions.c \
@CMAKE_CURRENT_SOURCE_DIR@/../openair3/NAS/COMMON/IES/EpsQualityOfService.c \
@CMAKE_CURRENT_SOURCE_DIR@/../openair3/NAS/COMMON/IES/AuthenticationResponseParameter.h \
@CMAKE_CURRENT_SOURCE_DIR@/../openair3/NAS/COMMON/IES/EapMessage.h \
@CMAKE_CURRENT_SOURCE_DIR@/../openair3/NAS/COMMON/IES/PdnType.h \
@CMAKE_CURRENT_SOURCE_DIR@/../openair3/NAS/COMMON/IES/EpsMobileIdentity.c \
@CMAKE_CURRENT_SOURCE_DIR@/../openair3/NAS/COMMON/IES/SupportedCodecList.c \
......
......@@ -44,12 +44,25 @@ int encode_fgs_authentication_response(fgs_authentication_response_msg *authenti
int encode_result = 0;
if ((encode_result =
encode_authentication_response_parameter(&authentication_response->authenticationresponseparameter,
AUTHENTICATION_RESPONSE_PARAMETER_IEI, buffer + encoded, len - encoded)) < 0) //Return in case of error
return encode_result;
else
encoded += encode_result;
if ((authentication_response->presencemask & FGS_AUTHENTICATION_RESPONSE_AUTH_RESPONSE_PARAM_PRESENT)
== FGS_AUTHENTICATION_RESPONSE_AUTH_RESPONSE_PARAM_PRESENT) {
if ((encode_result =
encode_authentication_response_parameter(&authentication_response->authenticationresponseparameter,
FGS_AUTHENTICATION_RESPONSE_AUTH_RESPONSE_PARAM_IEI, buffer + encoded, len - encoded)) < 0) //Return in case of error
return encode_result;
else
encoded += encode_result;
}
if ((authentication_response->presencemask & FGS_AUTHENTICATION_RESPONSE_EAP_MESSAGE_PRESENT)
== FGS_AUTHENTICATION_RESPONSE_EAP_MESSAGE_PRESENT) {
if ((encode_result =
encode_eap_message(&authentication_response->eapmessage,
FGS_AUTHENTICATION_RESPONSE_EAP_MESSAGE_IEI, buffer + encoded, len - encoded)) < 0) //Return in case of error
return encode_result;
else
encoded += encode_result;
}
return encoded;
}
......
......@@ -37,11 +37,18 @@
#include "SpareHalfOctet.h"
#include "MessageType.h"
#include "AuthenticationResponseParameter.h"
#include "EapMessage.h"
#ifndef FGS_AUTHENTICATION_RESPONSE_H_
#define FGS_AUTHENTICATION_RESPONSE_H_
#define AUTHENTICATION_RESPONSE_PARAMETER_IEI 0x2d
# define FGS_AUTHENTICATION_RESPONSE_AUTH_RESPONSE_PARAM_PRESENT (1<<0)
# define FGS_AUTHENTICATION_RESPONSE_EAP_MESSAGE_PRESENT (1<<1)
typedef enum fgs_authentication_response_iei_tag {
FGS_AUTHENTICATION_RESPONSE_AUTH_RESPONSE_PARAM_IEI = 0x2D, /* 0x2D = 45 */
FGS_AUTHENTICATION_RESPONSE_EAP_MESSAGE_IEI = 0x78, /* 0x78 = 120 */
} fgs_authentication_response_iei;
/*
* Message name: Identity response
......@@ -56,7 +63,10 @@ typedef struct fgs_authentication_response_msg_tag {
SecurityHeaderType securityheadertype:4;
SpareHalfOctet sparehalfoctet:4;
MessageType messagetype;
/* Optional fields */
uint32_t presencemask;
AuthenticationResponseParameter authenticationresponseparameter;
EapMessage eapmessage;
} fgs_authentication_response_msg;
int encode_fgs_authentication_response(fgs_authentication_response_msg *authentication_response, uint8_t *buffer, uint32_t len);
......
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "TLVEncoder.h"
#include "TLVDecoder.h"
#include "EapMessage.h"
int decode_eap_message(EapMessage *eapmessage, uint8_t iei, uint8_t *buffer, uint32_t len)
{
int decoded = 0;
uint16_t ielen = 0;
int decode_result;
if (iei > 0) {
CHECK_IEI_DECODER(iei, *buffer);
decoded++;
}
ielen = (uint16_t)(*(buffer + decoded) << 8);
ielen |= (uint16_t)(*(buffer + decoded + 1));
decoded += 2;
CHECK_LENGTH_DECODER(len - decoded, ielen);
if ((decode_result = decode_octet_string(&eapmessage->eapMsg, ielen, buffer + decoded, len - decoded)) < 0)
return decode_result;
else
decoded += decode_result;
#if defined (NAS_DEBUG)
dump_eap_message_xml(eapmessage, iei);
#endif
return decoded;
}
int encode_eap_message(EapMessage *eapmessage, uint8_t iei, uint8_t *buffer, uint32_t len)
{
uint16_t ielen = 0;
uint8_t *lenPtr;
uint32_t encoded = 0;
int encode_result;
/* Checking IEI and pointer */
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, EAP_MESSAGE_MINIMUM_LENGTH, len);
#if defined (NAS_DEBUG)
dump_eap_message_xml(eapmessage, iei);
#endif
if (iei > 0) {
*buffer = iei;
encoded++;
}
lenPtr = (buffer + encoded);
encoded += 2;
if ((encode_result = encode_octet_string(&eapmessage->eapMsg, buffer + encoded, len - encoded)) < 0)
return encode_result;
else
encoded += encode_result;
ielen = encoded - 2 - ((iei > 0) ? 1 : 0);
*lenPtr = (uint8_t)((ielen >> 8) & 0xFF);
*(lenPtr + 1) = (uint8_t)(ielen & 0xFF);
return encoded;
}
void dump_eap_message_xml(EapMessage *eapmessage, uint8_t iei)
{
printf("<EAP Message>\n");
dump_octet_string_xml(&eapmessage->eapMsg);
printf("</EAP Message>\n");
}
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "OctetString.h"
#ifndef EAP_MESSAGE_H_
#define EAP_MESSAGE_H_
#define EAP_MESSAGE_MINIMUM_LENGTH 7
#define EAP_MESSAGE_MAXIMUM_LENGTH 1503
typedef struct EapMessage_tag {
OctetString eapMsg;
} EapMessage;
int encode_eap_message(EapMessage *eapmessage, uint8_t iei, uint8_t *buffer, uint32_t len);
int decode_eap_message(EapMessage *eapmessage, uint8_t iei, uint8_t *buffer, uint32_t len);
void dump_eap_message_xml(EapMessage *eapmessage, uint8_t iei);
#endif /* EAP_MESSAGE_H_ */
This diff is collapsed.
......@@ -103,6 +103,9 @@
/* Security Key for SA UE */
typedef struct {
uint8_t mk[256]; // EAP-AKA' master-key.
// PRF' produces as many bits of output as is needed,
// lets define 256 bytes MK.
uint8_t kausf[32];
uint8_t kseaf[32];
uint8_t kamf[32];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment