def test_verify(self):
        addr = random_name(34)
        signup_info = \
            poet.create_signup_info(
                originator_public_key_hash=self._originator_public_key_hash,
                nonce=poet.NULL_IDENTIFIER)
        sealed_data = signup_info.sealed_signup_data

        wait_cert = self.get_wait_cert(sealed_data, addr=addr)
        poet.verify_wait_certificate(
            wait_cert,
            signup_info.poet_public_key)

        # Bad wait certificate types
        with self.assertRaises(TypeError):
            poet.verify_wait_certificate([], signup_info.poet_public_key)

        with self.assertRaises(TypeError):
            poet.verify_wait_certificate({}, signup_info.poet_public_key)

        with self.assertRaises(ValueError):
            poet.verify_wait_certificate(None, signup_info.poet_public_key)

        with self.assertRaises(TypeError):
            poet.verify_wait_certificate("3", signup_info.poet_public_key)

        with self.assertRaises(TypeError):
            poet.verify_wait_certificate(3, signup_info.poet_public_key)

        # Bad public key types
        with self.assertRaises(TypeError):
            poet.verify_wait_certificate(wait_cert, [])

        with self.assertRaises(TypeError):
            poet.verify_wait_certificate(wait_cert, {})

        with self.assertRaises(ValueError):
            poet.verify_wait_certificate(wait_cert, None)

        with self.assertRaises(TypeError):
            poet.verify_wait_certificate(wait_cert, 3)

        # A different public key
        other_signup_info = \
            poet.create_signup_info(
                originator_public_key_hash=create_random_public_key_hash(),
                nonce=poet.NULL_IDENTIFIER)

        with self.assertRaises(ValueError):
            poet.verify_wait_certificate(
                wait_cert,
                other_signup_info.poet_public_key)
Пример #2
0
    def setUpClass(cls):

        enclave_path = \
            os.path.join(
                os.path.abspath(
                    os.path.dirname(
                        os.path.relpath(__file__))),
                '..',
                '..',
                'sawtooth_poet_sgx',
                'poet_enclave_sgx')
        cls.proxy_proc = \
            subprocess.Popen(
                args=['python3', 'ias_proxy.py'],
                cwd=enclave_path)
        print('Launched proxy server on pid: ' + str(cls.proxy_proc.pid))

        # Depending upon timing, the test can try to contact the proxy before
        # it is ready to accept connections.  So, until the proxy is ready
        # block the tests from progressing.
        # Note - if IAS proxy port changes, change this also
        while True:
            sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            if sock.connect_ex(('localhost', 8899)) == 0:
                sock.close()
                break
            sock.close()
            print('IAS proxy not ready to accept connections')
            time.sleep(1)

        cls._mock_toml_config = {
            'spid':
            os.environ['POET_ENCLAVE_SPID'],
            'ias_url':
            'http://localhost:8899',
            'spid_cert_file':
            os.path.join(get_default_path_config().config_dir,
                         'maiden-lane-poet-linkable-quotes.pem')
        }

        cls._temp_dir = tempfile.mkdtemp()

        with mock.patch(
                'sawtooth_poet_sgx.poet_enclave_sgx.poet_enclave.open') as _:
            with mock.patch(
                    'sawtooth_poet_sgx.poet_enclave_sgx.poet_enclave.toml') \
                    as mock_toml:
                mock_toml.loads.return_value = cls._mock_toml_config
                poet.initialize(config_dir='', data_dir=cls._temp_dir)

        cls._originator_public_key_hash = create_random_public_key_hash()
Пример #3
0
    def setUpClass(cls):

        enclave_path = \
            os.path.join(
                os.path.abspath(
                    os.path.dirname(
                        os.path.relpath(__file__))),
                '..',
                '..',
                'sawtooth_poet_sgx',
                'poet_enclave_sgx')
        cls.proxy_proc = \
            subprocess.Popen(
                args=['python3', 'ias_proxy.py'],
                cwd=enclave_path)
        print('Launched proxy server on pid: ' + str(cls.proxy_proc.pid))

        # Depending upon timing, the test can try to contact the proxy before
        # it is ready to accept connections.  So, until the proxy is ready
        # block the tests from progressing.
        # Note - if IAS proxy port changes, change this also
        while True:
            sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            if sock.connect_ex(('localhost', 8899)) == 0:
                sock.close()
                break
            sock.close()
            print('IAS proxy not ready to accept connections')
            time.sleep(1)

        cls._mock_toml_config = {
            'spid': os.environ['POET_ENCLAVE_SPID'],
            'ias_url': 'http://localhost:8899',
            'spid_cert_file': os.path.join(
                get_default_path_config().config_dir,
                'maiden-lane-poet-linkable-quotes.pem')
        }

        cls._temp_dir = tempfile.mkdtemp()

        with mock.patch(
                'sawtooth_poet_sgx.poet_enclave_sgx.poet_enclave.open') as _:
            with mock.patch(
                    'sawtooth_poet_sgx.poet_enclave_sgx.poet_enclave.toml') \
                    as mock_toml:
                mock_toml.loads.return_value = cls._mock_toml_config
                poet.initialize(config_dir='', data_dir=cls._temp_dir)

        cls._originator_public_key_hash = create_random_public_key_hash()
    def setUpClass(cls):
        cls._mock_toml_config = {
            'spid': os.environ['POET_ENCLAVE_SPID'],
            'ias_url': 'https://test-as.sgx.trustedservices.intel.com:443',
            'spid_cert_file': os.path.join(
                get_default_path_config().config_dir,
                'maiden-lane-poet-linkable-quotes.pem')
        }

        cls._temp_dir = tempfile.mkdtemp()

        with mock.patch(
                'sawtooth_poet_sgx.poet_enclave_sgx.poet_enclave.open') as _:
            with mock.patch(
                    'sawtooth_poet_sgx.poet_enclave_sgx.poet_enclave.toml') \
                    as mock_toml:
                mock_toml.loads.return_value = cls._mock_toml_config
                poet.initialize(config_dir='', data_dir=cls._temp_dir)

        cls._originator_public_key_hash = create_random_public_key_hash()