plugins/yubikey/corelib.php
changeset 4 73aecd46bb56
parent 3 d0fe7acaf0e8
child 9 65965da01c41
equal deleted inserted replaced
3:d0fe7acaf0e8 4:73aecd46bb56
    83         'success' => false,
    83         'success' => false,
    84         'error' => 'http_response_error'
    84         'error' => 'http_response_error'
    85       );
    85       );
    86   }
    86   }
    87   $response = trim($response);
    87   $response = trim($response);
    88   $response_nosig = preg_replace('/^h=(.+?)$/m', '', $response);
    88   if ( !preg_match_all('/^([a-z0-9_]+)=(.*?)\r?$/m', $response, $matches) )
    89   if ( !preg_match_all('/^([a-z0-9_]+)=(.*?)$/m', $response, $matches) )
       
    90   {
    89   {
    91     return array(
    90     return array(
    92         'success' => false,
    91         'success' => false,
    93         'error' => 'malformed_response'
    92         'error' => 'malformed_response'
    94       );
    93       );
   143 function yubikey_sign($arr)
   142 function yubikey_sign($arr)
   144 {
   143 {
   145   static $api_key = false;
   144   static $api_key = false;
   146   
   145   
   147   ksort($arr);
   146   ksort($arr);
   148   if ( isset($arr['h']) )
       
   149     unset($arr['h']);
       
   150   
   147   
   151   if ( !$api_key )
   148   if ( !$api_key )
   152   {
   149   {
   153     $api_key = getConfig('yubikey_api_key');
   150     $api_key = getConfig('yubikey_api_key');
   154     $api_key = hexencode(base64_decode($api_key), '', '');
   151     $api_key = hexencode(base64_decode($api_key), '', '');
   155   }
   152   }
       
   153   
       
   154   if ( isset($arr['h']) )
       
   155     unset($arr['h']);
   156   
   156   
   157   $req = array();
   157   $req = array();
   158   foreach ( $arr as $key => $val )
   158   foreach ( $arr as $key => $val )
   159   {
   159   {
   160     $req[] = "$key=$val";
   160     $req[] = "$key=$val";