X-Git-Url: https://git.stricted.de/?p=GitHub%2FStricted%2Fspeedport-hybrid-php-api.git;a=blobdiff_plain;f=CryptLib%2FKey%2FSymmetric%2FGenerator%2FInternal.php;fp=CryptLib%2FKey%2FSymmetric%2FGenerator%2FInternal.php;h=3c374b4aa725b95e4890bda8a23fde2bfc55c8ab;hp=0000000000000000000000000000000000000000;hb=14d4f286d33b631a93207e4d13086c0a3bc0df12;hpb=c9e082da5cc662b64a74d3770f13d1270068678f diff --git a/CryptLib/Key/Symmetric/Generator/Internal.php b/CryptLib/Key/Symmetric/Generator/Internal.php new file mode 100644 index 0000000..3c374b4 --- /dev/null +++ b/CryptLib/Key/Symmetric/Generator/Internal.php @@ -0,0 +1,59 @@ + null, 'random' => null); + if (is_null($options['kdf'])) { + $factory = new KeyFactory(); + $options['kdf'] = $factory->getKdf('kdf3'); + } + $this->kdf = $options['kdf']; + if (is_null($options['random'])) { + $options['random'] = new RandomFactory(); + } + $this->random = $options['random']; + } + + public function __toString() { + } + + public function generate( + \CryptLib\Core\Strength $strength, + $size, + $passphrase = '' + ) { + $generator = $this->random->getGenerator($strength); + $seed = $generator->generate($size); + $key = $this->kdf->derive($seed, $size, $passphrase); + return new Raw(substr($key, 0, $size)); + } + + public function getType() { + return static::TYPE_SYMMETRIC; + } +}