5 cipher.h -- header file cipher.c
6 Copyright (C) 2007-2016 Guus Sliepen <guus@tinc-vpn.org>
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License along
19 with this program; if not, write to the Free Software Foundation, Inc.,
20 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 #define CIPHER_MAX_BLOCK_SIZE 32
26 #define CIPHER_MAX_IV_SIZE 16
27 #define CIPHER_MAX_KEY_SIZE 32
29 #ifndef DISABLE_LEGACY
31 typedef struct cipher cipher_t;
33 extern cipher_t *cipher_open_by_name(const char *name) __attribute__((__malloc__));
34 extern cipher_t *cipher_open_by_nid(int nid) __attribute__((__malloc__));
35 extern void cipher_close(cipher_t *cipher);
36 extern size_t cipher_keylength(const cipher_t *cipher);
37 extern size_t cipher_blocksize(const cipher_t *cipher);
38 extern uint64_t cipher_budget(const cipher_t *cipher);
39 extern bool cipher_set_key(cipher_t *cipher, void *key, bool encrypt) __attribute__((__warn_unused_result__));
40 extern bool cipher_set_key_from_rsa(cipher_t *cipher, void *rsa, size_t len, bool encrypt) __attribute__((__warn_unused_result__));
41 extern bool cipher_encrypt(cipher_t *cipher, const void *indata, size_t inlen, void *outdata, size_t *outlen, bool oneshot) __attribute__((__warn_unused_result__));
42 extern bool cipher_decrypt(cipher_t *cipher, const void *indata, size_t inlen, void *outdata, size_t *outlen, bool oneshot) __attribute__((__warn_unused_result__));
43 extern int cipher_get_nid(const cipher_t *cipher);
44 extern bool cipher_active(const cipher_t *cipher);