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

📄 security.psm

📁 基于spartan3e的串口调试和检测程序,可直接烧写,检测结果将同时通过LCD显示出来
💻 PSM
📖 第 1 页 / 共 5 页
字号:
                          ;
                          STORE sD, computed_CRC0                  ;store CRC value
                          STORE sE, computed_CRC1
                          CALL send_Computed_CRC                   ;display computed CRC value on PC via UART
                          LOAD s0, sE
                          CALL send_hex_byte
                          LOAD s0, sD
                          CALL send_hex_byte
                          CALL send_CR
                          ;
                          ;
                          ;
                          ; Read the authenticated CRC value stored in StrataFLASH memory.
                          ; 16-bit value is hidden in 256 bytes of random numbers to make it more difficult
                          ; for an attacker to identify.
                          ; Read value is stored in scratch pad memory and displayed on the PC via UART.
                          ;
                          CALL read_authentication                 ;read StrataFLASH memory into [sB,sA]
                          STORE sA, authentication_CRC0            ;store CRC value
                          STORE sB, authentication_CRC1
                          CALL send_FLASH_CRC                      ;display CRC value from FLASH on PC via UART
                          LOAD s0, sB
                          CALL send_hex_byte
                          LOAD s0, sA
                          CALL send_hex_byte
                          CALL send_CR
                          ;
                          ;
                          ; Compare the computed CRC value with the authentication value stored in StrataFLASH
                          ; and determine if the design is authenticated. Then decide course of action.
                          ;
                          CALL LCD_clear                           ;clear LCD display
                          CALL disp_Authentication                 ;prepare LCD display for result of authentication
                          CALL send_Authentication                 ;prepare PC display for result of authentication
                          ;
                          COMPARE sA, sD                           ;Perform comparison of CRC values
                          JUMP NZ, auth_failure
                          COMPARE sB, sE
                          JUMP NZ, auth_failure
                          ;
                          ;
                          ; Authentication Successful Process
                          ;
                          ; In this mode the design continues to operate and for evaluation
                          ; purposes this design transfers control to the simple menu immediately.
                          ;
             auth_passed: CALL disp_Passed                         ;display successful authentication on LCD display
                          CALL send_PASSED                         ;display successful authentication on PC via UART
                          JUMP Menu
                          ;
                          ; Authentication Failure Process
                          ;
                          ; When the authentication fails two hardware based disable methods are demonstrated. Then
                          ; the failed status is remembered for future software token messages to demonstrate software
                          ; based disabling of the 'real' application. Finally the simple menu of options is presented
                          ; to allow evaluation to continue.
                          ;
                          ;
            auth_failure: CALL disp_Failed                         ;display failure to authenticate on LCD display
                          CALL send_FAILED                         ;display failure to authenticate on PC via UART
                          CALL send_CR
                          CALL disable_app_hardware                ;sequence hardware disable signals
                          LOAD s0, character_F                     ;change authentication status to 'F' for failed.
                          STORE s0, authentication_status          ; so that application software disable is demonstrated
                          ;
                          ;
                          ;
                          ; Menu of options for authentication processing
                          ;
                    Menu: CALL send_Menu                           ;display menu and prompt
                          CALL read_from_UART                      ;read character from PC
                          CALL upper_case                          ;convert to upper case
                          COMPARE UART_data, character_R
                          JUMP Z, read_command
                          COMPARE UART_data, character_E
                          JUMP Z, erase_command
                          COMPARE UART_data, character_A
                          JUMP Z, authorise_command
                          JUMP Menu                                ;repeat menu for invalid selection
                          ;
                          ;
                          ;
            read_command: CALL send_CR
                          CALL send_auth_page
                          CALL send_CR
                          CALL send_CR
                          JUMP Menu
                          ;
                          ;
                          ;
           erase_command: CALL send_Erase_in_progress
                          CALL erase_authentication
                          CALL send_OK
                          JUMP Menu
                          ;
                          ;
                          ;
       authorise_command: CALL send_Writing                        ;Send 'Writing Authorisation' message
                          CALL send_CR
                          FETCH sD, computed_CRC0                  ;fetch computed CRC value
                          FETCH sE, computed_CRC1
                          CALL write_authentication                ;write computed CRC to FLASH with random data
                          CALL send_OK
                          JUMP Menu
                          ;
                          ;
                          ;**************************************************************************************
                          ; Drive failure signals to the application.
                          ;**************************************************************************************
                          ;
                          ; When the design fails to authorise, these controls cause the application to behave in
                          ; a strange way!
                          ;
                          ;
                          ; Disable interrupts to application PicoBlaze to stop PWM generation completely for 5 seconds
                          ;
    disable_app_hardware: LOAD s0, security_disable_interrupts
                          OUTPUT s0, authentication_control_port
                          LOAD s5, 05
                          CALL delay_Ns
                          ;
                          ; Enable application for 5 seconds
                          ;
                          LOAD s0, 00
                          OUTPUT s0, authentication_control_port
                          LOAD s5, 05
                          CALL delay_Ns
                          ;
                          ; Disable and/or scramble outputs connected to application PicoBlaze for 5 seconds
                          ;
                          LOAD s0, security_disable_outputs
                          OUTPUT s0, authentication_control_port
                          LOAD s5, 05
                          CALL delay_Ns
                          ;
                          ;
                          ; Enable application in hardware so that software disable function can then be
                          ; demonstrated until the design is reconfigured and authentication test repeated.
                          ;
                          LOAD s0, 00
                          OUTPUT s0, authentication_control_port
                          RETURN
                          ;
                          ;
                          ;
                          ;**************************************************************************************
                          ; Send the 64-bit serial number stored in scratch pad memory to the UART
                          ;**************************************************************************************
                          ;
                          ; The serial number should previously have been copied into the 8 ascending scratch pad
                          ; memory locations called 'serial_number0' through to 'serial_number7'.
                          ;
                          ; The serial number is displayed MS-Byte first.
                          ;
                          ; Registers used s0,s1,s2,s3
                          ;
      send_serial_number: CALL send_FLASH_Serial_Number            ;display text message
                          LOAD s3, serial_number7                  ;pointer to scratch pad memory
            send_SN_loop: FETCH s0, (s3)                           ;read serial number byte
                          CALL send_hex_byte                       ;display byte
                          CALL send_space                          ;display byte
                          COMPARE s3, serial_number0               ;check for 8 bytes sent to UART
                          JUMP Z, end_send_SN
                          SUB s3, 01                               ;increment memory pointer
                          JUMP send_SN_loop
                          ;
             end_send_SN: CALL send_CR
                          RETURN
                          ;
                          ;
                          ;
                          ;**************************************************************************************
                          ; Display the 64-bit serial number stored in scratch pad memory on the LCD display
                          ;**************************************************************************************
                          ;
                          ; The serial number should previously have been copied into the 8 ascending scratch pad
                          ; memory locations called 'serial_number0' through to 'serial_number7'.
                          ;
                          ; The serial number is displayed MS-Byte first.
                          ;
                          ; Registers used s0,s1,s2,s3,s4,s5,s6
                          ;
      disp_serial_number: CALL LCD_clear                           ;clear LCD display
                          LOAD s5, 10                              ;Line 1 position 0
                          CALL LCD_cursor
                          CALL disp_FLASH_Serial_No                ;display text message
                          LOAD s5, 20                              ;Line 2 position 0
                          CALL LCD_cursor
                          LOAD s6, serial_number7                  ;pointer to scratch pad memory
            disp_SN_loop: FETCH s0, (s6)                           ;read serial number byte
                          CALL disp_hex_byte                       ;display byte
                          COMPARE s6, serial_number0               ;check for 8 bytes sent to UART
                          JUMP Z, end_disp_SN
                          SUB s6, 01                               ;increment memory pointer

⌨️ 快捷键说明

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