big merge

This commit is contained in:
Philippe G
2021-12-18 21:04:23 -08:00
parent 955692f8ad
commit 898998efb0
583 changed files with 84472 additions and 1965 deletions

View File

@@ -0,0 +1,43 @@
#ifndef SHANNON_H
#define SHANNON_H
#include <cstdint>
#include <vector>
class Shannon
{
public:
static constexpr unsigned int N = 16;
void key(const std::vector<uint8_t> &key); /* set key */
void nonce(const std::vector<uint8_t> &nonce); /* set Init Vector */
void stream(std::vector<uint8_t> &buf); /* stream cipher */
void maconly(std::vector<uint8_t> &buf); /* accumulate MAC */
void encrypt(std::vector<uint8_t> &buf); /* encrypt + MAC */
void decrypt(std::vector<uint8_t> &buf); /* decrypt + MAC */
void finish(std::vector<uint8_t> &buf); /* finalise MAC */
private:
static constexpr unsigned int FOLD = Shannon::N;
static constexpr unsigned int INITKONST = 0x6996c53a;
static constexpr unsigned int KEYP = 13;
uint32_t R[Shannon::N];
uint32_t CRC[Shannon::N];
uint32_t initR[Shannon::N];
uint32_t konst;
uint32_t sbuf;
uint32_t mbuf;
int nbuf;
static uint32_t sbox1(uint32_t w);
static uint32_t sbox2(uint32_t w);
void cycle();
void crcfunc(uint32_t i);
void macfunc(uint32_t i);
void initState();
void saveState();
void reloadState();
void genkonst();
void diffuse();
void loadKey(const std::vector<uint8_t> &key);
};
#endif