/******************************************************************************/
// @copyright   Copyright Notification
//   No part may be reproduced except as authorized by written permission.
//   The copyright and the foregoing restriction extend to reproduction in all media.
//   Trademark 2010, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TTA, TTC).
//   All rights reserved.
// @version: IWD_10wk37
// $Date: 2010-03-18 18:53:05 +0100 (Thu, 18 Mar 2010) $
// $Rev: 2632 $
/******************************************************************************/

module EUTRA_ExternalSecurityFunctions {

  import from CommonDefs all;
  import from EUTRA_CommonDefs all;
  import from EPS_NAS_TypeDefs all;

  const integer tsc_DirectionUL := 0;   /* acc. to 33.401 B.1.1 and B.2.1                @status    APPROVED*/
  const integer tsc_DirectionDL := 1;   /* acc. to 33.401 B.1.1 and B.2.1                @status    APPROVED*/
  type integer MAC_Direction_Type (tsc_DirectionDL, tsc_DirectionUL);   /* direction bit for calculation of MAC acc. to 24.301 cl. 9.5    @status    APPROVED*/

  const integer tsc_KDF_HMAC_SHA_256 := 1;      /* @status    APPROVED */
  const integer tsc_KDF_Spare1 := 2;
  const integer tsc_KDF_Spare2 := 3;
  const integer tsc_KDF_Spare3 := 4;            /* @status    APPROVED */

  type integer KDF_Type ( tsc_KDF_HMAC_SHA_256 .. tsc_KDF_Spare3 );     /* @status    APPROVED */

  //============================================================================

  external function fx_KeyDerivationFunction(KDF_Type  p_KDF,
                                             B256_Type p_Key,
                                             octetstring p_String) return B256_Type;
  /* External function to hashing function with algorithm as defined in 33.401;
     SHA-256 encoding algorithm used as KEY Description Function
     @status    APPROVED */

  //----------------------------------------------------------------------------
  external function fx_NasIntegrityAlgorithm(octetstring   p_EncodedNasPdu,
                                             B3_Type       p_IntegrityAlgorithm,
                                             B128_Key_Type p_KNASint,
                                             NasCount_Type p_NasCount,
                                             B5_Type       p_BearerId,    /* R5-101050: BearerId changed to 5 bits */
                                             MAC_Direction_Type p_Direction) return MessageAuthenticationCode;    /* @status    APPROVED */

  external function fx_NasCiphering(octetstring p_EncodedNasPdu,
                                    B3_Type       p_CipheringAlgorithm,
                                    B128_Key_Type p_KNASenc,
                                    NasCount_Type p_NasCount,
                                    B5_Type p_BearerId) return octetstring;                                       /* R5-101050: BearerId changed to 5 bits
                                                                                                                     @status    APPROVED */

  external function fx_NasDeciphering(octetstring p_CipheredNasMsg,
                                      B3_Type       p_CipheringAlgorithm,
                                      B128_Key_Type p_KNASenc,
                                      NasCount_Type p_NasCount,
                                      B5_Type p_BearerId) return octetstring;                                     /*  R5-101050: BearerId changed to 5 bits
                                                                                                                      @status    APPROVED */

  //----------------------------------------------------------------------------

  external function fx_AsIntegrityAlgorithm(octetstring   p_EncodedPdcpPdu,
                                            IntegrityProtAlgorithm_Type p_IntegrityAlgorithm,
                                            B128_Key_Type p_KRRCint,
                                            O4_Type       p_PdcpCount,
                                            B5_Type       p_BearerId,
                                            MAC_Direction_Type p_Direction) return MessageAuthenticationCode;      /* R5-101050: BearerId changed to 5 bits
                                                                                                                      see TS 36.323 clause 5.7 */

  external function fx_AsCiphering(octetstring p_EncodedSdu,
                                   CipheringAlgorithm_Type p_CipheringAlgorithm,
                                   B128_Key_Type p_Key,
                                   O4_Type p_PdcpCount,
                                   B5_Type p_BearerId) return octetstring;                                         /* R5-101050: BearerId changed to 5 bits
                                                                                                                      see TS 36.323 clause 5.6 */

  external function fx_AsDeciphering(octetstring p_CipheredSdu,
                                     CipheringAlgorithm_Type p_CipheringAlgorithm,
                                     B128_Key_Type p_Key,
                                     O4_Type p_PdcpCount,
                                     B5_Type p_BearerId) return octetstring;                                       /* R5-101050: BearerId changed to 5 bits
                                                                                                                      see TS 36.323 clause 5.6 */

  //----------------------------------------------------------------------------
}
