Skip to content

Question: Encrypting/Decrypting across restarts #145

@santosh-shaastry

Description

@santosh-shaastry

Hi,

I am a newbie to SoftHSM/PKCS 11. I am trying to:

Step 1

  1. Initialize the SoftHSM module
  2. Login to access the token/slot
  3. Obtain the session
  4. Encrypt a message using the session's cipher methods as described in your README documentation
  5. Persist the encrypted value in a file/database

Step 2

  • Restart the application

Step 3

  1. Initialize the SoftHSM module
  2. Read the encrypted value from the file/database
  3. Login to access the token/slot
  4. Obtain the session
  5. Attempt to decrypt the encrypted message using the session's cipher methods as described in your README documentation

Though I am able to login successfully using the same token and seem to obtain the same session, I run into the following error when performing Buffer.concat([dec, decipher.final()]).toString();

[Pkcs11Error: CKR_GENERAL_ERROR] {
relayer_1 | method: 'crypto_final',
relayer_1 | nativeStack: ' at Error (native) crypto_final:710',
relayer_1 | code: 5
relayer_1 | }

From what I understand about the PKCS 11 Session as described in the spec, unless a session is closed/logged out the application should be able to access the same session and hence the token/slot.

Appreciate any direction, inputs and help on this one. Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions