2 * Copyright (C) 2005-2011 Andre Noll <maan@systemlinux.org>
4 * Licensed under the GPL v2. For licencing details see COPYING.
7 /** \file crypt.h Prototypes for paraslash crypto functions. */
9 /** Opaque structure for public and private keys. */
10 struct asymmetric_key;
12 int pub_encrypt(struct asymmetric_key *pub, unsigned char *inbuf,
13 unsigned len, unsigned char *outbuf);
14 int priv_decrypt(const char *key_file, unsigned char *outbuf,
15 unsigned char *inbuf, int inlen);
16 int get_asymmetric_key(const char *key_file, int private,
17 struct asymmetric_key **result);
18 void free_asymmetric_key(struct asymmetric_key *key);
20 void get_random_bytes_or_die(unsigned char *buf, int num);
21 void init_random_seed_or_die(void);
24 * Used on the server-side for client-server communication encryption.
26 * The traffic between (the forked child of) para_server and the remote
27 * client process is crypted by a RC4 session key. This structure contains
28 * the RC4 keys and the file descriptor for which these keys should be used.
31 /** The socket file descriptor. */
33 /** Key used for sending data. */
35 /** Key used for receiving data. */
38 int rc4_send_bin_buffer(struct rc4_context *rc4c, const char *buf, size_t len);
39 int rc4_send_buffer(struct rc4_context *rc4c, const char *buf);
40 __printf_2_3 int rc4_send_va_buffer(struct rc4_context *rc4c, const char *fmt, ...);
41 int rc4_recv_bin_buffer(struct rc4_context *rcc, char *buf, size_t size);
42 int rc4_recv_buffer(struct rc4_context *rcc, char *buf, size_t size);
44 /** \cond used to distinguish between loading of private/public key */
45 #define LOAD_PUBLIC_KEY 0
46 #define LOAD_PRIVATE_KEY 1
47 #define CHALLENGE_SIZE 64