[ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 <?php 2 3 if (class_exists('ParagonIE_Sodium_Core32_HChaCha20', false)) { 4 return; 5 } 6 7 /** 8 * Class ParagonIE_Sodium_Core_HChaCha20 9 */ 10 class ParagonIE_Sodium_Core32_HChaCha20 extends ParagonIE_Sodium_Core32_ChaCha20 11 { 12 /** 13 * @param string $in 14 * @param string $key 15 * @param string|null $c 16 * @return string 17 * @throws SodiumException 18 * @throws TypeError 19 */ 20 public static function hChaCha20($in = '', $key = '', $c = null) 21 { 22 $ctx = array(); 23 24 if ($c === null) { 25 $ctx[0] = new ParagonIE_Sodium_Core32_Int32(array(0x6170, 0x7865)); 26 $ctx[1] = new ParagonIE_Sodium_Core32_Int32(array(0x3320, 0x646e)); 27 $ctx[2] = new ParagonIE_Sodium_Core32_Int32(array(0x7962, 0x2d32)); 28 $ctx[3] = new ParagonIE_Sodium_Core32_Int32(array(0x6b20, 0x6574)); 29 } else { 30 $ctx[0] = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($c, 0, 4)); 31 $ctx[1] = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($c, 4, 4)); 32 $ctx[2] = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($c, 8, 4)); 33 $ctx[3] = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($c, 12, 4)); 34 } 35 $ctx[4] = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($key, 0, 4)); 36 $ctx[5] = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($key, 4, 4)); 37 $ctx[6] = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($key, 8, 4)); 38 $ctx[7] = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($key, 12, 4)); 39 $ctx[8] = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($key, 16, 4)); 40 $ctx[9] = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($key, 20, 4)); 41 $ctx[10] = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($key, 24, 4)); 42 $ctx[11] = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($key, 28, 4)); 43 $ctx[12] = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($in, 0, 4)); 44 $ctx[13] = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($in, 4, 4)); 45 $ctx[14] = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($in, 8, 4)); 46 $ctx[15] = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($in, 12, 4)); 47 48 return self::hChaCha20Bytes($ctx); 49 } 50 51 /** 52 * @param array $ctx 53 * @return string 54 * @throws SodiumException 55 * @throws TypeError 56 */ 57 protected static function hChaCha20Bytes(array $ctx) 58 { 59 /** @var ParagonIE_Sodium_Core32_Int32 $x0 */ 60 $x0 = $ctx[0]; 61 /** @var ParagonIE_Sodium_Core32_Int32 $x1 */ 62 $x1 = $ctx[1]; 63 /** @var ParagonIE_Sodium_Core32_Int32 $x2 */ 64 $x2 = $ctx[2]; 65 /** @var ParagonIE_Sodium_Core32_Int32 $x3 */ 66 $x3 = $ctx[3]; 67 /** @var ParagonIE_Sodium_Core32_Int32 $x4 */ 68 $x4 = $ctx[4]; 69 /** @var ParagonIE_Sodium_Core32_Int32 $x5 */ 70 $x5 = $ctx[5]; 71 /** @var ParagonIE_Sodium_Core32_Int32 $x6 */ 72 $x6 = $ctx[6]; 73 /** @var ParagonIE_Sodium_Core32_Int32 $x7 */ 74 $x7 = $ctx[7]; 75 /** @var ParagonIE_Sodium_Core32_Int32 $x8 */ 76 $x8 = $ctx[8]; 77 /** @var ParagonIE_Sodium_Core32_Int32 $x9 */ 78 $x9 = $ctx[9]; 79 /** @var ParagonIE_Sodium_Core32_Int32 $x10 */ 80 $x10 = $ctx[10]; 81 /** @var ParagonIE_Sodium_Core32_Int32 $x11 */ 82 $x11 = $ctx[11]; 83 /** @var ParagonIE_Sodium_Core32_Int32 $x12 */ 84 $x12 = $ctx[12]; 85 /** @var ParagonIE_Sodium_Core32_Int32 $x13 */ 86 $x13 = $ctx[13]; 87 /** @var ParagonIE_Sodium_Core32_Int32 $x14 */ 88 $x14 = $ctx[14]; 89 /** @var ParagonIE_Sodium_Core32_Int32 $x15 */ 90 $x15 = $ctx[15]; 91 92 for ($i = 0; $i < 10; ++$i) { 93 # QUARTERROUND( x0, x4, x8, x12) 94 list($x0, $x4, $x8, $x12) = self::quarterRound($x0, $x4, $x8, $x12); 95 96 # QUARTERROUND( x1, x5, x9, x13) 97 list($x1, $x5, $x9, $x13) = self::quarterRound($x1, $x5, $x9, $x13); 98 99 # QUARTERROUND( x2, x6, x10, x14) 100 list($x2, $x6, $x10, $x14) = self::quarterRound($x2, $x6, $x10, $x14); 101 102 # QUARTERROUND( x3, x7, x11, x15) 103 list($x3, $x7, $x11, $x15) = self::quarterRound($x3, $x7, $x11, $x15); 104 105 # QUARTERROUND( x0, x5, x10, x15) 106 list($x0, $x5, $x10, $x15) = self::quarterRound($x0, $x5, $x10, $x15); 107 108 # QUARTERROUND( x1, x6, x11, x12) 109 list($x1, $x6, $x11, $x12) = self::quarterRound($x1, $x6, $x11, $x12); 110 111 # QUARTERROUND( x2, x7, x8, x13) 112 list($x2, $x7, $x8, $x13) = self::quarterRound($x2, $x7, $x8, $x13); 113 114 # QUARTERROUND( x3, x4, x9, x14) 115 list($x3, $x4, $x9, $x14) = self::quarterRound($x3, $x4, $x9, $x14); 116 } 117 118 return $x0->toReverseString() . 119 $x1->toReverseString() . 120 $x2->toReverseString() . 121 $x3->toReverseString() . 122 $x12->toReverseString() . 123 $x13->toReverseString() . 124 $x14->toReverseString() . 125 $x15->toReverseString(); 126 } 127 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated : Sun Dec 22 08:20:01 2024 | Cross-referenced by PHPXref |