Hi Bob,
Thanks for your response. So, running the code below I get the following error:
import zymkey
data = bytearray(‘hello world!’)
encrypted_payload = zymkey.client.lock(data)
payload_sig = zymkey.client.sign(encrypted_payload)
I get the following error:
Traceback (most recent call last):
File “encrypt_test.py”, line 5, in
payload_sig = zymkey.client.sign(encrypted_payload)
File “/usr/local/lib/python2.7/dist-packages/zymkey/module.py”, line 340, in sign
sha256.update(src.encode(‘utf-8’))
AttributeError: ‘bytearray’ object has no attribute ‘encode’
When I change the var ‘data’ to just a string, I get the following error:
File “encrypt_test.py”, line 4, in
encrypted_payload = zymkey.client.lock(data)
File “/usr/local/lib/python2.7/dist-packages/zymkey/module.py”, line 213, in lock
raise AssertionError(‘bad return code %d’ % ret)
AssertionError: bad return code -2
Also running the below code I found on the community website,
import zkpkcs11
# Initialise our PKCS#11 library
lib = pkcs11.lib(os.environ[‘PKCS11_MODULE’])
token = lib.get_token(token_label=‘Zymkey’)
data = b’INPUT DATA’
# Open a session on our token
with token.open(user_pin=‘123456’) as session:
# Generate an AES key in this session
key = session.generate_key(pkcs11.KeyType.AES, 256)
# Get an initialisation vector
iv = session.generate_random(128) # AES blocks are fixed at 128 bits
# Encrypt our data
crypttext = key.encrypt(data, mechanism_param=iv)
I get the following error:
Traceback (most recent call last):
File “aes_gen.py”, line 1, in
import zkpkcs11
ImportError: No module named zkpkcs11
I’m quite familiar with Python, but cannot understanding the errors.
Thanks and regards
Abdul