Cosmetic changes

This commit is contained in:
wiire-a 2017-12-03 21:18:02 +01:00
parent 3d4d56ed0b
commit fd21867311
2 changed files with 16 additions and 17 deletions

View File

@ -1,15 +1,15 @@
/* public domain hmac_sha256 implementation written by rofl0r for pixiewps */
/* Public domain hmac_sha256 implementation written by rofl0r for pixiewps */
#include <stdint.h>
#include <string.h>
#ifdef USE_OPENSSL
#include <openssl/sha.h>
# include <openssl/sha.h>
#else
#include "../mbedtls/sha256.h"
#define SHA256_CTX mbedtls_sha256_context
#define SHA256_Init(x) do { mbedtls_sha256_init(x); mbedtls_sha256_starts(x, 0); } while(0)
#define SHA256_Update(x, y, z) mbedtls_sha256_update(x, y, z)
#define SHA256_Final(y, x) mbedtls_sha256_finish(x, y)
# include "../mbedtls/sha256.h"
# define SHA256_CTX mbedtls_sha256_context
# define SHA256_Init(x) do { mbedtls_sha256_init(x); mbedtls_sha256_starts(x, 0); } while(0)
# define SHA256_Update(x, y, z) mbedtls_sha256_update(x, y, z)
# define SHA256_Final(y, x) mbedtls_sha256_finish(x, y)
#endif
#define PAD_SIZE 64
@ -66,23 +66,23 @@ struct hmac_ctx {
SHA256_CTX octx;
};
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;
uint8_t opad[PAD_SIZE], ipad[PAD_SIZE];
uint8_t opad[PAD_SIZE], ipad[PAD_SIZE], hash[HASH_SIZE];
SHA256_CTX ctx;
memset(ipad, 0x36, PAD_SIZE);
memset(opad, 0x5C, PAD_SIZE);
if (keylen > PAD_SIZE) {
uint8_t hash[HASH_SIZE];
SHA256_Init(&ctx);
SHA256_Update(&ctx, key, keylen);
SHA256_Final(hash, &ctx);
for (i = 0; i<HASH_SIZE; i++) {
for (i = 0; i < HASH_SIZE; i++) {
ipad[i] ^= hash[i];
opad[i] ^= hash[i];
}
@ -111,7 +111,6 @@ static void hmac_sha256_yield(const struct hmac_ctx *hctx,
SHA256_Update(&ctx, input, ilen);
SHA256_Final(hash, &ctx);
memcpy(&ctx, &hctx->octx, sizeof(ctx));
SHA256_Update(&ctx, hash, sizeof hash);

View File

@ -355,7 +355,7 @@ static int find_rtl_es(struct global *wps)
init_crack_jobs(wps, -RTL819x);
/* checking distance 0 in the main thread, as it is the most likely */
/* Checking distance 0 in the main thread, as it is the most likely */
uint8_t nonce_buf[WPS_SECRET_NONCE_LEN];
char pin[WPS_PIN_LEN + 1];
@ -373,7 +373,7 @@ static int find_rtl_es(struct global *wps)
char pin_copy[WPS_PIN_LEN + 1];
strcpy(pin_copy, wps->pin);
int j;
/* we assume that the seed used for es2 is within a range of 10 seconds
/* We assume that the seed used for es2 is within a range of 10 seconds
forwards in time only */
for (j = 0; j < 10; j++) {
strcpy(wps->pin, pin_copy);
@ -392,7 +392,7 @@ static int find_rtl_es(struct global *wps)
static void empty_pin_hmac(struct global *wps)
{
/* since the empty pin psk is static once initialized, we calculate it only once */
/* Since the empty pin psk is static once initialized, we calculate it only once */
hmac_sha256(wps->authkey, WPS_AUTHKEY_LEN, NULL, 0, wps->empty_psk);
}
@ -1474,7 +1474,7 @@ static uint32_t ecos_rand_knuth(uint32_t *seed)
return *seed;
}
/* 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)
{
uint8_t buffer[WPS_SECRET_NONCE_LEN + WPS_PSK_LEN + WPS_PKEY_LEN * 2];
@ -1490,7 +1490,7 @@ static int check_pin_half(const struct hmac_ctx *hctx, const char pinhalf[4], ui
return !memcmp(result, ehash, WPS_HASH_LEN);
}
/* return non-zero if pin half is correct, zero otherwise */
/* Return non-zero if pin half is correct, zero otherwise */
static int check_empty_pin_half(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];