public String toString() { StringBuffer buf = new StringBuffer(); String nl = Strings.lineSeparator(); buf.append("RSA Public Key [").append(RSAUtil.generateKeyFingerprint(this.getModulus())).append("]") .append(",[") .append(RSAUtil.generateExponentFingerprint(this.getPublicExponent())) .append("]") .append(nl); buf.append(" modulus: ").append(this.getModulus().toString(16)).append(nl); buf.append("public exponent: ").append(this.getPublicExponent().toString(16)).append(nl); return buf.toString(); }
protected void engineInitSign( PrivateKey privateKey) throws InvalidKeyException { CipherParameters param = RSAUtil.generatePrivateKeyParameter((RSAPrivateKey)privateKey); signer.init(true, param); }
protected void engineInitVerify( PublicKey publicKey) throws InvalidKeyException { CipherParameters param = RSAUtil.generatePublicKeyParameter((RSAPublicKey)publicKey); signer.init(false, param); }
public PublicKey generatePublic(SubjectPublicKeyInfo keyInfo) throws IOException { ASN1ObjectIdentifier algOid = keyInfo.getAlgorithm().getAlgorithm(); if (RSAUtil.isRsaOid(algOid)) { return new BCRSAPublicKey(keyInfo); } else { throw new IOException("algorithm identifier " + algOid + " in key not recognised"); } } }
param = RSAUtil.generatePublicKeyParameter((RSAPublicKey)key); param = RSAUtil.generatePrivateKeyParameter((RSAPrivateKey)key);
public String toString() { StringBuffer buf = new StringBuffer(); String nl = Strings.lineSeparator(); buf.append("RSA Private Key [").append( RSAUtil.generateKeyFingerprint(this.getModulus())).append("],[]").append(nl); buf.append(" modulus: ").append(this.getModulus().toString(16)).append(nl); return buf.toString(); } }
public PrivateKey generatePrivate(PrivateKeyInfo keyInfo) throws IOException { ASN1ObjectIdentifier algOid = keyInfo.getPrivateKeyAlgorithm().getAlgorithm(); if (RSAUtil.isRsaOid(algOid)) { RSAPrivateKey rsaPrivKey = RSAPrivateKey.getInstance(keyInfo.parsePrivateKey()); if (rsaPrivKey.getCoefficient().intValue() == 0) { return new BCRSAPrivateKey(rsaPrivKey); } else { return new BCRSAPrivateCrtKey(keyInfo); } } else { throw new IOException("algorithm identifier " + algOid + " in key not recognised"); } }
private String getKeyFactoryHint(ASN1Object keyInfo) { ASN1ObjectIdentifier algId = getAlgorithmId(keyInfo); String hint = null; if (RSAUtil.isRsaOid(algId)) { hint = "RSA"; } else if (DSAUtil.isDsaOid(algId)) { hint = "DSA"; } else if (algId.equals(PKCSObjectIdentifiers.dhKeyAgreement) || algId.equals(X9ObjectIdentifiers.dhpublicnumber)) { hint = "DH"; } else if (algId.equals(OIWObjectIdentifiers.elGamalAlgorithm)) { hint = "ElGamal"; } else if (algId.equals(CryptoProObjectIdentifiers.gostR3410_94)) { hint = "GOST3410"; } if (hint == null) { throw new UnsupportedOperationException("Asymmetric key algorithm not supported: " + algId.getId()); } return hint; }
public String toString() { StringBuffer buf = new StringBuffer(); String nl = Strings.lineSeparator(); buf.append("RSA Private CRT Key [").append( RSAUtil.generateKeyFingerprint(this.getModulus())).append("]") .append(",[") .append(RSAUtil.generateExponentFingerprint(this.getPublicExponent())) .append("]") .append(nl); buf.append(" modulus: ").append(this.getModulus().toString(16)).append(nl); buf.append(" public exponent: ").append(this.getPublicExponent().toString(16)).append(nl); return buf.toString(); } }
protected void engineInitSign( PrivateKey privateKey) throws InvalidKeyException { CipherParameters param = RSAUtil.generatePrivateKeyParameter((RSAPrivateKey)privateKey); signer.init(true, param); }
protected void engineInitVerify( PublicKey publicKey) throws InvalidKeyException { CipherParameters param = RSAUtil.generatePublicKeyParameter((RSAPublicKey)publicKey); signer.init(false, param); }
private String getKeyFactoryHint(ASN1Object keyInfo) { ASN1ObjectIdentifier algId = getAlgorithmId(keyInfo); String hint = null; if (RSAUtil.isRsaOid(algId)) { hint = "RSA"; } else if (DSAUtil.isDsaOid(algId)) { hint = "DSA"; } else if (algId.equals(PKCSObjectIdentifiers.dhKeyAgreement) || algId.equals(X9ObjectIdentifiers.dhpublicnumber)) { hint = "DH"; } else if (algId.equals(OIWObjectIdentifiers.elGamalAlgorithm)) { hint = "ElGamal"; } else if (algId.equals(CryptoProObjectIdentifiers.gostR3410_94)) { hint = "GOST3410"; } if (hint == null) { throw new UnsupportedOperationException("Asymmetric key algorithm not supported: " + algId.getId()); } return hint; }
protected void engineInitSign( PrivateKey privateKey) throws InvalidKeyException { if (!(privateKey instanceof RSAPrivateKey)) { throw new InvalidKeyException("Supplied key is not a RSAPrivateKey instance"); } key = RSAUtil.generatePrivateKeyParameter((RSAPrivateKey)privateKey); pss = new org.bouncycastle.crypto.signers.PSSSigner(signer, contentDigest, mgfDigest, saltLength, trailer); pss.init(true, key); isInitState = true; }
protected void engineInitVerify( PublicKey publicKey) throws InvalidKeyException { if (!(publicKey instanceof RSAPublicKey)) { throw new InvalidKeyException("Supplied key is not a RSAPublicKey instance"); } key = RSAUtil.generatePublicKeyParameter((RSAPublicKey)publicKey); pss = new org.bouncycastle.crypto.signers.PSSSigner(signer, contentDigest, mgfDigest, saltLength, trailer); pss.init(false, key); isInitState = true; }
protected void engineInitSign( PrivateKey privateKey) throws InvalidKeyException { if (!(privateKey instanceof RSAPrivateKey)) { throw new InvalidKeyException("Supplied key (" + getType(privateKey) + ") is not a RSAPrivateKey instance"); } CipherParameters param = RSAUtil.generatePrivateKeyParameter((RSAPrivateKey)privateKey); digest.reset(); cipher.init(true, param); }
protected void engineInitVerify( PublicKey publicKey) throws InvalidKeyException { if (!(publicKey instanceof RSAPublicKey)) { throw new InvalidKeyException("Supplied key (" + getType(publicKey) + ") is not a RSAPublicKey instance"); } CipherParameters param = RSAUtil.generatePublicKeyParameter((RSAPublicKey)publicKey); digest.reset(); cipher.init(false, param); }
protected void engineInitSign( PrivateKey privateKey, SecureRandom random) throws InvalidKeyException { if (!(privateKey instanceof RSAPrivateKey)) { throw new InvalidKeyException("Supplied key is not a RSAPrivateKey instance"); } key = RSAUtil.generatePrivateKeyParameter((RSAPrivateKey)privateKey); pss = new org.bouncycastle.crypto.signers.PSSSigner(signer, contentDigest, mgfDigest, saltLength, trailer); pss.init(true, new ParametersWithRandom(key, random)); isInitState = true; }