Exemplo n.º 1
0
 /**
  * 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();
 }
Exemplo n.º 2
0
 /**
  * @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);
 }
Exemplo n.º 3
0
 public function getVectors()
 {
     $math = MathAdapterFactory::getAdapter();
     return [[$math, 1, '04'], [$math, 1, '41'], [$math, 4, '0488b21e']];
 }
Exemplo n.º 4
0
 /**
  * @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));
 }
Exemplo n.º 5
0
 /**
  * @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);
 }
Exemplo n.º 6
0
 /**
  *
  * @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);
 }
Exemplo n.º 7
0
 /**
  * @return SecgCurve
  */
 private static function getSecpFactory()
 {
     return new SecgCurve(MathAdapterFactory::getAdapter());
 }
Exemplo n.º 8
0
 /**
  * @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));
 }
Exemplo n.º 9
0
 /**
  * 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);
 }
Exemplo n.º 10
0
 /**
  * @param $content
  * @return int|string
  */
 private function hash($content)
 {
     $messages = new MessageFactory(MathAdapterFactory::getAdapter());
     return $messages->plaintext($content, 'sha256')->getHash();
 }