Beispiel #1
0
 /**
  * @dataProvider vectors
  */
 public function testPoly1305($input, $key, $tag)
 {
     $input = pack('H*', $input);
     $key = pack('H*', $key);
     $tag = pack('H*', $tag);
     $mac = new \fpoirotte\Pssht\Poly1305($key);
     $this->assertSame($tag, $mac->mac($input));
 }
Beispiel #2
0
 public function ad($IV, $C, $A, $T)
 {
     $len = $this->header->decrypt($A, $IV, 0);
     if ($C === null && $T === null) {
         return $len;
     }
     $polyKey = $this->main->encrypt(str_repeat("", 32), $IV, 0);
     $poly = new \fpoirotte\Pssht\Poly1305($polyKey);
     if ($poly->mac($A . $C) !== $T) {
         return null;
     }
     return $this->main->decrypt($C, $IV, 1);
 }