Change year in COPYRIGHT to 2010.
[paraslash.git] / crypt.h
1 /*
2 * Copyright (C) 2005-2010 Andre Noll <maan@systemlinux.org>
3 *
4 * Licensed under the GPL v2. For licencing details see COPYING.
5 */
6
7 /** \file crypt.h prototypes for the RSA crypt functions */
8
9 #include <openssl/pem.h>
10 int para_encrypt_buffer(RSA* rsa, unsigned char *inbuf, unsigned len,
11 unsigned char *outbuf);
12 int para_decrypt_buffer(char *key_file, unsigned char *outbuf, unsigned char *inbuf,
13 unsigned rsa_inlen);
14 int get_rsa_key(char *key_file, RSA **rsa, int private);
15
16 void rsa_free(RSA *rsa);
17 void get_random_bytes_or_die(unsigned char *buf, int num);
18 void init_random_seed_or_die(void);
19
20 /**
21 * Used on the server-side for client-server communication encryption.
22 *
23 * The traffic between (the forked child of) para_server and the remote
24 * client process is crypted by a RC4 session key. This structure contains
25 * the RC4 keys and the file descriptor for which these keys should be used.
26 */
27 struct rc4_context {
28 /** The socket file descriptor. */
29 int fd;
30 /** Key used for sending data. */
31 RC4_KEY recv_key;
32 /** Key used for receiving data. */
33 RC4_KEY send_key;
34 };
35 int rc4_send_bin_buffer(struct rc4_context *rc4c, const char *buf, size_t len);
36 int rc4_send_buffer(struct rc4_context *rc4c, const char *buf);
37 __printf_2_3 int rc4_send_va_buffer(struct rc4_context *rc4c, const char *fmt, ...);
38 int rc4_recv_bin_buffer(struct rc4_context *rcc, char *buf, size_t size);
39 int rc4_recv_buffer(struct rc4_context *rcc, char *buf, size_t size);
40
41 /** \cond used to distinguish between loading of private/public key */
42 #define LOAD_PUBLIC_KEY 0
43 #define LOAD_PRIVATE_KEY 1
44 #define CHALLENGE_SIZE 64
45 /** \endcond **/