diff --git a/ykksm-db.sql b/ykksm-db.sql index 558c138..cf515df 100644 --- a/ykksm-db.sql +++ b/ykksm-db.sql @@ -1,15 +1,15 @@ create table yubikeys ( -- identities: - serialNr int not null, - publicName varchar(16) unique not null, + serialnr int not null, + publicname varchar(16) unique not null, -- timestamps: created varchar(24) not null, -- the data: - internalName varchar(12) not null, - aesKey varchar(32) not null, - lockCode varchar(12) not null, + internalname varchar(12) not null, + aeskey varchar(32) not null, + lockcode varchar(12) not null, -- key creator, typically pgp key id of key generator creator varchar(8) not null, @@ -18,5 +18,5 @@ create table yubikeys ( active boolean default true, hardware boolean default true, - primary key (publicName) + primary key (publicname) ); diff --git a/ykksm-decrypt.php b/ykksm-decrypt.php index 0f2b98c..52f1cb5 100644 --- a/ykksm-decrypt.php +++ b/ykksm-decrypt.php @@ -55,8 +55,8 @@ try { die("ERR Database error\n"); } -$sql = "SELECT aesKey, internalName FROM yubikeys " . - "WHERE publicName = '$id' AND active"; +$sql = "SELECT aeskey, internalname FROM yubikeys " . + "WHERE publicname = '$id' AND active"; $result = $dbh->query($sql); if (!$result) { syslog(LOG_ERR, "Database query error. Query: " . $sql . " Error: " . @@ -70,15 +70,15 @@ if ($result->rowCount() != 1) { } $row = $result->fetch(PDO::FETCH_ASSOC); -$aesKey = $row['aesKey']; -$internalName = $row['internalName']; +$aeskey = $row['aeskey']; +$internalname = $row['internalname']; $ciphertext = modhex2hex($modhex_ciphertext); -$plaintext = aes128ecb_decrypt($aesKey, $ciphertext); +$plaintext = aes128ecb_decrypt($aeskey, $ciphertext); $uid = substr($plaintext, 0, 12); -if (strcmp($uid, $internalName) != 0) { - syslog(LOG_ERR, "UID error: $otp $plaintext: $uid vs $internalName"); +if (strcmp($uid, $internalname) != 0) { + syslog(LOG_ERR, "UID error: $otp $plaintext: $uid vs $internalname"); die("ERR Corrupt OTP\n");; } diff --git a/ykksm-export.pl b/ykksm-export.pl index 5c15a44..436d88a 100755 --- a/ykksm-export.pl +++ b/ykksm-export.pl @@ -79,7 +79,7 @@ if ($#ARGV>=0) { my $dbh = DBI->connect($db, $dbuser, $dbpasswd, {'RaiseError' => 1}); my $sth = $dbh->prepare - ('SELECT serialNr, publicName, internalName, aesKey, lockCode, created FROM yubikeys') + ('SELECT serialnr, publicname, internalname, aeskey, lockcode, created FROM yubikeys') or die "Couldn't prepare statement: " . $dbh->errstr; $sth->execute() or die "Couldn't execute statement: " . $sth->errstr; @@ -93,11 +93,11 @@ while ($row = $sth->fetchrow_hashref()) { } print "\n"; } - print $row->{'serialNr'} . ","; - print $row->{'publicName'} . ","; - print $row->{'internalName'} . ","; - print $row->{'aesKey'} . ","; - print $row->{'lockCode'} . ","; + print $row->{'serialnr'} . ","; + print $row->{'publicname'} . ","; + print $row->{'internalname'} . ","; + print $row->{'aeskey'} . ","; + print $row->{'lockcode'} . ","; print $row->{'created'} . ",\n"; } diff --git a/ykksm-import.pl b/ykksm-import.pl index d279110..a666be7 100755 --- a/ykksm-import.pl +++ b/ykksm-import.pl @@ -118,8 +118,8 @@ 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) +INSERT INTO yubikeys (creator, created, serialnr, + publicname, internalname, aeskey, lockcode) VALUES (?, ?, ?, ?, ?, ?, ?) }); my $now = strftime "%Y-%m-%dT%H:%M:%S", localtime; @@ -130,14 +130,14 @@ open(GPGV, "gpg < $infilename 2>/dev/null |") or die "Cannot launch gpg"; while () { next if m:^#:; - my ($serialNr, $publicName, $internalName, $aesKey, - $lockCode, $created, $accessed) = + my ($serialnr, $publicname, $internalname, $aeskey, + $lockcode, $created, $accessed) = m%^([0-9]+),([cbdefghijklnrtuv]+),([0-9a-f]+),([0-9a-f]+),([0-9a-f]+),([T:0-9 -]*),([T:0-9 -]*)%; if ($verbose) { print "line: $_"; } - print "\tserialnr $serialNr publicName $publicName " . - "internalName $internalName aesKey $aesKey lockCode $lockCode " . + print "\tserialnr $serialnr publicname $publicname " . + "internalname $internalname aeskey $aeskey lockcode $lockcode " . "created $created accessed $accessed eol"; if ($verbose) { print "\n"; @@ -148,9 +148,9 @@ while () { $created = $now if !$created; $accessed = "NULL" if !$accessed; - $inserth->execute($creator, $created, $serialNr, - $publicName, $internalName, - $aesKey, $lockCode) + $inserth->execute($creator, $created, $serialnr, + $publicname, $internalname, + $aeskey, $lockcode) or die "Database insert error: " . $dbh->errstr; } print "\n"; diff --git a/ykksm-upgrade.pl b/ykksm-upgrade.pl index c4c31ab..387dfca 100755 --- a/ykksm-upgrade.pl +++ b/ykksm-upgrade.pl @@ -114,8 +114,8 @@ 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) +INSERT INTO yubikeys (creator, created, serialnr, + publicname, internalname, aeskey, lockcode) VALUES (?, NOW(), 0, ?, ?, ?, '000000000000') }) or die "Couldn't prepare statement: " . $dbh->errstr; @@ -126,15 +126,15 @@ open(GPGV, "gpg < $infilename 2>/dev/null |") or die "Cannot launch gpg"; while () { next if m:^#:; - my ($publicName, $aesKey, $internalName) = + 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"; + 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)) + 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) + $inserth->execute($creator, $publicname, $internalname, $aeskey) or die "Database insert error: " . $dbh->errstr; }