A method for maximizing a number of registers at an end of an iteration of a hash algorithm for use in a next iteration, wherein the secure hash algorithm comprises at least one of an SHA-512 algorithm and an SHA-384 algorithm implemented on an advanced reduced instruction set computer machine type ARM processor comprising sixteen 32-bit registers of which one is a program counter (PC), another is a stack pointer (SP) and 14 working registers, and a stack for storing values A-H representing the state words of the iteration, with an architecture including data preloading and doubleword loading/storing, the method comprising: categorizing and unrolling secure hash algorithm iterations into even iterations and odd iterations, wherein the even iterations comprise a sequence of computations: loading, from the stack in the registers, a set of stored values A-C; computing and storing in a pair of registers a first value t= Σ0(A)+Maj(A,B,C) ; loading, from the stack in the registers, the remaining values D-H; computing a second value u based on Σ1(E)+Ch(E,F,G) and input bytes w[i]; computing using the first value t and the second value u and storing on the stack new values E and A, new values E-H and A being found in the registers; reversing, in the odd iterations the sequence of computations in the even iterations by: computing a new second value u based on Σ1(E)+Ch(E,F,G) and input bytes w[i] first and updating the new value E; using the new second value u loading, from the stack in the registers, another set of values B-D; computing a new first value t=Σ0(A)+Maj(A,B,C) and updating based on the new first value t the new value A, new values A-C being found in the registers; and combining an even iteration and an odd iteration to provide a new iteration of a loop. categorizing and unrolling secure hash algorithm iterations into even iterations and odd iterations, wherein the even iterations comprise a sequence of computations: loading, from the stack in the registers, a set of stored values A-C; computing and storing in a pair of registers a first value t= Σ0(A)+Maj(A,B,C) ; loading, from the stack in the registers, the remaining values D-H; computing a second value u based on Σ1(E)+Ch(E,F,G) and input bytes w[i]; computing using the first value t and the second value u and storing on the stack new values E and A, new values E-H and A being found in the registers; loading, from the stack in the registers, a set of stored values A-C; computing and storing in a pair of registers a first value t= Σ0(A)+Maj(A,B,C) ; loading, from the stack in the registers, the remaining values D-H; computing a second value u based on Σ1(E)+Ch(E,F,G) and input bytes w[i]; computing using the first value t and the second value u and storing on the stack new values E and A, new values E-H and A being found in the registers; reversing, in the odd iterations the sequence of computations in the even iterations by: computing a new second value u based on Σ1(E)+Ch(E,F,G) and input bytes w[i] first and updating the new value E; using the new second value u loading, from the stack in the registers, another set of values B-D; computing a new first value t=Σ0(A)+Maj(A,B,C) and updating based on the new first value t the new value A, new values A-C being found in the registers; and computing a new second value u based on Σ1(E)+Ch(E,F,G) and input bytes w[i] first and updating the new value E; using the new second value u loading, from the stack in the registers, another set of values B-D; computing a new first value t=Σ0(A)+Maj(A,B,C) and updating based on the new first value t the new value A, new values A-C being found in the registers; and combining an even iteration and an odd iteration to provide a new iteration of a loop. <EOS>