function test_validate_priv_key_invalid() { $this->setExpectedException('invalid_private_key_exception'); validate_priv_key('invalid_public_key'); }
function send_ping($url, $type, $user, $pub_key, $priv_key, $data, $return_xml = false) { validate_username($user); validate_pub_key($pub_key); validate_priv_key($priv_key); // Genereate signature $signature_str = PROTOCOL_VERSION . $type . $user . $data; $pkeyid = @openssl_get_privatekey($priv_key); @openssl_sign($signature_str, $signature, $pkeyid); @openssl_free_key($pkeyid); // Generate XML $ping_XML = new SimpleXMLElement("<ping></ping>"); $ping_XML->addChild('protocol_version', PROTOCOL_VERSION); $ping_XML->addChild('user_pub_key', base64_encode($pub_key)); $ping_XML->addChild('data_sig', base64_encode($signature)); $ping_XML->addChild('type', base64_encode($type)); $ping_XML->addChild('user', base64_encode($user)); $ping_XML->addChild('data', base64_encode($data)); $ping_XML = $ping_XML->asXML(); if($return_xml == true) return $ping_XML; // send ping XML using POST return $this->http_request($url, array('data' => $ping_XML)); }