update speck module

This commit is contained in:
Zhi Guan
2017-03-26 15:23:37 +08:00
parent 019924627e
commit 64cedcdf29
7 changed files with 45 additions and 9 deletions

48
include/openssl/speck.h Normal file
View File

@@ -0,0 +1,48 @@
#ifndef SPECK_H
#define SPECK_H
/*
* define speck type to use
*(one of SPECK_32_64, SPECK_64_128, SPECK_128_256)
*/
#define SPECK_32_64
#ifdef SPECK_32_64
#define SPECK_TYPE uint16_t
#define SPECK_ROUNDS 22
#define SPECK_KEY_LEN 4
#endif
#ifdef SPECK_64_128
#define SPECK_TYPE uint32_t
#define SPECK_ROUNDS 27
#define SPECK_KEY_LEN 4
#endif
#ifdef SPECK_128_256
#define SPECK_TYPE uint64_t
#define SPECK_ROUNDS 34
#define SPECK_KEY_LEN 4
#endif
#define num_word sizeof(SPECK_TYPE)
#include <sys/types.h>
#include <stdint.h>
#include <string.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
unsigned char rk[num_word];
} speck_key_t;
void speck_set_encrypt_key(speck_key_t *key, const unsigned char *user_key);
void speck_expand(SPECK_TYPE const K[SPECK_KEY_LEN], SPECK_TYPE S[SPECK_ROUNDS]);
void speck_encrypt(SPECK_TYPE const pt[2], SPECK_TYPE ct[2], SPECK_TYPE const K[SPECK_ROUNDS]);
void speck_decrypt(SPECK_TYPE const ct[2], SPECK_TYPE pt[2], SPECK_TYPE const K[SPECK_ROUNDS]);
#ifdef __cplusplus
}
#endif
#endif