#!/usr/bin/perl -w # # extract-mod-sig # # Reads the module file and writes out some or all of the signature # section to stdout. Part is the bit to be written and is one of: # # -0: The unsigned module, no signature data at all # -a: All of the signature data, including magic number # -d: Just the descriptor values as a sequence of numbers # -n: Just the signer's name # -k: Just the key ID # -s: Just the crypto signature or PKCS#7 message # use strict; die "Format: $0 -[0adnks] module-file >out\n" if ($#ARGV != 1); my $part = $ARGV[0]; my $modfile = $ARGV[1]; my $magic_number = "~Module signature appended~\n"; # # Read the module contents # open FD, "<$modfile" || die $modfile; binmode(FD); my @st = stat(FD); die "$modfile" unless (@st); my $buf = ""; my $len = sysread(FD, $buf, $st[7]); die "$modfile" unless (defined($len)); die "Short read on $modfile\n" unless ($len == $st[7]); close(FD) || die $modfile; print STDERR "Read ", $len, " bytes from module file\n"; die "The file is too short to have a sig magic number and descriptor\n" if ($len < 12 + length($magic_number)); # # Check for the magic number and extract the information block # my $p = $len - length($magic_number); my $raw_magic = substr($buf, $p); die "Magic number not found at $len\n" if ($raw_magic ne $magic_number); print STDERR "Found magic number at $len\n"; $p -= 12; my $raw_info = substr($buf, $p, 12); my @info = unpack("CCCCCxxxN", $raw_info); my ($algo, $hash, $id_type, $name_len, $kid_len, $sig_len) = @info; if ($id_type == 0) { print STDERR "Found PGP key identifier\n"; } elsif ($id_type == 1) { print STDERR "Found X.509 cert identifier\n"; } elsif ($id_type == 2) { print STDERR "Found PKCS#7/CMS encapsulation\n"; } else { print STDERR "Found unsupported identifier type $id_type\n"; } # # Extract the three pieces of info data # die "Insufficient name+kid+sig data in file\n" unless ($p >= $name_len + $kid_len + $sig_len); $p -= $sig_len; my $raw_sig = substr($buf, $p, $sig_len); $p -= $kid_len; my $raw_kid = substr($buf, $p, $kid_len); $p -= $name_len; my $raw_name = substr($buf, $p, $name_len); my $module_len = $p; if ($sig_len > 0) { print STDERR "Found $sig_len bytes of signature ["; my $n = $sig_len > 16 ? 16 : $sig_len; foreach my $i (unpack("C" x $n, substr($raw_sig, 0, $n))) { printf STDERR "%02x", $i; } print STDERR "]\n"; } if ($kid_len > 0) { print STDERR "Found $kid_len bytes of key identifier ["; my $n = $kid_len > 16 ? 16 : $kid_len; foreach my $i (unpack("C" x $n, substr($raw_kid, 0, $n))) { printf STDERR "%02x", $i; } print STDERR "]\n"; } if ($name_len > 0) { print STDERR "Found $name_len bytes of signer's name [$raw_name]\n"; } # # Produce the requested output # if ($part eq "-0") { # The unsigned module, no signature data at all binmode(STDOUT); print substr($buf, 0, $module_len); } elsif ($part eq "-a") { # All of the signature data, including magic number binmode(STDOUT); print substr($buf, $module_len); } elsif ($part eq "-d") { # Just the descriptor values as a sequence of numbers print join(" ", @info), "\n"; } elsif ($part eq "-n") { # Just the signer's name print STDERR "No signer's name for PKCS#7 message type sig\n" if ($id_type == 2); binmode(STDOUT); print $raw_name; } elsif ($part eq "-k") { # Just the key identifier print STDERR "No key ID for PKCS#7 message type sig\n" if ($id_type == 2); binmode(STDOUT); print $raw_kid; } elsif ($part eq "-s") { # Just the crypto signature or PKCS#7 message binmode(STDOUT); print $raw_sig; } '2017-02-10 14:31:51 -0500'>2017-02-10Merge tag 'mac80211-next-for-davem-2017-02-09' of ↵David S. Miller4-40/+114 git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211-next Johannes Berg says: ==================== Some more updates: * use shash in mac80211 crypto code where applicable * some documentation fixes * pass RSSI levels up in change notifications * remove unused rfkill-regulator * various other cleanups ==================== Signed-off-by: David S. Miller <davem@davemloft.net> 2017-02-09cfg80211: fix NAN bands definitionLuca Coelho3-17/+37 The nl80211_nan_dual_band_conf enumeration doesn't make much sense. The default value is assigned to a bit, which makes it weird if the default bit and other bits are set at the same time. To improve this, get rid of NL80211_NAN_BAND_DEFAULT and add a wiphy configuration to let the drivers define which bands are supported. This is exposed to the userspace, which then can make a decision on which band(s) to use. Additionally, rename all "dual_band" elements to "bands", to make things clearer. Signed-off-by: Luca Coelho <luciano.coelho@intel.com> Signed-off-by: Johannes Berg <johannes.berg@intel.com> 2017-02-08cfg80211: Pass new RSSI level in CQM RSSI notificationAndrzej Zaborowski2-6/+14 Update the drivers to pass the RSSI level as a cfg80211_cqm_rssi_notify parameter and pass this value to userspace in a new nl80211 attribute. This helps both userspace and also helps in the implementation of the multiple RSSI thresholds CQM mechanism. Note for marvell/mwifiex I pass 0 for the RSSI value because the new RSSI value is not available to the driver at the time of the cfg80211_cqm_rssi_notify call, but the driver queries the new value immediately after that, so it is actually available just a moment later if we wanted to defer caling cfg80211_cqm_rssi_notify until that moment. Without this, the new cfg80211 code (patch 3) will call .get_station which will send a duplicate HostCmd_CMD_RSSI_INFO command to the hardware. Signed-off-by: Andrew Zaborowski <andrew.zaborowski@intel.com> Signed-off-by: Johannes Berg <johannes.berg@intel.com> 2017-02-08nl80211: fix validation of scheduled scan info for wowlan netdetectArend Van Spriel1-4/+6 For wowlan netdetect a separate limit is defined for the number of matchsets. Currently, this limit is ignored and the regular limit for scheduled scan matchsets, ie. struct wiphy::max_match_sets, is used for the net-detect case as well. Cc: Johannes Berg <johannes@sipsolutions.net> Reviewed-by: Hante Meuleman <hante.meuleman@broadcom.com> Reviewed-by: Pieter-Paul Giesberts <pieter-paul.giesberts@broadcom.com> Reviewed-by: Franky Lin <franky.lin@broadcom.com> Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com> Signed-off-by: Johannes Berg <johannes.berg@intel.com> 2017-02-08nl80211: add HT/VHT capabilities to AP parametersJohannes Berg1-1/+46 For the benefit of drivers that rebuild IEs in firmware, parse the IEs for HT/VHT capabilities and the respective membership selector in the (extended) supported rates. This avoids duplicating the same code into all drivers that need this information. Signed-off-by: Johannes Berg <johannes.berg@intel.com> 2017-02-08cfg80211: make rdev assignment clearer in nl80211_testmode_dump()Luca Coelho1-7/+6 Avoid assigning rdev to NULL when we already have it and getting it again from the wiphy index, by moving this code to relevant if block. Signed-off-by: Luca Coelho <luciano.coelho@intel.com> Signed-off-by: Johannes Berg <johannes.berg@intel.com> 2017-02-08cfg80211 debugfs: Cleanup some checkpatch issuesPichugin Dmitry1-5/+5 This fixes the checkpatch.pl warnings: * Macros should not use a trailing semicolon. * Spaces required around that '='. * Symbolic permissions 'S_IRUGO' are not preferred. Signed-off-by: Dmitriy Pichugin <smokeman85@gmail.com> Signed-off-by: Johannes Berg <johannes.berg@intel.com> 2017-02-07Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/netDavid S. Miller