NidNmk.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*===========================================================================
  2. Combined Charging System (CCS): SECC
  3. NidNmk.h
  4. initiated by Vern, Joseph
  5. (since 2019/07/19)
  6. =============================================================================*/
  7. #include <stdint.h>
  8. #include <unistd.h>
  9. #include <stdlib.h>
  10. #include <string.h>
  11. typedef struct sha256
  12. {
  13. uint32_t count [2];
  14. uint32_t state [8];
  15. uint8_t block [64];
  16. uint8_t extra [64];
  17. } SHA256;
  18. #define SHA256_DIGEST_LENGTH 256 / 8
  19. #define HPAVKEY_NMK_LEN 16
  20. #define HPAVKEY_NID_LEN 7
  21. #define SHR(word, bits) ((word & 0xFFFFFFFF) >> bits)
  22. #define ROTR(word, bits) (SHR(word, bits) | (word << (32 - bits)))
  23. #define DEFAULT_LEVEL 0
  24. //--------------------------------------------------------------------------
  25. /* Functions -----------------------------------------------------------*/
  26. //--------------------------------------------------------------------------
  27. void HPAVKeyNMK(uint8_t NMK [], const char *string);
  28. void HPAVKeyNID(uint8_t NID [], const uint8_t NMK [], uint8_t level);
  29. void SHA256Reset(struct sha256 *sha256);
  30. void SHA256Block(struct sha256 *sha256, void const *memory);
  31. void SHA256Write(struct sha256 *sha256, void const *memory, uint16_t extent);
  32. void SHAEncode(uint8_t memory [], uint32_t number);
  33. void SHA256Fetch(struct sha256 *sha256, uint8_t digest []);