aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <nhofmeyr@sysmocom.de>2016-04-19 01:21:41 +0200
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2016-04-19 01:32:25 +0200
commita9f5566482f164564fe639da434aa9e8d6dc12c0 (patch)
tree834fcdc98be02e9f16e20e4ff2be59bdc0895d92
parent68b7a4786887dc0b055780f650a5a16e6e57bba2 (diff)
ranap_msg_factory: add Security Mode Complete msg generator
Needed by hnb-test to reply to a Security Mode Command message.
-rw-r--r--include/osmocom/ranap/ranap_msg_factory.h7
-rw-r--r--src/ranap_msg_factory.c31
2 files changed, 38 insertions, 0 deletions
diff --git a/include/osmocom/ranap/ranap_msg_factory.h b/include/osmocom/ranap/ranap_msg_factory.h
index 7a9f3d2..d0fe4a2 100644
--- a/include/osmocom/ranap/ranap_msg_factory.h
+++ b/include/osmocom/ranap/ranap_msg_factory.h
@@ -4,6 +4,8 @@
#include <osmocom/ranap/RANAP_Cause.h>
#include <osmocom/ranap/RANAP_CN-DomainIndicator.h>
#include <osmocom/ranap/RANAP_GlobalRNC-ID.h>
+#include <osmocom/ranap/RANAP_ChosenIntegrityProtectionAlgorithm.h>
+#include <osmocom/ranap/RANAP_ChosenEncryptionAlgorithm.h>
/*! \brief generate RANAP DIRECT TRANSFER message */
struct msgb *ranap_new_msg_dt(uint8_t sapi, const uint8_t *nas, unsigned int nas_len);
@@ -11,6 +13,11 @@ struct msgb *ranap_new_msg_dt(uint8_t sapi, const uint8_t *nas, unsigned int nas
/*! \brief generate RANAP SECURITY MODE COMMAND message */
struct msgb *ranap_new_msg_sec_mod_cmd(const uint8_t *ik, const uint8_t *ck);
+/*! \brief generate RANAP SECURITY MODE COMPLETE message */
+struct msgb *ranap_new_msg_sec_mod_compl(
+ RANAP_ChosenIntegrityProtectionAlgorithm_t chosen_ip_alg,
+ RANAP_ChosenEncryptionAlgorithm_t chosen_enc_alg);
+
/*! \brief generate RANAP COMMON ID message */
struct msgb *ranap_new_msg_common_id(const char *imsi);
diff --git a/src/ranap_msg_factory.c b/src/ranap_msg_factory.c
index bdae92e..5ca7d96 100644
--- a/src/ranap_msg_factory.c
+++ b/src/ranap_msg_factory.c
@@ -263,6 +263,37 @@ struct msgb *ranap_new_msg_sec_mod_cmd(const uint8_t *ik, const uint8_t *ck)
return msg;
}
+struct msgb *ranap_new_msg_sec_mod_compl(
+ RANAP_ChosenIntegrityProtectionAlgorithm_t chosen_ip_alg,
+ RANAP_ChosenEncryptionAlgorithm_t chosen_enc_alg)
+{
+ RANAP_SecurityModeCompleteIEs_t ies;
+ RANAP_SecurityModeComplete_t out;
+ struct msgb *msg;
+ int i, rc;
+
+ memset(&ies, 0, sizeof(ies));
+ memset(&out, 0, sizeof(out));
+
+ ies.presenceMask = SECURITYMODECOMPLETEIES_RANAP_CHOSENENCRYPTIONALGORITHM_PRESENT;
+ ies.chosenIntegrityProtectionAlgorithm = chosen_ip_alg;
+ ies.chosenEncryptionAlgorithm = chosen_enc_alg;
+
+ /* ies -> out */
+ rc = ranap_encode_securitymodecompleteies(&out, &ies);
+
+ /* out -> msg */
+ msg = ranap_generate_successful_outcome(RANAP_ProcedureCode_id_SecurityModeControl,
+ RANAP_Criticality_reject,
+ &asn_DEF_RANAP_SecurityModeComplete,
+ &out);
+
+ /* release dynamic allocations attached to out */
+ ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_RANAP_SecurityModeComplete, &out);
+
+ return msg;
+}
+
/*! \brief generate RANAP COMMON ID message */
struct msgb *ranap_new_msg_common_id(const char *imsi)
{