noinst_HEADERS = \
xalloc.h utils.h getopt.h list.h splay_tree.h dropin.h fake-getaddrinfo.h fake-getnameinfo.h fake-gai-errnos.h ipv6.h ipv4.h ethernet.h \
buffer.h conf.h connection.h control.h control_common.h device.h edge.h graph.h info.h logger.h meta.h net.h netutl.h node.h process.h \
- protocol.h route.h subnet.h sptps.h tincctl.h top.h hash.h event.h names.h have.h system.h
+ protocol.h route.h subnet.h sptps.h tincctl.h top.h hash.h event.h names.h have.h system.h \
+ cipher.h crypto.h digest.h ecdh.h ecdsa.h ecdsagen.h prf.h rsa.h rsagen.h
LIBS = @LIBS@ @LIBGCRYPT_LIBS@
--- /dev/null
+/*
+ cipher.h -- header file cipher.c
+ Copyright (C) 2007-2013 Guus Sliepen <guus@tinc-vpn.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
+
+#ifndef __TINC_CIPHER_H__
+#define __TINC_CIPHER_H__
+
+#define CIPHER_MAX_BLOCK_SIZE 32
+#define CIPHER_MAX_IV_SIZE 16
+#define CIPHER_MAX_KEY_SIZE 32
+
+typedef struct cipher cipher_t;
+
+extern cipher_t *cipher_open_by_name(const char *);
+extern cipher_t *cipher_open_by_nid(int);
+extern cipher_t *cipher_open_blowfish_ofb(void);
+extern void cipher_close(cipher_t *);
+extern size_t cipher_keylength(const cipher_t *);
+extern void cipher_get_key(const cipher_t *, void *);
+extern bool cipher_set_key(cipher_t *, void *, bool);
+extern bool cipher_set_key_from_rsa(cipher_t *, void *, size_t, bool);
+extern bool cipher_set_counter(cipher_t *, const void *, size_t);
+extern bool cipher_set_counter_key(cipher_t *, void *);
+extern bool cipher_encrypt(cipher_t *, const void *indata, size_t inlen, void *outdata, size_t *outlen, bool oneshot);
+extern bool cipher_decrypt(cipher_t *, const void *indata, size_t inlen, void *outdata, size_t *outlen, bool oneshot);
+extern bool cipher_counter_xor(cipher_t *, const void *indata, size_t inlen, void *outdata);
+extern int cipher_get_nid(const cipher_t *);
+extern bool cipher_active(const cipher_t *);
+
+
+#endif
--- /dev/null
+/*
+ crypto.h -- header for crypto.c
+ Copyright (C) 2007-2013 Guus Sliepen <guus@tinc-vpn.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
+
+#ifndef __TINC_CRYPTO_H__
+#define __TINC_CRYPTO_H__
+
+extern void crypto_init();
+extern void crypto_exit();
+extern void randomize(void *, size_t);
+
+#endif
--- /dev/null
+/*
+ digest.h -- header file digest.c
+ Copyright (C) 2007-2013 Guus Sliepen <guus@tinc-vpn.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
+
+#ifndef __TINC_DIGEST_H__
+#define __TINC_DIGEST_H__
+
+#define DIGEST_MAX_SIZE 64
+
+typedef struct digest digest_t;
+
+extern digest_t *digest_open_by_name(const char *name, int maclength);
+extern digest_t *digest_open_by_nid(int nid, int maclength);
+extern digest_t *digest_open_sha1(int maclength);
+extern void digest_close(digest_t *);
+extern bool digest_create(digest_t *, const void *indata, size_t inlen, void *outdata);
+extern bool digest_verify(digest_t *, const void *indata, size_t inlen, const void *digestdata);
+extern bool digest_set_key(digest_t *, const void *key, size_t len);
+extern int digest_get_nid(const digest_t *);
+extern size_t digest_keylength(const digest_t *);
+extern size_t digest_length(const digest_t *);
+extern bool digest_active(const digest_t *);
+
+#endif
--- /dev/null
+/*
+ ecdh.h -- header file for ecdh.c
+ Copyright (C) 2011-2013 Guus Sliepen <guus@tinc-vpn.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
+
+#ifndef __TINC_ECDH_H__
+#define __TINC_ECDH_H__
+
+#define ECDH_SIZE 67
+#define ECDH_SHARED_SIZE 66
+
+#ifndef __TINC_ECDH_INTERNAL__
+typedef struct ecdh ecdh_t;
+#endif
+
+extern ecdh_t *ecdh_generate_public(void *pubkey);
+extern bool ecdh_compute_shared(ecdh_t *ecdh, const void *pubkey, void *shared);
+extern void ecdh_free(ecdh_t *ecdh);
+
+#endif
--- /dev/null
+/*
+ ecdsa.h -- ECDSA key handling
+ Copyright (C) 2011-2013 Guus Sliepen <guus@tinc-vpn.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
+
+#ifndef __TINC_ECDSA_H__
+#define __TINC_ECDSA_H__
+
+#ifndef __TINC_ECDSA_INTERNAL__
+typedef struct ecdsa ecdsa_t;
+#endif
+
+extern ecdsa_t *ecdsa_set_base64_public_key(const char *p);
+extern char *ecdsa_get_base64_public_key(ecdsa_t *ecdsa);
+extern ecdsa_t *ecdsa_read_pem_public_key(FILE *fp);
+extern ecdsa_t *ecdsa_read_pem_private_key(FILE *fp);
+extern size_t ecdsa_size(ecdsa_t *ecdsa);
+extern bool ecdsa_sign(ecdsa_t *ecdsa, const void *in, size_t inlen, void *out);
+extern bool ecdsa_verify(ecdsa_t *ecdsa, const void *in, size_t inlen, const void *out);
+extern bool ecdsa_active(ecdsa_t *ecdsa);
+extern void ecdsa_free(ecdsa_t *ecdsa);
+
+#endif
--- /dev/null
+/*
+ ecdsagen.h -- ECDSA key generation and export
+ Copyright (C) 2011-2013 Guus Sliepen <guus@tinc-vpn.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
+
+#ifndef __TINC_ECDSAGEN_H__
+#define __TINC_ECDSAGEN_H__
+
+#include "ecdsa.h"
+
+extern ecdsa_t *ecdsa_generate(void);
+extern bool ecdsa_write_pem_public_key(ecdsa_t *ecdsa, FILE *fp);
+extern bool ecdsa_write_pem_private_key(ecdsa_t *ecdsa, FILE *fp);
+
+#endif
--- /dev/null
+/*
+ prf.h -- header file for prf.c
+ Copyright (C) 2011-2013 Guus Sliepen <guus@tinc-vpn.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
+
+#ifndef __TINC_PRF_H__
+#define __TINC_PRF_H__
+
+extern bool prf(const char *secret, size_t secretlen, char *seed, size_t seedlen, char *out, size_t outlen);
+
+#endif
--- /dev/null
+/*
+ rsa.h -- RSA key handling
+ Copyright (C) 2007-2013 Guus Sliepen <guus@tinc-vpn.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
+
+#ifndef __TINC_RSA_H__
+#define __TINC_RSA_H__
+
+#ifndef __TINC_RSA_INTERNAL__
+typedef struct rsa rsa_t;
+#endif
+
+extern void rsa_free(rsa_t *rsa);
+extern rsa_t *rsa_set_hex_public_key(char *n, char *e);
+extern rsa_t *rsa_set_hex_private_key(char *n, char *e, char *d);
+extern rsa_t *rsa_read_pem_public_key(FILE *fp);
+extern rsa_t *rsa_read_pem_private_key(FILE *fp);
+extern size_t rsa_size(rsa_t *rsa);
+extern bool rsa_public_encrypt(rsa_t *rsa, void *in, size_t len, void *out);
+extern bool rsa_private_decrypt(rsa_t *rsa, void *in, size_t len, void *out);
+
+#endif
--- /dev/null
+/*
+ rsagen.h -- RSA key generation and export
+ Copyright (C) 2008-2013 Guus Sliepen <guus@tinc-vpn.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
+
+#ifndef __TINC_RSAGEN_H__
+#define __TINC_RSAGEN_H__
+
+#include "rsa.h"
+
+extern rsa_t *rsa_generate(size_t bits, unsigned long exponent);
+extern bool rsa_write_pem_public_key(rsa_t *rsa, FILE *fp);
+extern bool rsa_write_pem_private_key(rsa_t *rsa, FILE *fp);
+
+#endif