@Override public int getInputBlockSize() { return (param.getKeysize() + 7) / 8; }
@Override public int getInputBlockSize() { return (param.keysize() + 7) / 8; }
protected void engineInitSign(PrivateKey privateKey, SecureRandom random) throws InvalidKeyException { if (!(privateKey instanceof P11PrivateKey)) { throw new InvalidKeyException("privateKey is not instanceof " + P11PrivateKey.class.getName()); } String algo = privateKey.getAlgorithm(); if (!"RSA".equals(algo)) { throw new InvalidKeyException("privateKey is not an RSA private key: " + algo); } this.signingKey = (P11PrivateKey) privateKey; pss = new org.bouncycastle.crypto.signers.PSSSigner(signer, contentDigest, mgfDigest, saltLength, trailer); P11RSAKeyParameter p11KeyParam = P11RSAKeyParameter.getInstance( signingKey.getP11CryptService(), signingKey.getIdentityId()); if (random == null) { pss.init(true, p11KeyParam); } else { pss.init(true, new ParametersWithRandom(p11KeyParam, random)); } }
@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); } }
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(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); } }
protected void engineInitSign(PrivateKey privateKey, SecureRandom random) throws InvalidKeyException { if (!(privateKey instanceof P11PrivateKey)) { throw new InvalidKeyException("privateKey is not instanceof " + P11PrivateKey.class.getName()); } String algo = privateKey.getAlgorithm(); if (!"RSA".equals(algo)) { throw new InvalidKeyException("privateKey is not an RSA private key: " + algo); } this.signingKey = (P11PrivateKey) privateKey; pss = new org.bouncycastle.crypto.signers.PSSSigner(signer, contentDigest, mgfDigest, saltLength, trailer); P11RSAKeyParameter p11KeyParam = P11RSAKeyParameter.getInstance( signingKey.getP11CryptService(), signingKey.getIdentityId()); if (random == null) { pss.init(true, p11KeyParam); } else { pss.init(true, new ParametersWithRandom(p11KeyParam, random)); } }
@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); } }
public static P11RSAKeyParameter getInstance(P11CryptService p11CryptService, P11IdentityId identityId) throws InvalidKeyException { ParamUtil.requireNonNull("p11CryptService", p11CryptService); ParamUtil.requireNonNull("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); }
protected void engineInitSign(final PrivateKey privateKey, final SecureRandom random) throws InvalidKeyException { if (!(privateKey instanceof P11PrivateKey)) { throw new InvalidKeyException("privateKey is not instanceof " + P11PrivateKey.class.getName()); } String algo = privateKey.getAlgorithm(); if (!"RSA".equals(algo)) { throw new InvalidKeyException("privateKey is not an RSA private key: " + algo); } this.signingKey = (P11PrivateKey) privateKey; pss = new org.bouncycastle.crypto.signers.PSSSigner(signer, contentDigest, mgfDigest, saltLength, trailer); P11RSAKeyParameter p11KeyParam = P11RSAKeyParameter.getInstance( signingKey.p11CryptService(), signingKey.identityId()); if (random == null) { pss.init(true, p11KeyParam); } else { pss.init(true, new ParametersWithRandom(p11KeyParam, random)); } }
public static P11RSAKeyParameter getInstance(final P11CryptService p11CryptService, final P11EntityIdentifier identityId) throws InvalidKeyException { ParamUtil.requireNonNull("p11CryptService", p11CryptService); ParamUtil.requireNonNull("identityId", identityId); RSAPublicKey key; try { key = (RSAPublicKey) p11CryptService.getIdentity(identityId).publicKey(); } 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 int getOutputBlockSize() { return (param.getKeysize() + 7) / 8; }
@Override public int getOutputBlockSize() { return (param.keysize() + 7) / 8; }
P11RSAKeyParameter keyParam; try { keyParam = P11RSAKeyParameter.getInstance(cryptService, identityId); } catch (InvalidKeyException ex) { throw new XiSecurityException(ex.getMessage(), ex);
@Override public int getInputBlockSize() { return (param.getKeysize() + 7) / 8; }
P11RSAKeyParameter keyParam; try { keyParam = P11RSAKeyParameter.getInstance(cryptService, identityId); } catch (InvalidKeyException ex) { throw new XiSecurityException(ex.getMessage(), ex);
@Override public int getOutputBlockSize() { return (param.getKeysize() + 7) / 8; }
P11RSAKeyParameter keyParam; try { keyParam = P11RSAKeyParameter.getInstance(cryptService, identityId); } catch (InvalidKeyException ex) { throw new XiSecurityException(ex.getMessage(), ex);