pfodParser 5.0.1 The pfodParser library is handles commands sent from the Android pfodApp, pfodApp supports WiFi, BLE, Bluetooth and SMS connections

SipHash_2_4.h
Go to the documentation of this file.
1 #ifndef SipHash_2_4_H
2 #define SipHash_2_4_H
3
4 /*
5 SipHash_2_4.h
6 SipHash for 8bit Atmel processors
7
8 Note: one instance sipHash is already constructed in .cpp file
9
10 Usage
11 uint8_t key[] PROGMEM = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
12 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f};
13 sipHash.initFromPROGMEM(key); // initialize with key NOTE: key is stored in flash (PROGMEM)
14 // use sipHash.initFromRAM(key); if key in RAM
15 for (int i=0; i<msgLen;i++) {
16 sipHash.updateHash((byte)c); // update hash with each byte of msg
17 }
18 sipHash.finish(); // finish
19 // sipHash.result then contains the 8bytes of the hash in BigEndian format
20
21
22 see https://131002.net/siphash/ for details of algorithm
23 */
24 /*
25 * (c)2014-2017 Forward Computing and Control Pty. Ltd.
26 * NSW Australia, www.forward.com.au
27 * This code is not warranted to be fit for any purpose. You may only use it at your own risk.
28 * This code may be freely used for both private and commercial use
29 * Provide this copyright is maintained.
30 */
31
32 #include <inttypes.h>
33 #if defined(ESP_PLATFORM) || defined(ARDUINO_ARCH_ESP8266)
34 #include <pgmspace.h>
35 #elif ARDUINO_ARDUINO_NANO33BLE
36 #include <api/deprecated-avr-comp/avr/pgmspace.h>
37 #else
38 #include <avr/pgmspace.h>
39 #endif
40
41 extern void reverse64(uint8_t *x);
42
43 class SipHash_2_4 {
44 public:
45 SipHash_2_4(void); // This class already defines an instance sipHash, see the SipHashTest.ino
46 /*
47 ** use this init if the key is in an flash (program) memory
48 // Define your 'secret' 16 byte key in program memory (flash memory)
49 uint8_t key[] PROGMEM = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
50 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f};
51 // to start hashing initialize with your key
52 sipHash.initFromPROGMEM(key);
53 */
54 void initFromPROGMEM(const uint8_t *keyPrgPtrIn);
55
56 /*
57 ** use this init if the key is in an RAM memory
58 // Define your 'secret' 16 byte key array
59 uint8_t key[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
60 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f};
61 // to start hashing initialize with your key
62 sipHash.initFromRAM(key);
63 */
64 void initFromRAM(const uint8_t *key);
65 void updateHash(uint8_t c);
66 void finish();
67 uint8_t *result; // after finalize() always points to v0
68
69 // the state in RAM public for debugging
70 uint8_t v0[8];
71 uint8_t v1[8];
72 uint8_t v2[8];
73 uint8_t v3[8];
74
75 private:
76
77 void hash(uint8_t* m);
78 void siphash_round();
79
80 // the local storage to bytes to hash
81 uint8_t m[8]; // bytes to hash
82 int8_t m_idx; // counts from 7 down to -1
83 uint8_t msg_byte_counter; // count of msg bytes % 256
84 // total ram 42 bytes + stack usage for calls
85 };
86 extern SipHash_2_4 sipHash; // defined in .cpp file
87
88 #endif
sipHash
SipHash_2_4 sipHash
reverse64
void reverse64(uint8_t *x)
SipHash_2_4
Definition: SipHash_2_4.h:43
SipHash_2_4::v0
uint8_t v0[8]
Definition: SipHash_2_4.h:70
SipHash_2_4::SipHash_2_4
SipHash_2_4(void)
SipHash_2_4::v2
uint8_t v2[8]
Definition: SipHash_2_4.h:72
SipHash_2_4::finish
void finish()
SipHash_2_4::v3
uint8_t v3[8]
Definition: SipHash_2_4.h:73
SipHash_2_4::initFromPROGMEM
void initFromPROGMEM(const uint8_t *keyPrgPtrIn)
SipHash_2_4::updateHash
void updateHash(uint8_t c)
SipHash_2_4::v1
uint8_t v1[8]
Definition: SipHash_2_4.h:71
SipHash_2_4::result
uint8_t * result
Definition: SipHash_2_4.h:67
SipHash_2_4::initFromRAM
void initFromRAM(const uint8_t *key)