Search in sources :

Example 1 with PBEKeySpec

use of de.flexiprovider.core.pbe.PBEKeySpec in project core by jcryptool.

the class PBESecretKeyContentProvider method getKeySpecElements.

@Override
protected List<TableEntry> getKeySpecElements(Key key) {
    List<TableEntry> paramElements = new ArrayList<TableEntry>();
    try {
        PBEKeyFactory keyFactory = new PBEKeyFactory();
        PBEKeySpec keySpec = (PBEKeySpec) keyFactory.getKeySpec((SecretKey) key, PBEKeySpec.class);
        if (keySpec == null)
            return null;
        paramElements.add(// $NON-NLS-2$
        new TableEntry(Messages.ContentProvider_iterationcount, "" + keySpec.getIterationCount()));
        // $NON-NLS-2$
        paramElements.add(new TableEntry(Messages.ContentProvider_keylength, "" + keySpec.getKeyLength()));
        paramElements.add(new TableEntry(Messages.ContentProvider_password, // $NON-NLS-2$
        "" + Arrays.toString(keySpec.getPassword())));
        // $NON-NLS-2$
        paramElements.add(new TableEntry(Messages.ContentProvider_salt, "" + Arrays.toString(keySpec.getSalt())));
    } catch (ClassCastException e) {
        return null;
    } catch (InvalidKeySpecException e) {
        return null;
    }
    return paramElements;
}
Also used : TableEntry(org.jcryptool.crypto.keystore.ui.dialogs.TableEntry) PBEKeySpec(de.flexiprovider.core.pbe.PBEKeySpec) SecretKey(de.flexiprovider.api.keys.SecretKey) ECSecretKey(de.flexiprovider.ec.keys.ECSecretKey) PBEKeyFactory(de.flexiprovider.core.pbe.PBEKeyFactory) ArrayList(java.util.ArrayList) InvalidKeySpecException(de.flexiprovider.api.exceptions.InvalidKeySpecException)

Aggregations

InvalidKeySpecException (de.flexiprovider.api.exceptions.InvalidKeySpecException)1 SecretKey (de.flexiprovider.api.keys.SecretKey)1 PBEKeyFactory (de.flexiprovider.core.pbe.PBEKeyFactory)1 PBEKeySpec (de.flexiprovider.core.pbe.PBEKeySpec)1 ECSecretKey (de.flexiprovider.ec.keys.ECSecretKey)1 ArrayList (java.util.ArrayList)1 TableEntry (org.jcryptool.crypto.keystore.ui.dialogs.TableEntry)1