You are here

class VerifierB64Data in Automatic Updates 8

Same name and namespace in other branches
  1. 7 vendor/drupal/php-signify/src/VerifierB64Data.php \Drupal\Signify\VerifierB64Data

Hierarchy

Expanded class hierarchy of VerifierB64Data

File

vendor/drupal/php-signify/src/VerifierB64Data.php, line 5

Namespace

Drupal\Signify
View source
class VerifierB64Data {
  const PKALG = 'Ed';
  const KEYNUMLEN = 8;
  public $keyNum;
  public $data;
  public function __construct($b64data, $length) {
    $decoded = base64_decode($b64data, true);
    $alg = substr($decoded, 0, 2);
    if ($alg !== self::PKALG) {
      throw new VerifierException(sprintf('Unexpected algorithm string %s', $alg));
    }
    $this->keyNum = substr($decoded, 2, self::KEYNUMLEN);
    $this->data = substr($decoded, 2 + self::KEYNUMLEN);
    if ($length !== SODIUM_CRYPTO_SIGN_BYTES && $length !== SODIUM_CRYPTO_SIGN_PUBLICKEYBYTES) {
      throw new VerifierException(sprintf('Length must be %d or %d. Got %d', SODIUM_CRYPTO_SIGN_BYTES, SODIUM_CRYPTO_SIGN_PUBLICKEYBYTES, $length));
    }
    if (strlen($this->data) !== $length) {
      throw new VerifierException('Data does not match expected length.');
    }
  }

}

Members