You are here

public static function ParagonIE_Sodium_Core_Ed25519::check_S_lt_L in Automatic Updates 8

Same name and namespace in other branches
  1. 7 vendor/paragonie/sodium_compat/src/Core/Ed25519.php \ParagonIE_Sodium_Core_Ed25519::check_S_lt_L()

@internal You should not use this directly from another application

Parameters

string $S:

Return value

bool

Throws

SodiumException

TypeError

2 calls to ParagonIE_Sodium_Core_Ed25519::check_S_lt_L()
ParagonIE_Sodium_Core_Ed25519::verify_detached in vendor/paragonie/sodium_compat/src/Core/Ed25519.php
@internal You should not use this directly from another application
ParagonIE_Sodium_File::verify in vendor/paragonie/sodium_compat/src/File.php
Verify a file (rather than a string). Uses less memory than ParagonIE_Sodium_Compat::crypto_sign_verify_detached(), but produces the same result.

File

vendor/paragonie/sodium_compat/src/Core/Ed25519.php, line 341

Class

ParagonIE_Sodium_Core_Ed25519
Class ParagonIE_Sodium_Core_Ed25519

Code

public static function check_S_lt_L($S) {
  if (self::strlen($S) < 32) {
    throw new SodiumException('Signature must be 32 bytes');
  }
  $L = array(
    0xed,
    0xd3,
    0xf5,
    0x5c,
    0x1a,
    0x63,
    0x12,
    0x58,
    0xd6,
    0x9c,
    0xf7,
    0xa2,
    0xde,
    0xf9,
    0xde,
    0x14,
    0x0,
    0x0,
    0x0,
    0x0,
    0x0,
    0x0,
    0x0,
    0x0,
    0x0,
    0x0,
    0x0,
    0x0,
    0x0,
    0x0,
    0x0,
    0x10,
  );
  $c = 0;
  $n = 1;
  $i = 32;

  /** @var array<int, int> $L */
  do {
    --$i;
    $x = self::chrToInt($S[$i]);
    $c |= $x - $L[$i] >> 8 & $n;
    $n &= ($x ^ $L[$i]) - 1 >> 8;
  } while ($i !== 0);
  return $c === 0;
}