Good Day All,
I'm having problem to develop a sample signature
application.
I can load the keystore and extract its objects
(certificates, public key
and private key) but when i try to sign something, is thrown
an exception
InvalidKeyException
i'm using de code below
p = new PKCS11Provider("dkck201.dll");
//p = new PKCS11Provider("eTpkcs11.dll");
Security.addProvider(p);
lps = PKCS11Slot.enumerateSlots(p);
p11Session = null;
String senha = null;
BufferedReader input = new BufferedReader(new
InputStreamReader(System.in));
for (Iterator<PKCS11Slot> iter = lps.iterator();
iter.hasNext()) {
p11Slot = iter.next();
b = p11Slot.isTokenPresent();
if (b) {
System.out.println(p11Slot.getTokenSerialNumber());
p11Session = PKCS11Session.open(p11Slot,
PKCS11Session.OPEN_MODE_READ_ONLY);
senha = input.readLine();
p11Session.loginUser(senha.toCharArray());
List<PKCS11PrivateKey> pkeys = PKCS11PrivateKey
.getPrivateKeys(p11Session);
byte[] sb = null;
for (PKCS11PrivateKey key : pkeys) {
Signature s =
Signature.getInstance("SHA1WithRSA");
s.initSign(key);
s.update("teste".getBytes());
sb = s.sign();
System.out.println(new String(sb));
}
}
}
Thanks in advance
De La Croix
--
View this message in context: http://ww
w.nabble.com/InvalidKeyException%3A-Neither-a-public-nor-a-p
rivate-key-tf3186197.html#a8843270
Sent from the OpenSC - User mailing list archive at
Nabble.com.
_______________________________________________
opensc-user mailing list
opensc-user lists.opensc-project.org
http://www.opensc-project.org/mailman/listinfo/opensc-
user
|