diff options
| -rw-r--r-- | .gitignore | 2 | ||||
| -rw-r--r-- | PHPINFO | 6 | ||||
| -rw-r--r-- | REFLECTION | 371 | ||||
| -rw-r--r-- | gnupg-build.patch | 73 | ||||
| -rw-r--r-- | gnupgt.inc | 211 | ||||
| -rw-r--r-- | php-pecl-gnupg.spec | 74 | ||||
| -rw-r--r-- | vars.inc | 69 | 
7 files changed, 714 insertions, 92 deletions
@@ -1,5 +1,7 @@ +clog  package-*.xml  *.tgz +*.tar.bz2  *.tar.gz  *.tar.xz  *.tar.xz.asc @@ -0,0 +1,6 @@ + +gnupg + +gnupg support => enabled +GPGme Version => 1.14.0 +Extension Version => 1.5.0RC1 @@ -1,39 +1,65 @@ -Extension [ <persistent> extension #86 gnupg version 1.4.0 ] { - -  - Constants [25] { -    Constant [ integer GNUPG_SIG_MODE_NORMAL ] { 0 } -    Constant [ integer GNUPG_SIG_MODE_DETACH ] { 1 } -    Constant [ integer GNUPG_SIG_MODE_CLEAR ] { 2 } -    Constant [ integer GNUPG_VALIDITY_UNKNOWN ] { 0 } -    Constant [ integer GNUPG_VALIDITY_UNDEFINED ] { 1 } -    Constant [ integer GNUPG_VALIDITY_NEVER ] { 2 } -    Constant [ integer GNUPG_VALIDITY_MARGINAL ] { 3 } -    Constant [ integer GNUPG_VALIDITY_FULL ] { 4 } -    Constant [ integer GNUPG_VALIDITY_ULTIMATE ] { 5 } -    Constant [ integer GNUPG_PROTOCOL_OpenPGP ] { 0 } -    Constant [ integer GNUPG_PROTOCOL_CMS ] { 1 } -    Constant [ integer GNUPG_SIGSUM_VALID ] { 1 } -    Constant [ integer GNUPG_SIGSUM_GREEN ] { 2 } -    Constant [ integer GNUPG_SIGSUM_RED ] { 4 } -    Constant [ integer GNUPG_SIGSUM_KEY_REVOKED ] { 16 } -    Constant [ integer GNUPG_SIGSUM_KEY_EXPIRED ] { 32 } -    Constant [ integer GNUPG_SIGSUM_SIG_EXPIRED ] { 64 } -    Constant [ integer GNUPG_SIGSUM_KEY_MISSING ] { 128 } -    Constant [ integer GNUPG_SIGSUM_CRL_MISSING ] { 256 } -    Constant [ integer GNUPG_SIGSUM_CRL_TOO_OLD ] { 512 } -    Constant [ integer GNUPG_SIGSUM_BAD_POLICY ] { 1024 } -    Constant [ integer GNUPG_SIGSUM_SYS_ERROR ] { 2048 } -    Constant [ integer GNUPG_ERROR_WARNING ] { 1 } -    Constant [ integer GNUPG_ERROR_EXCEPTION ] { 2 } -    Constant [ integer GNUPG_ERROR_SILENT ] { 3 } +Extension [ <persistent> extension #120 gnupg version 1.5.0RC1 ] { + +  - Constants [36] { +    Constant [ int GNUPG_SIG_MODE_NORMAL ] { 0 } +    Constant [ int GNUPG_SIG_MODE_DETACH ] { 1 } +    Constant [ int GNUPG_SIG_MODE_CLEAR ] { 2 } +    Constant [ int GNUPG_VALIDITY_UNKNOWN ] { 0 } +    Constant [ int GNUPG_VALIDITY_UNDEFINED ] { 1 } +    Constant [ int GNUPG_VALIDITY_NEVER ] { 2 } +    Constant [ int GNUPG_VALIDITY_MARGINAL ] { 3 } +    Constant [ int GNUPG_VALIDITY_FULL ] { 4 } +    Constant [ int GNUPG_VALIDITY_ULTIMATE ] { 5 } +    Constant [ int GNUPG_PROTOCOL_OpenPGP ] { 0 } +    Constant [ int GNUPG_PROTOCOL_CMS ] { 1 } +    Constant [ int GNUPG_SIGSUM_VALID ] { 1 } +    Constant [ int GNUPG_SIGSUM_GREEN ] { 2 } +    Constant [ int GNUPG_SIGSUM_RED ] { 4 } +    Constant [ int GNUPG_SIGSUM_KEY_REVOKED ] { 16 } +    Constant [ int GNUPG_SIGSUM_KEY_EXPIRED ] { 32 } +    Constant [ int GNUPG_SIGSUM_SIG_EXPIRED ] { 64 } +    Constant [ int GNUPG_SIGSUM_KEY_MISSING ] { 128 } +    Constant [ int GNUPG_SIGSUM_CRL_MISSING ] { 256 } +    Constant [ int GNUPG_SIGSUM_CRL_TOO_OLD ] { 512 } +    Constant [ int GNUPG_SIGSUM_BAD_POLICY ] { 1024 } +    Constant [ int GNUPG_SIGSUM_SYS_ERROR ] { 2048 } +    Constant [ int GNUPG_ERROR_WARNING ] { 1 } +    Constant [ int GNUPG_ERROR_EXCEPTION ] { 2 } +    Constant [ int GNUPG_ERROR_SILENT ] { 3 } +    Constant [ int GNUPG_PK_RSA ] { 1 } +    Constant [ int GNUPG_PK_RSA_E ] { 2 } +    Constant [ int GNUPG_PK_RSA_S ] { 3 } +    Constant [ int GNUPG_PK_DSA ] { 17 } +    Constant [ int GNUPG_PK_ELG ] { 20 } +    Constant [ int GNUPG_PK_ELG_E ] { 16 } +    Constant [ int GNUPG_PK_ECC ] { 18 } +    Constant [ int GNUPG_PK_ECDSA ] { 301 } +    Constant [ int GNUPG_PK_ECDH ] { 302 } +    Constant [ int GNUPG_PK_EDDSA ] { 303 } +    Constant [ string GNUPG_GPGME_VERSION ] { 1.14.0 }    }    - Functions {      Function [ <internal:gnupg> function gnupg_init ] { + +      - Parameters [1] { +        Parameter #0 [ <optional> $options ] +      }      }      Function [ <internal:gnupg> function gnupg_keyinfo ] { + +      - Parameters [3] { +        Parameter #0 [ <required> $res ] +        Parameter #1 [ <required> $pattern ] +        Parameter #2 [ <optional> $secret_only ] +      }      }      Function [ <internal:gnupg> function gnupg_sign ] { + +      - Parameters [2] { +        Parameter #0 [ <required> $res ] +        Parameter #1 [ <required> $text ] +      }      }      Function [ <internal:gnupg> function gnupg_verify ] { @@ -45,26 +71,83 @@ Extension [ <persistent> extension #86 gnupg version 1.4.0 ] {        }      }      Function [ <internal:gnupg> function gnupg_clearsignkeys ] { + +      - Parameters [1] { +        Parameter #0 [ <required> $res ] +      }      }      Function [ <internal:gnupg> function gnupg_clearencryptkeys ] { + +      - Parameters [1] { +        Parameter #0 [ <required> $res ] +      }      }      Function [ <internal:gnupg> function gnupg_cleardecryptkeys ] { + +      - Parameters [1] { +        Parameter #0 [ <required> $res ] +      }      }      Function [ <internal:gnupg> function gnupg_setarmor ] { + +      - Parameters [2] { +        Parameter #0 [ <required> $res ] +        Parameter #1 [ <required> $armor ] +      }      }      Function [ <internal:gnupg> function gnupg_encrypt ] { + +      - Parameters [2] { +        Parameter #0 [ <required> $res ] +        Parameter #1 [ <required> $text ] +      }      }      Function [ <internal:gnupg> function gnupg_decrypt ] { + +      - Parameters [2] { +        Parameter #0 [ <required> $res ] +        Parameter #1 [ <required> $enctext ] +      }      }      Function [ <internal:gnupg> function gnupg_export ] { + +      - Parameters [2] { +        Parameter #0 [ <required> $res ] +        Parameter #1 [ <required> $pattern ] +      }      }      Function [ <internal:gnupg> function gnupg_import ] { + +      - Parameters [2] { +        Parameter #0 [ <required> $res ] +        Parameter #1 [ <required> $kye ] +      } +    } +    Function [ <internal:gnupg> function gnupg_getengineinfo ] { + +      - Parameters [1] { +        Parameter #0 [ <required> $res ] +      }      }      Function [ <internal:gnupg> function gnupg_getprotocol ] { + +      - Parameters [1] { +        Parameter #0 [ <required> $res ] +      }      }      Function [ <internal:gnupg> function gnupg_setsignmode ] { + +      - Parameters [2] { +        Parameter #0 [ <required> $res ] +        Parameter #1 [ <required> $signmode ] +      }      }      Function [ <internal:gnupg> function gnupg_encryptsign ] { + +      - Parameters [2] { +        Parameter #0 [ <required> $res ] +        Parameter #1 [ <required> $text ] +      }      }      Function [ <internal:gnupg> function gnupg_decryptverify ] { @@ -75,52 +158,110 @@ Extension [ <persistent> extension #86 gnupg version 1.4.0 ] {        }      }      Function [ <internal:gnupg> function gnupg_geterror ] { + +      - Parameters [1] { +        Parameter #0 [ <required> $res ] +      } +    } +    Function [ <internal:gnupg> function gnupg_geterrorinfo ] { + +      - Parameters [1] { +        Parameter #0 [ <required> $res ] +      }      }      Function [ <internal:gnupg> function gnupg_addsignkey ] { + +      - Parameters [3] { +        Parameter #0 [ <required> $res ] +        Parameter #1 [ <required> $kye ] +        Parameter #2 [ <required> $passphrase ] +      }      }      Function [ <internal:gnupg> function gnupg_addencryptkey ] { + +      - Parameters [2] { +        Parameter #0 [ <required> $res ] +        Parameter #1 [ <required> $kye ] +      }      }      Function [ <internal:gnupg> function gnupg_adddecryptkey ] { + +      - Parameters [3] { +        Parameter #0 [ <required> $res ] +        Parameter #1 [ <required> $kye ] +        Parameter #2 [ <required> $passphrase ] +      }      }      Function [ <internal:gnupg> function gnupg_deletekey ] { + +      - Parameters [3] { +        Parameter #0 [ <required> $res ] +        Parameter #1 [ <required> $kye ] +        Parameter #2 [ <required> $allow_secret ] +      }      }      Function [ <internal:gnupg> function gnupg_gettrustlist ] { + +      - Parameters [2] { +        Parameter #0 [ <required> $res ] +        Parameter #1 [ <required> $pattern ] +      }      }      Function [ <internal:gnupg> function gnupg_listsignatures ] { + +      - Parameters [2] { +        Parameter #0 [ <required> $res ] +        Parameter #1 [ <required> $kyeid ] +      }      }      Function [ <internal:gnupg> function gnupg_seterrormode ] { + +      - Parameters [2] { +        Parameter #0 [ <required> $res ] +        Parameter #1 [ <required> $errnmode ] +      }      }    }    - Classes [2] {      Class [ <internal:gnupg> class gnupg ] { -      - Constants [25] { -        Constant [ integer SIG_MODE_NORMAL ] { 0 } -        Constant [ integer SIG_MODE_DETACH ] { 1 } -        Constant [ integer SIG_MODE_CLEAR ] { 2 } -        Constant [ integer VALIDITY_UNKNOWN ] { 0 } -        Constant [ integer VALIDITY_UNDEFINED ] { 1 } -        Constant [ integer VALIDITY_NEVER ] { 2 } -        Constant [ integer VALIDITY_MARGINAL ] { 3 } -        Constant [ integer VALIDITY_FULL ] { 4 } -        Constant [ integer VALIDITY_ULTIMATE ] { 5 } -        Constant [ integer PROTOCOL_OpenPGP ] { 0 } -        Constant [ integer PROTOCOL_CMS ] { 1 } -        Constant [ integer SIGSUM_VALID ] { 1 } -        Constant [ integer SIGSUM_GREEN ] { 2 } -        Constant [ integer SIGSUM_RED ] { 4 } -        Constant [ integer SIGSUM_KEY_REVOKED ] { 16 } -        Constant [ integer SIGSUM_KEY_EXPIRED ] { 32 } -        Constant [ integer SIGSUM_SIG_EXPIRED ] { 64 } -        Constant [ integer SIGSUM_KEY_MISSING ] { 128 } -        Constant [ integer SIGSUM_CRL_MISSING ] { 256 } -        Constant [ integer SIGSUM_CRL_TOO_OLD ] { 512 } -        Constant [ integer SIGSUM_BAD_POLICY ] { 1024 } -        Constant [ integer SIGSUM_SYS_ERROR ] { 2048 } -        Constant [ integer ERROR_WARNING ] { 1 } -        Constant [ integer ERROR_EXCEPTION ] { 2 } -        Constant [ integer ERROR_SILENT ] { 3 } +      - Constants [35] { +        Constant [ public int SIG_MODE_NORMAL ] { 0 } +        Constant [ public int SIG_MODE_DETACH ] { 1 } +        Constant [ public int SIG_MODE_CLEAR ] { 2 } +        Constant [ public int VALIDITY_UNKNOWN ] { 0 } +        Constant [ public int VALIDITY_UNDEFINED ] { 1 } +        Constant [ public int VALIDITY_NEVER ] { 2 } +        Constant [ public int VALIDITY_MARGINAL ] { 3 } +        Constant [ public int VALIDITY_FULL ] { 4 } +        Constant [ public int VALIDITY_ULTIMATE ] { 5 } +        Constant [ public int PROTOCOL_OpenPGP ] { 0 } +        Constant [ public int PROTOCOL_CMS ] { 1 } +        Constant [ public int SIGSUM_VALID ] { 1 } +        Constant [ public int SIGSUM_GREEN ] { 2 } +        Constant [ public int SIGSUM_RED ] { 4 } +        Constant [ public int SIGSUM_KEY_REVOKED ] { 16 } +        Constant [ public int SIGSUM_KEY_EXPIRED ] { 32 } +        Constant [ public int SIGSUM_SIG_EXPIRED ] { 64 } +        Constant [ public int SIGSUM_KEY_MISSING ] { 128 } +        Constant [ public int SIGSUM_CRL_MISSING ] { 256 } +        Constant [ public int SIGSUM_CRL_TOO_OLD ] { 512 } +        Constant [ public int SIGSUM_BAD_POLICY ] { 1024 } +        Constant [ public int SIGSUM_SYS_ERROR ] { 2048 } +        Constant [ public int ERROR_WARNING ] { 1 } +        Constant [ public int ERROR_EXCEPTION ] { 2 } +        Constant [ public int ERROR_SILENT ] { 3 } +        Constant [ public int PK_RSA ] { 1 } +        Constant [ public int PK_RSA_E ] { 2 } +        Constant [ public int PK_RSA_S ] { 3 } +        Constant [ public int PK_DSA ] { 17 } +        Constant [ public int PK_ELG ] { 20 } +        Constant [ public int PK_ELG_E ] { 16 } +        Constant [ public int PK_ECC ] { 18 } +        Constant [ public int PK_ECDSA ] { 301 } +        Constant [ public int PK_ECDH ] { 302 } +        Constant [ public int PK_EDDSA ] { 303 }        }        - Static properties [0] { @@ -132,8 +273,20 @@ Extension [ <persistent> extension #86 gnupg version 1.4.0 ] {        - Properties [0] {        } -      - Methods [23] { +      - Methods [26] { +        Method [ <internal:gnupg, ctor> public method __construct ] { + +          - Parameters [1] { +            Parameter #0 [ <optional> $options ] +          } +        } +          Method [ <internal:gnupg> public method keyinfo ] { + +          - Parameters [2] { +            Parameter #0 [ <required> $pattern ] +            Parameter #1 [ <optional> $secret_only ] +          }          }          Method [ <internal:gnupg> public method verify ] { @@ -145,43 +298,102 @@ Extension [ <persistent> extension #86 gnupg version 1.4.0 ] {            }          } +        Method [ <internal:gnupg> public method getengineinfo ] { + +          - Parameters [0] { +          } +        } +          Method [ <internal:gnupg> public method geterror ] { + +          - Parameters [0] { +          } +        } + +        Method [ <internal:gnupg> public method geterrorinfo ] { + +          - Parameters [0] { +          }          }          Method [ <internal:gnupg> public method clearsignkeys ] { + +          - Parameters [0] { +          }          }          Method [ <internal:gnupg> public method clearencryptkeys ] { + +          - Parameters [0] { +          }          }          Method [ <internal:gnupg> public method cleardecryptkeys ] { + +          - Parameters [0] { +          }          }          Method [ <internal:gnupg> public method setarmor ] { + +          - Parameters [1] { +            Parameter #0 [ <required> $armor ] +          }          }          Method [ <internal:gnupg> public method encrypt ] { + +          - Parameters [1] { +            Parameter #0 [ <required> $text ] +          }          }          Method [ <internal:gnupg> public method decrypt ] { + +          - Parameters [1] { +            Parameter #0 [ <required> $enctext ] +          }          }          Method [ <internal:gnupg> public method export ] { + +          - Parameters [1] { +            Parameter #0 [ <required> $pattern ] +          }          }          Method [ <internal:gnupg> public method import ] { + +          - Parameters [1] { +            Parameter #0 [ <required> $kye ] +          }          }          Method [ <internal:gnupg> public method getprotocol ] { + +          - Parameters [0] { +          }          }          Method [ <internal:gnupg> public method setsignmode ] { + +          - Parameters [1] { +            Parameter #0 [ <required> $signmode ] +          }          }          Method [ <internal:gnupg> public method sign ] { + +          - Parameters [1] { +            Parameter #0 [ <required> $text ] +          }          }          Method [ <internal:gnupg> public method encryptsign ] { + +          - Parameters [1] { +            Parameter #0 [ <required> $text ] +          }          }          Method [ <internal:gnupg> public method decryptverify ] { @@ -193,24 +405,55 @@ Extension [ <persistent> extension #86 gnupg version 1.4.0 ] {          }          Method [ <internal:gnupg> public method addsignkey ] { + +          - Parameters [2] { +            Parameter #0 [ <required> $kye ] +            Parameter #1 [ <required> $passphrase ] +          }          }          Method [ <internal:gnupg> public method addencryptkey ] { + +          - Parameters [1] { +            Parameter #0 [ <required> $kye ] +          }          }          Method [ <internal:gnupg> public method adddecryptkey ] { + +          - Parameters [2] { +            Parameter #0 [ <required> $kye ] +            Parameter #1 [ <required> $passphrase ] +          }          }          Method [ <internal:gnupg> public method deletekey ] { + +          - Parameters [2] { +            Parameter #0 [ <required> $kye ] +            Parameter #1 [ <required> $allow_secret ] +          }          }          Method [ <internal:gnupg> public method gettrustlist ] { + +          - Parameters [1] { +            Parameter #0 [ <required> $pattern ] +          }          }          Method [ <internal:gnupg> public method listsignatures ] { + +          - Parameters [1] { +            Parameter #0 [ <required> $kyeid ] +          }          }          Method [ <internal:gnupg> public method seterrormode ] { + +          - Parameters [1] { +            Parameter #0 [ <required> $errnmode ] +          }          }        }      } @@ -231,21 +474,39 @@ Extension [ <persistent> extension #86 gnupg version 1.4.0 ] {        - Methods [6] {          Method [ <internal:gnupg, ctor> public method __construct ] { + +          - Parameters [0] { +          }          }          Method [ <internal:gnupg, prototype Iterator> public method current ] { + +          - Parameters [0] { +          }          }          Method [ <internal:gnupg, prototype Iterator> public method key ] { + +          - Parameters [0] { +          }          }          Method [ <internal:gnupg, prototype Iterator> public method next ] { + +          - Parameters [0] { +          }          }          Method [ <internal:gnupg, prototype Iterator> public method rewind ] { + +          - Parameters [0] { +          }          }          Method [ <internal:gnupg, prototype Iterator> public method valid ] { + +          - Parameters [0] { +          }          }        }      } diff --git a/gnupg-build.patch b/gnupg-build.patch new file mode 100644 index 0000000..cedea9f --- /dev/null +++ b/gnupg-build.patch @@ -0,0 +1,73 @@ +From 618e7ffc698f948dfe4feef38258e42a7c24130e Mon Sep 17 00:00:00 2001 +From: Remi Collet <remi@remirepo.net> +Date: Mon, 15 Feb 2021 08:04:31 +0100 +Subject: [PATCH] fix build with libgpgme 1.3 + +--- + gnupg.c | 12 ++++-------- + 1 file changed, 4 insertions(+), 8 deletions(-) + +diff --git a/gnupg.c b/gnupg.c +index 3ec2f07..67e8c7f 100644 +--- a/gnupg.c ++++ b/gnupg.c +@@ -170,7 +170,9 @@ static void php_gnupg_this_make(PHPC_THIS_DECLARE(gnupg), zval *options TSRMLS_D + 					ctx, GPGME_PROTOCOL_OpenPGP, file_name, home_dir); + 		} + 		gpgme_set_armor(ctx, 1); ++#if GPGME_VERSION_NUMBER >= 0x010400  /* GPGME >= 1.4.0 */ + 		gpgme_set_pinentry_mode(ctx, GPGME_PINENTRY_MODE_LOOPBACK); ++#endif + 	} + } + /* }}} */ +@@ -591,10 +593,8 @@ PHP_MINIT_FUNCTION(gnupg) + #if GPGME_VERSION_NUMBER >= 0x010500  /* GPGME >= 1.5.0 */ + 	PHP_GNUPG_SET_CLASS_CONST("PK_ECC",             GPGME_PK_ECC); + #endif /* gpgme >= 1.5.0 */	 +-#if GPGME_VERSION_NUMBER >= 0x010300  /* GPGME >= 1.3.0 */ + 	PHP_GNUPG_SET_CLASS_CONST("PK_ECDSA",           GPGME_PK_ECDSA); + 	PHP_GNUPG_SET_CLASS_CONST("PK_ECDH",            GPGME_PK_ECDH); +-#endif /* gpgme >= 1.3.0 */	 + #if GPGME_VERSION_NUMBER >= 0x010700  /* GPGME >= 1.7.0 */ + 	PHP_GNUPG_SET_CLASS_CONST("PK_EDDSA",           GPGME_PK_EDDSA); + #endif /* gpgme >= 1.7.0 */ +@@ -633,10 +633,8 @@ PHP_MINIT_FUNCTION(gnupg) + #if GPGME_VERSION_NUMBER >= 0x010500  /* GPGME >= 1.5.0 */ + 	PHP_GNUPG_REG_CONST("GNUPG_PK_ECC",             GPGME_PK_ECC); + #endif /* gpgme >= 1.5.0 */	 +-#if GPGME_VERSION_NUMBER >= 0x010300  /* GPGME >= 1.3.0 */ + 	PHP_GNUPG_REG_CONST("GNUPG_PK_ECDSA",           GPGME_PK_ECDSA); + 	PHP_GNUPG_REG_CONST("GNUPG_PK_ECDH",            GPGME_PK_ECDH); +-#endif /* gpgme >= 1.3.0 */	 + #if GPGME_VERSION_NUMBER >= 0x010700  /* GPGME >= 1.7.0 */ + 	PHP_GNUPG_REG_CONST("GNUPG_PK_EDDSA",           GPGME_PK_EDDSA); + #endif /* gpgme >= 1.7.0 */ +@@ -1099,9 +1097,7 @@ PHP_FUNCTION(gnupg_keyinfo) + 			PHP_GNUPG_ARRAY_ADD_ASSOC_BOOL(subkey, revoked, gpgme_subkey); + 			PHP_GNUPG_ARRAY_ADD_ASSOC_BOOL(subkey, can_certify, gpgme_subkey); + 			PHP_GNUPG_ARRAY_ADD_ASSOC_BOOL(subkey, can_authenticate, gpgme_subkey); +-#if GPGME_VERSION_NUMBER >= 0x010100  /* GPGME >= 1.1.0 */ + 			PHP_GNUPG_ARRAY_ADD_ASSOC_BOOL(subkey, is_qualified, gpgme_subkey); +-#endif /* gpgme >= 1.1.0 */ + #if GPGME_VERSION_NUMBER >= 0x010900  /* GPGME >= 1.9.0 */ + 			PHP_GNUPG_ARRAY_ADD_ASSOC_BOOL(subkey, is_de_vs, gpgme_subkey); + #endif /* gpgme >= 1.9.0 */ +@@ -1117,15 +1113,15 @@ PHP_FUNCTION(gnupg_keyinfo) + 				PHP_GNUPG_ARRAY_ADD_ASSOC_CSTR(subkey, keygrip, gpgme_subkey); + 			} + #endif /* gpgme >= 1.7.0 */ +-#if GPGME_VERSION_NUMBER >= 0x010200  /* GPGME >= 1.2.0 */ + 			PHP_GNUPG_ARRAY_ADD_ASSOC_BOOL(subkey, is_cardkey, gpgme_subkey); + 			if (gpgme_subkey->card_number) { + 				PHP_GNUPG_ARRAY_ADD_ASSOC_CSTR(subkey, card_number, gpgme_subkey); + 			} +-#endif /* gpgme >= 1.2.0 */ ++#if GPGME_VERSION_NUMBER >= 0x010403  /* GPGME >= 1.4.3 */ + 			if (gpgme_subkey->curve) { + 				PHP_GNUPG_ARRAY_ADD_ASSOC_CSTR(subkey, curve, gpgme_subkey); + 			} ++#endif +  + 			PHPC_ARRAY_ADD_NEXT_INDEX_ZVAL( + 					PHPC_VAL_CAST_TO_PZVAL(subkeys), diff --git a/gnupgt.inc b/gnupgt.inc new file mode 100644 index 0000000..c31415d --- /dev/null +++ b/gnupgt.inc @@ -0,0 +1,211 @@ +<?php + +require_once __DIR__ . "/vars.inc"; + +class gnupgt { +    /** +     * Import all keys +     */ +    static public function import_key() +    { +        global $testkey; + +        self::reset_key(); + +        $gpg = new gnupg(); +        $gpg->import($testkey); +    } + +    /** +     * Delete all keys. +     * @param null|string $homeDir +     */ +    static public function delete_key($homeDir = null) +    { +        if (is_null($homeDir)) { +            $homeDir = self::get_home_dir(); +        } +        if (!is_dir($homeDir)) { +            return; +        } +        foreach (glob($homeDir . '/*') as $filename) { +            if (!is_dir($filename)) { +                unlink($filename); +            } +        } +        $privKeyDir = self::get_priv_key_dir($homeDir); +        if (is_dir($privKeyDir)) { +            foreach (glob($privKeyDir . '/*') as $key) { +                unlink($key); +            } +            rmdir($privKeyDir); +        } +        rmdir($homeDir); +    } + +    /** +     * Initialize key directory. +     */ +    static public function init_key_dir() +    { +        mkdir(self::get_home_dir()); +        mkdir(self::get_priv_key_dir(), 0700); +    } + +    /** +     * Reset all keys. +     */ +    static public function reset_key() +    { +        self::delete_key(); +        self::init_key_dir(); +    } + +    /** +     * Get home directory. +     * +     * @return string +     */ +    static private function get_home_dir() +    { +        return __DIR__ . '/home'; +    } + +    /** +     * Get private key directory (for GPG2). +     * @param null|string $homeDir +     * @return string +     */ +    static private function get_priv_key_dir($homeDir = null) +    { +        if (is_null($homeDir)) { +            $homeDir = self::get_home_dir(); +        } +        return $homeDir . '/private-keys-v1.d'; +    } + +    /** +     * Print error message and return false. +     * +     * @param string $msg +     * @return bool +     */ +    static private function error($msg) +    { +        echo "ERROR: " . $msg; +        return false; +    } + +    /** +     * Check single array value. +     * +     * @param mixed $expected +     * @param array $a +     * @param string $key1 +     * @return bool +     */ +    static public function check_array($expected, $a, $key1) +    { +        $args = func_get_args(); +        $keys = array_splice($args, 2); +        $value = $a; +        foreach ($keys as $key) { +            if (!isset($value[$key])) { +                return self::error("key $key not found in the array"); +            } +            $value = $value[$key]; +        } +        if ($value !== $expected) { + +            return self::error( +                sprintf( +                    "key %s value %s does not match expected %s\n", +                    $key, +                    var_export($value, true), +                    var_export($expected, true) +                ) +            ); +        } + +        return true; +    } + +    /** +     * Check single array value but only for GpgME version higher than supplied. +     * +     * @param mixed $expected +     * @param array $a +     * @param string $key1 +     * @return bool +     */ +    static public function check_array_from_version($version, $expected, $a, $key1) +    { +        if (version_compare(GNUPG_GPGME_VERSION,  $version) < 0) { +            return true; +        } + +        $args = func_get_args(); +        return call_user_func_array('gnupgt::check_array', array_splice($args, 1)); +    } + +    /** +     * Check keyinfo for var key +     * +     * @param $ret +     * @param $secret_only +     */ +    static public function check_keyinfo($ret, $secret_only) { +        self::check_array(false, $ret, 0, 'disabled'); +        self::check_array(false, $ret, 0, 'expired'); +        self::check_array(false, $ret, 0, 'revoked'); +        self::check_array($secret_only, $ret, 0, 'is_secret'); +        self::check_array(true, $ret, 0, 'can_sign'); +        self::check_array(true, $ret, 0, 'can_encrypt'); +        // uid +        self::check_array('PHP GnuPG', $ret, 0, 'uids', 0, 'name'); +        self::check_array('', $ret, 0, 'uids', 0, 'comment'); +        self::check_array('gnupg@php.net', $ret, 0, 'uids', 0, 'email'); +        self::check_array('PHP GnuPG <gnupg@php.net>', $ret, 0, 'uids', 0, 'uid'); +        self::check_array(false, $ret, 0, 'uids', 0, 'revoked'); +        self::check_array(false, $ret, 0, 'uids', 0, 'invalid'); +        self::check_array(false, $ret, 0, 'uids', 0, 'invalid'); +        // subkey 1 +        self::check_array("2DF0DD02DC9B70B7F64F572E669E775E0A6284B3", $ret, 0, 'subkeys', 0, 'fingerprint'); +        self::check_array("669E775E0A6284B3", $ret, 0, 'subkeys', 0, 'keyid'); +        self::check_array(1567958444, $ret, 0, 'subkeys', 0, 'timestamp'); +        self::check_array(0, $ret, 0, 'subkeys', 0, 'expires'); +        self::check_array($secret_only, $ret, 0, 'subkeys', 0, 'is_secret'); +        self::check_array(false, $ret, 0, 'subkeys', 0, 'can_encrypt'); +        self::check_array(true, $ret, 0, 'subkeys', 0, 'can_sign'); +        self::check_array(false, $ret, 0, 'subkeys', 0, 'disabled'); +        self::check_array(false, $ret, 0, 'subkeys', 0, 'expired'); +        self::check_array(false, $ret, 0, 'subkeys', 0, 'revoked'); +        self::check_array(true, $ret, 0, 'subkeys', 0, 'can_certify'); +        self::check_array(false, $ret, 0, 'subkeys', 0, 'can_authenticate'); +        self::check_array(false, $ret, 0, 'subkeys', 0, 'is_qualified'); +        // TODO: The is_de_vs seems to differ between gpg2 (true) and gpg1 (false) - differenatiate the test +        //self::check_array_from_version('1.9.0', true, $ret, 0, 'subkeys', 0, 'is_de_vs'); +        self::check_array(GNUPG_PK_RSA, $ret, 0, 'subkeys', 0, 'pubkey_algo'); +        self::check_array(2048, $ret, 0, 'subkeys', 0, 'length'); +        self::check_array_from_version('1.7.0', false, $ret, 0, 'subkeys', 0, 'is_cardkey'); +        // subkey 2 +        self::check_array("9E84AE800874DFF647B6062B46DCA9B3662C7DFC", $ret, 0, 'subkeys', 1, 'fingerprint'); +        self::check_array("46DCA9B3662C7DFC", $ret, 0, 'subkeys', 1, 'keyid'); +        self::check_array(1567958444, $ret, 0, 'subkeys', 1, 'timestamp'); +        self::check_array(0, $ret, 0, 'subkeys', 1, 'expires'); +        self::check_array($secret_only, $ret, 0, 'subkeys', 1, 'is_secret'); +        self::check_array(true, $ret, 0, 'subkeys', 1, 'can_encrypt'); +        self::check_array(false, $ret, 0, 'subkeys', 1, 'can_sign'); +        self::check_array(false, $ret, 0, 'subkeys', 1, 'disabled'); +        self::check_array(false, $ret, 0, 'subkeys', 1, 'expired'); +        self::check_array(false, $ret, 0, 'subkeys', 1, 'revoked'); +        self::check_array(false, $ret, 0, 'subkeys', 1, 'can_certify'); +        self::check_array(false, $ret, 0, 'subkeys', 1, 'can_authenticate'); +        self::check_array(false, $ret, 0, 'subkeys', 1, 'is_qualified'); +        // TODO: The is_de_vs seems to differ between gpg2 (true) and gpg1 (false) - differenatiate the test +        // self::check_array_from_version('1.9.0', true, $ret, 0, 'subkeys', 1, 'is_de_vs'); +        self::check_array(GNUPG_PK_RSA, $ret, 0, 'subkeys', 1, 'pubkey_algo'); +        self::check_array(2048, $ret, 0, 'subkeys', 1, 'length'); +        self::check_array_from_version('1.7.0', false, $ret, 0, 'subkeys', 1, 'is_cardkey'); +    } +} diff --git a/php-pecl-gnupg.spec b/php-pecl-gnupg.spec index 7cec4c6..f3624ea 100644 --- a/php-pecl-gnupg.spec +++ b/php-pecl-gnupg.spec @@ -19,35 +19,40 @@  %else  %global ini_name   40-%{pecl_name}.ini  %endif -#global prever     RC2 +%global upstream_version 1.5.0 +%global upstream_prever  RC1  Summary:      Wrapper around the gpgme library  Name:         %{?sub_prefix}php-pecl-gnupg -Version:      1.4.0 -Release:      10%{?dist}%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')} +Version:      %{upstream_version}%{?upstream_prever:~%{upstream_prever}} +Release:      1%{?dist}%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}  License:      BSD  URL:          https://pecl.php.net/package/gnupg -Source0:      https://pecl.php.net/get/%{pecl_name}-%{version}%{?prever}.tgz +Source0:      https://pecl.php.net/get/%{pecl_name}-%{upstream_version}%{?upstream_prever}.tgz + +Source1:      https://raw.githubusercontent.com/php-gnupg/php-gnupg/master/tests/gnupgt.inc +Source2:      https://raw.githubusercontent.com/php-gnupg/php-gnupg/master/tests/vars.inc +Patch0:       gnupg-build.patch  BuildRequires: make  BuildRequires: %{?dtsprefix}gcc  BuildRequires: %{?scl_prefix}php-devel  BuildRequires: %{?scl_prefix}php-pear  BuildRequires: gpgme-devel -%if 0%{?fedora} >= 30 || 0%{?rhel} >= 6 +%if 0%{?rhel} == 7  BuildRequires: gnupg1  %else -BuildRequires: gnupg < 2 +BuildRequires: gnupg  %endif  Requires:     %{?scl_prefix}php(zend-abi) = %{php_zend_api}  Requires:     %{?scl_prefix}php(api) = %{php_core_api}  # We force use of /usr/bin/gpg as gpg2 is unusable in non-interactive mode -%if 0%{?fedora} >= 30 || 0%{?rhel} >= 6 +%if 0%{?rhel} == 7  Requires:     gnupg1  %else -Requires:     gnupg < 2 +Requires:     gnupg  %endif  %{?_sclreq:Requires: %{?scl_prefix}runtime%{?_sclreq}%{?_isa}} @@ -62,37 +67,14 @@ Provides:     %{?scl_prefix}php-pecl-%{pecl_name}%{?_isa}  = %{version}-%{releas  %if "%{?packager}" == "Remi Collet" && 0%{!?scl:1} && 0%{?rhel}  # Other third party repo stuff -Obsoletes:     php53-pecl-%{pecl_name}  <= %{version} -Obsoletes:     php53u-pecl-%{pecl_name} <= %{version} -Obsoletes:     php54-pecl-%{pecl_name}  <= %{version} -Obsoletes:     php54w-pecl-%{pecl_name} <= %{version} -%if "%{php_version}" > "5.5" -Obsoletes:     php55u-pecl-%{pecl_name} <= %{version} -Obsoletes:     php55w-pecl-%{pecl_name} <= %{version} -%endif -%if "%{php_version}" > "5.6" -Obsoletes:     php56u-pecl-%{pecl_name} <= %{version} -Obsoletes:     php56w-pecl-%{pecl_name} <= %{version} -%endif -%if "%{php_version}" > "7.0" -Obsoletes:     php70u-pecl-%{pecl_name} <= %{version} -Obsoletes:     php70w-pecl-%{pecl_name} <= %{version} -%endif -%if "%{php_version}" > "7.1" -Obsoletes:     php71u-pecl-%{pecl_name} <= %{version} -Obsoletes:     php71w-pecl-%{pecl_name} <= %{version} -%endif -%if "%{php_version}" > "7.2" -Obsoletes:     php72u-pecl-%{pecl_name} <= %{version} -Obsoletes:     php72w-pecl-%{pecl_name} <= %{version} -%endif  %if "%{php_version}" > "7.3"  Obsoletes:      php73-pecl-%{pecl_name} <= %{version} -Obsoletes:     php73w-pecl-%{pecl_name} <= %{version}  %endif  %if "%{php_version}" > "7.4"  Obsoletes:      php74-pecl-%{pecl_name} <= %{version} -Obsoletes:     php74w-pecl-%{pecl_name} <= %{version} +%endif +%if "%{php_version}" > "8.0" +Obsoletes:      php80-pecl-%{pecl_name} <= %{version}  %endif  %endif @@ -119,13 +101,15 @@ cat >%{ini_name} << 'EOF'  extension=%{pecl_name}.so  EOF -mv %{pecl_name}-%{version}%{?prever} NTS +mv %{pecl_name}-%{upstream_version}%{?upstream_prever} NTS  cd NTS +cp %{SOURCE1} %{SOURCE2} tests/ +%patch0 -p1  # Check extension version  extver=$(sed -n '/#define PHP_GNUPG_VERSION/{s/.* "//;s/".*$//;p}' php_gnupg.h) -if test "x${extver}" != "x%{version}%{?prever}"; then -   : Error: Upstream extension version is ${extver}, expecting %{version}%{?prever}. +if test "x${extver}" != "x%{upstream_version}%{?upstream_prever}"; then +   : Error: Upstream extension version is ${extver}, expecting %{upstream_version}%{?upstream_prever}.     exit 1  fi  cd .. @@ -141,13 +125,19 @@ cp -r NTS ZTS  export PHP_RPATH=no  export CFLAGS="$RPM_OPT_FLAGS -D_FILE_OFFSET_BITS=64" +%if 0%{?rhel} == 7  export GPG1=$(which gpg1 2>/dev/null || which gpg)  $GPG1 --version +%else +gpg --version +%endif  peclbuild() {  %{_bindir}/${1}ize  %configure \ +%if 0%{?rhel} == 7      --with-gpg=$GPG1 \ +%endif      --with-libdir=%{_lib} \      --with-php-config=%{_bindir}/${1}-config @@ -252,6 +242,16 @@ cd ../ZTS  %changelog +* Mon Feb 15 2021 Remi Collet <remi@remirepo.net> - 1.5.0~RC1-1 +- Update to 1.5.0RC1 +- open https://github.com/php-gnupg/php-gnupg/pull/25 +  missing files in pecl archive +- open https://github.com/php-gnupg/php-gnupg/pull/26 +  also cleanup socket files +- open https://github.com/php-gnupg/php-gnupg/pull/27 +  fix build with old libgpgme 1.3 +- use gnupg version 2 (Fedora and EL-8) +  * Tue Feb  2 2021 Remi Collet <remi@remirepo.net> - 1.4.0-10  - EL-7 rebuild diff --git a/vars.inc b/vars.inc new file mode 100644 index 0000000..02d2819 --- /dev/null +++ b/vars.inc @@ -0,0 +1,69 @@ +<?php +putenv("GNUPGHOME=".dirname(__FILE__) . '/home'); +error_reporting (E_ALL); +$fingerprint = "2DF0DD02DC9B70B7F64F572E669E775E0A6284B3"; +$passphrase = "blabla"; + +$plaintext = "foo bar"; + +$testkey =<<<EOF +-----BEGIN PGP PRIVATE KEY BLOCK----- + +lQPGBF11JawBCAC6bWTtKtAj1dBih/UHR9iH1iADEmZde52aKyd7EXKtjs4Q2aXJ +kbn9R+kcJNx+AlnTSePQBkNz5brmEAQgk93rOsHaPUEROkfBR2C6AkjaJNnk0E43 +pbUy6bWhmGR4kmpbvRnR/7kxVyplb5zSFAcio1I8RQ3ql0HkF//zLUouYzrMJn6e +GvffHw1revlSxo0leCcOsNE7AHGVgMxvUWYO0JT4Fs+JcpsTxG8MFE6I6SLZoY5W +XmtOsO0vMNJoTaXdqfJoLTkviPkRUZuF0DtzuT1oQLUTTaKvWxx2+33YF5HYrlNy +eepLFLh5mZ1/2HFWoQo2X1gFfb1R9EJPbFtJABEBAAH+BwMCTBMnieCYP1Fg2yqq +wz42qlU7CjG2ES8+y4AgKMn4P9tB/FUUjzHHgkZRYkD0aa/3K0QrobPB/clval+h +px6xCgz83fL4gT2xKMU5lKrwtkBjJWwk8Ju/3Mf7Ngs31YdhfRG+aypoAQRktMtB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