PHP Classes

File: src/Operations/PKE/PKETrait.php

Recommend this page to a friend!
  Classes of Scott Arciszewski   PASERK PHP   src/Operations/PKE/PKETrait.php   Download  
File: src/Operations/PKE/PKETrait.php
Role: Class source
Content type: text/plain
Description: Class source
Class: PASERK PHP
Extend PASETO to wrap and serialize keys
Author: By
Last change:
Date: 2 years ago
Size: 603 bytes
 

Contents

Class file image Download
<?php
declare(strict_types=1);
namespace
ParagonIE\Paserk\Operations\PKE;

use
ParagonIE\Paserk\PaserkException;
use
ParagonIE\Paseto\KeyInterface;
use
ParagonIE\Paseto\ProtocolInterface;

/**
 * @method ProtocolInterface getProtocol()
 */
trait PKETrait
{
   
/**
     * @param KeyInterface $key
     * @throws PaserkException
     */
   
protected function assertKeyVersion(KeyInterface $key): void
   
{
       
$protocol = static::getProtocol();
        if (!
$key->getProtocol() instanceof $protocol) {
            throw new
PaserkException("Invalid version for this secret key");
        }
    }
}