/* ARM assembly Raspberry PI */ /* program sha1-1.s */ /* use with library openssl */ /* link with gcc option -lcrypto -lssl */ /* REMARK 1 : this program use routines in a include file see task Include a file language arm assembly for the routine affichageMess conversion10 see at end of this program the instruction include */ /* for constantes see task include a file in arm assembly */ /************************************/ /* Constantes */ /************************************/ .include "../constantes.inc" .equ SHA_DIGEST_LENGTH, 20 /*******************************************/ /* Fichier des macros */ /********************************************/ .include "../../ficmacros.s" /*********************************/ /* Initialized data */ /*********************************/ .data szMessRosetta: .asciz "Rosetta Code" .equ LGMESSROSETTA, . - szMessRosetta - 1 szCarriageReturn: .asciz "\n" szMessSup64: .ascii "ABCDEFGHIJKLMNOPQRSTUVWXYZ" .ascii "abcdefghijklmnopqrstuvwxyz" .asciz "1234567890AZERTYUIOP" .equ LGMESSSUP64, . - szMessSup64 - 1 szMessTest2: .asciz "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" .equ LGMESSTEST2, . - szMessTest2 - 1 /*********************************/ /* UnInitialized data */ /*********************************/ .bss .align 4 szMessResult: .skip 24 sZoneConv: .skip 24 /*********************************/ /* code section */ /*********************************/ .text .global main main: @ entry of program ldr r0,iAdrszMessRosetta mov r1,#LGMESSROSETTA ldr r2,iAdrszMessResult bl SHA1 @ appel fonction openssl ldr r0,iAdrszMessResult bl displaySHA1 100: @ standard end of the program mov r0, #0 @ return code mov r7, #EXIT @ request to exit program svc #0 @ perform the system call iAdrszMessRosetta: .int szMessRosetta iAdrszCarriageReturn: .int szCarriageReturn iAdrszMessResult: .int szMessResult iAdrsZoneConv: .int sZoneConv iAdrszMessSup64: .int szMessSup64 iAdrszMessTest2: .int szMessTest2 /******************************************************************/ /* display hash SHA1 */ /******************************************************************/ /* r0 contains the address of hash */ displaySHA1: push {r1-r3,lr} @ save registres mov r3,r0 mov r2,#0 1: ldr r0,[r3,r2,lsl #2] @ load 4 bytes rev r0,r0 @ reverse bytes ldr r1,iAdrsZoneConv bl conversion16 @ conversion hexa ldr r0,iAdrsZoneConv bl affichageMess add r2,r2,#1 cmp r2,#SHA_DIGEST_LENGTH / 4 blt 1b @ and loop ldr r0,iAdrszCarriageReturn bl affichageMess @ display message 100: pop {r1-r3,lr} @ restaur registers bx lr @ return /***************************************************/ /* ROUTINES INCLUDE */ /***************************************************/ .include "../affichage.inc"