/** * @param HiddenString $keyMaterial - The actual key data * @throws InvalidKey */ public function __construct(HiddenString $keyMaterial) { if (CryptoUtil::safeStrlen($keyMaterial->getString()) !== \Sodium\CRYPTO_BOX_SECRETKEYBYTES) { throw new InvalidKey('Encryption secret key must be CRYPTO_BOX_SECRETKEYBYTES bytes long'); } parent::__construct($keyMaterial); }
/** * @param string $keyMaterial - The actual key data * @param bool $signing - Is this a signing key? */ public function __construct(string $keyMaterial = '', ...$args) { if (CryptoUtil::safeStrlen($keyMaterial) !== \Sodium\CRYPTO_SIGN_SECRETKEYBYTES) { throw new InvalidKey('Signature secret key must be CRYPTO_SIGN_SECRETKEYBYTES bytes long'); } parent::__construct($keyMaterial, true); }
/** * @param HiddenString $keyMaterial - The actual key data * @throws InvalidKey */ public function __construct(HiddenString $keyMaterial) { if (CryptoUtil::safeStrlen($keyMaterial->getString()) !== \Sodium\CRYPTO_SIGN_SECRETKEYBYTES) { throw new InvalidKey('Signature secret key must be CRYPTO_SIGN_SECRETKEYBYTES bytes long'); } parent::__construct($keyMaterial); $this->isSigningKey = true; }