This commit is contained in:
wiire 2015-06-06 12:33:33 +02:00
parent c06bd61cc3
commit 0cf0e7ce82
5 changed files with 28 additions and 28 deletions

View File

@ -1,4 +1,4 @@
CCFLAGS = -std=c99 -O3
CCFLAGS = -std=c99 -O3 -Wno-error=deprecated-declarations
LDFLAGS = -lcrypto -I../include
TARGET = pixiewps
@ -6,7 +6,7 @@ PREFIX = $(DESTDIR)/usr
BINDIR = $(PREFIX)/bin
all:
$(CC) $(CCFLAGS) -o $(TARGET) $(TARGET).c random_r.c $(LDFLAGS)
$(CC) $(CCFLAGS) -o $(TARGET) $(TARGET).c $(LDFLAGS)
install:
install -D $(TARGET) $(BINDIR)/$(TARGET)

View File

@ -47,9 +47,9 @@
#include <sys/time.h>
#ifdef __MACH__
#include <libkern/OSByteOrder.h>
# include <libkern/OSByteOrder.h>
#else
#include <asm/byteorder.h>
# include <asm/byteorder.h>
#endif /* __MACH__ */
#include "pixiewps.h"
@ -423,11 +423,11 @@ int main(int argc, char **argv) {
srandom_r(print_seed + 1, buf);
for (int i = 0; i < 4; i++) {
random_r(buf, &res);
#ifdef __MACH__
uint32_t be = OSSwapBigToHostInt32(res);
#else
uint32_t be = __be32_to_cpu(res);
#endif
#ifdef __MACH__
uint32_t be = OSSwapBigToHostInt32(res);
#else
uint32_t be = __be32_to_cpu(res);
#endif
memcpy(&(wps->e_s1[4 * i]), &be, 4);
memcpy(wps->e_s2, wps->e_s1, WPS_SECRET_NONCE_LEN); /* E-S1 = E-S2 != E-Nonce */
}

View File

@ -37,8 +37,8 @@
* files in the program, then also delete it here.
*/
#ifndef _PIXIEWPS_H
#define _PIXIEWPS_H
#ifndef PIXIEWPS_H
#define PIXIEWPS_H
#define VERSION "1.1"
#define MAX_MODE 4
@ -155,18 +155,18 @@ void kdf(unsigned char *key, size_t key_len, unsigned char *res) {
unsigned char *buffer = malloc(WPS_KDF_SALT_LEN + 4 * 2);
for (i = 1; i < 4; i++) {
#ifdef __MACH__
uint32_t be = OSSwapBigToHostInt32(i);
#else
uint32_t be = __be32_to_cpu(i);
#endif
#ifdef __MACH__
uint32_t be = OSSwapBigToHostInt32(i);
#else
uint32_t be = __be32_to_cpu(i);
#endif
memcpy(buffer, &be, 4);
memcpy(buffer + 4, salt, WPS_KDF_SALT_LEN);
#ifdef __MACH__
be = OSSwapBigToHostInt32(kdk_len);
#else
be = __be32_to_cpu(kdk_len);
#endif
#ifdef __MACH__
be = OSSwapBigToHostInt32(kdk_len);
#else
be = __be32_to_cpu(kdk_len);
#endif
memcpy(buffer + 4 + 36, &be, 4);
hmac_sha256(key, WPS_HASH_LEN, buffer, WPS_KDF_SALT_LEN + 4 * 2, res + j);
j += WPS_HASH_LEN;
@ -191,4 +191,4 @@ unsigned int wps_pin_valid(unsigned int pin) {
return wps_pin_checksum(pin / 10) == (pin % 10);
}
#endif /* _PIXIEWPS_H */
#endif /* PIXIEWPS_H */

View File

@ -37,8 +37,8 @@
* files in the program, then also delete it here.
*/
#ifndef _RANDOM_R_H
#define _RANDOM_R_H
#ifndef RANDOM_R_H
#define RANDOM_R_H
#include <stdint.h>
@ -57,4 +57,4 @@ int srandom_r(unsigned int seed, struct random_data *buf);
int initstate_r(unsigned int seed, char *arg_state, size_t n, struct random_data *buf);
int setstate_r(char *arg_state, struct random_data *buf);
#endif /* _RANDOM_R_H */
#endif /* RANDOM_R_H */

View File

@ -37,8 +37,8 @@
* files in the program, then also delete it here.
*/
#ifndef _UTILS_H
#define _UTILS_H
#ifndef UTILS_H
#define UTILS_H
/* Converts an hex string to a byte array */
int hex_string_to_byte_array(char *in, unsigned char *out, int n_len) {
@ -106,4 +106,4 @@ void byte_array_print(unsigned char *buffer, unsigned int length) {
}
}
#endif /* _UTILS_H */
#endif /* UTILS_H */