@Override public byte[] getSignature() { try { byte[] dataToSign = outputStream.toByteArray(); outputStream.reset(); return cryptService.getIdentity(identityId).sign(mechanism, null, dataToSign); } catch (P11TokenException ex) { LogUtil.warn(LOG, ex); throw new RuntimeCryptoException("P11TokenException: " + ex.getMessage()); } catch (Throwable th) { LogUtil.warn(LOG, th); throw new RuntimeCryptoException(th.getClass().getName() + ": " + th.getMessage()); } }
public static P11RSAKeyParameter getInstance(P11CryptService p11CryptService, P11IdentityId identityId) throws InvalidKeyException { Args.notNull(p11CryptService, "p11CryptService"); Args.notNull(identityId, "identityId"); RSAPublicKey key; try { key = (RSAPublicKey) p11CryptService.getIdentity(identityId).getPublicKey(); } catch (P11TokenException ex) { throw new InvalidKeyException(ex.getMessage(), ex); } BigInteger modulus = key.getModulus(); BigInteger publicExponent = key.getPublicExponent(); return new P11RSAKeyParameter(p11CryptService, identityId, modulus, publicExponent); }
@Override public byte[] processBlock(byte[] in, int inOff, int len) throws InvalidCipherTextException { byte[] content = new byte[getInputBlockSize()]; System.arraycopy(in, inOff, content, content.length - len, len); try { P11Identity identity = param.getP11CryptService().getIdentity(param.getIdentityId()); return identity.sign(PKCS11Constants.CKM_RSA_X_509, null, content); } catch (P11TokenException ex) { throw new InvalidCipherTextException(ex.getMessage(), ex); } }
@Override public byte[] getSignature() { if (outputStream instanceof PSSSignerOutputStream) { try { return ((PSSSignerOutputStream) outputStream).generateSignature(); } catch (CryptoException ex) { LogUtil.warn(LOG, ex); throw new RuntimeCryptoException("CryptoException: " + ex.getMessage()); } } byte[] dataToSign; if (outputStream instanceof ByteArrayOutputStream) { dataToSign = ((ByteArrayOutputStream) outputStream).toByteArray(); } else { dataToSign = ((DigestOutputStream) outputStream).digest(); } try { return cryptService.getIdentity(identityId).sign(mechanism, parameters, dataToSign); } catch (P11TokenException ex) { LogUtil.warn(LOG, ex, "could not sign"); throw new RuntimeCryptoException("SignerException: " + ex.getMessage()); } }
publicKey.getEcdsaParams().setByteArrayValue(ecParams.getEncoded()); } catch (IOException ex2) { throw new P11TokenException(ex.getMessage(), ex);