List of utility methods to do Key Create
KeyPairGenerator | getKeyPairGenerator(final String algorithm) get Key Pair Generator return KeyPairGenerator.getInstance(algorithm);
|
HashMap | getKeys() get Keys HashMap<String, Object> map = new HashMap<String, Object>(); KeyPairGenerator keyPairGen = KeyPairGenerator.getInstance("RSA"); keyPairGen.initialize(1024); KeyPair keyPair = keyPairGen.generateKeyPair(); RSAPublicKey publicKey = (RSAPublicKey) keyPair.getPublic(); RSAPrivateKey privateKey = (RSAPrivateKey) keyPair.getPrivate(); map.put("public", publicKey); map.put("private", privateKey); ... |
int | getKeySize(final Key key) Get the key size for the given Key . if (key instanceof ECKey) { ECParameterSpec params = ((ECKey) key).getParams(); if (params != null) { return params.getOrder().bitLength(); } else if (key instanceof DSAKey) { DSAParams params = ((DSAKey) key).getParams(); if (params != null) { ... |
int | getKeySize(PrivateKey key) Returns the key size of the given key object in bits. int size = -1; if (key instanceof RSAKey) { RSAKey pubk = (RSAKey) key; size = pubk.getModulus().bitLength(); } else if (key instanceof ECKey) { ECKey pubk = (ECKey) key; size = pubk.getParams().getOrder().bitLength(); } else if (key instanceof DSAKey) { ... |
KeyStore | getKeyStore() Obtain OpenSC PKCS#11 keystore without init return KeyStore.getInstance("PKCS11", pkcs11Provider); |
KeyStore | getKeyStore() get Key Store if (keyStore == null) { String filename = System.getProperty("keyStore"); if (filename == null) { return null; try { InputStream in = new BufferedInputStream(new FileInputStream(filename)); keyStore = KeyStore.getInstance(KeyStore.getDefaultType()); ... |
KeyStore | getKeyStore(byte[] bytes, char[] password) get Key Store ByteArrayInputStream bais = null; try { bais = new ByteArrayInputStream(bytes); try { KeyStore keyStore = KeyStore.getInstance(TOLVEN_CREDENTIAL_FORMAT_PKCS12); keyStore.load(bais, password); return keyStore; } catch (Exception ex) { ... |
KeyStore | getKeyStore(Certificate[] certificateChain, PrivateKey privateKey, char[] password) get Key Store KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType()); keyStore.load(null, null); keyStore.setKeyEntry("key", privateKey, password, certificateChain); return keyStore; |
KeyStore | getKeyStore(char[] password) get Key Store KeyStore ks = null; try { ks = getKeyStore(null, password, null, null, null); } catch (IOException ioe) { return ks; |
KeyStore | getKeyStore(File file, char[] storePass) get Key Store FileInputStream ksInputStream = new FileInputStream(file); KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType()); ks.load(ksInputStream, storePass); return ks; |