def server_identity_is_verified(self):
        """ GPGAuth stage0 """
        # Encrypt a uuid token for the server
        server_verify_token = self.gpg.encrypt(self._nonce0,
                                               self.server_fingerprint, always_trust=True)
        if not server_verify_token.ok:
            raise GPGAuthStage0Exception(
                'Encryption of the nonce0 (%s) '
                'to the server fingerprint (%s) failed.' %
                (self._nonce0, self.server_fingerprint)
            )

        server_verify_response = post_server_verify_token(
            self,
            keyid=self.user_fingerprint,
            server_verify_token=str(server_verify_token)
        )

        if not check_server_verify_response(server_verify_response):
            raise GPGAuthStage0Exception("Verify endpoint wrongly formatted")

        if server_verify_response.headers.get('X-GPGAuth-Verify-Response') != self._nonce0:
            raise GPGAuthStage0Exception(
                'The server decrypted something different than what we sent '
                '(%s <> %s)' %
                (server_verify_response.headers.get('X-GPGAuth-Verify-Response'), self._nonce0))
        logger.info('server_identity_is_verified: OK')
        return True
def server_identity_is_verified ( self ) : server_verify_token = self . gpg . encrypt ( self . _nonce0 , self . server_fingerprint , always_trust = True ) if not server_verify_token . ok : raise GPGAuthStage0Exception ( 'Encryption of the nonce0 (%s) ' 'to the server fingerprint (%s) failed.' % ( self . _nonce0 , self . server_fingerprint ) ) server_verify_response = post_server_verify_token ( self , keyid = self . user_fingerprint , server_verify_token = str ( server_verify_token ) ) if not check_server_verify_response ( server_verify_response ) : raise GPGAuthStage0Exception ( "Verify endpoint wrongly formatted" ) if server_verify_response . headers . get ( 'X-GPGAuth-Verify-Response' ) != self . _nonce0 : raise GPGAuthStage0Exception ( 'The server decrypted something different than what we sent ' '(%s <> %s)' % ( server_verify_response . headers . get ( 'X-GPGAuth-Verify-Response' ) , self . _nonce0 ) ) logger . info ( 'server_identity_is_verified: OK' ) return True
GPGAuth stage0