SLAA547C July   2013  – July 2021 MSP430FR5739

 

  1. 1Software Benchmarks
    1. 1.1 AES Benchmarks
    2. 1.2 DES Benchmarks
    3. 1.3 SHA-2 Benchmarks
  2. 2Using Library Functions
    1. 2.1 AES 128
      1. 2.1.1 Encrypting With AES 128
      2. 2.1.2 Decrypting With AES 128
    2. 2.2 DES
      1. 2.2.1 Setting the Key Schedule for DES
      2. 2.2.2 Encrypting and Decryption With DES
      3. 2.2.3 Encryption and Decryption With DES CBC Mode
    3. 2.3 3DES
      1. 2.3.1 Encrypting and Decrypting With Triple DES
    4. 2.4 SHA-2
      1. 2.4.1 Hashing With SHA-256
      2. 2.4.2 Hashing With SHA-224
  3. 3Overview of Library Functions
    1. 3.1 AES 128
      1.      aes_enc_dec
      2.      aes_encrypt
    2. 3.2 DES and 3DES
      1.      Des_Key
      2.      Des_Enc
      3.      Des_Dec
      4.      DES_ENC_CBC
      5.      DES_DEC_CBC
      6.      TripleDES_ENC
      7.      TripleDES_DEC
      8.      TripleDES_ENC_CBC
      9.      TripleDES_DEC_CBC
    3. 3.3 SHA-256 and SHA-224
      1.      SHA_256
  4. 4Cryptographic Standard Definitions
    1. 4.1 AES
      1. 4.1.1 Basic Concept of Algorithm
      2. 4.1.2 Structure of Key and Input Data
      3. 4.1.3 Substitute Bytes (Subbytes Operation)
      4. 4.1.4 Shift Rows (Shiftrows Operation)
      5. 4.1.5 Mix Columns (Mixcolumns Operation)
      6. 4.1.6 Add Round Key (Addroundkey Operation)
      7. 4.1.7 Key Expansion (Keyexpansion Operation)
    2. 4.2 DES and 3DES
      1. 4.2.1 DES Algorithm Structure
      2. 4.2.2 The Function Block
      3. 4.2.3 Key Schedule
      4. 4.2.4 Triple DES
      5. 4.2.5 Cipher Block Chaining (CBC) Mode
    3. 4.3 SHA-256 and SHA-224
      1. 4.3.1 Message Padding and Parsing
      2. 4.3.2 SHA-256 Algorithm
      3. 4.3.3 Equations Found in SHA-256 Algorithm
      4. 4.3.4 SHA-224
  5. 5References
    1.     Revision History

Hashing With SHA-256

The following code example shows an example of a data hash using SHA-256.

#include "msp430xxxx.h"
#include "TI_SHA2.h"

uint32_t M[32]; //Message array to be hashed
uint64_t L = 0x0000000000000000;  //Bit Length of message to be hashed
uint32_t Ha[8]; // Hash Array to be used during calculation and to store result

int main( void )
{  
   M[0] =0x41424344;  //Data
   M[1] =0x45464748;  //Data
   M[2] =0x494A4B4C;  //Data
   L = 0x0000000000000060 //Length == 96 bits or 0x60 bits

   SHA_256(M, L, Ha, 1); // "1" indicates SHA-256 mode

return 0;
}

Although this example does not show full initialization of the array M[ ], all relevant values have been populated with meaningful data. M[ ] must be initialized to sizes equal to a 512-bit block of data or hashing block. If the message to be hashed exceeds 448 bits within a hashing block, then an additional hashing block must be reserved. Table 2-1 explains minimum sizes of M[ ] according to message size.

Table 2-1 Minimum Sizes of M[ ]
Message Size x (bits)Minimum Size of Array M[ ]
× < 448M[16]
448 ≤ × ≤ 512M[32]
512 < × < 960M[32]
960 ≤ × < 1024M[48]