Calculating Message Digest; Calculating Md5 Hash; Calculating Sha Hash - Libelium Waspmote v15 and Plug & Sense Programming Manual

Waspmote encryption libraries
Table of Contents

Advertisement

2.2. Calculating Message Digest

This section will describe how calculate a message digest depends on the selected algorithm. The different algorithms provide
different messages digest size.
For example, the Message Digest (MD5) hash is a mathematical algorithm which produces a unique 128 bit number (a hash)
created from the data input. If even one bit of data changes, the hash value will change.

2.2.1. Calculating MD5 hash

Previously, a variable to store the message digest must be declared. This variable must be correctly dimensioned to contain the
calculated hash message.
{
uint8_t hash_message[16];
}
The features that must be met in order to calculate the MD5 algorithm are:
Output size
Algorithms
MD5
The next code shows how to calculate the message digest with
where the output is stored, the input message pointer and the length of the input message.
{
char message[] = "Libelium";
HASH.md5(hash_message_md5, (uint8_t*)message, strlen(message)*8);
}

2.2.2. Calculating SHA hash

The features that must be met in order to calculate the SHA algorithm are:
Output size
Algorithms
(bits)
SHA-1
160
SHA-224
224
SHA-256
256
SHA-384
384
SHA-512
512
Previously, a variable to store the message digest must be declared. This variable must be correctly dimensioned to contain the
calculated hash message.
If SHA-1 is used, the variable that stores the hash message is defined:
{
uint8_t hash_message[20];
}
If SHA-384 is used, the variable that stores the hash message is defined:
{
uint8_t hash_message[48];
}
Internal state
(bits)
size (bits)
128
128
Internal state
size (bits)
160
256
256
512
512
Block size
(bits)
512
. The inputs expected are: the pointer to the buffer
HASH.md5()
Block size
Max message
(bits)
size (bits)
512
2⁶⁴− 1
512
2⁶⁴− 1
512
2⁶⁴− 1
512
2¹²⁸− 1
1024
2¹²⁸− 1
-7-
Max message
Word size
size (bits)
(bits)
2⁶⁴− 1
Word size
(bits)
32
32
32
64
64
Integrity
32
Rounds
80
64
64
80
80
v7.0

Advertisement

Table of Contents
loading

Table of Contents