/** * Signs the content. * @param mechanism * the mechanism * @param parameters * the parameters. Could be {@code null}. * @param content * the content to be signed. * @return the signature. * @throws XiSecurityException * if security error happens * @throws P11TokenException * if token error happens. */ public byte[] sign(long mechanism, P11Params parameters, byte[] content) throws XiSecurityException, P11TokenException { return p11CryptService.getIdentity(identityId).sign(mechanism, parameters, content); }
/** * Signs the content. * @param mechanism * the mechanism * @param parameters * the parameters. Could be {@code null}. * @param content * the content to be signed. * @return the signature. * @throws XiSecurityException * if security error happens * @throws P11TokenException * if token error happens. */ public byte[] sign(final long mechanism, final P11Params parameters, final byte[] content) throws XiSecurityException, P11TokenException { return p11CryptService.getIdentity(identityId).sign(mechanism, parameters, content); }
/** * Signs the content. * @param mechanism * the mechanism * @param parameters * the parameters. Could be {@code null}. * @param content * the content to be signed. * @return the signature. * @throws XiSecurityException * if security error happens * @throws P11TokenException * if token error happens. */ public byte[] sign(long mechanism, P11Params parameters, byte[] content) throws XiSecurityException, P11TokenException { return p11CryptService.getIdentity(identityId).sign(mechanism, parameters, content); }
private byte[] getPlainSignature() throws XiSecurityException, P11TokenException { byte[] dataToSign; if (outputStream instanceof ByteArrayOutputStream) { dataToSign = ((ByteArrayOutputStream) outputStream).toByteArray(); ((ByteArrayOutputStream) outputStream).reset(); } else { dataToSign = ((DigestOutputStream) outputStream).digest(); ((DigestOutputStream) outputStream).reset(); } return cryptService.getIdentity(identityId).sign(mechanism, null, dataToSign); } }
private byte[] getPlainSignature() throws XiSecurityException, P11TokenException { byte[] dataToSign; if (outputStream instanceof ByteArrayOutputStream) { dataToSign = ((ByteArrayOutputStream) outputStream).toByteArray(); ((ByteArrayOutputStream) outputStream).reset(); } else { dataToSign = ((DigestOutputStream) outputStream).digest(); ((DigestOutputStream) outputStream).reset(); } return cryptService.getIdentity(identityId).sign(mechanism, null, dataToSign); }
private byte[] getPlainSignature() throws XiSecurityException, P11TokenException { byte[] dataToSign; if (outputStream instanceof ByteArrayOutputStream) { dataToSign = ((ByteArrayOutputStream) outputStream).toByteArray(); ((ByteArrayOutputStream) outputStream).reset(); } else { dataToSign = ((DigestOutputStream) outputStream).digest(); ((DigestOutputStream) outputStream).reset(); } return cryptService.getIdentity(identityId).sign(mechanism, null, dataToSign); }
private byte[] getPlainSignature() throws XiSecurityException, P11TokenException { byte[] dataToSign; if (outputStream instanceof ByteArrayOutputStream) { dataToSign = ((ByteArrayOutputStream) outputStream).toByteArray(); ((ByteArrayOutputStream) outputStream).reset(); } else { dataToSign = ((DigestOutputStream) outputStream).digest(); ((DigestOutputStream) outputStream).reset(); } return cryptService.getIdentity(identityId).sign(mechanism, null, dataToSign); }
private byte[] getPlainSignature() throws XiSecurityException, P11TokenException { byte[] dataToSign; if (outputStream instanceof ByteArrayOutputStream) { dataToSign = ((ByteArrayOutputStream) outputStream).toByteArray(); ((ByteArrayOutputStream) outputStream).reset(); } else { dataToSign = ((DigestOutputStream) outputStream).digest(); ((DigestOutputStream) outputStream).reset(); } return cryptService.getIdentity(identityId).sign(mechanism, null, dataToSign); } }
private byte[] getPlainSignature() throws XiSecurityException, P11TokenException { byte[] dataToSign; if (outputStream instanceof ByteArrayOutputStream) { dataToSign = ((ByteArrayOutputStream) outputStream).toByteArray(); ((ByteArrayOutputStream) outputStream).reset(); } else { dataToSign = ((DigestOutputStream) outputStream).digest(); ((DigestOutputStream) outputStream).reset(); } return cryptService.getIdentity(identityId).sign(mechanism, null, dataToSign); } }
@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()); } }
@Override public byte[] getSignature() { try { byte[] dataToSign = outputStream.toByteArray(); outputStream.reset(); return cryptService.getIdentity(identityId).sign(mechanism, null, dataToSign); } catch (XiSecurityException ex) { LogUtil.warn(LOG, ex); throw new RuntimeCryptoException("XiSecurityException: " + ex.getMessage()); } catch (Throwable th) { LogUtil.warn(LOG, th); throw new RuntimeCryptoException(th.getClass().getName() + ": " + th.getMessage()); } }
@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()); } }
@Override public byte[] processBlock(final byte[] in, final int inOff, final int len) throws InvalidCipherTextException { byte[] content = new byte[getInputBlockSize()]; System.arraycopy(in, inOff, content, content.length - len, len); try { P11Identity identity = param.p11CryptService().getIdentity(param.identityId()); return identity.sign(PKCS11Constants.CKM_RSA_X_509, null, content); } catch (XiSecurityException | P11TokenException ex) { throw new InvalidCipherTextException(ex.getMessage(), ex); } }
@Override public byte[] getSignature() { byte[] dataToSign; if (outputStream instanceof ByteArrayOutputStream) { dataToSign = ((ByteArrayOutputStream) outputStream).toByteArray(); ((ByteArrayOutputStream) outputStream).reset(); } else { byte[] hashValue = ((DigestOutputStream) outputStream).digest(); ((DigestOutputStream) outputStream).reset(); dataToSign = new byte[digestPkcsPrefix.length + hashValue.length]; System.arraycopy(digestPkcsPrefix, 0, dataToSign, 0, digestPkcsPrefix.length); System.arraycopy(hashValue, 0, dataToSign, digestPkcsPrefix.length, hashValue.length); } try { if (mechanism == PKCS11Constants.CKM_RSA_X_509) { dataToSign = SignerUtil.EMSA_PKCS1_v1_5_encoding(dataToSign, modulusBitLen); } return cryptService.getIdentity(identityId).sign(mechanism, null, dataToSign); } catch (XiSecurityException | P11TokenException ex) { LogUtil.error(LOG, ex, "could not sign"); throw new RuntimeCryptoException("SignerException: " + ex.getMessage()); } }
@Override public byte[] getSignature() { byte[] dataToSign; if (outputStream instanceof ByteArrayOutputStream) { dataToSign = ((ByteArrayOutputStream) outputStream).toByteArray(); ((ByteArrayOutputStream) outputStream).reset(); } else { byte[] hashValue = ((DigestOutputStream) outputStream).digest(); ((DigestOutputStream) outputStream).reset(); dataToSign = new byte[digestPkcsPrefix.length + hashValue.length]; System.arraycopy(digestPkcsPrefix, 0, dataToSign, 0, digestPkcsPrefix.length); System.arraycopy(hashValue, 0, dataToSign, digestPkcsPrefix.length, hashValue.length); } try { if (mechanism == PKCS11Constants.CKM_RSA_X_509) { dataToSign = SignerUtil.EMSA_PKCS1_v1_5_encoding(dataToSign, modulusBitLen); } return cryptService.getIdentity(identityId).sign(mechanism, null, dataToSign); } catch (XiSecurityException | P11TokenException ex) { LogUtil.error(LOG, ex, "could not sign"); throw new RuntimeCryptoException("SignerException: " + ex.getMessage()); } }
@Override public byte[] getSignature() { byte[] dataToSign; if (outputStream instanceof ByteArrayOutputStream) { dataToSign = ((ByteArrayOutputStream) outputStream).toByteArray(); ((ByteArrayOutputStream) outputStream).reset(); } else { byte[] hashValue = ((DigestOutputStream) outputStream).digest(); ((DigestOutputStream) outputStream).reset(); dataToSign = new byte[digestPkcsPrefix.length + hashValue.length]; System.arraycopy(digestPkcsPrefix, 0, dataToSign, 0, digestPkcsPrefix.length); System.arraycopy(hashValue, 0, dataToSign, digestPkcsPrefix.length, hashValue.length); } try { if (mechanism == PKCS11Constants.CKM_RSA_X_509) { dataToSign = SignerUtil.EMSA_PKCS1_v1_5_encoding(dataToSign, modulusBitLen); } return cryptService.getIdentity(identityId).sign(mechanism, null, dataToSign); } catch (XiSecurityException | P11TokenException ex) { LogUtil.error(LOG, ex, "could not sign"); throw new RuntimeCryptoException("SignerException: " + ex.getMessage()); } }
private byte[] getPlainSignature() throws XiSecurityException, P11TokenException { byte[] dataToSign; P11Params.P11ByteArrayParams params; if (outputStream instanceof ByteArrayOutputStream) { // dataToSign is the real message params = new P11Params.P11ByteArrayParams(GMUtil.getDefaultIDA()); dataToSign = ((ByteArrayOutputStream) outputStream).toByteArray(); } else { // dataToSign is Hash(Z||Real Message) params = null; dataToSign = ((DigestOutputStream) outputStream).digest(); } reset(); return cryptService.getIdentity(identityId).sign(mechanism, params, dataToSign); } }
@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[] 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); } }
private byte[] getPlainSignature() throws XiSecurityException, P11TokenException { byte[] dataToSign; P11ByteArrayParams params; if (outputStream instanceof ByteArrayOutputStream) { // dataToSign is the real message params = new P11ByteArrayParams(GMUtil.getDefaultIDA()); dataToSign = ((ByteArrayOutputStream) outputStream).toByteArray(); } else { // dataToSign is Hash(Z||Real Message) params = null; dataToSign = ((DigestOutputStream) outputStream).digest(); } reset(); return cryptService.getIdentity(identityId).sign(mechanism, params, dataToSign); } }