Add crypto hash SM3.
[libgcrypt.git] / cipher / cipher-selftest.h
1 /* cipher-selftest.h - Helper functions for bulk encryption selftests.
2  * Copyright (C) 2013 Jussi Kivilinna <jussi.kivilinna@iki.fi>
3  *
4  * This file is part of Libgcrypt.
5  *
6  * Libgcrypt is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser general Public License as
8  * published by the Free Software Foundation; either version 2.1 of
9  * the License, or (at your option) any later version.
10  *
11  * Libgcrypt is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this program; if not, see <http://www.gnu.org/licenses/>.
18  */
19
20 #ifndef G10_SELFTEST_HELP_H
21 #define G10_SELFTEST_HELP_H
22
23 #include <config.h>
24 #include "types.h"
25 #include "g10lib.h"
26 #include "cipher.h"
27
28 typedef void (*gcry_cipher_bulk_cbc_dec_t)(void *context, unsigned char *iv,
29                                            void *outbuf_arg,
30                                            const void *inbuf_arg,
31                                            size_t nblocks);
32
33 typedef void (*gcry_cipher_bulk_cfb_dec_t)(void *context, unsigned char *iv,
34                                            void *outbuf_arg,
35                                            const void *inbuf_arg,
36                                            size_t nblocks);
37
38 typedef void (*gcry_cipher_bulk_ctr_enc_t)(void *context, unsigned char *iv,
39                                            void *outbuf_arg,
40                                            const void *inbuf_arg,
41                                            size_t nblocks);
42
43 /* Helper function to allocate an aligned context for selftests.  */
44 void *_gcry_cipher_selftest_alloc_ctx (const int context_size,
45                                        unsigned char **r_mem);
46
47
48 /* Helper function for bulk CBC decryption selftest */
49 const char *
50 _gcry_selftest_helper_cbc (const char *cipher, gcry_cipher_setkey_t setkey,
51                            gcry_cipher_encrypt_t encrypt_one,
52                            gcry_cipher_bulk_cbc_dec_t bulk_cbc_dec,
53                            const int nblocks, const int blocksize,
54                            const int context_size);
55
56 /* Helper function for bulk CFB decryption selftest */
57 const char *
58 _gcry_selftest_helper_cfb (const char *cipher, gcry_cipher_setkey_t setkey,
59                            gcry_cipher_encrypt_t encrypt_one,
60                            gcry_cipher_bulk_cfb_dec_t bulk_cfb_dec,
61                            const int nblocks, const int blocksize,
62                            const int context_size);
63
64 /* Helper function for bulk CTR encryption selftest */
65 const char *
66 _gcry_selftest_helper_ctr (const char *cipher, gcry_cipher_setkey_t setkey,
67                            gcry_cipher_encrypt_t encrypt_one,
68                            gcry_cipher_bulk_ctr_enc_t bulk_ctr_enc,
69                            const int nblocks, const int blocksize,
70                            const int context_size);
71
72 #endif /*G10_SELFTEST_HELP_H*/