Changeset 61419
- Timestamp:
- 12/30/2025 10:53:23 PM (2 months ago)
- Location:
- trunk/src/wp-includes/sodium_compat/src
- Files:
-
- 2 edited
-
Core/Ed25519.php (modified) (4 diffs)
-
File.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/sodium_compat/src/Core/Ed25519.php
r60905 r61419 108 108 109 109 /** 110 * Returns TRUE if $A represents a point on the order of the Edwards25519 prime order subgroup. 111 * Returns FALSE if $A is on a different subgroup. 112 * 113 * @param ParagonIE_Sodium_Core_Curve25519_Ge_P3 $A 114 * @return bool 115 * 116 * @throws SodiumException 117 */ 118 public static function is_on_main_subgroup(ParagonIE_Sodium_Core_Curve25519_Ge_P3 $A) 119 { 120 $p1 = self::ge_mul_l($A); 121 $t = self::fe_sub($p1->Y, $p1->Z); 122 return self::fe_isnonzero($p1->X) && self::fe_isnonzero($t); 123 } 124 125 /** 110 126 * @param string $pk 111 127 * @return string … … 119 135 } 120 136 $A = self::ge_frombytes_negate_vartime(self::substr($pk, 0, 32)); 121 $p1 = self::ge_mul_l($A); 122 if (!self::fe_isnonzero($p1->X)) { 123 throw new SodiumException('Unexpected zero result'); 137 if (!self::is_on_main_subgroup($A)) { 138 throw new SodiumException('Public key is not on a member of the main subgroup'); 124 139 } 125 140 … … 288 303 } 289 304 if ((self::chrToInt($sig[63]) & 240) && self::check_S_lt_L(self::substr($sig, 32, 32))) { 290 throw new SodiumException('S <L - Invalid signature');305 throw new SodiumException('S >= L - Invalid signature'); 291 306 } 292 307 if (self::small_order($sig)) { … … 312 327 /** @var ParagonIE_Sodium_Core_Curve25519_Ge_P3 $A */ 313 328 $A = self::ge_frombytes_negate_vartime($pk); 329 if (!self::is_on_main_subgroup($A)) { 330 throw new SodiumException('Public key is not on a member of the main subgroup'); 331 } 314 332 315 333 /** @var string $hDigest */ -
trunk/src/wp-includes/sodium_compat/src/File.php
r60905 r61419 787 787 ParagonIE_Sodium_Compat::$fastMult = true; 788 788 789 if (ParagonIE_Sodium_Core_Ed25519::small_order($publicKey)) { 790 throw new SodiumException('Public key has small order'); 791 } 789 792 /** @var ParagonIE_Sodium_Core_Curve25519_Ge_P3 $A */ 790 793 $A = ParagonIE_Sodium_Core_Ed25519::ge_frombytes_negate_vartime($publicKey); 794 if (!ParagonIE_Sodium_Core_Ed25519::is_on_main_subgroup($A)) { 795 throw new SodiumException('Public key is not on a member of the main subgroup'); 796 } 791 797 792 798 $hs = hash_init('sha512');
Note: See TracChangeset
for help on using the changeset viewer.