mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2025-07-07 08:58:49 +00:00
[securemail] Upgrade singpolyma/openpgp to version 0.6.0
- Add missing use statement in SecureTestEmail - Address https://github.com/friendica/friendica/issues/12011#issuecomment-1321196332 - phpseclib version 3 dependency is implied from the core so it is removed from the addon
This commit is contained in:
parent
30329df0dd
commit
c18e0dc66a
60 changed files with 660 additions and 36426 deletions
|
@ -1,20 +1,24 @@
|
|||
<?php
|
||||
|
||||
use phpseclib3\Crypt\RSA;
|
||||
use phpseclib3\Crypt\RSA\Formats\Keys\PKCS1;
|
||||
|
||||
@include_once dirname(__FILE__).'/../vendor/autoload.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']);
|
||||
$privateKey = RSA::createKey(512);
|
||||
$publickey = $privateKey->getPublicKey();
|
||||
|
||||
$privateKeyComponents = PKCS1::load($privateKey->toString('PKCS1'));
|
||||
|
||||
$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()
|
||||
'n' => $privateKeyComponents["modulus"]->toBytes(),
|
||||
'e' => $privateKeyComponents["publicExponent"]->toBytes(),
|
||||
'd' => $privateKeyComponents["privateExponent"]->toBytes(),
|
||||
'p' => $privateKeyComponents["primes"][1]->toBytes(),
|
||||
'q' => $privateKeyComponents["primes"][2]->toBytes(),
|
||||
'u' => $privateKeyComponents["coefficients"][2]->toBytes()
|
||||
));
|
||||
|
||||
$uid = new OpenPGP_UserIDPacket('Test <test@example.com>');
|
||||
|
|
|
@ -1,21 +1,25 @@
|
|||
<?php
|
||||
|
||||
use phpseclib3\Crypt\RSA;
|
||||
use phpseclib3\Crypt\RSA\Formats\Keys\PKCS1;
|
||||
|
||||
@include_once dirname(__FILE__).'/../vendor/autoload.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';
|
||||
|
||||
$rsa = new \phpseclib\Crypt\RSA();
|
||||
$k = $rsa->createKey(512);
|
||||
$rsa->loadKey($k['privatekey']);
|
||||
$privateKey = RSA::createKey(512);
|
||||
$publickey = $privateKey->getPublicKey();
|
||||
|
||||
$privateKeyComponents = PKCS1::load($privateKey->toString('PKCS1'));
|
||||
|
||||
$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()
|
||||
'n' => $privateKeyComponents["modulus"]->toBytes(),
|
||||
'e' => $privateKeyComponents["publicExponent"]->toBytes(),
|
||||
'd' => $privateKeyComponents["privateExponent"]->toBytes(),
|
||||
'p' => $privateKeyComponents["primes"][1]->toBytes(),
|
||||
'q' => $privateKeyComponents["primes"][2]->toBytes(),
|
||||
'u' => $privateKeyComponents["coefficients"][2]->toBytes()
|
||||
));
|
||||
|
||||
$uid = new OpenPGP_UserIDPacket('Test <test@example.com>');
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
<?php
|
||||
|
||||
use phpseclib3\Crypt\RSA;
|
||||
use phpseclib3\Crypt\RSA\Formats\Keys\PKCS1;
|
||||
|
||||
@include_once dirname(__FILE__).'/../vendor/autoload.php';
|
||||
require_once dirname(__FILE__).'/../lib/openpgp.php';
|
||||
require_once dirname(__FILE__).'/../lib/openpgp_crypt_rsa.php';
|
||||
|
@ -8,18 +11,16 @@ require_once dirname(__FILE__).'/../lib/openpgp_crypt_rsa.php';
|
|||
$key_length = 512;
|
||||
|
||||
// Generate a master signing key
|
||||
|
||||
$rsa = new \phpseclib\Crypt\RSA();
|
||||
$k = $rsa->createKey($key_length);
|
||||
$rsa->loadKey($k['privatekey']);
|
||||
$privateKey = RSA::createKey(512);
|
||||
$privateKeyComponents = PKCS1::load($privateKey->toString('PKCS1'));
|
||||
|
||||
$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()
|
||||
'n' => $privateKeyComponents["modulus"]->toBytes(),
|
||||
'e' => $privateKeyComponents["publicExponent"]->toBytes(),
|
||||
'd' => $privateKeyComponents["privateExponent"]->toBytes(),
|
||||
'p' => $privateKeyComponents["primes"][1]->toBytes(),
|
||||
'q' => $privateKeyComponents["primes"][2]->toBytes(),
|
||||
'u' => $privateKeyComponents["coefficients"][2]->toBytes()
|
||||
));
|
||||
|
||||
// Start assembling packets for our eventual OpenPGP_Message
|
||||
|
@ -28,7 +29,7 @@ $packets = array($nkey);
|
|||
$wkey = new OpenPGP_Crypt_RSA($nkey);
|
||||
$fingerprint = $wkey->key()->fingerprint;
|
||||
$key = $wkey->private_key();
|
||||
$key->setHash('sha256');
|
||||
$key = $key->withHash('sha256');
|
||||
$keyid = substr($fingerprint, -16);
|
||||
|
||||
// Add multiple UID packets and signatures
|
||||
|
@ -54,17 +55,16 @@ foreach($uids as $uid) {
|
|||
|
||||
// Generate an encryption subkey
|
||||
|
||||
$rsa_subkey = new \phpseclib\Crypt\RSA();
|
||||
$sub_k = $rsa_subkey->createKey($key_length);
|
||||
$rsa_subkey->loadKey($sub_k['privatekey']);
|
||||
$rsa_subkey = RSA::createKey(512);
|
||||
$privateKeyComponents = PKCS1::load($rsa_subkey->toString('PKCS1'));
|
||||
|
||||
$subkey = new OpenPGP_SecretSubkeyPacket(array(
|
||||
'n' => $rsa_subkey->modulus->toBytes(),
|
||||
'e' => $rsa_subkey->publicExponent->toBytes(),
|
||||
'd' => $rsa_subkey->exponent->toBytes(),
|
||||
'p' => $rsa_subkey->primes[2]->toBytes(),
|
||||
'q' => $rsa_subkey->primes[1]->toBytes(),
|
||||
'u' => $rsa_subkey->coefficients[2]->toBytes()
|
||||
$subkey = new OpenPGP_SecretKeyPacket(array(
|
||||
'n' => $privateKeyComponents["modulus"]->toBytes(),
|
||||
'e' => $privateKeyComponents["publicExponent"]->toBytes(),
|
||||
'd' => $privateKeyComponents["privateExponent"]->toBytes(),
|
||||
'p' => $privateKeyComponents["primes"][2]->toBytes(),
|
||||
'q' => $privateKeyComponents["primes"][1]->toBytes(),
|
||||
'u' => $privateKeyComponents["coefficients"][2]->toBytes()
|
||||
));
|
||||
|
||||
// Append the encryption subkey
|
||||
|
@ -113,4 +113,4 @@ foreach($pubm as $idx => $p) {
|
|||
$public_bytes = $pubm->to_bytes();
|
||||
|
||||
// Note: If using PHP 7.4 CLI, disable deprecated warnings:
|
||||
// php -d error_reporting="E_ALL & ~E_DEPRECATED" examples/keygenSubkeys.php > mykey.gpg
|
||||
// php -d error_reporting="E_ALL & ~E_DEPRECATED" examples/keygenSubkeys.php > mykey.gpg
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue