Skip to content

Commit 8f7bdcd

Browse files
authored
Create speck.h
a not good speck.h
1 parent d225417 commit 8f7bdcd

1 file changed

Lines changed: 48 additions & 0 deletions

File tree

demos/mycipher/speck.h

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#ifndef SPECK_H
2+
#define SPECK_H
3+
4+
/*
5+
* define speck type to use
6+
*(one of SPECK_32_64, SPECK_64_128, SPECK_128_256)
7+
*/
8+
#define SPECK_32_64
9+
10+
#ifdef SPECK_32_64
11+
#define SPECK_TYPE uint16_t
12+
#define SPECK_ROUNDS 22
13+
#define SPECK_KEY_LEN 4
14+
#endif
15+
16+
#ifdef SPECK_64_128
17+
#define SPECK_TYPE uint32_t
18+
#define SPECK_ROUNDS 27
19+
#define SPECK_KEY_LEN 4
20+
#endif
21+
22+
#ifdef SPECK_128_256
23+
#define SPECK_TYPE uint64_t
24+
#define SPECK_ROUNDS 34
25+
#define SPECK_KEY_LEN 4
26+
#endif
27+
28+
#define num_word sizeof(SPECK_TYPE)
29+
#include <sys/types.h>
30+
#include <stdint.h>
31+
#include <string.h>
32+
#ifdef __cplusplus
33+
extern "C" {
34+
#endif
35+
36+
typedef struct {
37+
unsigned char rk[num_word];
38+
} mycipher_key_t;
39+
40+
void mycipher_set_encrypt_key(mycipher_key_t *key, const unsigned char *user_key);
41+
void speck_expand(SPECK_TYPE const K[SPECK_KEY_LEN], SPECK_TYPE S[SPECK_ROUNDS]);
42+
void speck_encrypt(SPECK_TYPE const pt[2], SPECK_TYPE ct[2], SPECK_TYPE const K[SPECK_ROUNDS]);
43+
void speck_decrypt(SPECK_TYPE const ct[2], SPECK_TYPE pt[2], SPECK_TYPE const K[SPECK_ROUNDS]);
44+
45+
#ifdef __cplusplus
46+
}
47+
#endif
48+
#endif

0 commit comments

Comments
 (0)