Example #1
0
 /**
  * {@inheritdoc}
  */
 public function getCEK(JWKInterface $key, array $header)
 {
     if ('dir' !== $key->getKeyType()) {
         throw new \InvalidArgumentException('The key is not valid');
     }
     return Base64Url::decode($key->getValue('dir'));
 }
Example #2
0
 /**
  * @param JWKInterface $key
  */
 protected function checkKey(JWKInterface $key)
 {
     if ('oct' !== $key->getKeyType() || null === $key->getValue('k')) {
         throw new \InvalidArgumentException('The key is not valid');
     }
 }
Example #3
0
 /**
  * @param JWKInterface $key
  *
  * @throws \Exception
  *
  * @return \Mdanter\Ecc\Primitives\GeneratorPoint
  */
 private function getGenerator(JWKInterface $key)
 {
     $crv = $key->getValue('crv');
     switch ($crv) {
         case 'P-256':
             return EccFactory::getNistCurves()->generator256();
         case 'P-384':
             return EccFactory::getNistCurves()->generator384();
         case 'P-521':
             return EccFactory::getNistCurves()->generator521();
         default:
             throw new \Exception("Curve {$crv} is not supported");
     }
 }