public function verifySignature(array $request_data, $ip_address = '127.0.0.1')
    {
        if (empty($request_data['sig'])) {
            throw new SignatureException('No signature was present on the request data');
        }

        $base64_signature = $request_data['sig'];

        // Get the data that needs to be verified.
        unset($request_data['sig']);
        $data_to_verify = http_build_query($request_data);

        // Verify the signature
        $verify = $this->keypair->verify($data_to_verify, $base64_signature);
        if (! $verify) {
            throw new SignatureException('The signature on the request data did not verify');
        }

        // Verify the client nonce if present.  This will normally be created at
        // the time that the signature is created.
        if (empty($request_data['cnonce'])) {
            throw new NonceException('No client nonce was present in signature verification');
        }
        $this->verifyClientNonce($request_data['cnonce']);

        // Verify the server nonce if present.  Note that the client must request
        // this.
        if (! empty($request_data['snonce'])) {
            $this->verifyServerNonce($request_data['snonce'], $ip_address);
        }
    }
public function verifySignature(array $request_data, $ip_address = '127.0.0.1')
    {
        if (empty($request_data['sig'])) {
            throw new SignatureException('No signature was present on the request data');
        }

        $base64_signature = $request_data['sig'];

        // Get the data that needs to be verified.
        unset($request_data['sig']);
        $data_to_verify = http_build_query($request_data);

        // Verify the signature
        $verify = $this->keypair->verify($data_to_verify, $base64_signature);
        if (! $verify) {
            throw new SignatureException('The signature on the request data did not verify');
        }

        // Verify the client nonce if present.  This will normally be created at
        // the time that the signature is created.
        if (empty($request_data['cnonce'])) {
            throw new NonceException('No client nonce was present in signature verification');
        }
        $this->verifyClientNonce($request_data['cnonce']);

        // Verify the server nonce if present.  Note that the client must request
        // this.
        if (! empty($request_data['snonce'])) {
            $this->verifyServerNonce($request_data['snonce'], $ip_address);
        }
    }
public function verifySignature ( array $ request_data , $ ip_address = '127.0.0.1' ) { if ( empty ( $ request_data [ 'sig' ] ) ) { throw new SignatureException ( 'No signature was present on the request data' ) ; } $ base64_signature = $ request_data [ 'sig' ] ; // Get the data that needs to be verified. unset ( $ request_data [ 'sig' ] ) ; $ data_to_verify = http_build_query ( $ request_data ) ; // Verify the signature $ verify = $ this -> keypair -> verify ( $ data_to_verify , $ base64_signature ) ; if ( ! $ verify ) { throw new SignatureException ( 'The signature on the request data did not verify' ) ; } // Verify the client nonce if present.  This will normally be created at // the time that the signature is created. if ( empty ( $ request_data [ 'cnonce' ] ) ) { throw new NonceException ( 'No client nonce was present in signature verification' ) ; } $ this -> verifyClientNonce ( $ request_data [ 'cnonce' ] ) ; // Verify the server nonce if present.  Note that the client must request // this. if ( ! empty ( $ request_data [ 'snonce' ] ) ) { $ this -> verifyServerNonce ( $ request_data [ 'snonce' ] , $ ip_address ) ; } }
Verify a signature on the request URL, the request data and the key.

Verifying the signature requires knowledge of the client's public key, which
can be made public knowledge.  It does not require knowledge of the client's
private key, which should be known only to the client.  Each client should have
a unique public/private key pair.  See the KeyPair class for generating public/
private key pairs.

The request data *should* contain a nonce generated on the client and it
*should* contain a nonce generated on the server.  The client nonce should
never have been used before (generated and used once, then discarded), and
the server nonce should have been used exactly once before (generated by
the server, used once and then discarded).  These nonces ensure that the
request data is unique even for identical requests.

An exception is thrown if the signature did not verify or was not present.

@param array  $request_data
@param string $ip_address

@throws SignatureException
@throws NonceException

@return void
Verify a signature on the request URL the request data and the key .