⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mac_security.s51

📁 zigbee location examples
💻 S51
📖 第 1 页 / 共 2 页
字号:
//////////////////////////////////////////////////////////////////////////////
//                                                                           /
// IAR 8051 C/C++ Compiler V7.20H/W32                  16/Jan/2007  15:30:28 /
// Copyright 2004-2006 IAR Systems. All rights reserved.                     /
//                                                                           /
//    Core               =  plain                                            /
//    Code model         =  banked                                           /
//    Data model         =  large                                            /
//    Calling convention =  xdata reentrant                                  /
//    Constant location  =  data                                             /
//    Dptr setup         =  1,16                                             /
//    Source file        =  E:\公司产品资料\Zigbee\cc2431\cc2431定位\LOC_Eng /
//                          ine\lib\mac\CC2430\mac_security.c                /
//    Command line       =  -I "C:\Program Files\IAR Systems\Embedded        /
//                          Workbench 4.05 Evaluation version\8051\INC\" -I  /
//                          "C:\Program Files\IAR Systems\Embedded           /
//                          Workbench 4.05 Evaluation                        /
//                          version\8051\SRC\LIB\" -I "C:\Program Files\IAR  /
//                          Systems\Embedded Workbench 4.05 Evaluation       /
//                          version\8051\INC\CLIB\" -I                       /
//                          E:\公司产品资料\Zigbee\cc2431\cc2431定位\LOC_Eng /
//                          ine\Test\mac\mac_loc\..\..\..\include\ -I        /
//                          E:\公司产品资料\Zigbee\cc2431\cc2431定位\LOC_Eng /
//                          ine\Test\mac\mac_loc\..\..\..\include\mac\cc2430 /
//                          \ -I E:\公司产品资料\Zigbee\cc2431\cc2431定位\LO /
//                          C_Engine\Test\mac\mac_loc\..\..\..\include\hal\c /
//                          c2430\ -I E:\公司产品资料\Zigbee\cc2431\cc2431定 /
//                          位\LOC_Engine\Test\mac\mac_loc\..\..\..\apps\    /
//                          -D CC2430EB -D USE_LED -lCN                      /
//                          E:\公司产品资料\Zigbee\cc2431\cc2431定位\LOC_Eng /
//                          ine\Test\mac\mac_loc\CC2430EB\List\ -lA          /
//                          E:\公司产品资料\Zigbee\cc2431\cc2431定位\LOC_Eng /
//                          ine\Test\mac\mac_loc\CC2430EB\List\ -o           /
//                          E:\公司产品资料\Zigbee\cc2431\cc2431定位\LOC_Eng /
//                          ine\Test\mac\mac_loc\CC2430EB\Obj\ -e -s9        /
//                          --debug --core=plain --dptr=16,1                 /
//                          --data_model=large --code_model=banked           /
//                          --calling_convention=xdata_reentrant             /
//                          --place_constants=data --nr_virtual_regs 8       /
//                          E:\公司产品资料\Zigbee\cc2431\cc2431定位\LOC_Eng /
//                          ine\lib\mac\CC2430\mac_security.c                /
//    List file          =  E:\公司产品资料\Zigbee\cc2431\cc2431定位\LOC_Eng /
//                          ine\Test\mac\mac_loc\CC2430EB\List\mac_security. /
//                          s51                                              /
//                                                                           /
//                                                                           /
//////////////////////////////////////////////////////////////////////////////

        NAME mac_security

        RTMODEL "__calling_convention", "xdata_reentrant"
        RTMODEL "__code_model", "banked"
        RTMODEL "__core", "plain"
        RTMODEL "__data_model", "large"
        RTMODEL "__dptr_size", "16"
        RTMODEL "__extended_stack", "disabled"
        RTMODEL "__location_for_constants", "data"
        RTMODEL "__number_of_dptrs", "1"
        RTMODEL "__rt_version", "1"

        RSEG DOVERLAY:DATA:NOROOT(0)
        RSEG IOVERLAY:IDATA:NOROOT(0)
        RSEG ISTACK:IDATA:NOROOT(0)
        RSEG PSTACK:XDATA:NOROOT(0)
        RSEG XSTACK:XDATA:NOROOT(0)


        END
