aboutsummarylogtreecommitdiffstats
path: root/rc4.h
blob: 4634bebfadaafe2067409589b6d9605e33d2fd1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#ifndef RC4_H
#define RC4_H

#define PASS_MAX 32
#define BACKSPACE 127
#define KEY_SCHEDULE_LENGTH 256

#include <stdlib.h>
#include <string.h>
#include <ncurses.h>

/**
 * Takes a password from user input and returns it (max 32 chars)
 * @return password
 */
char* rc4_getPassword(void);

/**
 * Performs key exchange
 * @param keySchedule
 * @param key password
 */
void rc4_key_exchange(int keySchedule[KEY_SCHEDULE_LENGTH], char* key);

/**
 * Performs pseudo-random generation algorithm
 * @param keySchedule
 * @param len size of portfolio in bytes
 * @return string that can be XOR'ed with message to be en/decoded
 */
char* rc4_prga(int keySchedule[KEY_SCHEDULE_LENGTH], size_t len);

/**
 * XOR's the string created by prga by the portfolio to encrypt or decrypt it
 * @param output string to be XOR'ed
 * @param message portoflio string
 * @param len length of portfolio in bytes
 */
void rc4_execute(char* output, char* message, size_t len);

#endif