diff --git a/src/aes_gcm_plug.c b/src/aes_gcm_plug.c index bb2c9b003d..371c2a79b7 100644 --- a/src/aes_gcm_plug.c +++ b/src/aes_gcm_plug.c @@ -293,6 +293,7 @@ static void aes_gcm_ghash(const uint8_t *H, const uint8_t *aad, size_t aad_len, } +#if 0 /** * aes_gcm_ae - GCM-AE_K(IV, P, A) */ @@ -324,6 +325,7 @@ int aes_gcm_ae(const uint8_t *key, size_t key_len, const uint8_t *iv, size_t iv_ return 0; } +#endif /** @@ -361,12 +363,14 @@ int aes_gcm_ad(const uint8_t *key, size_t key_len, const uint8_t *iv, size_t iv_ } +#if 0 int aes_gmac(const uint8_t *key, size_t key_len, const uint8_t *iv, size_t iv_len, const uint8_t *aad, size_t aad_len, uint8_t *tag) { return aes_gcm_ae(key, key_len, iv, iv_len, NULL, 0, aad, aad_len, NULL, tag); } +#endif #ifdef TEST diff --git a/src/andotp_fmt_plug.c b/src/andotp_fmt_plug.c index 8c3e70555e..05c85eb19d 100644 --- a/src/andotp_fmt_plug.c +++ b/src/andotp_fmt_plug.c @@ -167,7 +167,8 @@ static int check_password(int index, struct custom_salt *cs) SHA256_Update(&ctx, saved_key[index], saved_len[index]); SHA256_Final(key, &ctx); - ret = aes_gcm_ad(key, 32, cs->iv, IVLEN, cs->ciphertext, cs->ctlen, NULL, 0, cur_salt->tag, NULL, 1); + void *empty = ∅ /* Could be NULL, but we'd end up with NULL+0, which is UB */ + ret = aes_gcm_ad(key, 32, cs->iv, IVLEN, cs->ciphertext, cs->ctlen, empty, 0, cur_salt->tag, empty, 1); if (!ret) return 1; diff --git a/src/configure b/src/configure index ceff406402..bcffcf1db7 100755 --- a/src/configure +++ b/src/configure @@ -18048,117 +18048,11 @@ Fuzzing test ....................................... ${fuzz} EOF fi -if test -z "$NPROC" -then : - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}nproc", so it can be a program name with args. -set dummy ${ac_tool_prefix}nproc; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_NPROC+y} -then : - printf %s "(cached) " >&6 -else $as_nop - if test -n "$NPROC"; then - ac_cv_prog_NPROC="$NPROC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then - ac_cv_prog_NPROC="${ac_tool_prefix}nproc" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -NPROC=$ac_cv_prog_NPROC -if test -n "$NPROC"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $NPROC" >&5 -printf "%s\n" "$NPROC" >&6; } -else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_NPROC"; then - ac_ct_NPROC=$NPROC - # Extract the first word of "nproc", so it can be a program name with args. -set dummy nproc; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_ac_ct_NPROC+y} -then : - printf %s "(cached) " >&6 -else $as_nop - if test -n "$ac_ct_NPROC"; then - ac_cv_prog_ac_ct_NPROC="$ac_ct_NPROC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_NPROC="nproc" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_NPROC=$ac_cv_prog_ac_ct_NPROC -if test -n "$ac_ct_NPROC"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_NPROC" >&5 -printf "%s\n" "$ac_ct_NPROC" >&6; } -else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } -fi - - if test "x$ac_ct_NPROC" = x; then - NPROC="""" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - NPROC=$ac_ct_NPROC - fi -else - NPROC="$ac_cv_prog_NPROC" -fi - -fi -if test -z "$NPROC"; then - NUM_CORES=4 -else - NUM_CORES=$(${NPROC}) -fi - echo "Install missing libraries to get any needed features that were omitted." echo "" -echo "Configure finished. Now \"${use_make} -s clean && ${use_make} -sj${NUM_CORES}\" to compile." + +NPROC=`(exec nproc) 2> /dev/null` +test -n "$NPROC" || NPROC=`grep -c '^processor' /proc/cpuinfo 2> /dev/null` +test -n "$NPROC" || NPROC=4 + +echo "Configure finished. Now \"${use_make} -s clean && ${use_make} -sj${NPROC}\" to compile." diff --git a/src/configure.ac b/src/configure.ac index 6fe350d192..83c945070d 100644 --- a/src/configure.ac +++ b/src/configure.ac @@ -1300,16 +1300,12 @@ Fuzzing test ....................................... ${fuzz} EOF fi -dnl Try to figure out number of cpu cores for make -j suggestion -AS_IF([test -z "$NPROC"], [AC_CHECK_TOOL([NPROC], [nproc], [""])]) -if test -z "$NPROC"; then - dnl default to 4 - NUM_CORES=4 -else - NUM_CORES=$(${NPROC}) -fi - echo "Install missing libraries to get any needed features that were omitted." echo "" -echo "Configure finished. Now \"${use_make} -s clean && ${use_make} -sj${NUM_CORES}\" to compile." + +NPROC=`(exec nproc) 2> /dev/null` +test -n "$NPROC" || NPROC=`grep -c '^processor' /proc/cpuinfo 2> /dev/null` +test -n "$NPROC" || NPROC=4 + +echo "Configure finished. Now \"${use_make} -s clean && ${use_make} -sj${NPROC}\" to compile." dnl ====================================================================== diff --git a/src/racf_kdfaes_fmt_plug.c b/src/racf_kdfaes_fmt_plug.c index a170edded7..aafa0b5ce0 100644 --- a/src/racf_kdfaes_fmt_plug.c +++ b/src/racf_kdfaes_fmt_plug.c @@ -330,7 +330,6 @@ static int crypt_all(int *pcount, struct db_salt *salt) char mac1[32] = { 0 }; char t1[32] = { 0 }; unsigned char key[32]; - unsigned char *key_p = key; unsigned char m[MAX_SALT_SIZE + HASH_OUTPUT_SIZE + 32]; unsigned char *t1f = mem_alloc(HASH_OUTPUT_SIZE * cur_salt->mfact); unsigned char *h_out = (unsigned char*)crypt_out[index]; @@ -340,7 +339,7 @@ static int crypt_all(int *pcount, struct db_salt *salt) unsigned char dh[8]; ml = cur_salt->length; - memset(key_p, 0, sizeof(key)); + memset(key, 0, sizeof(key)); memcpy(m, cur_salt->salt, ml); // get des hash @@ -369,25 +368,22 @@ static int crypt_all(int *pcount, struct db_salt *salt) memcpy(key, t1, 32); for (n = 0; n < cur_salt->mfact; n++) { - n_key =(((key_p[28]<<24) & 0xff000000) + - ((key_p[29]<<16) & 0xff0000) + - ((key_p[30]<<8) & 0xff00) + - (key_p[31] & 0xff)) & (cur_salt->mfact-1); + n_key = (((uint32_t)key[30] << 8) | key[31]) & (cur_salt->mfact - 1); memcpy(m, t1f + (n_key * HASH_OUTPUT_SIZE), HASH_OUTPUT_SIZE); memcpy(m + HASH_OUTPUT_SIZE, "\x00\x00\x00\x01", 4); - JTR_hmac_sha256(key_p, HASH_OUTPUT_SIZE, m, HASH_OUTPUT_SIZE + 4, h_out, HASH_OUTPUT_SIZE); + JTR_hmac_sha256(key, HASH_OUTPUT_SIZE, m, HASH_OUTPUT_SIZE + 4, h_out, HASH_OUTPUT_SIZE); memcpy(t1f + (n*HASH_OUTPUT_SIZE), h_out, HASH_OUTPUT_SIZE); memcpy(key, h_out, HASH_OUTPUT_SIZE); } memcpy(t1f + (HASH_OUTPUT_SIZE * (cur_salt->mfact-1)), "\x00\x00\x00\x01", 4); ml = (HASH_OUTPUT_SIZE * (cur_salt->mfact-1))+4; - JTR_hmac_sha256(key_p, HASH_OUTPUT_SIZE, t1f, ml, h_out, HASH_OUTPUT_SIZE); + JTR_hmac_sha256(key, HASH_OUTPUT_SIZE, t1f, ml, h_out, HASH_OUTPUT_SIZE); ml = 32; memcpy(t1, h_out, HASH_OUTPUT_SIZE); for (x = 0; x < (cur_salt->rfact*100)-1; x++) { - JTR_hmac_sha256(key_p, HASH_OUTPUT_SIZE, h_out, ml, h_out, HASH_OUTPUT_SIZE); + JTR_hmac_sha256(key, HASH_OUTPUT_SIZE, h_out, ml, h_out, HASH_OUTPUT_SIZE); for (i = 0; i < HASH_OUTPUT_SIZE; i++) t1[i] ^= h_out[i]; } diff --git a/src/wpapcap2john.c b/src/wpapcap2john.c index 02e7bbd16d..7ac619ad99 100644 --- a/src/wpapcap2john.c +++ b/src/wpapcap2john.c @@ -1980,23 +1980,23 @@ static int process_ng(FILE *in) pcapngpb.len = swap32u(pcapngpb.len); } - if ((pcapngepb.timestamp_high == 0) && - (pcapngepb.timestamp_low == 0) && !warn_wpaclean++) + if ((pcapngpb.timestamp_high == 0) && + (pcapngpb.timestamp_low == 0) && !warn_wpaclean++) fprintf(stderr, "**\n** Warning: %s seems to be processed with some dubious tool like\n" "** 'wpaclean'. Important information may be lost.\n**\n", filename); MEM_FREE(full_packet); - safe_malloc(full_packet, pcapngepb.caplen); + safe_malloc(full_packet, pcapngpb.caplen); res = fread(full_packet, 1, pcapngpb.caplen, in); if (res != pcapngpb.caplen) { printf("failed to read packet: %s truncated?\n", filename); break; } - fseek(in, pcapngbh.total_length - BH_SIZE - PB_SIZE - pcapngepb.caplen, SEEK_CUR); + fseek(in, pcapngbh.total_length - BH_SIZE - PB_SIZE - pcapngpb.caplen, SEEK_CUR); MEM_FREE(full_packet); - safe_malloc(full_packet, pcapngepb.caplen); + safe_malloc(full_packet, pcapngpb.caplen); res = fread(full_packet, 1, pcapngpb.caplen, in); if (res != pcapngpb.caplen) { printf("failed to read packet: %s truncated?\n", filename);