Skip to content

timsky/CryptoC

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cryptosuite is a cryptographic library for Arduino forked from: https://github.com/Cathedrow/Cryptosuite

SHA implements secure hash functions that can be used for cryptography, data integrity and security purposes.

Currently covers the following standards:
  SHA-256 (FIPS 180-2)
  HMAC-SHA-256 (FIPS 198a)

What is a hash function?
  A hash function takes a message, and generates a number.
  A good hash function has the following properties:
    The number is large enough that you will never find two messages with the same number (a 'collision')
    It is computationally unfeasible to extract message information from its hash (without trying every possible combination)
    A small (1 bit) change in the message will produce a huge (approximately half of all bits) change in the hash.
    Fast to calculate

  SHA is slower than simple hashes (eg. parity), but has very high security - high enough to be used in currency transactions and confidential documents.
  SHA-256 is slightly slower, but has higher security.

What is an HMAC?
  HMACs are Hashed Message Authentication Codes. Using them, it is possible to prove that you have a secret key without actually disclosing it.

Installation:
  Make a 'libraries' directory with your Arduino sketches folder if you do not already have one.
  Copy the 'Sha' directory into that directory.
  Restart Arduino to rescan for new libraries.

Using SHA-256:
  #include "sha256.h"
  ...
  uint8_t *hash;
  Sha256.init();
  Sha256.print("This is a message to hash");
  hash = Sha256.result();

  The hash result is then stored in hash[0], hash[1] .. hash[31].

Using HMAC-SHA-256:
  #include "sha256.h"
  ...
  uint8_t *hash;
  Sha256.initHmac("hash key",8); // key, and length of key in bytes
  Sha256.print("This is a message to hash");
  hash = Sha256.resultHmac();

  The hash result is then stored in hash[0], hash[1] .. hash[31].

Verification:
  The provided example code tests against published test vectors.
  SHA-256: FIPS 180-2, RFC4231 compliant
  HMAC-SHA-256:  RFC4231 compliant

  hash algorithm derived from http://www.rfc-editor.org/rfc/rfc6234.txt

About

Cryptographic suite for Arduino (SHA, HMAC-SHA)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Other 59.0%
  • C++ 41.0%