mirror of
https://github.com/Yubico/yubikey-ksm.git
synced 2025-03-16 03:29:20 +01:00
Removed .pl suffix from scripts.
Added man page generation to Makefile.
This commit is contained in:
parent
bdda65d4cc
commit
cf81fea550
30
Makefile
30
Makefile
@ -29,13 +29,15 @@
|
||||
VERSION = 1.6
|
||||
PACKAGE = yubikey-ksm
|
||||
CODE = .htaccess Makefile NEWS ykksm-config.php ykksm-db.sql \
|
||||
ykksm-decrypt.php ykksm-export.pl ykksm-gen-keys.pl \
|
||||
ykksm-import.pl ykksm-utils.php ykksm-checksum.pl
|
||||
ykksm-decrypt.php ykksm-export ykksm-gen-keys \
|
||||
ykksm-import ykksm-utils.php ykksm-checksum
|
||||
DOCS = doc/DecryptionProtocol.wiki doc/DesignGoals.wiki \
|
||||
doc/GenerateKeys.wiki doc/GenerateKSMKey.wiki \
|
||||
doc/ImportKeysToKSM.wiki doc/Installation.wiki \
|
||||
doc/KeyProvisioningFormat.wiki doc/ServerHardening.wiki \
|
||||
doc/SyncMonitor.wiki
|
||||
MANS = ykksm-checksum.1 ykksm-export.1 ykksm-gen-keys.1 \
|
||||
ykksm-import.1
|
||||
|
||||
all:
|
||||
@echo "Try 'make install' or 'make symlink'."
|
||||
@ -54,10 +56,10 @@ install:
|
||||
install -D .htaccess $(phpprefix)/.htaccess
|
||||
install -D ykksm-decrypt.php $(phpprefix)/ykksm-decrypt.php
|
||||
install -D ykksm-utils.php $(phpprefix)/ykksm-utils.php
|
||||
install -D ykksm-gen-keys.pl $(binprefix)/ykksm-gen-keys
|
||||
install -D ykksm-import.pl $(binprefix)/ykksm-import
|
||||
install -D ykksm-export.pl $(binprefix)/ykksm-export
|
||||
install -D ykksm-checksum.pl $(binprefix)/ykksm-checksum
|
||||
install -D ykksm-gen-keys $(binprefix)/ykksm-gen-keys
|
||||
install -D ykksm-import $(binprefix)/ykksm-import
|
||||
install -D ykksm-export $(binprefix)/ykksm-export
|
||||
install -D ykksm-checksum $(binprefix)/ykksm-checksum
|
||||
install -D --backup --mode 640 --group $(wwwgroup) ykksm-config.php $(etcprefix)/ykksm-config.php
|
||||
install -D ykksm-db.sql $(docprefix)/ykksm-db.sql
|
||||
install -D Makefile $(docprefix)/ykksm.mk
|
||||
@ -76,9 +78,10 @@ PROJECT = $(PACKAGE)
|
||||
USER = simon@yubico.com
|
||||
KEYID = B9156397
|
||||
|
||||
$(PACKAGE)-$(VERSION).tgz: $(FILES)
|
||||
$(PACKAGE)-$(VERSION).tgz: $(FILES) $(MANS)
|
||||
mkdir $(PACKAGE)-$(VERSION) $(PACKAGE)-$(VERSION)/doc
|
||||
cp $(CODE) $(PACKAGE)-$(VERSION)/
|
||||
cp $(MANS) $(PACKAGE)-$(VERSION)/
|
||||
cp $(DOCS) $(PACKAGE)-$(VERSION)/doc/
|
||||
tar cfz $(PACKAGE)-$(VERSION).tgz $(PACKAGE)-$(VERSION)
|
||||
rm -rf $(PACKAGE)-$(VERSION)
|
||||
@ -89,6 +92,19 @@ clean:
|
||||
rm -f *~
|
||||
rm -rf $(PACKAGE)-$(VERSION)
|
||||
|
||||
NAME_ykksm-checksum = 'Print checksum of important database fields. Useful for quickly determining whether several KSMs are in sync.'
|
||||
NAME_ykksm-export = 'Tool to export keys to the YKKSM-KEYPROV format.'
|
||||
NAME_ykksm-gen-keys = 'Tool to generate keys on the YKKSM-KEYPROV format.'
|
||||
NAME_ykksm-import = 'Tool to import key data on the YKKSM-KEYPROV format.'
|
||||
|
||||
%.1: %
|
||||
help2man -N --name=$(NAME_$*) --version-string=1 ./$* > $@
|
||||
|
||||
man: $(MANS)
|
||||
|
||||
clean-man:
|
||||
rm -f *.1
|
||||
|
||||
release: dist
|
||||
gpg --detach-sign --default-key $(KEYID) $(PACKAGE)-$(VERSION).tgz
|
||||
gpg --verify $(PACKAGE)-$(VERSION).tgz.sig
|
||||
|
5
ykksm-checksum.pl → ykksm-checksum
Normal file → Executable file
5
ykksm-checksum.pl → ykksm-checksum
Normal file → Executable file
@ -34,8 +34,7 @@ use POSIX qw(strftime);
|
||||
use Digest::SHA;
|
||||
|
||||
sub usage {
|
||||
print "Usage: $0 [--verbose] [--help]\n";
|
||||
print " [--database DBI] [--db-user USER] [--db-passwd PASSWD]\n";
|
||||
print "Usage: $0 [--verbose] [--help] [--database DBI] [--db-user USER] [--db-passwd PASSWD]\n";
|
||||
print "\n";
|
||||
print "Print checksum of important database fields. Useful for quickly\n";
|
||||
print "determining whether several KSMs are in sync.\n";
|
||||
@ -51,7 +50,7 @@ sub usage {
|
||||
print "\n";
|
||||
print "Usage example:\n";
|
||||
print "\n";
|
||||
print " ./ykksm-checksum.pl --database dbi:mysql:ykksm --db-user user --db-passwd pencil\n";
|
||||
print " ./ykksm-checksum --database dbi:mysql:ykksm --db-user user --db-passwd pencil\n";
|
||||
print "\n";
|
||||
exit 1;
|
||||
}
|
@ -33,10 +33,9 @@ use DBI;
|
||||
use MIME::Base64;
|
||||
|
||||
sub usage {
|
||||
print "Usage: $0 [--verbose] [--help]\n";
|
||||
print " [--database DBI] [--db-user USER] [--db-passwd PASSWD]\n";
|
||||
print "Usage: $0 [--verbose] [--help] [--database DBI] [--db-user USER] [--db-passwd PASSWD]\n";
|
||||
print "\n";
|
||||
print " Tool to export keys to the YKKSM-KEYPROV format.\n";
|
||||
print "Tool to export keys to the YKKSM-KEYPROV format.\n";
|
||||
print "\n";
|
||||
print " --database DBI: Database identifier, see http://dbi.perl.org/\n";
|
||||
print " defaults to a MySQL database ykksm on localhost,\n";
|
||||
@ -48,7 +47,7 @@ sub usage {
|
||||
print "\n";
|
||||
print "Usage example:\n";
|
||||
print "\n";
|
||||
print " ./ykksm-export.pl --db-user foo --db-passwd pass123 |\n";
|
||||
print " ./ykksm-export --db-user foo --db-passwd pass123 |\n";
|
||||
print " gpg -a --sign --encrypt -r 1D2F473E > keys.txt\n";
|
||||
print "\n";
|
||||
exit 1;
|
@ -35,17 +35,13 @@ use MIME::Base64;
|
||||
my $device = "/dev/random";
|
||||
|
||||
sub usage {
|
||||
print "Usage: ykksm-gen-keys.pl [--verbose] [--help]\n";
|
||||
print " [--urandom]\n";
|
||||
print " [--progflags PROGFLAGS]\n";
|
||||
print " [--pskc]\n";
|
||||
print " START [END]\n";
|
||||
print "Usage: ykksm-gen-keys [--verbose] [--help] [--urandom] [--progflags PROGFLAGS] [--pskc] START [END]\n";
|
||||
print "\n";
|
||||
print " Tool to generate keys on the YKKSM-KEYPROV format.\n";
|
||||
print "Tool to generate keys on the YKKSM-KEYPROV format.\n";
|
||||
print "\n";
|
||||
print " START: Decimal start point.\n";
|
||||
print "START: Decimal start point.\n";
|
||||
print "\n";
|
||||
print " END: Decimal end point, if absent START is used as END.\n";
|
||||
print "END: Decimal end point, if absent START is used as END.\n";
|
||||
print "\n";
|
||||
print " --urandom: Use /dev/urandom instead of /dev/random as entropy source.\n";
|
||||
print "\n";
|
||||
@ -55,7 +51,7 @@ sub usage {
|
||||
print "\n";
|
||||
print "Usage example:\n";
|
||||
print "\n";
|
||||
print " ./ykksm-gen-keys.pl --urandom 1 10 |\n";
|
||||
print " ./ykksm-gen-keys --urandom 1 10 |\n";
|
||||
print " gpg -a --sign --encrypt -r 1D2F473E > keys.txt\n";
|
||||
print "\n";
|
||||
exit 1;
|
@ -33,9 +33,7 @@ use DBI;
|
||||
use POSIX qw(strftime);
|
||||
|
||||
sub usage {
|
||||
print "Usage: $0 [--verbose] [--help]\n";
|
||||
print " [--database DBI] [--db-user USER] [--db-passwd PASSWD]\n";
|
||||
print " [--creator CREATOR]\n";
|
||||
print "Usage: $0 [--verbose] [--help] [--database DBI] [--db-user USER] [--db-passwd PASSWD] [--creator CREATOR]\n";
|
||||
print "\n";
|
||||
print "Tool to import key data on the YKKSM-KEYPROV format.\n";
|
||||
print "\n";
|
||||
@ -54,7 +52,7 @@ sub usage {
|
||||
print "\n";
|
||||
print "Usage example:\n";
|
||||
print "\n";
|
||||
print " ./ykksm-import.pl < keys.txt\n";
|
||||
print " ./ykksm-import < keys.txt\n";
|
||||
print "\n";
|
||||
exit 1;
|
||||
}
|
144
ykksm-upgrade.pl
144
ykksm-upgrade.pl
@ -1,144 +0,0 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
# Written by Simon Josefsson <simon@josefsson.org>.
|
||||
# Copyright (c) 2009-2012 Yubico AB
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are
|
||||
# met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
#
|
||||
# * Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following
|
||||
# disclaimer in the documentation and/or other materials provided
|
||||
# with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
use strict;
|
||||
use DBI;
|
||||
use POSIX qw(strftime);
|
||||
|
||||
sub usage {
|
||||
print "Usage: $0 [--help]\n";
|
||||
print " [--database DBI] [--db-user USER] [--db-passwd PASSWD]\n";
|
||||
print " [--creator CREATOR]\n";
|
||||
print "\n";
|
||||
print "Tool to upgrade data in database based on special format.\n";
|
||||
print "\n";
|
||||
print " --database DBI: Database identifier, see http://dbi.perl.org/\n";
|
||||
print " defaults to a MySQL database ykksm on localhost,\n";
|
||||
print " i.e., DBI::mysql:ykksm.\n";
|
||||
print "\n";
|
||||
print " --db-user USER: Database username to use, defaults to empty string.\n";
|
||||
print "\n";
|
||||
print " --db-passwd PASSWD: Database password to use, defaults to empty string.\n";
|
||||
print "\n";
|
||||
print " --creator CREATOR: Short string with creator info.\n";
|
||||
print " Defaults to using the PGP signer key id, normally.\n";
|
||||
print " you don't change this.\n";
|
||||
print "\n";
|
||||
print "Usage example:\n";
|
||||
print "\n";
|
||||
print " $0 < keys.txt\n";
|
||||
print "\n";
|
||||
exit 1;
|
||||
}
|
||||
|
||||
my $creator;
|
||||
my $db = "dbi:mysql:ykksm";
|
||||
my $dbuser;
|
||||
my $dbpasswd;
|
||||
while ($ARGV[0] =~ m/^-(.*)/) {
|
||||
my $cmd = shift @ARGV;
|
||||
if (($cmd eq "-h") || ($cmd eq "--help")) {
|
||||
usage();
|
||||
} elsif ($cmd eq "--creator") {
|
||||
$creator = shift;
|
||||
} elsif ($cmd eq "--database") {
|
||||
$db = shift;
|
||||
} elsif ($cmd eq "--db-user") {
|
||||
$dbuser = shift;
|
||||
} elsif ($cmd eq "--db-passwd") {
|
||||
$dbpasswd = shift;
|
||||
}
|
||||
}
|
||||
|
||||
if ($#ARGV>=0) {
|
||||
usage();
|
||||
}
|
||||
|
||||
my $infilename = "tmp.$$";
|
||||
my $verify_status;
|
||||
my $encrypted_to;
|
||||
my $signed_by;
|
||||
|
||||
# Read input into temporary file.
|
||||
open TMPFILE, ">$infilename"
|
||||
or die "Cannot open $infilename for writing";
|
||||
while (<>) {
|
||||
print TMPFILE $_;
|
||||
}
|
||||
close TMPFILE;
|
||||
|
||||
END { unlink $infilename; }
|
||||
|
||||
# Get status
|
||||
open(GPGV, "gpg --status-fd 1 --output /dev/null < $infilename 2>&1 |")
|
||||
or die "Cannot launch gpg";
|
||||
while (<GPGV>) {
|
||||
$verify_status .= $_;
|
||||
$encrypted_to = $1 if m,^\[GNUPG:\] ENC_TO ([0-9A-F]+) ,;
|
||||
$signed_by = $1 if m,^\[GNUPG:\] VALIDSIG ([0-9A-F]+) ,;
|
||||
}
|
||||
close GPGV;
|
||||
|
||||
print "Verification output:\n" . $verify_status;
|
||||
print "encrypted to: " . $encrypted_to . "\n";
|
||||
print "signed by: " . $signed_by . "\n";
|
||||
|
||||
die "Input not signed?" if !$signed_by;
|
||||
|
||||
my $dbh = DBI->connect($db, $dbuser, $dbpasswd, {'RaiseError' => 1});
|
||||
my $inserth = $dbh->prepare_cached(qq{
|
||||
INSERT INTO yubikeys (creator, created, serialnr,
|
||||
publicname, internalname, aeskey, lockcode)
|
||||
VALUES (?, NOW(), 0, ?, ?, ?, '000000000000')
|
||||
})
|
||||
or die "Couldn't prepare statement: " . $dbh->errstr;
|
||||
|
||||
$creator = $signed_by if !$creator;
|
||||
|
||||
open(GPGV, "gpg < $infilename 2>/dev/null |")
|
||||
or die "Cannot launch gpg";
|
||||
while (<GPGV>) {
|
||||
next if m:^#:;
|
||||
my ($publicname, $aeskey, $internalname) =
|
||||
m%^id ([cbdefghijklnrtuv]+) key ([0-9a-f]+) uid ([0-9a-f]+)%;
|
||||
print "line: $_";
|
||||
print "\tpublicname $publicname internalname $internalname aeskey $aeskey eol\n";
|
||||
|
||||
my $rows_changed = $dbh->do(q{UPDATE yubikeys SET publicname = ? WHERE publicname = ?}, undef, ("old-" . $publicname, $publicname))
|
||||
or die "Cannot update database: " . $dbh->errstr;
|
||||
|
||||
$inserth->execute($creator, $publicname, $internalname, $aeskey)
|
||||
or die "Database insert error: " . $dbh->errstr;
|
||||
}
|
||||
|
||||
close GPGV;
|
||||
$dbh->disconnect();
|
||||
|
||||
exit 0;
|
Loading…
x
Reference in New Issue
Block a user