Skip to content

Commit

Permalink
Fix ThalesGroup#37 - bad arg for c_initialize with flags (ThalesGroup#38
Browse files Browse the repository at this point in the history
)
  • Loading branch information
astraw38 authored Oct 17, 2022
1 parent a873d91 commit 1d0b943
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
# The short X.Y version.
version = "2.6"
# The full version, including alpha/beta/rc tags.
release = "2.6.5"
release = "2.6.6"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
6 changes: 3 additions & 3 deletions pycryptoki/session_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ def c_initialize(flags=None, init_struct=None):
:returns: Cryptoki return code.
"""
if flags:
if not init_struct:
if init_struct is None:
init_struct = CK_C_INITIALIZE_ARGS()
init_struct.flags = flags
if init_struct:
init_struct_p = cast(init_struct, c_void_p)
if init_struct is not None:
init_struct_p = cast(pointer(init_struct), c_void_p)
else:
init_struct_p = None
LOG.info("Initializing Cryptoki Library")
Expand Down
2 changes: 1 addition & 1 deletion pycryptoki/string_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def pformat_pyc_args(func_args):
hex, mask passwords, and truncate args over ``PYC_MAX_ARG_LENGTH`` to that size.
:param func_args: dictionary
:return: formatted string.
:return: List of string lines
"""
log_list = []
for key, value in func_args.items():
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
description="A python wrapper around the C cryptoki library.",
author="Ashley Straw",
url="https://github.com/gemalto/pycryptoki",
version="2.6.5",
version="2.6.6",
packages=[
"pycryptoki",
"pycryptoki.cryptoki",
Expand Down
12 changes: 6 additions & 6 deletions tests/unittests/test_daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""
import logging
import os
import random

import pytest
from pycryptoki.daemon.rpyc_pycryptoki import (
Expand All @@ -28,22 +29,21 @@ def local_rpyc():
"allow_setattr": True,
"allow_delattr": True,
}
port = random.randint(10000, 65535)
server = create_server_subprocess(
server_launch,
args=(PycryptokiService, "127.0.0.1", os.getpid(), server_config),
logger=logger,
server_launch, args=(PycryptokiService, "127.0.0.1", port, server_config), logger=logger,
)
assert server.exitcode is None
assert server.is_alive()
yield
yield port
server.terminate()


class TestPycryptokiDaemon(object):
def test_simple_connect(self, local_rpyc):
client = RemotePycryptokiClient("127.0.0.1", os.getpid())
client = RemotePycryptokiClient("127.0.0.1", local_rpyc)
assert client.test_conn()

def test_attribute_delivery(self, local_rpyc):
client = RemotePycryptokiClient("127.0.0.1", os.getpid())
client = RemotePycryptokiClient("127.0.0.1", local_rpyc)
client.test_attrs(get_default_key_template(CKM_AES_KEY_GEN))
3 changes: 2 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
[tox]
envlist=clean,py27,py36,py37,py38,py39,py310,report
[testenv]
deps=pytest==3.10.1
deps=pytest==3.10.1;python_version<'3'
pytest;python_version>='3'
six
rpyc==3.4.4;python_version<='2.7'
rpyc==4.0.2;python_version>'3'
Expand Down

0 comments on commit 1d0b943

Please sign in to comment.