removed test_gnu_dummy_s2k_extension(); no longer necessary
[monkeysphere.git] / src / keytrans / pem2openpgp
index 37b372a5e1ad5afba65cf76a2867737d587f60e3..8bf17fb2df6b2a2a212b1af218eac6eaad8d70d8 100755 (executable)
@@ -29,6 +29,7 @@ use Crypt::OpenSSL::Bignum;
 use Crypt::OpenSSL::Bignum::CTX;
 use Digest::SHA1;
 use MIME::Base64;
+use POSIX;
 
 ## make sure all length() and substr() calls use bytes only:
 use bytes;
@@ -329,7 +330,7 @@ sub read_mpi {
   $bitlen = unpack('n', $bitlen);
   $$readtally += 2;
 
-  my $bytestoread = ($bitlen + 7)/8;
+  my $bytestoread = POSIX::floor(($bitlen + 7)/8);
   my $ret;
   read($instr, $ret, $bytestoread) or die "could not read MPI body.\n";
   $$readtally += $bytestoread;
@@ -724,6 +725,14 @@ for (basename($0)) {
   if (/^pem2openpgp$/) {
     my $rsa;
     my $stdin;
+
+    my $uid = shift;
+    defined($uid) or die "You must specify a user ID string.\n";
+
+    # FIXME: fail if there is no given user ID; or should we default to
+    # hostname_long() from Sys::Hostname::Long ?
+
+
     if (defined $ENV{PEM2OPENPGP_NEWKEY}) {
       $rsa = Crypt::OpenSSL::RSA->generate_key($ENV{PEM2OPENPGP_NEWKEY});
     } else {
@@ -735,11 +744,6 @@ for (basename($0)) {
       $rsa = Crypt::OpenSSL::RSA->new_private_key($stdin);
     }
 
-    my $uid = shift;
-
-    # FIXME: fail if there is no given user ID; or should we default to
-    # hostname_long() from Sys::Hostname::Long ?
-
     print pem2openpgp($rsa,
                      $uid,
                      { timestamp => $ENV{PEM2OPENPGP_TIMESTAMP},