-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathkuznyechik.h
62 lines (50 loc) · 1.59 KB
/
kuznyechik.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
* kuznyechik.h
*
* Copyright (C) 2017 Vlasta Vesely
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of General Public License version 2.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
/*
* Most basic example usage:
* struct kuznyechik_subkeys subkeys;
* kuznyechik_set_key(&subkeys, key);
* kuznyechik_encrypt(&subkeys, ciphertext, plaintext);
* kuznyechik_decrypt(&subkeys, plaintext, ciphertext);
* kuznyechik_wipe_key(&subkeys);
*
* Test vectors (from the reference document):
* K = 8899aabbccddeeff0011223344556677fedcba98765432100123456789abcdef
* P = 1122334455667700ffeeddccbbaa9988
* C = 7f679d90bebc24305a468d42b9d4edcd
*/
#ifndef __KUZNYECHIK_H
#define __KUZNYECHIK_H
#if defined (__cplusplus)
extern "C" {
#endif
#include <stdint.h>
#ifndef ALIGN
#define ALIGN(n) __attribute__((aligned(n)))
#endif
struct kuznyechik_subkeys {
uint64_t ek[10][2];
uint64_t dk[10][2];
};
int kuznyechik_set_key(struct kuznyechik_subkeys *subkeys,
const unsigned char *key);
void kuznyechik_encrypt(struct kuznyechik_subkeys *subkeys, unsigned char *out,
const unsigned char *in);
void kuznyechik_decrypt(struct kuznyechik_subkeys *subkeys, unsigned char *out,
const unsigned char *in);
void kuznyechik_wipe_key(struct kuznyechik_subkeys *subkeys);
#if defined (__cplusplus)
}
#endif
#endif /* __KUZNYECHIK_H */