Chameleon-Mini
Crypto1.h
1 #ifndef CRYPTO1_H
2 #define CRYPTO1_H
3 
4 #include <stdint.h>
5 #include <stdbool.h>
6 
7 void Crypto1GetState(uint8_t *pEven, uint8_t *pOdd);
8 
9 /* Gets the current keystream-bit, without shifting the internal LFSR */
10 uint8_t Crypto1FilterOutput(void);
11 
12 /* Set up Crypto1 cipher using the given Key, Uid and CardNonce. Also encrypts
13  * the CardNonce in-place while in non-linear mode. */
14 void Crypto1Setup(uint8_t Key[6], uint8_t Uid[4], uint8_t CardNonce[4]);
15 /* Same for nested auth. CardNonce[4]..[7] will contain the parity bits after return */
16 void Crypto1SetupNested(uint8_t Key[6], uint8_t Uid[4], uint8_t CardNonce[8], bool Decrypt);
17 
18 /* Load the decrypted ReaderNonce into the Crypto1 state LFSR */
19 void Crypto1Auth(uint8_t EncryptedReaderNonce[4]);
20 
21 /* Generate 8 Bits of key stream */
22 uint8_t Crypto1Byte(void);
23 
24 /* Encrypt/Decrypt array */
25 void Crypto1ByteArray(uint8_t *Buffer, uint8_t Count);
26 void Crypto1ByteArrayWithParity(uint8_t *Buffer, uint8_t Count);
27 
28 /* Generate 4 Bits of key stream */
29 uint8_t Crypto1Nibble(void);
30 
31 /* Execute 'ClockCount' cycles on the PRNG state 'State' */
32 void Crypto1PRNG(uint8_t State[4], uint8_t ClockCount);
33 
34 /* Encrypts buffer with consideration of parity bits */
35 void Crypto1EncryptWithParity(uint8_t *Buffer, uint8_t BitCount);
36 
37 /* Encrypts buffer with LFSR feedback within reader nonce and considers parity bits */
38 void Crypto1ReaderAuthWithParity(uint8_t PlainReaderAnswerWithParityBits[9]);
39 
40 #endif //CRYPTO1_H