Search in sources :

Example 1 with MerkleOTSKeyFactory

use of de.flexiprovider.pqc.ots.merkle.MerkleOTSKeyFactory in project core by jcryptool.

the class MerkleOTSPrivateKeyContentProvider method getKeySpecElements.

@Override
protected List<TableEntry> getKeySpecElements(Key key) {
    List<TableEntry> paramElements = new ArrayList<TableEntry>();
    try {
        MerkleOTSKeyFactory keyFactory = new MerkleOTSKeyFactory();
        MerkleOTSPrivateKeySpec keySpec = (MerkleOTSPrivateKeySpec) keyFactory.getKeySpec(key, MerkleOTSPrivateKeySpec.class);
        if (keySpec == null)
            return null;
        // $NON-NLS-2$
        paramElements.add(new TableEntry(Messages.ContentProvider_oidstring, "" + keySpec.getOIDString()));
        // $NON-NLS-2$
        paramElements.add(new TableEntry(Messages.ContentProvider_keybytes, "" + keySpec.getKeyBytes()));
    } catch (ClassCastException e) {
        return null;
    } catch (InvalidKeySpecException e) {
        return null;
    }
    return paramElements;
}
Also used : TableEntry(org.jcryptool.crypto.keystore.ui.dialogs.TableEntry) ArrayList(java.util.ArrayList) InvalidKeySpecException(de.flexiprovider.api.exceptions.InvalidKeySpecException) MerkleOTSKeyFactory(de.flexiprovider.pqc.ots.merkle.MerkleOTSKeyFactory) MerkleOTSPrivateKeySpec(de.flexiprovider.pqc.ots.merkle.MerkleOTSPrivateKeySpec)

Example 2 with MerkleOTSKeyFactory

use of de.flexiprovider.pqc.ots.merkle.MerkleOTSKeyFactory in project core by jcryptool.

the class MerkleOTSPublicKeyContentProvider method getKeySpecElements.

@Override
protected List<TableEntry> getKeySpecElements(Key key) {
    List<TableEntry> paramElements = new ArrayList<TableEntry>();
    try {
        MerkleOTSKeyFactory keyFactory = new MerkleOTSKeyFactory();
        MerkleOTSPublicKeySpec keySpec = (MerkleOTSPublicKeySpec) keyFactory.getKeySpec(key, MerkleOTSPublicKeySpec.class);
        if (keySpec == null)
            return null;
        // $NON-NLS-2$
        paramElements.add(new TableEntry(Messages.ContentProvider_oidstring, "" + keySpec.getOIDString()));
        // $NON-NLS-2$
        paramElements.add(new TableEntry(Messages.ContentProvider_keybytes, "" + keySpec.getKeyBytes()));
    } catch (ClassCastException e) {
        return null;
    } catch (InvalidKeySpecException e) {
        return null;
    }
    return paramElements;
}
Also used : TableEntry(org.jcryptool.crypto.keystore.ui.dialogs.TableEntry) ArrayList(java.util.ArrayList) InvalidKeySpecException(de.flexiprovider.api.exceptions.InvalidKeySpecException) MerkleOTSKeyFactory(de.flexiprovider.pqc.ots.merkle.MerkleOTSKeyFactory) MerkleOTSPublicKeySpec(de.flexiprovider.pqc.ots.merkle.MerkleOTSPublicKeySpec)

Aggregations

InvalidKeySpecException (de.flexiprovider.api.exceptions.InvalidKeySpecException)2 MerkleOTSKeyFactory (de.flexiprovider.pqc.ots.merkle.MerkleOTSKeyFactory)2 ArrayList (java.util.ArrayList)2 TableEntry (org.jcryptool.crypto.keystore.ui.dialogs.TableEntry)2 MerkleOTSPrivateKeySpec (de.flexiprovider.pqc.ots.merkle.MerkleOTSPrivateKeySpec)1 MerkleOTSPublicKeySpec (de.flexiprovider.pqc.ots.merkle.MerkleOTSPublicKeySpec)1