Fix modes.h so that indent doesn't complain
[openssl.git] / crypto / modes / modes.h
1 /* ====================================================================
2  * Copyright (c) 2008 The OpenSSL Project. All rights reserved.
3  *
4  * Rights for redistribution and usage in source and binary
5  * forms are granted according to the OpenSSL license.
6  */
7
8 #include <stddef.h>
9
10 #ifdef  __cplusplus
11 extern "C" {
12 #endif
13 typedef void (*block128_f)(const unsigned char in[16],
14                         unsigned char out[16],
15                         const void *key);
16
17 typedef void (*cbc128_f)(const unsigned char *in, unsigned char *out,
18                         size_t len, const void *key,
19                         unsigned char ivec[16], int enc);
20
21 typedef void (*ctr128_f)(const unsigned char *in, unsigned char *out,
22                         size_t blocks, const void *key,
23                         const unsigned char ivec[16]);
24
25 typedef void (*ccm128_f)(const unsigned char *in, unsigned char *out,
26                         size_t blocks, const void *key,
27                         const unsigned char ivec[16],unsigned char cmac[16]);
28
29 void CRYPTO_cbc128_encrypt(const unsigned char *in, unsigned char *out,
30                         size_t len, const void *key,
31                         unsigned char ivec[16], block128_f block);
32 void CRYPTO_cbc128_decrypt(const unsigned char *in, unsigned char *out,
33                         size_t len, const void *key,
34                         unsigned char ivec[16], block128_f block);
35
36 void CRYPTO_ctr128_encrypt(const unsigned char *in, unsigned char *out,
37                         size_t len, const void *key,
38                         unsigned char ivec[16], unsigned char ecount_buf[16],
39                         unsigned int *num, block128_f block);
40
41 void CRYPTO_ctr128_encrypt_ctr32(const unsigned char *in, unsigned char *out,
42                         size_t len, const void *key,
43                         unsigned char ivec[16], unsigned char ecount_buf[16],
44                         unsigned int *num, ctr128_f ctr);
45
46 void CRYPTO_ofb128_encrypt(const unsigned char *in, unsigned char *out,
47                         size_t len, const void *key,
48                         unsigned char ivec[16], int *num,
49                         block128_f block);
50
51 void CRYPTO_cfb128_encrypt(const unsigned char *in, unsigned char *out,
52                         size_t len, const void *key,
53                         unsigned char ivec[16], int *num,
54                         int enc, block128_f block);
55 void CRYPTO_cfb128_8_encrypt(const unsigned char *in, unsigned char *out,
56                         size_t length, const void *key,
57                         unsigned char ivec[16], int *num,
58                         int enc, block128_f block);
59 void CRYPTO_cfb128_1_encrypt(const unsigned char *in, unsigned char *out,
60                         size_t bits, const void *key,
61                         unsigned char ivec[16], int *num,
62                         int enc, block128_f block);
63
64 size_t CRYPTO_cts128_encrypt_block(const unsigned char *in, unsigned char *out,
65                         size_t len, const void *key,
66                         unsigned char ivec[16], block128_f block);
67 size_t CRYPTO_cts128_encrypt(const unsigned char *in, unsigned char *out,
68                         size_t len, const void *key,
69                         unsigned char ivec[16], cbc128_f cbc);
70 size_t CRYPTO_cts128_decrypt_block(const unsigned char *in, unsigned char *out,
71                         size_t len, const void *key,
72                         unsigned char ivec[16], block128_f block);
73 size_t CRYPTO_cts128_decrypt(const unsigned char *in, unsigned char *out,
74                         size_t len, const void *key,
75                         unsigned char ivec[16], cbc128_f cbc);
76
77 size_t CRYPTO_nistcts128_encrypt_block(const unsigned char *in, unsigned char *out,
78                         size_t len, const void *key,
79                         unsigned char ivec[16], block128_f block);
80 size_t CRYPTO_nistcts128_encrypt(const unsigned char *in, unsigned char *out,
81                         size_t len, const void *key,
82                         unsigned char ivec[16], cbc128_f cbc);
83 size_t CRYPTO_nistcts128_decrypt_block(const unsigned char *in, unsigned char *out,
84                         size_t len, const void *key,
85                         unsigned char ivec[16], block128_f block);
86 size_t CRYPTO_nistcts128_decrypt(const unsigned char *in, unsigned char *out,
87                         size_t len, const void *key,
88                         unsigned char ivec[16], cbc128_f cbc);
89
90 typedef struct gcm128_context GCM128_CONTEXT;
91
92 GCM128_CONTEXT *CRYPTO_gcm128_new(void *key, block128_f block);
93 void CRYPTO_gcm128_init(GCM128_CONTEXT *ctx,void *key,block128_f block);
94 void CRYPTO_gcm128_setiv(GCM128_CONTEXT *ctx, const unsigned char *iv,
95                         size_t len);
96 int CRYPTO_gcm128_aad(GCM128_CONTEXT *ctx, const unsigned char *aad,
97                         size_t len);
98 int CRYPTO_gcm128_encrypt(GCM128_CONTEXT *ctx,
99                         const unsigned char *in, unsigned char *out,
100                         size_t len);
101 int CRYPTO_gcm128_decrypt(GCM128_CONTEXT *ctx,
102                         const unsigned char *in, unsigned char *out,
103                         size_t len);
104 int CRYPTO_gcm128_encrypt_ctr32(GCM128_CONTEXT *ctx,
105                         const unsigned char *in, unsigned char *out,
106                         size_t len, ctr128_f stream);
107 int CRYPTO_gcm128_decrypt_ctr32(GCM128_CONTEXT *ctx,
108                         const unsigned char *in, unsigned char *out,
109                         size_t len, ctr128_f stream);
110 int CRYPTO_gcm128_finish(GCM128_CONTEXT *ctx,const unsigned char *tag,
111                         size_t len);
112 void CRYPTO_gcm128_tag(GCM128_CONTEXT *ctx, unsigned char *tag, size_t len);
113 void CRYPTO_gcm128_release(GCM128_CONTEXT *ctx);
114
115 typedef struct ccm128_context CCM128_CONTEXT;
116
117 void CRYPTO_ccm128_init(CCM128_CONTEXT *ctx,
118         unsigned int M, unsigned int L, void *key,block128_f block);
119 int CRYPTO_ccm128_setiv(CCM128_CONTEXT *ctx,
120         const unsigned char *nonce, size_t nlen, size_t mlen);
121 void CRYPTO_ccm128_aad(CCM128_CONTEXT *ctx,
122         const unsigned char *aad, size_t alen);
123 int CRYPTO_ccm128_encrypt(CCM128_CONTEXT *ctx,
124         const unsigned char *inp, unsigned char *out, size_t len);
125 int CRYPTO_ccm128_decrypt(CCM128_CONTEXT *ctx,
126         const unsigned char *inp, unsigned char *out, size_t len);
127 int CRYPTO_ccm128_encrypt_ccm64(CCM128_CONTEXT *ctx,
128         const unsigned char *inp, unsigned char *out, size_t len,
129         ccm128_f stream);
130 int CRYPTO_ccm128_decrypt_ccm64(CCM128_CONTEXT *ctx,
131         const unsigned char *inp, unsigned char *out, size_t len,
132         ccm128_f stream);
133 size_t CRYPTO_ccm128_tag(CCM128_CONTEXT *ctx, unsigned char *tag, size_t len);
134
135 typedef struct xts128_context XTS128_CONTEXT;
136
137 int CRYPTO_xts128_encrypt(const XTS128_CONTEXT *ctx, const unsigned char iv[16],
138         const unsigned char *inp, unsigned char *out, size_t len, int enc);
139
140 size_t CRYPTO_128_wrap(void *key, const unsigned char *iv,
141                 unsigned char *out,
142                 const unsigned char *in, size_t inlen, block128_f block);
143
144 size_t CRYPTO_128_unwrap(void *key, const unsigned char *iv,
145                 unsigned char *out,
146                 const unsigned char *in, size_t inlen, block128_f block);
147
148 #ifdef  __cplusplus
149 }
150 #endif