@Override public void foundPublicKey(PemBlock block) { String id = block.getString(PemBlock.IDENT, null); if (id == null) return; keys.put(id, block); }
@Override public void foundPrivateKey(PemBlock block) { String id = block.getString(PemBlock.IDENT, null); if (id == null) return; keys.put(id, block); }
@Override public String getPrivateIdForPublicKeyId(String pubId) throws CryptException { PemBlock pub = keys.get(pubId); if (pub == null) return null; return pub.getString(PemBlock.PRIV_ID, null); }
public static String toLine(PemBlock key) { return key.getString(PemBlock.METHOD, "?") + ":" + key.getBlock(); }
@Override public String decrypt(PemPriv key, PemBlock encoded, String passphrase) throws MException { try { byte[] xkey = key.getBytesBlock(); byte[] data = encoded.getBytesBlock(); Cipher c = Cipher.getInstance("AES"); SecretKeySpec k = new SecretKeySpec(xkey, "AES"); c.init(Cipher.DECRYPT_MODE, k); byte[] enc = c.doFinal(data); String stringEncoding = encoded.getString(PemBlock.STRING_ENCODING, "utf-8"); return new String(enc, stringEncoding); } catch (Throwable t) { throw new MException(t); } }
public PemEntry(PemBlock block) { String str = block.getString(PemBlock.IDENT, null); if (str == null) id = UUID.randomUUID(); description = block.getString(PemBlock.DESCRIPTION, ""); String method = block.getString(PemBlock.METHOD, "").toUpperCase(); if (PemUtil.isPubKey(block)) { if (method.contains("RSA"))
String stringEncoding = encoded.getString(PemBlock.STRING_ENCODING, "utf-8"); return new String(os.toByteArray(), stringEncoding);
String stringEncoding = encoded.getString(PemBlock.STRING_ENCODING, "utf-8"); return new String(os.toByteArray(), stringEncoding);