feat: LiteHashDRBG 생성시 상세 지정

This commit is contained in:
2022-03-12 20:31:13 +09:00
parent a2498506c3
commit 7ef9e67f5d
2 changed files with 23 additions and 2 deletions
+11 -1
View File
@@ -21,9 +21,19 @@ class LiteHashDRBG implements RNG
protected string $buffer;
protected int $bufferIdx;
public function __construct(protected string $seed, protected int $stateIdx = 0)
public function __construct(protected string $seed, protected int $stateIdx = 0, int $bufferIdx = 0)
{
if($bufferIdx < 0){
throw new \InvalidArgumentException("bufferIdx {$bufferIdx} < 0");
}
if($bufferIdx >= self::BUFFER_BYTE_SIZE){
throw new \InvalidArgumentException("bufferIdx {$bufferIdx} >= ".self::BUFFER_BYTE_SIZE);
}
if($stateIdx < 0){
throw new \InvalidArgumentException("stateIdx {$stateIdx} < 0");
}
$this->genNextBlock();
$this->bufferIdx = $bufferIdx;
}
protected function genNextBlock(): void