Usingstore_foreign_public_key

Hi,
I am trying to store a public key using the store_foreign_public_key method but I always receives an error message :
(File “/usr/local/lib/python3.5/dist-packages/zymkey/module.py”, line 618, in store_foreign_public_key
raise AssertionError(‘bad return code %d’ % ret)
AssertionError: bad return code -1)

I am trying to store one of the public key of HSM4 in the HSM6
I used secp256r1 as the key type
could you please give an example of how to use this method

The easiest way is to save the HSM4 key directly to a binary file, copy that file to the HSM6 and read in the binary file.

HSM4 side:

#!/usr/bin/python3
import zymkey

# Get the public key from slot 0 and save it in a file
pub_key_file = '/tmp/pub_key_slot0'
slot = 0
key = zymkey.client.get_public_key(slot)
with open(pub_key_file, "wb") as f:
    f.write(key)

copy /tmp/pub_key_slot0 over to the HSM6 PI

HSM6 side:

#!/usr/bin/python3
import zymkey

key_file = "/tmp/pub_key_slot0"
key = open(key_file, "rb").read()
# Store the key in the foreign key store
foreign_slot = zymkey.client.store_foreign_public_key('secp256r1', key)