New session per operation or cache sessions?

11/22/2017 2:53:54 PM
Gravatar
Total Posts 3

New session per operation or cache sessions?

hi,

currently in my application I am opening a new session for each operation:
- Login to the HSM
- Get the active slot
- Open a session with a token from that slot
- Do the operation f.e. encryption
- Close the session

I am wondering if this is the best way how to do it.

An alternative would be to 
- Login to the HSM only once + get active slot only once
- Open a session with a token from that slot + cache the session
- Reuse the cached session for each operation (encryption, decryption, signing)

But I also have to initialize the session different per operation type f.e. call "session.EncryptInit(...)" if I want to do encryption operations.
So in general - does it make sense to cache session or should one open a new session for each operation?

br,
Hannes
 

1/25/2018 6:28:49 PM
Gravatar
Total Posts 3
Felipe Venâncio

Re: New session per operation or cache sessions?

hi Hannes,

I have the same question! I maked it, open a new session for each operation.

br,


Venâncio (BR)

1/29/2018 8:13:01 AM
Gravatar
Total Posts 300
Ugo Chirico http://www.ugochirico.com

Re: New session per operation or cache sessions?

You can get a session object once and then reuse such an object for all subsequent operations such as EncryptInit, SignInit and so on

Consider that NCryptoki is a wrapper to a PKCS#11 module so it supports all programming models supported by PKCS#11 specifications. I suggest to read the PKCS#11 specifications

 

1/29/2018 6:35:13 PM
Gravatar
Total Posts 3
Felipe Venâncio

Re: New session per operation or cache sessions?

Hi! Ugo,

When I reuse such an object for all subsequent operations, my application receive the code 144 (OPERATION ACTIVE).

Do you understand?

Thanks.

1/29/2018 7:11:55 PM
Gravatar
Total Posts 3
Felipe Venâncio

Re: New session per operation or cache sessions?

Ugo,

Anything related to balanced server?

br,

Venâncio