From 69fb45dff3c6420f08de7596237962285d9afee1 Mon Sep 17 00:00:00 2001 From: Paragon Initiative Enterprises Date: Sat, 4 Jun 2016 16:22:02 -0400 Subject: [PATCH] Fix a bug in Hail --- src/Engine/Hail.php | 33 +++++++++++++++--------------- tools/hangar/src/Commands/Sign.php | 19 +++++++++++++++++ 2 files changed, 35 insertions(+), 17 deletions(-) diff --git a/src/Engine/Hail.php b/src/Engine/Hail.php index ac881f6..ab053ab 100755 --- a/src/Engine/Hail.php +++ b/src/Engine/Hail.php @@ -97,21 +97,6 @@ public function get(string $url, array $params = []): ResponseInterface ); } - /** - * Perform a GET request, get a decoded JSON response. - * - * @param string $url - * @param array $params - * @return mixed - */ - public function getJSON(string $url, array $params = []) - { - return \Airship\parseJSON( - $this->get($url, $params), - true - ); - } - /** * Perform a GET request, asynchronously * @@ -129,6 +114,21 @@ public function getAsync( ); } + /** + * Perform a GET request, get a decoded JSON response. + * + * @param string $url + * @param array $params + * @return mixed + */ + public function getJSON(string $url, array $params = []) + { + return \Airship\parseJSON( + $this->getReturnBody($url, $params), + true + ); + } + /** * Perform a POST request, get the body * @@ -151,7 +151,6 @@ public function getReturnBody( } throw new TransferException(); } - /** * Perform a GET request, get a decoded JSON response. * Internally verifies an Ed25519 signature. @@ -331,7 +330,7 @@ public function postAsync( public function postJSON(string $url, array $params = []) { return \Airship\parseJSON( - $this->post($url, $params), + $this->postReturnBody($url, $params), true ); } diff --git a/tools/hangar/src/Commands/Sign.php b/tools/hangar/src/Commands/Sign.php index 6db3a30..8a9988f 100644 --- a/tools/hangar/src/Commands/Sign.php +++ b/tools/hangar/src/Commands/Sign.php @@ -48,6 +48,22 @@ public function fire(array $args = []): bool $level = KeyFactory::SENSITIVE; break; } + } elseif (isset($this->config['keytype'])) { + switch (isset($this->config['keytype'])) { + case 'fast': + case 'i': + case 'interactive': + case 'weak': + $level = KeyFactory::INTERACTIVE; + break; + case 'm': + case 'moderate': + $level = KeyFactory::MODERATE; + break; + default: + $level = KeyFactory::SENSITIVE; + break; + } } else { $level = KeyFactory::SENSITIVE; } @@ -75,6 +91,9 @@ public function fire(array $args = []): bool } \file_put_contents($file.'.sig', $signature); echo 'File signed: ' . $file.'.sig', "\n"; + echo 'Public key: ' . \Sodium\bin2hex( + $sign_kp->getPublicKey()->getRawKeyMaterial() + ), "\n"; return true; }