From 0e0c31e6b65ed6649411e8e531c0eee48001233c Mon Sep 17 00:00:00 2001 From: Jaapio Date: Fri, 20 Nov 2020 14:56:42 +0100 Subject: [PATCH 1/2] Define new interfaces for version2 --- src/CliWrapper.php | 35 ++++++++++++++++++++++++++++ src/GPG.php | 44 ++++++++++++++++++++++++++++++++++++ src/InvalidHomeDirectory.php | 10 ++++++++ src/InvalidKey.php | 10 ++++++++ src/KeyInfo.php | 11 +++++++++ src/PeclWrapper.php | 35 ++++++++++++++++++++++++++++ src/PublicKey.php | 26 +++++++++++++++++++++ src/SecretKey.php | 15 ++++++++++++ src/Signature.php | 21 +++++++++++++++++ src/VerificiationFailed.php | 10 ++++++++ 10 files changed, 217 insertions(+) create mode 100644 src/CliWrapper.php create mode 100644 src/GPG.php create mode 100644 src/InvalidHomeDirectory.php create mode 100644 src/InvalidKey.php create mode 100644 src/KeyInfo.php create mode 100644 src/PeclWrapper.php create mode 100644 src/PublicKey.php create mode 100644 src/SecretKey.php create mode 100644 src/Signature.php create mode 100644 src/VerificiationFailed.php diff --git a/src/CliWrapper.php b/src/CliWrapper.php new file mode 100644 index 0000000..551ebee --- /dev/null +++ b/src/CliWrapper.php @@ -0,0 +1,35 @@ +gpg = new \Gnupg(); + } + + public function importPublicKey(string $keyData): PublicKey + { + // TODO: Implement importPublicKey() method. + } + + public function importSecretKey(string $keyData): SecretKey + { + // TODO: Implement importSecretKey() method. + } + + public function verify(string $message, Signature $signature): KeyInfo + { + // TODO: Implement verify() method. + } + + public function sign(SecretKey $privateKey, string $message): Signature + { + // TODO: Implement sign() method. + } +} diff --git a/src/PublicKey.php b/src/PublicKey.php new file mode 100644 index 0000000..7243af6 --- /dev/null +++ b/src/PublicKey.php @@ -0,0 +1,26 @@ + Date: Fri, 4 Dec 2020 15:55:06 +0100 Subject: [PATCH 2/2] Improve signature verification --- src/FingerPrint.php | 15 ++++++++++++++ src/GPG.php | 8 ++------ src/KeyId.php | 15 ++++++++++++++ src/Signature.php | 21 ------------------- src/Signature/SigatureFileData.php | 10 ++++++++++ src/Signature/SigatureStringData.php | 10 ++++++++++ src/Signature/Signature.php | 30 ++++++++++++++++++++++++++++ src/Signature/SignatureData.php | 11 ++++++++++ src/Signature/SignatureInfo.php | 16 +++++++++++++++ src/Signature/Status.php | 15 ++++++++++++++ src/UserId.php | 11 ++++++++++ 11 files changed, 135 insertions(+), 27 deletions(-) create mode 100644 src/FingerPrint.php create mode 100644 src/KeyId.php delete mode 100644 src/Signature.php create mode 100644 src/Signature/SigatureFileData.php create mode 100644 src/Signature/SigatureStringData.php create mode 100644 src/Signature/Signature.php create mode 100644 src/Signature/SignatureData.php create mode 100644 src/Signature/SignatureInfo.php create mode 100644 src/Signature/Status.php create mode 100644 src/UserId.php diff --git a/src/FingerPrint.php b/src/FingerPrint.php new file mode 100644 index 0000000..7e05efd --- /dev/null +++ b/src/FingerPrint.php @@ -0,0 +1,15 @@ +fingerPrint; + } +} diff --git a/src/GPG.php b/src/GPG.php index 4233fea..051c14f 100644 --- a/src/GPG.php +++ b/src/GPG.php @@ -22,17 +22,13 @@ public function importPublicKey(string $keyData): PublicKey; * @throws InvalidHomeDirectory * @throws InvalidKey */ - public function importSecretKey(string $keyData): SecretKey; + public function importSecretKey(string $keyData, ?string $passphrase = null): SecretKey; /** * Verifies the message is signed with the sigature * - * Ensures that the signature is valid. - * - * @throws VerificiationFailed When message was not signed with the signature - * @throws UnknownFingerPrint When signature doesn't belong to a known key, key must be imported first */ - public function verify(string $message, Signature $signature): KeyInfo; + public function verify(string $message, SignatureData $signature): Signature; /** * Uses the secret to create a signature. diff --git a/src/KeyId.php b/src/KeyId.php new file mode 100644 index 0000000..f9b7493 --- /dev/null +++ b/src/KeyId.php @@ -0,0 +1,15 @@ +id; + } +} diff --git a/src/Signature.php b/src/Signature.php deleted file mode 100644 index e341fdd..0000000 --- a/src/Signature.php +++ /dev/null @@ -1,21 +0,0 @@ -