Exemple #1
0
 private void cancelOperation() {
   token.ensureValid();
   if (initialized == false) {
     return;
   }
   initialized = false;
   if ((session == null) || (token.explicitCancel == false)) {
     return;
   }
   if (session.hasObjects() == false) {
     session = token.killSession(session);
     return;
   }
   try {
     PKCS11 p11 = token.p11;
     int inLen = maxInputSize;
     int outLen = buffer.length;
     switch (mode) {
       case MODE_ENCRYPT:
         p11.C_Encrypt(session.id(), buffer, 0, inLen, buffer, 0, outLen);
         break;
       case MODE_DECRYPT:
         p11.C_Decrypt(session.id(), buffer, 0, inLen, buffer, 0, outLen);
         break;
       case MODE_SIGN:
         byte[] tmpBuffer = new byte[maxInputSize];
         p11.C_Sign(session.id(), tmpBuffer);
         break;
       case MODE_VERIFY:
         p11.C_VerifyRecover(session.id(), buffer, 0, inLen, buffer, 0, outLen);
         break;
       default:
         throw new ProviderException("internal error");
     }
   } catch (PKCS11Exception e) {
     // XXX ensure this always works, ignore error
   }
 }
Exemple #2
0
 private void ensureInitialized() throws PKCS11Exception {
   token.ensureValid();
   if (initialized == false) {
     initialize();
   }
 }