/***************************************************************************//** \file zclKeyEstablishmentCluster.h \brief The header file describes the ZCL Key Establishment Cluster and its interface The file describes the types and interface of the ZCL Key Establishment Cluster \author Atmel Corporation: http://www.atmel.com \n Support email: avr@atmel.com Copyright (c) 2008-2011, Atmel Corporation. All rights reserved. Licensed under Atmel's Limited License Agreement (BitCloudTM). \internal History: 10.03.09 A. Potashov - Created. *******************************************************************************/ #ifndef _ZCLKEYESTABLISHMENTCLUSTER_H #define _ZCLKEYESTABLISHMENTCLUSTER_H /*! Attributes and commands necessary for managing secure communication between ZigBee devices. */ #ifdef _ZCL_SECURITY_ #ifdef _CERTICOM_SECURITY_ /******************************************************************************* Includes section *******************************************************************************/ #include #include #include /******************************************************************************* Define(s) section *******************************************************************************/ #define ZCL_KE_INVALID_ENDPOINT APS_ZDO_ENDPOINT #define ZCL_KE_INVALID_SHORT_ADDRESS 0xffff #define ZCL_KE_INVALID_EXT_ADDRESS 0xffffffffffffffffLL //KE Cluster timeout settings #ifndef ZCL_KE_EPHEMERAL_DATA_GENERATE_TIME #define ZCL_KE_EPHEMERAL_DATA_GENERATE_TIME 0x10 #endif #ifndef ZCL_KE_CONFIRM_KEY_GENERATE_TIME #define ZCL_KE_CONFIRM_KEY_GENERATE_TIME 0x10 #endif //!This timeout (seconds) will be sent in Terminate KE Command #ifndef ZCL_KE_TERMINATE_KE_TIMEOUT #define ZCL_KE_TERMINATE_KE_TIMEOUT 50 #endif //!This timeout (seconds) will be applied for commands receive wating with unspecified timeouts #ifndef ZCL_KE_TIMEOUT #define ZCL_KE_TIMEOUT 50 #endif /***************************************************************************//** \brief ZCL Key Establishment Cluster server side attributes amount *******************************************************************************/ #define ZCL_KE_CLUSTER_SERVER_ATTRIBUTES_AMOUNT 1 /***************************************************************************//** \brief ZCL Key Establishment Cluster client side attributes amount *******************************************************************************/ #define ZCL_KE_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT 1 /***************************************************************************//** \brief ZCL Key Establishment Cluster commands amount *******************************************************************************/ #define ZCL_KE_CLUSTER_COMMANDS_AMOUNT 8 //!Key Establishment Suite Attribute #define ZCL_KE_CLUSTER_SERVER_KEY_ESTABLISHMENT_SUITE_ATTRIBUTE_ID CCPU_TO_LE16(0x0000) //!Key Establishment Suite Attribute #define ZCL_KE_CLUSTER_CLIENT_KEY_ESTABLISHMENT_SUITE_ATTRIBUTE_ID CCPU_TO_LE16(0x0000) #define ZCL_KE_INITIATE_KEY_ESTABLISHMENT_REQUEST_COMMAND_ID 0x00 #define ZCL_KE_EPHEMERAL_DATA_REQUEST_COMMAND_ID 0x01 #define ZCL_KE_CONFIRM_KEY_DATA_REQUEST_COMMAND_ID 0x02 #define ZCL_KE_TERMINATE_KEY_ESTABLISHMENT_COMMAND_ID 0x03 #define ZCL_KE_INITIATE_KEY_ESTABLISHMENT_RESPONSE_COMMAND_ID 0x00 #define ZCL_KE_EPHEMERAL_DATA_RESPONSE_COMMAND_ID 0x01 #define ZCL_KE_CONFIRM_KEY_DATA_RESPONSE_COMMAND_ID 0x02 #define ZCL_KE_CBKE_ECMQV_KEY_ESTABLISHMENT_SUITE_ID 0x0001 /******************************************************************************* Types section *******************************************************************************/ /***************************************************************************//** \brief ZCL Key Establishment Cluster server side attributes defining macros This macros should be used for ZCL Key Establishment Cluster server side attributes defining. \return None \internal //The typical usage is: //Key Establishment Cluster server side related attributes ZCL_EKClusterServerAttributes_t ekClusterServerAttributes = ZCL_DEFINE_EK_CLUSTER_SERVER_ATTRIBUTES(); *******************************************************************************/ #define ZCL_DEFINE_EK_CLUSTER_SERVER_ATTRIBUTES() \ {DEFINE_ATTRIBUTE(keyEstablishmentSuite, ZCL_READONLY_ATTRIBUTE, ZCL_KE_CLUSTER_SERVER_KEY_ESTABLISHMENT_SUITE_ATTRIBUTE_ID, ZCL_16BIT_ENUM_DATA_TYPE_ID)} /***************************************************************************//** \brief ZCL Key Establishment Cluster client side attributes defining macros This macros should be used for ZCL Key Establishment Cluster client side attributes defining. \return None \internal //The typical usage is: //Key Establishment Cluster client side related attributes ZCL_EKClusterClientAttributes_t ekClusterClientAttributes = ZCL_DEFINE_EK_CLUSTER_CLIENT_ATTRIBUTES(); *******************************************************************************/ #define ZCL_DEFINE_EK_CLUSTER_CLIENT_ATTRIBUTES() \ {DEFINE_ATTRIBUTE(keyEstablishmentSuite, ZCL_READONLY_ATTRIBUTE, ZCL_KE_CLUSTER_CLIENT_KEY_ESTABLISHMENT_SUITE_ATTRIBUTE_ID, ZCL_16BIT_ENUM_DATA_TYPE_ID)} #define DEFINE_INITIATE_KEY_ESTABLISHMENT_REQUEST(initiateKeyEstablishmentReqInd) \ DEFINE_COMMAND(initiateKeyEstablishmentReq, ZCL_KE_INITIATE_KEY_ESTABLISHMENT_REQUEST_COMMAND_ID, \ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \ initiateKeyEstablishmentReqInd) #define DEFINE_INITIATE_KEY_ESTABLISHMENT_RESPONSE(initiateKeyEstablishmentRespInd) \ DEFINE_COMMAND(initiateKeyEstablishmentResp, ZCL_KE_INITIATE_KEY_ESTABLISHMENT_RESPONSE_COMMAND_ID, \ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \ initiateKeyEstablishmentRespInd) #define DEFINE_EPHEMERAL_DATA_REQUEST(ephemeralDataReqInd) \ DEFINE_COMMAND(ephemeralDataReq, ZCL_KE_EPHEMERAL_DATA_REQUEST_COMMAND_ID, \ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \ ephemeralDataReqInd) #define DEFINE_EPHEMERAL_DATA_RESPONSE(ephemeralDataRespInd) \ DEFINE_COMMAND(ephemeralDataResp, ZCL_KE_EPHEMERAL_DATA_RESPONSE_COMMAND_ID, \ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \ ephemeralDataRespInd) #define DEFINE_CONFIRM_KEY_DATA_REQUEST(confirmKeyDataReqInd) \ DEFINE_COMMAND(confirmKeyDataReq, ZCL_KE_CONFIRM_KEY_DATA_REQUEST_COMMAND_ID, \ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \ confirmKeyDataReqInd) #define DEFINE_CONFIRM_KEY_DATA_RESPONSE(confirmKeyDataRespInd) \ DEFINE_COMMAND(confirmKeyDataResp, ZCL_KE_CONFIRM_KEY_DATA_RESPONSE_COMMAND_ID, \ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \ confirmKeyDataRespInd) #define DEFINE_TERMINATE_KEY_ESTABLISHMENT_SERVER_PART(terminateKeyEstablishmentReqIndServerPart) \ DEFINE_COMMAND(terminateKeyEstablishmentReqServerPart, ZCL_KE_TERMINATE_KEY_ESTABLISHMENT_COMMAND_ID, \ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \ terminateKeyEstablishmentReqIndServerPart) #define DEFINE_TERMINATE_KEY_ESTABLISHMENT_CLIENT_PART(terminateKeyEstablishmentReqIndClientPart) \ DEFINE_COMMAND(terminateKeyEstablishmentReqClientPart, ZCL_KE_TERMINATE_KEY_ESTABLISHMENT_COMMAND_ID, \ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \ terminateKeyEstablishmentReqIndClientPart) #define KE_CLUSTER_COMMANDS(initiateKeyEstablishmentReqInd, initiateKeyEstablishmentRespInd, \ ephemeralDataReqInd, ephemeralDataRespInd, confirmKeyDataReqInd, confirmKeyDataRespInd, \ terminateKeyEstablishmentReqIndServerPart, terminateKeyEstablishmentReqIndClientPart) \ DEFINE_INITIATE_KEY_ESTABLISHMENT_REQUEST(initiateKeyEstablishmentReqInd), \ DEFINE_INITIATE_KEY_ESTABLISHMENT_RESPONSE(initiateKeyEstablishmentRespInd), \ DEFINE_EPHEMERAL_DATA_REQUEST(ephemeralDataReqInd), \ DEFINE_EPHEMERAL_DATA_RESPONSE(ephemeralDataRespInd), \ DEFINE_CONFIRM_KEY_DATA_REQUEST(confirmKeyDataReqInd), \ DEFINE_CONFIRM_KEY_DATA_RESPONSE(confirmKeyDataRespInd), \ DEFINE_TERMINATE_KEY_ESTABLISHMENT_SERVER_PART(terminateKeyEstablishmentReqIndServerPart), \ DEFINE_TERMINATE_KEY_ESTABLISHMENT_CLIENT_PART(terminateKeyEstablishmentReqIndClientPart) \ /***************************************************************************//** \brief ZCL Key Establishment Cluster server side defining macros This macros should be used with #ZCL_DEFINE_EK_CLUSTER_SERVER_ATTRIBUTES and #ZCL_DEFINE_EK_CLUSTER_SERVER_COMMANDS for ZCL Key Establishment Cluster server side defining. \param attributes - pointer to cluster server attributes (ZCL_KEClusterServerAttributes_t) \param commands - pointer to cluster server commands (ZCL_KEServerCommands_t) \return None \internal //The typical code is: //Key Establishment Cluster server side related attributes and commands ZCL_KEClusterServerAttributes_t keClusterServerAttributes = ZCL_DEFINE_EK_CLUSTER_SERVER_ATTRIBUTES(); ZCL_KEClusterServerCommands_t keClusterServerCommands = ZCL_DEFINE_EK_CLUSTER_SERVER_COMMANDS(handler1, handler2, handler3, handlerv); ZCL_Cluster_t ekClusterServer = ZCL_DEFINE_KE_CLUSTER_SERVER(&keClusterServerAttributes, &keClusterServerCommands); *******************************************************************************/ #define ZCL_DEFINE_KE_CLUSTER_SERVER(clattributes, clcommands) \ { \ .id = ZCL_KEY_ESTABLISHMENT_CLUSTER_ID, \ .options = \ { \ .type = ZCL_SERVER_CLUSTER_TYPE, \ .security = ZCL_NETWORK_KEY_CLUSTER_SECURITY, \ .reserved = 0, \ }, \ .attributesAmount = ZCL_KE_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \ .attributes = (uint8_t *) clattributes, \ .commandsAmount = ZCL_KE_CLUSTER_COMMANDS_AMOUNT, \ .commands = (uint8_t *) clcommands \ } /***************************************************************************//** \brief ZCL Key Establishment Cluster client side defining macros This macros should be used with #ZCL_DEFINE_EK_CLUSTER_CLIENT_ATTRIBUTES and #ZCL_DEFINE_EK_CLUSTER_CLIENT_COMMANDS for ZCL Key Establishment Cluster client side defining. \param attributes - pointer to cluster client attributes (ZCL_KEClusterClientAttributes_t) \param commands - pointer to cluster client commands (ZCL_KEClientCommands_t) \return None \internal //The typical code is: //Key Establishment Cluster client side related attributes and commands ZCL_KEClusterClientAttributes_t keClusterClientAttributes = ZCL_DEFINE_EK_CLUSTER_CLIENT_ATTRIBUTES(); ZCL_KEClusterClientCommands_t keClusterClientCommands = ZCL_DEFINE_EK_CLUSTER_CLIENT_COMMANDS(handler1, handler2, handler3, handlerv); ZCL_Cluster_t ekClusterClient = ZCL_DEFINE_KE_CLUSTER_Client(&keClusterClientAttributes, &keClusterClientCommands); *******************************************************************************/ #define ZCL_DEFINE_KE_CLUSTER_CLIENT(clattributes, clcommands) \ { \ .id = ZCL_KEY_ESTABLISHMENT_CLUSTER_ID, \ .options = \ { \ .type = ZCL_CLIENT_CLUSTER_TYPE, \ .security = ZCL_NETWORK_KEY_CLUSTER_SECURITY, \ .reserved = 0, \ }, \ .attributesAmount = ZCL_KE_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \ .attributes = (uint8_t *) clattributes, \ .commandsAmount = ZCL_KE_CLUSTER_COMMANDS_AMOUNT, \ .commands = (uint8_t *) clcommands \ } BEGIN_PACK /***************************************************************************//** \brief ZCL Key Establishment Cluster server side attributes *******************************************************************************/ typedef struct PACK { //!Information attribute set (Id == 0x00) /*!KeyEstablishmentSuite attribute (Read only, M) The KeyEstablishmentSuite attribute is 16-bits in length and specifies all the cryptographic schemes for key establishment on the device. A device shall set the corresponding bit to 1 for every cryptographic scheme that is supports. All other cryptographic schemes and reserved bits shall be set to 0. */ struct PACK { ZCL_AttributeId_t id; //!