/**
* @param string $Der der formatted string
- * @param string $Private key type optional, default false
+ * @param bool $Private key type optional, default false
* @return string
*/
private static function DerToPem($Der, $Private = false)
* @param string $m modulo reference
* @param object $e exponent reference
* @return void
+ * @throws \Exception
*/
private static function pubRsaToMe($key, &$m, &$e)
{
/**
* @param string $key key
* @return string
+ * @throws \Exception
*/
public static function rsaToPem($key)
{
/**
* @param string $key key
* @return string
+ * @throws \Exception
*/
private static function pemToRsa($key)
{
* @param string $m modulo reference
* @param string $e exponent reference
* @return void
+ * @throws \Exception
*/
public static function pemToMe($key, &$m, &$e)
{
/**
* @param integer $bits number of bits
* @return mixed
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function newKeypair($bits)
{
}
/**
- *
+ *
* Ported from Hubzilla: https://framagit.org/hubzilla/core/blob/master/include/crypto.php
- *
+ *
* @param string $data
* @param string $pubkey The public key.
* @param string $alg The algorithm used for encryption.
- *
+ *
* @return array
+ * @throws \Exception
*/
public static function encapsulate($data, $pubkey, $alg = 'aes256cbc')
{
}
/**
- *
+ *
* Ported from Hubzilla: https://framagit.org/hubzilla/core/blob/master/include/crypto.php
- *
- * @param type $data
- * @param type $pubkey The public key.
- * @param type $alg The algorithm used for encryption.
- *
+ *
+ * @param string $data
+ * @param string $pubkey The public key.
+ * @param string $alg The algorithm used for encryption.
+ *
* @return array
+ * @throws \Exception
*/
private static function encapsulateOther($data, $pubkey, $alg)
{
}
/**
- *
+ *
* Ported from Hubzilla: https://framagit.org/hubzilla/core/blob/master/include/crypto.php
- *
+ *
* @param string $data
* @param string $pubkey
- *
+ *
* @return array
+ * @throws \Exception
*/
private static function encapsulateAes($data, $pubkey)
{
}
/**
- *
+ *
* Ported from Hubzilla: https://framagit.org/hubzilla/core/blob/master/include/crypto.php
- *
- * @param string $data
- * @param string $prvkey The private key used for decryption.
- *
+ *
+ * @param array $data ['iv' => $iv, 'key' => $key, 'alg' => $alg, 'data' => $data]
+ * @param string $prvkey The private key used for decryption.
+ *
* @return string|boolean The decrypted string or false on failure.
+ * @throws \Exception
*/
- public static function unencapsulate($data, $prvkey)
+ public static function unencapsulate(array $data, $prvkey)
{
if (!$data) {
return;
$alg = ((array_key_exists('alg', $data)) ? $data['alg'] : 'aes256cbc');
if ($alg === 'aes256cbc') {
- return self::encapsulateAes($data, $prvkey);
+ return self::encapsulateAes($data['data'], $prvkey);
}
- return self::encapsulateOther($data, $prvkey, $alg);
+ return self::encapsulateOther($data['data'], $prvkey, $alg);
}
/**
- *
+ *
* Ported from Hubzilla: https://framagit.org/hubzilla/core/blob/master/include/crypto.php
- *
- * @param string $data
- * @param string $prvkey The private key used for decryption.
+ *
+ * @param array $data
+ * @param string $prvkey The private key used for decryption.
* @param string $alg
- *
+ *
* @return string|boolean The decrypted string or false on failure.
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
- private static function unencapsulateOther($data, $prvkey, $alg)
+ private static function unencapsulateOther(array $data, $prvkey, $alg)
{
$fn = 'decrypt' . strtoupper($alg);
}
/**
- *
+ *
* Ported from Hubzilla: https://framagit.org/hubzilla/core/blob/master/include/crypto.php
- *
+ *
* @param array $data
- * @param string $prvkey The private key used for decryption.
- *
+ * @param string $prvkey The private key used for decryption.
+ *
* @return string|boolean The decrypted string or false on failure.
+ * @throws \Exception
*/
private static function unencapsulateAes($data, $prvkey)
{