예제 #1
0
 /**
  * @param string $keyMaterial - The actual key data
  */
 public function __construct(string $keyMaterial = '', ...$args)
 {
     if (CryptoUtil::safeStrlen($keyMaterial) !== \Sodium\CRYPTO_AUTH_KEYBYTES) {
         throw new InvalidKey('Authentication key must be CRYPTO_AUTH_KEYBYTES bytes long');
     }
     parent::__construct($keyMaterial, true);
 }
예제 #2
0
 /**
  * @param HiddenString $keyMaterial - The actual key data
  * @throws InvalidKey
  */
 public function __construct(HiddenString $keyMaterial)
 {
     if (CryptoUtil::safeStrlen($keyMaterial->getString()) !== \Sodium\CRYPTO_STREAM_KEYBYTES) {
         throw new InvalidKey('Encryption key must be CRYPTO_STREAM_KEYBYTES bytes long');
     }
     parent::__construct($keyMaterial);
 }
예제 #3
0
 /**
  * @param HiddenString $keyMaterial - The actual key data
  * @throws InvalidKey
  */
 public function __construct(HiddenString $keyMaterial)
 {
     if (CryptoUtil::safeStrlen($keyMaterial->getString()) !== \Sodium\CRYPTO_AUTH_KEYBYTES) {
         throw new InvalidKey('Authentication key must be CRYPTO_AUTH_KEYBYTES bytes long');
     }
     parent::__construct($keyMaterial);
     $this->isSigningKey = true;
 }