| @@ 719-736 (lines=18) @@ | ||
| 716 | * @return string |
|
| 717 | * @throws RangeException |
|
| 718 | */ |
|
| 719 | public static function generichash_init($key = '', $outputLength = 32) |
|
| 720 | { |
|
| 721 | // This ensures that ParagonIE_Sodium_Core_BLAKE2b::$iv is initialized |
|
| 722 | ParagonIE_Sodium_Core_BLAKE2b::pseudoConstructor(); |
|
| 723 | ||
| 724 | $k = null; |
|
| 725 | if (!empty($key)) { |
|
| 726 | $k = ParagonIE_Sodium_Core_BLAKE2b::stringToSplFixedArray($key); |
|
| 727 | if ($k->count() > ParagonIE_Sodium_Core_BLAKE2b::KEYBYTES) { |
|
| 728 | throw new RangeException('Invalid key size'); |
|
| 729 | } |
|
| 730 | } |
|
| 731 | ||
| 732 | /** @var SplFixedArray $ctx */ |
|
| 733 | $ctx = ParagonIE_Sodium_Core_BLAKE2b::init($k, $outputLength); |
|
| 734 | ||
| 735 | return ParagonIE_Sodium_Core_BLAKE2b::contextToString($ctx); |
|
| 736 | } |
|
| 737 | ||
| 738 | /** |
|
| 739 | * Update a hashing context for BLAKE2b with $message |
|
| @@ 704-721 (lines=18) @@ | ||
| 701 | * @return string |
|
| 702 | * @throws RangeException |
|
| 703 | */ |
|
| 704 | public static function generichash_init($key = '', $outputLength = 32) |
|
| 705 | { |
|
| 706 | // This ensures that ParagonIE_Sodium_Core32_BLAKE2b::$iv is initialized |
|
| 707 | ParagonIE_Sodium_Core32_BLAKE2b::pseudoConstructor(); |
|
| 708 | ||
| 709 | $k = null; |
|
| 710 | if (!empty($key)) { |
|
| 711 | $k = ParagonIE_Sodium_Core32_BLAKE2b::stringToSplFixedArray($key); |
|
| 712 | if ($k->count() > ParagonIE_Sodium_Core32_BLAKE2b::KEYBYTES) { |
|
| 713 | throw new RangeException('Invalid key size'); |
|
| 714 | } |
|
| 715 | } |
|
| 716 | ||
| 717 | /** @var SplFixedArray $ctx */ |
|
| 718 | $ctx = ParagonIE_Sodium_Core32_BLAKE2b::init($k, $outputLength); |
|
| 719 | ||
| 720 | return ParagonIE_Sodium_Core32_BLAKE2b::contextToString($ctx); |
|
| 721 | } |
|
| 722 | ||
| 723 | /** |
|
| 724 | * Update a hashing context for BLAKE2b with $message |
|