From 2cf0d8f1ebe55f50a311db60519e89f1ed3ea455 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Mon, 28 Dec 2015 13:13:47 +0100 Subject: [PATCH] ranap_msg_factory: CipheringInformation is optional in SecurityModeCommand --- src/ranap_msg_factory.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ranap_msg_factory.c b/src/ranap_msg_factory.c index 41c4fbee..143c9566 100644 --- a/src/ranap_msg_factory.c +++ b/src/ranap_msg_factory.c @@ -218,8 +218,6 @@ struct msgb *ranap_new_msg_sec_mod_cmd(const uint8_t *ik, const uint8_t *ck) memset(&ies, 0, sizeof(ies)); memset(&out, 0, sizeof(out)); - ies.presenceMask = SECURITYMODECOMMANDIES_RANAP_ENCRYPTIONINFORMATION_PRESENT; - for (i = 0; i < ARRAY_SIZE(ip_alg); i++) { /* needs to be dynamically allocated, as * SET_OF_free() will call FREEMEM() on it */ @@ -231,6 +229,7 @@ struct msgb *ranap_new_msg_sec_mod_cmd(const uint8_t *ik, const uint8_t *ck) BIT_STRING_fromBuf(&ies.integrityProtectionInformation.key, ik, 16*8); if (ck) { + ies.presenceMask = SECURITYMODECOMMANDIES_RANAP_ENCRYPTIONINFORMATION_PRESENT; for (i = 0; i < ARRAY_SIZE(ip_alg); i++) { /* needs to be dynamically allocated, as * SET_OF_free() will call FREEMEM() on it */ @@ -248,7 +247,8 @@ struct msgb *ranap_new_msg_sec_mod_cmd(const uint8_t *ik, const uint8_t *ck) /* release dynamic allocations attached to ies */ ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_RANAP_IntegrityProtectionInformation, &ies.integrityProtectionInformation); - ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_RANAP_EncryptionInformation, &ies.encryptionInformation); + if (ck) + ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_RANAP_EncryptionInformation, &ies.encryptionInformation); /* out -> msg */ msg = ranap_generate_initiating_message(RANAP_ProcedureCode_id_SecurityModeControl,