|
@@ 1090-1110 (lines=21) @@
|
| 1087 |
|
* @return void |
| 1088 |
|
* @throws TypeError |
| 1089 |
|
*/ |
| 1090 |
|
public static function crypto_generichash_update(&$ctx, $message) |
| 1091 |
|
{ |
| 1092 |
|
/* Type checks: */ |
| 1093 |
|
ParagonIE_Sodium_Core_Util::declareScalarType($ctx, 'string', 1); |
| 1094 |
|
ParagonIE_Sodium_Core_Util::declareScalarType($message, 'string', 2); |
| 1095 |
|
|
| 1096 |
|
if (self::isPhp72OrGreater()) { |
| 1097 |
|
sodium_crypto_generichash_update($ctx, $message); |
| 1098 |
|
return; |
| 1099 |
|
} |
| 1100 |
|
if (self::use_fallback('crypto_generichash_update')) { |
| 1101 |
|
$func = '\\Sodium\\crypto_generichash_update'; |
| 1102 |
|
$func($ctx, $message); |
| 1103 |
|
return; |
| 1104 |
|
} |
| 1105 |
|
if (PHP_INT_SIZE === 4) { |
| 1106 |
|
$ctx = ParagonIE_Sodium_Crypto32::generichash_update($ctx, $message); |
| 1107 |
|
} else { |
| 1108 |
|
$ctx = ParagonIE_Sodium_Crypto::generichash_update($ctx, $message); |
| 1109 |
|
} |
| 1110 |
|
} |
| 1111 |
|
|
| 1112 |
|
/** |
| 1113 |
|
* Perform a key exchange, between a designated client and a server. |
|
@@ 1784-1802 (lines=19) @@
|
| 1781 |
|
* @param string $seed Input seed |
| 1782 |
|
* @return string Keypair |
| 1783 |
|
*/ |
| 1784 |
|
public static function crypto_sign_seed_keypair($seed) |
| 1785 |
|
{ |
| 1786 |
|
ParagonIE_Sodium_Core_Util::declareScalarType($seed, 'string', 1); |
| 1787 |
|
|
| 1788 |
|
if (self::isPhp72OrGreater()) { |
| 1789 |
|
return sodium_crypto_sign_seed_keypair($seed); |
| 1790 |
|
} |
| 1791 |
|
if (self::use_fallback('crypto_sign_keypair')) { |
| 1792 |
|
return call_user_func('\\Sodium\\crypto_sign_seed_keypair', $seed); |
| 1793 |
|
} |
| 1794 |
|
$publicKey = ''; |
| 1795 |
|
$secretKey = ''; |
| 1796 |
|
if (PHP_INT_SIZE === 4) { |
| 1797 |
|
ParagonIE_Sodium_Core32_Ed25519::seed_keypair($publicKey, $secretKey, $seed); |
| 1798 |
|
} else { |
| 1799 |
|
ParagonIE_Sodium_Core_Ed25519::seed_keypair($publicKey, $secretKey, $seed); |
| 1800 |
|
} |
| 1801 |
|
return $secretKey . $publicKey; |
| 1802 |
|
} |
| 1803 |
|
|
| 1804 |
|
/** |
| 1805 |
|
* Extract an Ed25519 public key from an Ed25519 keypair. |