summaryrefslogtreecommitdiffstats
path: root/web/server/h2o/libh2o/deps/picotls/deps/cifra/src/prp.h
blob: 1aa72588e037cb61a7dd906352614411de077ec8 (plain)
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
63
64
/*
 * cifra - embedded cryptography library
 * Written in 2014 by Joseph Birr-Pixton <jpixton@gmail.com>
 *
 * To the extent possible under law, the author(s) have dedicated all
 * copyright and related and neighboring rights to this software to the
 * public domain worldwide. This software is distributed without any
 * warranty.
 *
 * You should have received a copy of the CC0 Public Domain Dedication
 * along with this software. If not, see
 * <http://creativecommons.org/publicdomain/zero/1.0/>.
 */

#ifndef PRP_H
#define PRP_H

#include <stddef.h>
#include <stdint.h>

/**
 * General block cipher description
 * ================================
 * This allows us to implement block cipher modes which can work
 * with different block ciphers.
 */

/* .. c:type:: cf_prp_block
 * Block processing function type.
 *
 * The `in` and `out` blocks may alias.
 *
 * :rtype: void
 * :param ctx: block cipher-specific context object.
 * :param in: input block.
 * :param out: output block.
 */
typedef void (*cf_prp_block)(void *ctx, const uint8_t *in, uint8_t *out);

/* .. c:type:: cf_prp
 * Describes an PRP in a general way.
 *
 * .. c:member:: cf_prp.blocksz
 * Block size in bytes. Must be no more than :c:macro:`CF_MAXBLOCK`.
 *
 * .. c:member:: cf_prp.encrypt
 * Block encryption function.
 *
 * .. c:member:: cf_prp.decrypt
 * Block decryption function.
 */
typedef struct
{
  size_t blocksz;
  cf_prp_block encrypt;
  cf_prp_block decrypt;
} cf_prp;

/* .. c:macro:: CF_MAXBLOCK
 * The maximum block cipher blocksize we support, in bytes.
 */
#define CF_MAXBLOCK 16

#endif