#include <rc4.hpp>
|
void | byte_swap (uint8_t *a, uint8_t *b) |
|
void | trad_swap (unsigned char *a, unsigned char *b) |
|
void | XOR_swap (unsigned char *a, unsigned char *b) |
|
void | KSA (char *key, unsigned char *S, int swap_type) |
|
void | PRGA (unsigned char *S, char *plaintext, unsigned char *ciphertext, int swap_type) |
|
std::string | store_hash (char *plaintext, unsigned char *hashtext, int swap_type) |
|
unsigned char * | compute (char *key, char *plaintext, unsigned char *hashtext, int swap_type) |
|
- Examples
- rc4.cpp.
Definition at line 71 of file rc4.hpp.
◆ byte_swap()
void gpmp::RC4::byte_swap |
( |
uint8_t * |
a, |
|
|
uint8_t * |
b |
|
) |
| |
◆ compute()
unsigned char * gpmp::RC4::compute |
( |
char * |
key, |
|
|
char * |
plaintext, |
|
|
unsigned char * |
hashtext, |
|
|
int |
swap_type |
|
) |
| |
- Examples
- rc4.cpp.
Definition at line 142 of file rc4.cpp.
146 if (ciphertext == NULL) {
147 throw std::runtime_error(
"[-] Error Allocating Memory");
151 if (0 <= swap_type && swap_type <= 2) {
153 KSA(key, S, swap_type);
154 PRGA(S, plaintext, ciphertext, swap_type);
157 else if (swap_type > 2) {
158 throw std::runtime_error(
"[-] Invalid swap_type");
void PRGA(unsigned char *S, char *plaintext, unsigned char *ciphertext, int swap_type)
void KSA(char *key, unsigned char *S, int swap_type)
References BYTE_LIMIT.
Referenced by main().
◆ KSA()
void gpmp::RC4::KSA |
( |
char * |
key, |
|
|
unsigned char * |
S, |
|
|
int |
swap_type |
|
) |
| |
Definition at line 68 of file rc4.cpp.
69 uint32_t len = strlen(key);
77 j = (j + S[i] + key[i % len]) &
BITS;
82 }
else if (swap_type == 1) {
84 }
else if (swap_type == 2) {
void XOR_swap(unsigned char *a, unsigned char *b)
void byte_swap(uint8_t *a, uint8_t *b)
void trad_swap(unsigned char *a, unsigned char *b)
References BITS, and BYTE_LIMIT.
◆ PRGA()
void gpmp::RC4::PRGA |
( |
unsigned char * |
S, |
|
|
char * |
plaintext, |
|
|
unsigned char * |
ciphertext, |
|
|
int |
swap_type |
|
) |
| |
Definition at line 90 of file rc4.cpp.
97 for (
size_t n = 0, len = strlen(plaintext); n < len; n++) {
99 j = (j + S[i]) &
BITS;
102 if (swap_type == 0) {
104 }
else if (swap_type == 1) {
106 }
else if (swap_type == 2) {
110 uint32_t rnd = S[(S[i] + S[j]) &
BITS];
112 ciphertext[n] = rnd ^ plaintext[n];
References BITS.
◆ store_hash()
std::string gpmp::RC4::store_hash |
( |
char * |
plaintext, |
|
|
unsigned char * |
hashtext, |
|
|
int |
swap_type |
|
) |
| |
- Examples
- rc4.cpp.
Definition at line 117 of file rc4.cpp.
119 size_t len = strlen((
char *)plaintext);
121 char buffer[len + 1];
122 size_t size =
sizeof(buffer);
125 std::string stored_text =
"";
128 for (
size_t index = 0; index < len; index++) {
129 if (swap_type == 0) {
130 snprintf(buffer, size,
"|x%02hhx|", hashtext[index]);
134 snprintf(buffer, size,
"%02hhX", hashtext[index]);
137 stored_text += std::string(buffer);
Referenced by main().
◆ trad_swap()
void gpmp::RC4::trad_swap |
( |
unsigned char * |
a, |
|
|
unsigned char * |
b |
|
) |
| |
◆ XOR_swap()
void gpmp::RC4::XOR_swap |
( |
unsigned char * |
a, |
|
|
unsigned char * |
b |
|
) |
| |
The documentation for this class was generated from the following files: