From: Richard Kettlewell Date: Sat, 24 May 2014 13:59:48 +0000 (+0100) Subject: more appropriate data types for rc4 implementation X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=c1ff0073d7ff52791b1e5deda7d61c28bc6ff3d9;p=vbig.git more appropriate data types for rc4 implementation --- diff --git a/Arcfour.cc b/Arcfour.cc index 49c8590..bc8b356 100644 --- a/Arcfour.cc +++ b/Arcfour.cc @@ -21,7 +21,7 @@ #include #include "Arcfour.h" -void Arcfour::stream(char *outbuf, size_t length) { +void Arcfour::stream(uint8_t *outbuf, size_t length) { uint8_t i = idx_i; uint8_t j = idx_j; @@ -40,7 +40,7 @@ void Arcfour::stream(char *outbuf, size_t length) { idx_j = j; } -Arcfour::Arcfour(const char *key, size_t keylen) { +Arcfour::Arcfour(const uint8_t *key, size_t keylen) { size_t i, j, k; idx_i = idx_j = 0; for (i = 0; i < ARCFOUR_SBOX_SIZE; i++) diff --git a/Arcfour.h b/Arcfour.h index 7d7abf0..1ccf047 100644 --- a/Arcfour.h +++ b/Arcfour.h @@ -30,11 +30,11 @@ #define ARCFOUR_SBOX_SIZE 256 class Arcfour { - char sbox[ARCFOUR_SBOX_SIZE]; + uint8_t sbox[ARCFOUR_SBOX_SIZE]; uint8_t idx_i, idx_j; public: - Arcfour(const char *key, size_t keylen); - void stream(char *outbuf, size_t length); + Arcfour(const uint8_t *key, size_t keylen); + void stream(uint8_t *outbuf, size_t length); }; #endif /* ARCFOUR_H */ diff --git a/vbig.cc b/vbig.cc index 2a94519..7deee84 100644 --- a/vbig.cc +++ b/vbig.cc @@ -278,7 +278,7 @@ static void showprogress(long long amount, const char *show) { // write/verify the target file static long long execute(mode_type mode, bool entire, const char *show) { - Arcfour rng((const char*)seed, seedlen); + Arcfour rng((const uint8_t *)seed, seedlen); FILE *fp = fopen(path, mode == VERIFY ? "rb" : "wb"); if(!fp) fatal(errno, "%s", path); @@ -286,7 +286,7 @@ static long long execute(mode_type mode, bool entire, const char *show) { flushCache(fp); if(mode == CREATE && entire) setvbuf(fp, 0, _IONBF, 0); - char generated[4096], input[4096]; + uint8_t generated[4096], input[4096]; long long remain = size; static const size_t rc4drop = 3072; // en.wikipedia.org/wiki/RC4#Security assert(rc4drop <= sizeof(generated));