// E:\公司产品资料\Zigbee\cc2431\cc2431定位\LOC_Engine\lib\mac\CC2430\mac_security.c
//    1 /*******************************************************************************************************
//    2  *                                                                                                     *
//    3  *        **********                                                                                   *
//    4  *       ************                                                                                  *
//    5  *      ***        ***                                                                                 *
//    6  *      ***   +++   ***                                                                                *
//    7  *      ***   + +   ***                                                                                *
//    8  *      ***   +                        CHIPCON CC2430 INTEGRATED 802.15.4 MAC AND PHY                  *
//    9  *      ***   + +   ***                MAC Security Support                                            *
//   10  *      ***   +++   ***                                                                                *
//   11  *      ***        ***                                                                                 *
//   12  *       ************                                                                                  *
//   13  *        **********                                                                                   *
//   14  *                                                                                                     *
//   15  *******************************************************************************************************
//   16  * CONFIDENTIAL                                                                                        *
//   17  * The use of this file is restricted by the signed MAC software license agreement.                    *
//   18  *                                                                                                     *
//   19  * Copyright Chipcon AS, 2005                                                                          *
//   20  *******************************************************************************************************
//   21  * This file implements the MAC security support functions, used internally in the MAC sublayer        *
//   22  *******************************************************************************************************/
//   23 #include <mac_headers.h>
//   24 
//   25 
//   26 #if (MAC_OPT_SECURITY)
//   27 
//   28 //-------------------------------------------------------------------------------------------------------
//   29 //  BYTE msecFindSecurityMaterial(BOOL isTX, BYTE addrMode, WORD panId, ADDRESS *pAddr, ...
//   30 //
//   31 //  DESCRIPTION:
//   32 //      Support function for selecting the correct security material.
//   33 //      First search the ACL, then default security. If neither is available for this frame,
//   34 //      return with the value UNAVAILABLE_KEY
//   35 //      Used ONLY for outgoing packets (incoming packets handled in receive routine)
//   36 //
//   37 //  PARAMETERS:
//   38 //
//   39 //  RETURN VALUE:
//   40 //      BYTE
//   41 //          UNAVAILABLE_KEY if no key is available
//   42 //          securitySuite (0 - 7) otherwise
//   43 //-------------------------------------------------------------------------------------------------------
//   44 ROOT void msecFindTxSecurityMaterial(MAC_TX_PACKET *pPacket, BOOL securityEnable, BYTE addrMode, WORD panId, ADDRESS *pAddr) {
//   45     BYTE n;
//   46     BOOL aclFound = FALSE;
//   47     BYTE securitySuite;
//   48     SECURITY_MATERIAL *pSecurityMaterial;
//   49 
//   50     if (securityEnable) {
//   51         securitySuite = UNAVAILABLE_KEY;
//   52         pSecurityMaterial = NULL;
//   53 
//   54         // Search through ACL for extended addresses
//   55         for (n=0; n<mpib.macACLEntryDescriptorSetSize; n++) {
//   56             if (addrMode == AM_EXTENDED_64) {
//   57                 if (msupCompareAddress(&pAddr->Extended, &mpib.ppMacACLEntryDescriptorSet[n]->extendedAddress)) {
//   58                     aclFound = TRUE;
//   59                     break;
//   60                 }
//   61             } else if ((addrMode == AM_SHORT_16) && (panId == mpib.ppMacACLEntryDescriptorSet[n]->panId)) {
//   62                 if (pAddr->Short == mpib.ppMacACLEntryDescriptorSet[n]->shortAddress) {
//   63                     aclFound = TRUE;
//   64                     break;
//   65                 }
//   66             }
//   67         }
//   68 
//   69         if (aclFound) {
//   70             pSecurityMaterial = &mpib.ppMacACLEntryDescriptorSet[n]->securityMaterial;
//   71             securitySuite = mpib.ppMacACLEntryDescriptorSet[n]->securitySuite;
//   72 
//   73         // Is default security available ?
//   74         // Default security can only be used in TX (when the 64 bit destination address is equal to
//   75         // aExtendedAddress) or in RX when the source address mode is extended.
//   76         } else if ((mpib.macSecurityMode == MAC_SECURED_MODE) && (mpib.macDefaultSecurity) && (securityEnable)) {
//   77             // Default security enabled
//   78             pSecurityMaterial = mpib.pMacDefaultSecurityMaterial;
//   79             securitySuite = mpib.macDefaultSecuritySuite;
//   80         }
//   81 
//   82         pPacket->pSecurityMaterial = pSecurityMaterial;
//   83         pPacket->securitySuite = securitySuite;
//   84 
//   85     } else {
//   86         // Security not enabled, no key is necessary
//   87         pPacket->securitySuite = MAC_SECURITY_NONE;
//   88     }
//   89 } // msecFindSecurityMaterial
//   90 
//   91 
//   92 
//   93 
//   94 //-------------------------------------------------------------------------------------------------------
//   95 //  void msecDecodeSecuritySuite(MSEC_SETUP_INFO *pMSI, BYTE securityMode)
//   96 //
//   97 //  DESCRIPTION:
//   98 //      Decodes the given security mode, and sets up the MSEC_SETUP_INFO struct with the necessary
//   99 //      information.
//  100 //
//  101 //  PARAMETERS:
//  102 //      MSEC_SETUP_INFO *pMSI
//  103 //          Pointer to the MSEC_SETUP_INFO struct used for RX or TX
//  104 //
//  105 //      BYTE securityMode
//  106 //          MAC security mode
//  107 //          (MAC_SECURITY_NONE |  MAC_SECURITY_AES_CTR | MAC_SECURITY_AES_CCM128 |
//  108 //           MAC_SECURITY_AES_CCM64 | MAC_SECURITY_AES_CCM32 | MAC_SECURITY_AES_CBC_MAC128 |
//  109 //           MAC_SECURITY_AES_CBC_MAC64 | MAC_SECURITY_AES_CBC_MAC32)
//  110 //
//  111 //  RETURN VALUE:
//  112 //      void
//  113 //-------------------------------------------------------------------------------------------------------
//  114 ROOT void msecDecodeSecuritySuite(MSEC_SETUP_INFO *pMSI, BYTE securitySuite) {
//  115 
//  116     // Which security mode is used?
//  117     switch (securitySuite) {
//  118     case MAC_SECURITY_AES_CCM128:
//  119         pMSI->secFlags2420 = MAC_CC2420_CCM_FLAGS;
//  120         pMSI->secMode2420 = CC2420_SECCTRL0_CCM | (7 << CC2420_SECCTRL0_SEC_M_IDX);
//  121         pMSI->micLength = 16;
//  122         break;
//  123     case MAC_SECURITY_AES_CCM64:
//  124         pMSI->secFlags2420 = MAC_CC2420_CCM_FLAGS;
//  125         pMSI->secMode2420 = CC2420_SECCTRL0_CCM | (3 << CC2420_SECCTRL0_SEC_M_IDX);
//  126         pMSI->micLength = 8;
//  127         break;
//  128     case MAC_SECURITY_AES_CCM32:
//  129         pMSI->secFlags2420 = MAC_CC2420_CCM_FLAGS;
//  130         pMSI->secMode2420 = CC2420_SECCTRL0_CCM | (1 << CC2420_SECCTRL0_SEC_M_IDX);
//  131         pMSI->micLength = 4;
//  132         break;
//  133     case MAC_SECURITY_AES_CBC_MAC128:
//  134         pMSI->secFlags2420 = 0;
//  135         pMSI->secMode2420 = CC2420_SECCTRL0_CBC_MAC | (7 << CC2420_SECCTRL0_SEC_M_IDX);
//  136         pMSI->micLength = 16;
//  137         pMSI->clearTextLength = 0;
//  138         break;
//  139     case MAC_SECURITY_AES_CBC_MAC64:

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -