User Tools

Site Tools


en:pfw:sha-256

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en:pfw:sha-256 [2024-10-17 12:50] jeroenhen:pfw:sha-256 [2024-10-17 13:09] (current) jeroenh
Line 187: Line 187:
  
 </code> </code>
- +  
- +  
- +  
- +  
 + 
 **Testing the SHA-256 algorithm** **Testing the SHA-256 algorithm**
  
  
 Testing the SHA-256 algorithm can be done with the following code. The 'abc' example comes directly from the the standard document. Testing the SHA-256 algorithm can be done with the following code. The 'abc' example comes directly from the the standard document.
- +  
 + 
 <code> <code>
  
Line 233: Line 233:
  
 </code> </code>
- +  
- +  
- +  
 +  
 + 
 **Optimising performance of the SHA-256 hash generator - step 1 ** **Optimising performance of the SHA-256 hash generator - step 1 **
  
Line 243: Line 244:
  
 One way of optimising performance is to use Forth-Macros, as described by Wil Baden in Forth Dimensions Vol. 19, No. 2. There is a version floating around on the internet which does exactly that. Here is an simplified version of that code. It is not totally using generic Forth as I wanted to keep te original as unchanged as possible. The extensive use of PICK and the 64DROP used after each block are noteworthy. One way of optimising performance is to use Forth-Macros, as described by Wil Baden in Forth Dimensions Vol. 19, No. 2. There is a version floating around on the internet which does exactly that. Here is an simplified version of that code. It is not totally using generic Forth as I wanted to keep te original as unchanged as possible. The extensive use of PICK and the 64DROP used after each block are noteworthy.
- +  
- +  
 + 
 <code> <code>
- +  
 + 
 \ ======================================================== \ ========================================================
 \ ANS Forth code for Secure Hash Algorithms SHA-256 \ ANS Forth code for Secure Hash Algorithms SHA-256
Line 473: Line 474:
  
  
-</code\ +</code> 
- +  
- +  
- +  
 + 
 **Optimising performance of the SHA-256 hash generator - step 2 ** **Optimising performance of the SHA-256 hash generator - step 2 **
  
-A more thorough optimisation would be to look at often used parts of the code and optimise those.+A more thorough optimisation is possible by looking at often used parts of the code and optimising those.
  
  
Line 495: Line 496:
  
 The following is an example where ARM32 assembly is used for the subloop and the HASH1BLOCK word: The following is an example where ARM32 assembly is used for the subloop and the HASH1BLOCK word:
- +  
 + 
 <code> <code>
  
Line 775: Line 776:
  
 </code> </code>
- +  
- +  
- +  
 + 
 Please note that this is all done using bog-standard ARM32 assembly, no SHA-256 specific opcodes are used. These  SHA_256 specific opcodes would increase the performance even more. Another option would be to use the NEON coprocessor. This is available on Raspberry Pi2 and later and would allow some parallel processing of the subloop. If this really raises throughput is as yet unproven. Please note that this is all done using bog-standard ARM32 assembly, no SHA-256 specific opcodes are used. These  SHA_256 specific opcodes would increase the performance even more. Another option would be to use the NEON coprocessor. This is available on Raspberry Pi2 and later and would allow some parallel processing of the subloop. If this really raises throughput is as yet unproven.
  
en/pfw/sha-256.1729162244.txt.gz · Last modified: 2024-10-17 12:50 by jeroenh