Make rc4 encryption/decryption more explicit.
[paraslash.git] / crypt.h
1 /*
2 * Copyright (C) 2005-2009 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_decrypt_challenge(char *key_file, long unsigned *challenge_nr,
11 unsigned char *buf, unsigned rsa_inlen);
12 int para_encrypt_challenge(RSA* rsa, long unsigned challenge_nr,
13 unsigned char *outbuf);
14 int para_encrypt_buffer(RSA* rsa, unsigned char *inbuf, unsigned len,
15 unsigned char *outbuf);
16 int para_decrypt_buffer(char *key_file, unsigned char *outbuf, unsigned char *inbuf,
17 unsigned rsa_inlen);
18 int get_rsa_key(char *key_file, RSA **rsa, int private);
19
20 void rsa_free(RSA *rsa);
21 void get_random_bytes_or_die(unsigned char *buf, int num);
22 void init_random_seed_or_die(void);
23
24 struct rc4_context {
25 int fd;
26 RC4_KEY recv_key;
27 RC4_KEY send_key;
28 };
29 int rc4_send_bin_buffer(struct rc4_context *rc4c, const char *buf, size_t len);
30 int rc4_send_buffer(struct rc4_context *rc4c, const char *buf);
31 __printf_2_3 int rc4_send_va_buffer(struct rc4_context *rc4c, const char *fmt, ...);
32 int rc4_recv_bin_buffer(struct rc4_context *rcc, char *buf, size_t size);
33 int rc4_recv_buffer(struct rc4_context *rcc, char *buf, size_t size);
34
35 /** \cond used to distinguish between loading of private/public key */
36 #define LOAD_PUBLIC_KEY 0
37 #define LOAD_PRIVATE_KEY 1
38 /** \endcond **/