makdimka077 / xades4j

Automatically exported from code.google.com/p/xades4j
GNU Lesser General Public License v3.0
0 stars 0 forks source link

Using different slot from HSM for each call or Re-initialize the HSM #87

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hello, 

I am signing xml files successfully, but I have more then one slots and I need 
to use one of them for each call. 

If I close the application and re-run it works and get correct slot from HSM,
But It is running on Tcp service therefore can not re-run for each signature 
request.

My question is, how can I re-initialize or use different slots for each call?

Main signer code: 
main_signer.getSigner(...

//getSigner Method-----
ptccKeyingDataProv = new 
PKCS11KeyStoreKeyingDataProvider("C:\\Windows\\System32\\cryptoki.dll", "", 
slot, new FirstCertificateSelector(), pass, entry, false);

 SignerBES main_signer = (SignerBES) new XadesBesSigningProfile1(ptccKeyingDataProv).withAlgorithmsProviderEx(PtCcAlgorithmsProvider.class).withBasicSignatureOptionsProvider(BasicOptionsProvider.class).newSigner();

...
...
main_signer.sign(dataObjs, elemToSign, 
SignatureAppendingStrategies.AsLastChild);

Platform
Win 7 64 bit 
Java 8 

Thank You! 

Original issue reported on code.google.com by hak...@gmail.com on 1 May 2014 at 7:55

GoogleCodeExporter commented 9 years ago
PKCS11KeyStoreKeyingDataProvider initializes a KeyStore based on a provider 
configured with the slot. Changing the slot would require to reconfigure the 
KeyStore and would probably be an explicit operation (dedicated method). None 
of this is currently supported, i.e. a PKCS11KeyStoreKeyingDataProvider 
instance will only work with a given slot.

You probably could implement a KeyingDataProvider which is a composite around 
multiple PKCS11KeyStoreKeyingDataProvider, each one configured for its own 
slot. 

Another option is to redefine the KeyingDataProvider on the profile and use a 
new signer on each operation. This one sounds worst.

Original comment by luis.fgoncalv on 11 May 2014 at 9:58

GoogleCodeExporter commented 9 years ago
Any comments?

Original comment by luis.fgoncalv on 13 May 2014 at 8:05