Exemplo n.º 1
0
 function testHash()
 {
     $data = array(603604794, -1992726684, 1050533917, -2049282207, 378026414, -38779290, -25761049, -551699343);
     $result = array(31505934, 205022762, -1518051379, -194223946, 2000539338, 1835853132, -99974255, 477201633);
     $this->assertEqual(Sha256::hash($data), $result);
 }
Exemplo n.º 2
0
 /**
  * @test
  *
  * @covers Lcobucci\JWT\Signer\Ecdsa\Sha256::getAlgorithm
  */
 public function getAlgorithmMustBeCorrect()
 {
     $signer = new Sha256();
     $this->assertEquals(OPENSSL_ALGO_SHA256, $signer->getAlgorithm());
 }
Exemplo n.º 3
0
 function find($iterations = 0xffffffff)
 {
     $ret = null;
     while ($this->nonce < 0xffffffff && $iterations--) {
         $this->data[3] = $this->nonce;
         $h0 = Sha256::hash($this->midstate, $this->data);
         for ($j = 0; $j < 8; $j++) {
             $this->hash1[$j] = $h0[$j];
         }
         $h = Sha256::hash($this->hash1);
         if ($h[7] == 0) {
             foreach ($this->data as $d) {
                 $this->half[] = $d;
             }
             $ret = $this->half;
             break;
         }
         $this->nonce++;
         #if ($this->nonce % 100 == 0) {
         #	echo '|' . $this->nonce . '|';
         #	if ($this->nonce % 1000 === 0) echo '<br>';
         #	ob_flush();
         #	flush();
         #}
     }
     return $ret;
 }
Exemplo n.º 4
0
 /**
  * @test
  *
  * @covers \Lcobucci\JWT\Signer\Hmac\Sha256::getAlgorithm
  */
 public function getAlgorithmMustBeCorrect()
 {
     $signer = new Sha256();
     self::assertEquals('sha256', $signer->getAlgorithm());
 }
Exemplo n.º 5
0
 /**
  * @test
  *
  * @uses Lcobucci\JWT\Signer\Ecdsa
  * @uses Lcobucci\JWT\Signer\Ecdsa\KeyParser
  *
  * @covers Lcobucci\JWT\Signer\Ecdsa\Sha256::getSignatureLength
  */
 public function getSignatureLengthMustBeCorrect()
 {
     $signer = new Sha256();
     $this->assertEquals(64, $signer->getSignatureLength());
 }
Exemplo n.º 6
0
 /**
  * @test
  *
  * @covers \Lcobucci\JWT\Signer\Ecdsa::create
  * @covers \Lcobucci\JWT\Signer\Ecdsa::__construct
  *
  * @uses \Lcobucci\JWT\Signer\Ecdsa\EccAdapter
  * @uses \Lcobucci\JWT\Signer\Ecdsa\KeyParser
  * @uses \Lcobucci\JWT\Signer\Ecdsa\SignatureSerializer
  */
 public function createShouldReturnAValidInstance()
 {
     self::assertInstanceOf(Sha256::class, Sha256::create());
 }