Openwall GNU/*/Linux - a small security-enhanced Linux distro for servers
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Sat, 18 May 2013 17:30:55 +0400
From: Alexander Cherepanov <cherepan@...me.ru>
To: john-dev@...ts.openwall.com
Subject: Unused macros

Hi!

Attached is a naive perl script to find unused macros (i.e. #define's) 
in .c files. Its output mimicks gcc's warnings so that you can easily 
navigate using usual means like next-error in emacs.

It knows to ignore several macros used in john which are listed at
https://gnu.org/software/libc/manual/html_node/Feature-Test-Macros.html
(such as _POSIX_SOURCE) but that's all.

For core it outputs the following:

bench.c:7: warning: unused macro '__POSIX'
best.c:11: warning: unused macro '__POSIX'
c3_fmt.c:11: warning: unused macro '_XOPEN_VERSION'
c3_fmt.c:12: warning: unused macro '_XPG4_2'
DES_bs_b.c:721: warning: unused macro 'vandn'
DES_bs_b.c:723: warning: unused macro 'vsel'
DES_bs_b.c:762: warning: unused macro 'vnot'
DES_bs_b.c:1108: warning: unused macro 'DEPTH'
DES_bs_b.c:1452: warning: unused macro 'kd'
sboxes.c:2: warning: unused macro 'andn'
signals.c:9: warning: unused macro '__POSIX'
status.c:7: warning: unused macro '__POSIX'

All these seems to be falses but I'm not sure they are worth to be being 
blacklisted in the script.

For bleeding a list is attached. It contains 215 items and some are 
quite amusing (like several unused FORMAT_LABELs). Hope it would be 
useful for someone.

-- 
Alexander Cherepanov

#!/usr/bin/perl

# Print unused macros
# Copyright (C) 2013 Alexander Cherepanov <cherepan at mccme.ru>
# 
# Redistribution and use in source and binary forms, with or without
# modification, are permitted.

# Usage:
#   unused-macros *.c

use strict;
use warnings;

for my $file (@...V) {
    my %def;
    open IN, '<', $file;
    my $k;
    while (<IN>) {
        $k++;
        if (s/^#\s*define\s+(\w+)//) {
            $def{$1} = $k;
        }
        while (/\w+/g) {
            delete $def{$&};
        }
    }
    close IN;

    # Ignore some macros from https://gnu.org/software/libc/manual/html_node/Feature-Test-Macros.html
    delete @def{qw(_POSIX_SOURCE _BSD_SOURCE _XOPEN_SOURCE _XOPEN_SOURCE_EXTENDED _LARGEFILE64_SOURCE _GNU_SOURCE)};
    # ?
    #delete @def{qw(__POSIX _XOPEN_VERSION)};

    # To sort by line numbers we need to reverse out hash
    my %rev_def = reverse %def;
    for my $lineno (sort { $a <=> $b } keys %rev_def) { # numeric sort
        my $macro = $rev_def{$lineno};
        if (!($macro =~ /^NEED_OS_/)) { # ignore john specific macros NEED_OS_*
            print "$file:$def{$macro}: warning: unused macro '$macro'\n";
        }
    }
}

agilekeychain_fmt_plug.c:50: warning: unused macro 'IVLEN'
asaMD5_fmt_plug.c:20: warning: unused macro 'PLAINTEXT_LENGTH'
bench.c:15: warning: unused macro '__POSIX'
best.c:11: warning: unused macro '__POSIX'
c3_fmt.c:11: warning: unused macro '_XOPEN_VERSION'
c3_fmt.c:12: warning: unused macro '_XPG4_2'
clipperz_srp_fmt_plug.c:82: warning: unused macro 'USERNAMELEN'
cloudkeychain_fmt_plug.c:52: warning: unused macro 'IVLEN'
cuda_cryptsha256_fmt.c:25: warning: unused macro 'MD5_DIGEST_LENGTH'
cuda_cryptsha512_fmt.c:23: warning: unused macro 'CIPHERTEXT_LENGTH'
cuda_cryptsha512_fmt.c:25: warning: unused macro 'MD5_DIGEST_LENGTH'
cuda_phpass_fmt.c:26: warning: unused macro 'MD5_DIGEST_LENGTH'
cuda_pwsafe_fmt.c:32: warning: unused macro 'MIN_KEYS_PER_CRYPT'
cuda_pwsafe_fmt.c:33: warning: unused macro 'MAX_KEYS_PER_CRYPT'
DES_bs_b.c:726: warning: unused macro 'vandn'
DES_bs_b.c:728: warning: unused macro 'vsel'
DES_bs_b.c:767: warning: unused macro 'vnot'
DES_bs_b.c:1113: warning: unused macro 'DEPTH'
DES_bs_b.c:1607: warning: unused macro 'kd'
dynamic_big_crypt.c:25: warning: unused macro 'WAS_MMX_OPENMP'
dynamic_big_crypt.c:44: warning: unused macro 'USING_OSSL_WHRLP'
dynamic_fmt.c:70: warning: unused macro 'WAS_MMX_OPENMP'
dynamic_parser.c:75: warning: unused macro 'DEFINE_MD5_PREDICATE_POINTERS'
formspring_fmt_plug.c:38: warning: unused macro 'PROCESSED_SALT_SIZE'
formspring_fmt_plug.c:43: warning: unused macro 'MIN_KEYS_PER_CRYPT'
formspring_fmt_plug.c:44: warning: unused macro 'MAX_KEYS_PER_CRYPT'
haval_fmt_plug.c:25: warning: unused macro 'FORMAT_LABEL'
haval_fmt_plug.c:26: warning: unused macro 'FORMAT_NAME'
haval_helper.c:38: warning: unused macro 'SPH_XCAT_'
haval_plug.c:119: warning: unused macro 'FP3_1'
haval_plug.c:121: warning: unused macro 'FP3_2'
haval_plug.c:123: warning: unused macro 'FP3_3'
haval_plug.c:126: warning: unused macro 'FP4_1'
haval_plug.c:128: warning: unused macro 'FP4_2'
haval_plug.c:130: warning: unused macro 'FP4_3'
haval_plug.c:132: warning: unused macro 'FP4_4'
haval_plug.c:135: warning: unused macro 'FP5_1'
haval_plug.c:137: warning: unused macro 'FP5_2'
haval_plug.c:139: warning: unused macro 'FP5_3'
haval_plug.c:141: warning: unused macro 'FP5_4'
haval_plug.c:143: warning: unused macro 'FP5_5'
haval_plug.c:598: warning: unused macro 'WSTATE'
haval_plug.c:645: warning: unused macro 'IN_PREPARE'
haval_plug.c:652: warning: unused macro 'INW'
haval_plug.c:872: warning: unused macro 'PASSES'
john.c:15: warning: unused macro 'CRTDBG_MAP_ALLOC'
john.c:75: warning: unused macro 'JOHN_BLD'
john.c:90: warning: unused macro '_MP_VERSION'
KeccakF-1600-opt32_plug.c:229: warning: unused macro 'ROL32'
KRB4_std_plug.c:19: warning: unused macro '_XOPEN_VERSION'
KRB4_std_plug.c:20: warning: unused macro '_XPG4_2'
kwallet2john.c:26: warning: unused macro 'KWALLET_CIPHER_3DES_CBC'
kwallet2john.c:29: warning: unused macro 'KWALLET_HASH_MD5'
kwallet2john.c:30: warning: unused macro 'N'
kwallet2john.c:31: warning: unused macro 'MIN'
lastpass_sniffed_fmt_plug.c:52: warning: unused macro 'SALTLEN'
lastpass_sniffed_fmt_plug.c:53: warning: unused macro 'IVLEN'
lastpass_sniffed_fmt_plug.c:54: warning: unused macro 'CTLEN'
lowpbe.c:151: warning: unused macro 'HMAC_BUFFER'
lowpbe.c:152: warning: unused macro 'NSSPBE_ROUNDUP'
lowpbe.c:153: warning: unused macro 'NSSPBE_MIN'
md_helper.c:86: warning: unused macro 'SPH_XCAT_'
mediawiki_fmt_plug.c:63: warning: unused macro 'PROCESSED_SALT_SIZE'
mediawiki_fmt_plug.c:67: warning: unused macro 'MIN_KEYS_PER_CRYPT'
mediawiki_fmt_plug.c:68: warning: unused macro 'MAX_KEYS_PER_CRYPT'
misc.c:24: warning: unused macro 'INCLUDED_FROM_MISC_C'
mkvcalcproba.c:24: warning: unused macro 'MAX_LVL_LEN'
mkvcalcproba.c:25: warning: unused macro 'MAX_LEN'
mscash2_fmt_plug.c:132: warning: unused macro 'U16_KEY_LEN'
MSCHAPv2_bs_fmt_plug.c:63: warning: unused macro 'DOMAIN_LENGTH'
mssql12_fmt_plug.c:53: warning: unused macro 'CIPHERTEXT_LENGTH'
mssql-old_fmt_plug.c:53: warning: unused macro 'SALT_EXTRA_LEN'
mssql-old_fmt_plug.c:66: warning: unused macro 'ENDIAN_SHIFT_R'
NETLMv2_fmt_plug.c:103: warning: unused macro 'uint16'
NS_fmt_plug.c:49: warning: unused macro 'CIPHERTEXT_LENGTH'
nukedclan_fmt_plug.c:21: warning: unused macro 'COMMON_DIGEST_FOR_OPENSSL'
opencl_agilekeychain_fmt.c:46: warning: unused macro 'uint16_t'
opencl_cryptsha256_fmt.c:30: warning: unused macro '_USE_CPU_SOURCE'
opencl_cryptsha512_fmt.c:30: warning: unused macro '_USE_CPU_SOURCE'
opencl_DES_bs_b.c:13: warning: unused macro 'LOG_SIZE'
opencl_DES_bs.c:19: warning: unused macro 'for_each_depth'
opencl_dmg_fmt.c:41: warning: unused macro 'uint16_t'
opencl_encfs_fmt.c:40: warning: unused macro 'uint16_t'
opencl_keychain_fmt.c:27: warning: unused macro 'SWAP'
opencl_keychain_fmt.c:38: warning: unused macro 'uint16_t'
opencl_krb5pa-sha1_fmt.c:75: warning: unused macro 'MAX'
opencl_mscash2_fmt.c:34: warning: unused macro 'KERNEL_NAME'
opencl_nt_fmt.c:94: warning: unused macro 'SQRT_2'
opencl_ntlmv2_fmt.c:55: warning: unused macro 'MAX'
opencl_odf_aes_fmt.c:35: warning: unused macro 'uint16_t'
opencl_odf_fmt.c:35: warning: unused macro 'uint16_t'
opencl_office2007_fmt.c:51: warning: unused macro 'MAX'
opencl_office2010_fmt.c:51: warning: unused macro 'MAX'
opencl_office2013_fmt.c:51: warning: unused macro 'MAX'
opencl_pwsafe_fmt.c:56: warning: unused macro 'SWAP32'
opencl_rar_fmt.c:49: warning: unused macro 'COMMON_DIGEST_FOR_OPENSSL'
opencl_rar_fmt.c:106: warning: unused macro 'ROUNDS'
opencl_rar_fmt.c:109: warning: unused macro 'MAX'
opencl_rar_fmt.c:117: warning: unused macro 'OMP_SCALE'
opencl_rar_fmt.c:151: warning: unused macro 'CPU_GPU_RATIO'
opencl_rawmd4_fmt.c:46: warning: unused macro 'MAX'
opencl_rawmd5_fmt.c:46: warning: unused macro 'MAX'
opencl_rawsha1_fmt.c:59: warning: unused macro 'MIN'
opencl_strip_fmt.c:34: warning: unused macro 'uint16_t'
opencl_strip_fmt.c:40: warning: unused macro 'HMAC_SALT_MASK'
opencl_strip_fmt.c:41: warning: unused macro 'FAST_PBKDF2_ITER'
opencl_sxc_fmt.c:36: warning: unused macro 'uint16_t'
opencl_wpapsk_fmt.c:22: warning: unused macro 'JOHN_OCL_WPAPSK'
opencl_wpapsk_fmt.c:41: warning: unused macro 'MAX'
opencl_zip_fmt.c:28: warning: unused macro 'SWAP'
opencl_zip_fmt.c:38: warning: unused macro 'uint16_t'
opencl_zip_fmt.c:72: warning: unused macro 'SALT_LENGTH'
options.c:44: warning: unused macro '_PER_NODE'
oracle_fmt_plug.c:74: warning: unused macro 'ENDIAN_SHIFT_L'
oracle_fmt_plug.c:75: warning: unused macro 'ENDIAN_SHIFT_R'
osc_fmt_plug.c:43: warning: unused macro 'PROCESSED_SALT_SIZE'
osc_fmt_plug.c:48: warning: unused macro 'MIN_KEYS_PER_CRYPT'
osc_fmt_plug.c:49: warning: unused macro 'MAX_KEYS_PER_CRYPT'
para-best.c:13: warning: unused macro '__POSIX'
pbkdf2-hmac-sha512_fmt_plug.c:48: warning: unused macro 'KEYS_PER_CRYPT'
pbkdf2-hmac-sha512_fmt_plug.c:58: warning: unused macro 'MIN'
pbkdf2-hmac-sha512_fmt_plug.c:59: warning: unused macro 'MAX'
PHPS_fmt_plug.c:53: warning: unused macro 'PROCESSED_SALT_SIZE'
PHPS_fmt_plug.c:58: warning: unused macro 'MIN_KEYS_PER_CRYPT'
PHPS_fmt_plug.c:59: warning: unused macro 'MAX_KEYS_PER_CRYPT'
pixMD5_fmt_plug.c:20: warning: unused macro 'PLAINTEXT_LENGTH'
PO_fmt_plug.c:51: warning: unused macro 'CIPHERTEXT_LENGTH'
putty2john.c:11: warning: unused macro 'PUTTY_COMMON_H'
putty2john.c:26: warning: unused macro 'srealloc'
putty2john.c:35: warning: unused macro 'snew'
putty2john.c:36: warning: unused macro 'snewn'
putty2john.c:37: warning: unused macro 'sresize'
putty2john.c:44: warning: unused macro 'TRUE'
putty2john.c:48: warning: unused macro 'lenof'
putty2john.c:52: warning: unused macro 'min'
putty2john.c:55: warning: unused macro 'max'
putty2john.c:58: warning: unused macro 'GET_32BIT_LSB_FIRST'
putty2john.c:64: warning: unused macro 'PUT_32BIT_LSB_FIRST'
putty2john.c:70: warning: unused macro 'GET_16BIT_LSB_FIRST'
putty2john.c:74: warning: unused macro 'PUT_16BIT_LSB_FIRST'
putty2john.c:84: warning: unused macro 'GET_32BIT'
putty2john.c:92: warning: unused macro 'PUT_32BIT'
putty2john.c:94: warning: unused macro 'GET_16BIT_MSB_FIRST'
putty2john.c:98: warning: unused macro 'PUT_16BIT_MSB_FIRST'
putty2john.c:102: warning: unused macro 'SSH_CIPHER_IDEA'
putty2john.c:103: warning: unused macro 'SSH_CIPHER_DES'
putty2john.c:104: warning: unused macro 'SSH_CIPHER_3DES'
putty2john.c:105: warning: unused macro 'SSH_CIPHER_BLOWFISH'
putty2john.c:130: warning: unused macro 'PASSPHRASE_MAXLEN'
pwsafe_fmt_plug.c:171: warning: unused macro 'rotl'
rar5_fmt_plug.c:33: warning: unused macro 'SIZE_PSWCHECK_CSUM'
rar5_fmt_plug.c:34: warning: unused macro 'SIZE_INITV'
rar_fmt.c:49: warning: unused macro 'COMMON_DIGEST_FOR_OPENSSL'
rar_fmt.c:101: warning: unused macro 'MAX'
rawSHA1_ng_fmt.c:53: warning: unused macro 'SHA1_BLOCK_SIZE'
rawSHA256_ng_i_fmt.c:51: warning: unused macro 'NUMKEYS'
ripemd_fmt_plug.c:25: warning: unused macro 'FORMAT_LABEL'
ripemd_fmt_plug.c:26: warning: unused macro 'FORMAT_NAME'
ripemd_plug.c:309: warning: unused macro 'sK11'
ripemd_plug.c:310: warning: unused macro 'sK12'
ripemd_plug.c:311: warning: unused macro 'sK13'
ripemd_plug.c:312: warning: unused macro 'sK14'
ripemd_plug.c:314: warning: unused macro 'sK21'
ripemd_plug.c:315: warning: unused macro 'sK22'
ripemd_plug.c:316: warning: unused macro 'sK23'
ripemd_plug.c:317: warning: unused macro 'sK24'
ripemd_plug.c:661: warning: unused macro 'K11'
ripemd_plug.c:662: warning: unused macro 'K12'
ripemd_plug.c:663: warning: unused macro 'K13'
ripemd_plug.c:664: warning: unused macro 'K14'
ripemd_plug.c:665: warning: unused macro 'K15'
ripemd_plug.c:667: warning: unused macro 'K21'
ripemd_plug.c:668: warning: unused macro 'K22'
ripemd_plug.c:669: warning: unused macro 'K23'
ripemd_plug.c:670: warning: unused macro 'K24'
ripemd_plug.c:671: warning: unused macro 'K25'
sboxes.c:2: warning: unused macro 'andn'
sha2.c:25: warning: unused macro 'FORCE_GENERIC_SHA2'
signals.c:11: warning: unused macro '__POSIX'
SIPdump.c:20: warning: unused macro '__FAVOR_BSD'
sse-intrinsics.c:492: warning: unused macro 'MD4_SSE_NUM_KEYS'
sse-intrinsics.c:641: warning: unused macro 'SHA1_SSE_NUM_KEYS'
sse-intrinsics.c:1519: warning: unused macro 'SHA256_STEP'
status.c:9: warning: unused macro '__POSIX'
strip_fmt_plug.c:48: warning: unused macro 'HMAC_SALT_MASK'
strip_fmt_plug.c:49: warning: unused macro 'FAST_PBKDF2_ITER'
sunmd5_fmt_plug.c:426: warning: unused macro 'ROUND_BUFFER_LEN'
sunmd5_fmt_plug.c:433: warning: unused macro 'md5bit_1'
sunmd5_fmt_plug.c:435: warning: unused macro 'md5bit_2'
tiger_plug.c:575: warning: unused macro 'ROUND'
tiger_plug.c:658: warning: unused macro 'RFUN'
tiger_plug.c:660: warning: unused macro 'LE64'
tiger_plug.c:661: warning: unused macro 'BLEN'
tiger_plug.c:663: warning: unused macro 'PLW1'
tiger_plug.c:684: warning: unused macro 'HASH'
tiger_plug.c:686: warning: unused macro 'CLOSE_ONLY'
uaf_encode_plug.c:40: warning: unused macro '_uaf_encode_plug_'
uaf_encode_plug.c:572: warning: unused macro 'UAF_INCLUDED_FROM_ENCODE'
uaf_encode_plug.c:578: warning: unused macro 'ONE_TIME'
uaf_hash.c:18: warning: unused macro '_uaf_hash_'
uaf_hash.c:70: warning: unused macro '__SSDEF_LOADED'
unicode.c:91: warning: unused macro 'uint16'
unicode.c:99: warning: unused macro 'int16'
vms_fmt_plug.c:28: warning: unused macro 'UAI'
vms_fmt_plug.c:33: warning: unused macro 'FORMAT_NAME_NOPWDMIX'
vms_fmt_plug.c:39: warning: unused macro 'CIPHERTEXT_LENGTH'
wbb3_fmt_plug.c:23: warning: unused macro 'COMMON_DIGEST_FOR_OPENSSL'
whirlpool_fmt_plug.c:25: warning: unused macro 'FORMAT_LABEL'
whirlpool_fmt_plug.c:26: warning: unused macro 'FORMAT_NAME'
whirlpool_plug.c:3435: warning: unused macro 'BE64'
whirlpool_plug.c:3436: warning: unused macro 'SVAL'
whirlpool_plug.c:3437: warning: unused macro 'BLEN'
whirlpool_plug.c:3438: warning: unused macro 'PLW4'
wordlist.c:213: warning: unused macro 'ENTRY_END_LIST'
zip_fmt.c:38: warning: unused macro 'PWD_VER_LENGTH'

Powered by blists - more mailing lists

Your e-mail address:

Powered by Openwall GNU/*/Linux - Powered by OpenVZ