Fixed a few warnings

This commit is contained in:
wiire-a 2017-12-03 15:02:19 +01:00
parent d6dab00354
commit 533070ae47
4 changed files with 11 additions and 30 deletions

View File

@ -69,13 +69,14 @@ struct hmac_ctx {
static void hmac_sha256_init(struct hmac_ctx *hctx, const uint8_t *key, size_t keylen) static void hmac_sha256_init(struct hmac_ctx *hctx, const uint8_t *key, size_t keylen)
{ {
size_t i; size_t i;
uint8_t opad[PAD_SIZE], ipad[PAD_SIZE], hash[HASH_SIZE]; uint8_t opad[PAD_SIZE], ipad[PAD_SIZE];
SHA256_CTX ctx; SHA256_CTX ctx;
memset(ipad, 0x36, PAD_SIZE); memset(ipad, 0x36, PAD_SIZE);
memset(opad, 0x5C, PAD_SIZE); memset(opad, 0x5C, PAD_SIZE);
if (keylen > PAD_SIZE) { if (keylen > PAD_SIZE) {
uint8_t hash[HASH_SIZE];
SHA256_Init(&ctx); SHA256_Init(&ctx);
SHA256_Update(&ctx, key, keylen); SHA256_Update(&ctx, key, keylen);
@ -116,4 +117,3 @@ static void hmac_sha256_yield(const struct hmac_ctx *hctx,
SHA256_Update(&ctx, hash, sizeof hash); SHA256_Update(&ctx, hash, sizeof hash);
SHA256_Final(output, &ctx); SHA256_Final(output, &ctx);
} }

View File

@ -178,13 +178,12 @@ static int crack_rt(uint32_t start, uint32_t end, uint32_t *result)
static void crack_thread_rt(struct crack_job *j) static void crack_thread_rt(struct crack_job *j)
{ {
uint64_t tmp;
uint32_t start = j->start, end; uint32_t start = j->start, end;
uint32_t res; uint32_t res;
while (!job_control.nonce_seed) { while (!job_control.nonce_seed) {
tmp = (uint64_t)start + (uint64_t)SEEDS_PER_JOB_BLOCK; uint64_t tmp = (uint64_t)start + (uint64_t)SEEDS_PER_JOB_BLOCK;
if (tmp > (uint64_t)job_control.end) tmp = job_control.end; if (tmp > (uint64_t)job_control.end) tmp = job_control.end;
end = tmp; end = tmp;
if (crack_rt(start, end, &res)) { if (crack_rt(start, end, &res)) {
@ -767,11 +766,13 @@ usage_err:
} }
if (wps->verbosity > 1) { if (wps->verbosity > 1) {
if (decrypted5) { if (decrypted5) {
if ((vtag = find_vtag(decrypted5, wps->m5_encr_len - 16, WPS_TAG_E_SNONCE_1, WPS_NONCE_LEN))) if ((vtag = find_vtag(decrypted5, wps->m5_encr_len - 16, WPS_TAG_E_SNONCE_1, WPS_NONCE_LEN))) {
printf("\n [*] ES1: "); byte_array_print(vtag->data, WPS_NONCE_LEN); printf("\n [*] ES1: "); byte_array_print(vtag->data, WPS_NONCE_LEN);
}
} }
if ((vtag = find_vtag(decrypted7, wps->m7_encr_len - 16, WPS_TAG_E_SNONCE_2, WPS_NONCE_LEN))) if ((vtag = find_vtag(decrypted7, wps->m7_encr_len - 16, WPS_TAG_E_SNONCE_2, WPS_NONCE_LEN))) {
printf("\n [*] ES2: "); byte_array_print(vtag->data, WPS_NONCE_LEN); printf("\n [*] ES2: "); byte_array_print(vtag->data, WPS_NONCE_LEN);
}
} }
if ((vtag = find_vtag(decrypted7, wps->m7_encr_len - 16, WPS_TAG_SSID, 0))) { if ((vtag = find_vtag(decrypted7, wps->m7_encr_len - 16, WPS_TAG_SSID, 0))) {
int tag_size = end_ntoh16(vtag->len); int tag_size = end_ntoh16(vtag->len);
@ -1472,23 +1473,13 @@ static uint32_t ecos_rand_knuth(uint32_t *seed)
return *seed; return *seed;
} }
/* Simple power function */
static int int_pow(int a, int exp)
{
if (exp <= 0) return 1;
int r = a;
while (--exp) r *= a;
return r;
}
/* return non-zero if pin half is correct, zero otherwise */ /* return non-zero if pin half is correct, zero otherwise */
static int check_pin_half(const struct hmac_ctx *hctx, const char pinhalf[4], uint8_t *psk, const uint8_t *es, struct global *wps, const uint8_t *ehash) static int check_pin_half(const struct hmac_ctx *hctx, const char pinhalf[4], uint8_t *psk, const uint8_t *es, struct global *wps, const uint8_t *ehash)
{ {
uint8_t buffer[WPS_SECRET_NONCE_LEN + WPS_PSK_LEN + WPS_PKEY_LEN * 2]; uint8_t buffer[WPS_SECRET_NONCE_LEN + WPS_PSK_LEN + WPS_PKEY_LEN * 2];
uint8_t result[WPS_HASH_LEN]; uint8_t result[WPS_HASH_LEN];
hmac_sha256_yield(hctx, pinhalf, 4, psk); hmac_sha256_yield(hctx, (uint8_t *)pinhalf, 4, psk);
memcpy(buffer, es, WPS_SECRET_NONCE_LEN); memcpy(buffer, es, WPS_SECRET_NONCE_LEN);
memcpy(buffer + WPS_SECRET_NONCE_LEN, psk, WPS_PSK_LEN); memcpy(buffer + WPS_SECRET_NONCE_LEN, psk, WPS_PSK_LEN);
memcpy(buffer + WPS_SECRET_NONCE_LEN + WPS_PSK_LEN, wps->pke, WPS_PKEY_LEN); memcpy(buffer + WPS_SECRET_NONCE_LEN + WPS_PSK_LEN, wps->pke, WPS_PKEY_LEN);

View File

@ -25,16 +25,6 @@ struct glibc_prng {
uint32_t state[344 + GLIBC_MAX_GEN + 1]; uint32_t state[344 + GLIBC_MAX_GEN + 1];
}; };
/*
* If only 3 numbers are generated then there's no need to store new values
*/
static uint32_t glibc_rand_fast(struct glibc_prng *prng)
{
const uint32_t *state = prng->state;
const int i = prng->index++;
return (state[i - 31] + state[i - 3]) >> 1;
}
/* /*
* There are no checks of bounds (GLIBC_MAX_GEN is the maximum number of times it can be called) * There are no checks of bounds (GLIBC_MAX_GEN is the maximum number of times it can be called)
*/ */

View File

@ -129,9 +129,9 @@ int get_int(char *in, int *out)
unsigned int bit_revert(unsigned int v) unsigned int bit_revert(unsigned int v)
{ {
size_t i; size_t i;
unsigned int lsb, n = 0; unsigned int n = 0;
for (i = 0; i < sizeof(unsigned int) * 8; i++) { for (i = 0; i < sizeof(unsigned int) * 8; i++) {
lsb = v & 1; const unsigned int lsb = v & 1;
v >>= 1; v >>= 1;
n <<= 1; n <<= 1;
n |= lsb; n |= lsb;