Beispiel #1
0
 /**
  * @param \Jose\JWKInterface $receiver_key
  * @param string             $encrypted_cek
  * @param int                $encryption_key_length
  * @param array              $complete_header
  *
  * @return string
  */
 public function unwrapAgreementKey(JWKInterface $receiver_key, $encrypted_cek, $encryption_key_length, array $complete_header)
 {
     $ecdh_es = new ECDHES();
     $agreement_key = $ecdh_es->getAgreementKey($encryption_key_length, $receiver_key, null, $complete_header);
     $wrapper = $this->getWrapper();
     return $wrapper->unwrap($agreement_key, $encrypted_cek);
 }
 /**
  * @see https://tools.ietf.org/html/rfc7518#appendix-C
  */
 public function testGetAgreementKey()
 {
     $receiver = new JWK(['kty' => 'EC', 'crv' => 'P-256', 'x' => 'weNJy2HscCSM6AEDTDg04biOvhFhyyWvOHQfeF_PxMQ', 'y' => 'e8lnCO-AlStT-NJVX-crhB7QRYhiix03illJOVAOyck', 'd' => 'VEmDZpDXXK8p8N0Cndsxs924q6nS1RXFASRl6BfUqdw']);
     $sender = new JWK(['kty' => 'EC', 'crv' => 'P-256', 'x' => 'gI0GAILBdu7T53akrFmMyGcsF3n5dO7MmwNBHKW5SV0', 'y' => 'SLW_xSffzlPWrHEVI30DHM_4egVwt3NQqeUD7nMFpps', 'd' => '0_NxaRPUMQoAJt50Gz8YiTr8gRTwyEaCumd']);
     $header = ['enc' => 'A128GCM', 'apu' => 'QWxpY2U', 'apv' => 'Qm9i'];
     $expected = Base64Url::decode('9FdsD3uzmeK4ImyoWpP5PA');
     $ecdh_es = new ECDHES();
     $additional_header_values = [];
     $this->assertEquals($expected, $ecdh_es->getAgreementKey(128, $sender, $receiver, $header, $additional_header_values));
     $this->assertTrue(array_key_exists('epk', $additional_header_values));
     $this->assertTrue(array_key_exists('kty', $additional_header_values['epk']));
     $this->assertTrue(array_key_exists('crv', $additional_header_values['epk']));
     $this->assertTrue(array_key_exists('x', $additional_header_values['epk']));
     $this->assertTrue(array_key_exists('y', $additional_header_values['epk']));
 }