mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2025-04-25 21:10:13 +00:00
[securemail] Update Composer dependencies
- Update phpseclib/phpseclib to version 2.0.4 - Update singpolyma/openpgp-php to version 0.3.0
This commit is contained in:
parent
37dd8a938b
commit
af672ecd1b
161 changed files with 13940 additions and 7678 deletions
31
securemail/vendor/singpolyma/openpgp-php/examples/clearsign.php
vendored
Normal file
31
securemail/vendor/singpolyma/openpgp-php/examples/clearsign.php
vendored
Normal file
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
require_once dirname(__FILE__).'/../lib/openpgp.php';
|
||||
require_once dirname(__FILE__).'/../lib/openpgp_crypt_rsa.php';
|
||||
|
||||
/* Parse secret key from STDIN, the key must not be password protected */
|
||||
$wkey = OpenPGP_Message::parse(file_get_contents('php://stdin'));
|
||||
$wkey = $wkey[0];
|
||||
|
||||
$string = "This\nis\na\ntest.";
|
||||
|
||||
/* Create a new literal data packet */
|
||||
$data = new OpenPGP_LiteralDataPacket($string, array('format' => 'u', 'filename' => 'stuff.txt'));
|
||||
$data->normalize(true); // Clearsign-style normalization of the LiteralDataPacket
|
||||
|
||||
/* Create a signer from the key */
|
||||
$sign = new OpenPGP_Crypt_RSA($wkey);
|
||||
|
||||
/* The message is the signed data packet */
|
||||
$m = $sign->sign($data);
|
||||
|
||||
/* Generate clearsigned data */
|
||||
$packets = $m->signatures()[0];
|
||||
echo "-----BEGIN PGP SIGNED MESSAGE-----\nHash: SHA256\n\n";
|
||||
// Output normalised data. You could convert line endings here
|
||||
// without breaking the signature, but do not add any
|
||||
// trailing whitespace to lines.
|
||||
echo preg_replace("/^-/", "- -", $packets[0]->data)."\n";
|
||||
echo OpenPGP::enarmor($packets[1][0]->to_bytes(), "PGP SIGNATURE");
|
||||
|
||||
?>
|
27
securemail/vendor/singpolyma/openpgp-php/examples/deASCIIdeCrypt.php
vendored
Normal file
27
securemail/vendor/singpolyma/openpgp-php/examples/deASCIIdeCrypt.php
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
// USAGE: php examples/deASCIIdeCrypt.php secretkey.asc password message.asc
|
||||
// This will fail if the algo on key or message is not 3DES or AES
|
||||
|
||||
require_once dirname(__FILE__).'/../lib/openpgp.php';
|
||||
require_once dirname(__FILE__).'/../lib/openpgp_crypt_rsa.php';
|
||||
require_once dirname(__FILE__).'/../lib/openpgp_crypt_symmetric.php';
|
||||
|
||||
$keyASCII = file_get_contents($argv[1]);
|
||||
$msgASCII = file_get_contents($argv[3]);
|
||||
|
||||
$keyEncrypted = OpenPGP_Message::parse(OpenPGP::unarmor($keyASCII, 'PGP PRIVATE KEY BLOCK'));
|
||||
|
||||
// Try each secret key packet
|
||||
foreach($keyEncrypted as $p) {
|
||||
if(!($p instanceof OpenPGP_SecretKeyPacket)) continue;
|
||||
|
||||
$key = OpenPGP_Crypt_Symmetric::decryptSecretKey($argv[2], $p);
|
||||
|
||||
$msg = OpenPGP_Message::parse(OpenPGP::unarmor($msgASCII, 'PGP MESSAGE'));
|
||||
|
||||
$decryptor = new OpenPGP_Crypt_RSA($key);
|
||||
$decrypted = $decryptor->decrypt($msg);
|
||||
|
||||
var_dump($decrypted);
|
||||
}
|
15
securemail/vendor/singpolyma/openpgp-php/examples/encryptDecrypt.php
vendored
Normal file
15
securemail/vendor/singpolyma/openpgp-php/examples/encryptDecrypt.php
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
|
||||
require_once dirname(__FILE__).'/../lib/openpgp.php';
|
||||
require_once dirname(__FILE__).'/../lib/openpgp_crypt_rsa.php';
|
||||
require_once dirname(__FILE__).'/../lib/openpgp_crypt_symmetric.php';
|
||||
|
||||
$key = OpenPGP_Message::parse(file_get_contents(dirname(__FILE__) . '/../tests/data/helloKey.gpg'));
|
||||
$data = new OpenPGP_LiteralDataPacket('This is text.', array('format' => 'u', 'filename' => 'stuff.txt'));
|
||||
$encrypted = OpenPGP_Crypt_Symmetric::encrypt($key, new OpenPGP_Message(array($data)));
|
||||
|
||||
// Now decrypt it with the same key
|
||||
$decryptor = new OpenPGP_Crypt_RSA($key);
|
||||
$decrypted = $decryptor->decrypt($encrypted);
|
||||
|
||||
var_dump($decrypted);
|
31
securemail/vendor/singpolyma/openpgp-php/examples/keygen.php
vendored
Normal file
31
securemail/vendor/singpolyma/openpgp-php/examples/keygen.php
vendored
Normal file
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
require_once dirname(__FILE__).'/../lib/openpgp.php';
|
||||
require_once dirname(__FILE__).'/../lib/openpgp_crypt_rsa.php';
|
||||
|
||||
$rsa = new \phpseclib\Crypt\RSA();
|
||||
$k = $rsa->createKey(512);
|
||||
$rsa->loadKey($k['privatekey']);
|
||||
|
||||
$nkey = new OpenPGP_SecretKeyPacket(array(
|
||||
'n' => $rsa->modulus->toBytes(),
|
||||
'e' => $rsa->publicExponent->toBytes(),
|
||||
'd' => $rsa->exponent->toBytes(),
|
||||
'p' => $rsa->primes[2]->toBytes(),
|
||||
'q' => $rsa->primes[1]->toBytes(),
|
||||
'u' => $rsa->coefficients[2]->toBytes()
|
||||
));
|
||||
|
||||
$uid = new OpenPGP_UserIDPacket('Test <test@example.com>');
|
||||
|
||||
$wkey = new OpenPGP_Crypt_RSA($nkey);
|
||||
$m = $wkey->sign_key_userid(array($nkey, $uid));
|
||||
|
||||
// Serialize private key
|
||||
print $m->to_bytes();
|
||||
|
||||
// Serialize public key message
|
||||
$pubm = clone($m);
|
||||
$pubm[0] = new OpenPGP_PublicKeyPacket($pubm[0]);
|
||||
|
||||
$public_bytes = $pubm->to_bytes();
|
22
securemail/vendor/singpolyma/openpgp-php/examples/sign.php
vendored
Normal file
22
securemail/vendor/singpolyma/openpgp-php/examples/sign.php
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
require_once dirname(__FILE__).'/../lib/openpgp.php';
|
||||
require_once dirname(__FILE__).'/../lib/openpgp_crypt_rsa.php';
|
||||
|
||||
/* Parse secret key from STDIN, the key must not be password protected */
|
||||
$wkey = OpenPGP_Message::parse(file_get_contents('php://stdin'));
|
||||
$wkey = $wkey[0];
|
||||
|
||||
/* Create a new literal data packet */
|
||||
$data = new OpenPGP_LiteralDataPacket('This is text.', array('format' => 'u', 'filename' => 'stuff.txt'));
|
||||
|
||||
/* Create a signer from the key */
|
||||
$sign = new OpenPGP_Crypt_RSA($wkey);
|
||||
|
||||
/* The message is the signed data packet */
|
||||
$m = $sign->sign($data);
|
||||
|
||||
/* Output the raw message bytes to STDOUT */
|
||||
echo $m->to_bytes();
|
||||
|
||||
?>
|
18
securemail/vendor/singpolyma/openpgp-php/examples/verify.php
vendored
Normal file
18
securemail/vendor/singpolyma/openpgp-php/examples/verify.php
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
require_once dirname(__FILE__).'/../lib/openpgp.php';
|
||||
require_once dirname(__FILE__).'/../lib/openpgp_crypt_rsa.php';
|
||||
|
||||
/* Parse public key from STDIN */
|
||||
$wkey = OpenPGP_Message::parse(file_get_contents('php://stdin'));
|
||||
|
||||
/* Parse signed message from file named "t" */
|
||||
$m = OpenPGP_Message::parse(file_get_contents('t'));
|
||||
|
||||
/* Create a verifier for the key */
|
||||
$verify = new OpenPGP_Crypt_RSA($wkey);
|
||||
|
||||
/* Dump verification information to STDOUT */
|
||||
var_dump($verify->verify($m));
|
||||
|
||||
?>
|
Loading…
Add table
Add a link
Reference in a new issue