OpenCores
URL https://opencores.org/ocsvn/gost28147-89/gost28147-89/trunk

Subversion Repositories gost28147-89

[/] [gost28147-89/] [trunk/] [utils/] [gost89.h] - Blame information for rev 5

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 fanatid
#ifndef __GOST89_H
2
#define __GOST89_H
3
 
4
#include <stdint.h>
5
#include <stddef.h>
6
 
7
 
8
/* GOST substitution blocks */
9
typedef struct {
10
  uint8_t k1[16];
11
  uint8_t k2[16];
12
  uint8_t k3[16];
13
  uint8_t k4[16];
14
  uint8_t k5[16];
15
  uint8_t k6[16];
16
  uint8_t k7[16];
17
  uint8_t k8[16];
18
} gost_subst_block;
19
 
20
/* Cipher context */
21
typedef struct {
22
  uint32_t k[8];
23
  uint32_t k87[256], k65[256], k43[256], k21[256];
24
} gost_ctx;
25
 
26
/* Set S-blocks into context */
27
void gost_init(gost_ctx *c, const gost_subst_block* b);
28
/* Clean up context */
29
void gost_destroy(gost_ctx* c);
30
/* Set key into context */
31
void gost_set_key(gost_ctx *c, const uint8_t *k);
32
/* Get key from context */
33
void gost_get_key(gost_ctx *c, uint8_t *k);
34
 
35
/* Encrypt several full blocks in ECB mode */
36
void gost_ecb_encrypt(gost_ctx *ctx, const uint8_t *in, uint8_t *out, size_t blocks);
37
/* Decrypt several full blocks in ECB mode */
38
void gost_ecb_decrypt(gost_ctx *ctx, const uint8_t *in, uint8_t *out, size_t blocks);
39
 
40
/* Encrypt several full blocks in CFB mode */
41
void gost_cfb_encrypt(gost_ctx *ctx, const uint8_t *iv, const uint8_t *in, uint8_t *out, size_t blocks);
42
/* Decrypt several full blocks in CFB mode */
43
void gost_cfb_decrypt(gost_ctx *ctx, const uint8_t *iv, const uint8_t *in, uint8_t *out, size_t blocks);
44
 
45
/* Compute MAC of given length in bits from data */
46
void gost_mac(gost_ctx *ctx, const uint8_t *data, size_t data_len, uint8_t *mac, size_t mac_len);
47
 
48
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.