/** * PKCS8Serializer constructor. * @param DerPrivateKeySerializer|null $serializer * @param GmpMathInterface|null $adapter */ public function __construct(DerPrivateKeySerializer $serializer = null, GmpMathInterface $adapter = null) { $this->serializer = $serializer ?: new DerPrivateKeySerializer(); $this->adapter = $adapter ?: MathAdapterFactory::getAdapter(); $this->crypter = new Crypter(); $this->digester = new Digester(); $this->pkcs5 = new Pkcs5v2Serializer(); }
/** * @param PrivateKeyInterface $privateKey * @param $messageHash * @param $algo * @param bool $debug * @return DebugDecorator|RandomNumberGeneratorInterface */ public static function getHmacRandomGenerator(PrivateKeyInterface $privateKey, $messageHash, $algo, $debug = false) { return self::wrapAdapter(new HmacRandomNumberGenerator(MathAdapterFactory::getAdapter($debug), $privateKey, $messageHash, $algo), 'rfc6979', $debug); }
public function getVectors() { $math = MathAdapterFactory::getAdapter(); return [[$math, 1, '04'], [$math, 1, '41'], [$math, 4, '0488b21e']]; }
/** * @param InputInterface $input * @param OutputInterface $output * @return void */ protected function execute(InputInterface $input, OutputInterface $output) { $hex = $input->getArgument('dec'); $adapter = MathAdapterFactory::getAdapter(); $output->writeln($adapter->decHex($hex)); }
/** * @param MathAdapterInterface $adapter * @param PemPublicKeySerializer $pubKeySerializer */ public function __construct(MathAdapterInterface $adapter = null, PemPublicKeySerializer $pubKeySerializer = null) { $this->adapter = $adapter ?: MathAdapterFactory::getAdapter(); $this->pubKeySerializer = $pubKeySerializer ?: new DerPublicKeySerializer($this->adapter); }
/** * * @param MathAdapterInterface $adapter */ public function __construct(MathAdapterInterface $adapter = null) { $this->adapter = $adapter ?: MathAdapterFactory::getAdapter(); $this->formatter = new Formatter($this->adapter); $this->parser = new Parser($this->adapter); }
/** * @return SecgCurve */ private static function getSecpFactory() { return new SecgCurve(MathAdapterFactory::getAdapter()); }
/** * @param InputInterface $input * @param OutputInterface $output */ protected function execute(InputInterface $input, OutputInterface $output) { $hex = str_replace(' ', '', $input->getArgument('hex')); $adapter = MathAdapterFactory::getAdapter(); $output->writeln($adapter->hexDec($hex)); }
/** * Selects and creates the most appropriate adapter for the running environment. * * @param $debug [optional] Set to true to get a trace of all mathematical operations * * @throws \RuntimeException * @return MathAdapterInterface */ public static function getAdapter($debug = false) { return MathAdapterFactory::getAdapter($debug); }
/** * @param $content * @return int|string */ private function hash($content) { $messages = new MessageFactory(MathAdapterFactory::getAdapter()); return $messages->plaintext($content, 'sha256')->getHash(); }