Exemplo n.º 1
0
Arquivo: JWE.php Projeto: nask0/jose
 private function cipher()
 {
     switch ($this->header['enc']) {
         case 'A128GCM':
         case 'A256GCM':
             throw new JOSE_Exception_UnexpectedAlgorithm('Algorithm not supported');
         case 'A128CBC-HS256':
         case 'A256CBC-HS512':
             $cipher = new Crypt_AES(CRYPT_AES_MODE_CBC);
             break;
         default:
             throw new JOSE_Exception_UnexpectedAlgorithm('Unknown algorithm');
     }
     switch ($this->header['enc']) {
         case 'A128GCM':
         case 'A128CBC-HS256':
             $cipher->setBlockLength(128);
             break;
         case 'A256GCM':
         case 'A256CBC-HS512':
             $cipher->setBlockLength(256);
             break;
         default:
             throw new JOSE_Exception_UnexpectedAlgorithm('Unknown algorithm');
     }
     return $cipher;
 }