Search in sources :

Example 6 with AlgorithmDescriptor

use of org.jcryptool.crypto.flexiprovider.descriptors.algorithms.AlgorithmDescriptor in project core by jcryptool.

the class AlgorithmsManager method performMessageDigestCalled.

private static void performMessageDigestCalled(IMetaAlgorithm algorithm) {
    // $NON-NLS-1$
    LogUtil.logInfo("has param generator: " + (algorithm.getParameterGeneratorClassName() != null));
    if (algorithm.getParameterGeneratorClassName() != null && !algorithm.isParameterSpecDisabled()) {
        AlgorithmParameterSpec generatedSpec = Reflector.getInstance().generateDefaultParameterSpec(algorithm);
        NewOperationManager.getInstance().fireNewOperation(new AlgorithmDescriptor(algorithm.getName(), RegistryType.MESSAGE_DIGEST, generatedSpec));
    } else {
        NewOperationManager.getInstance().fireNewOperation(new AlgorithmDescriptor(algorithm.getName(), RegistryType.MESSAGE_DIGEST, null));
    }
}
Also used : AlgorithmParameterSpec(de.flexiprovider.api.parameters.AlgorithmParameterSpec) AlgorithmDescriptor(org.jcryptool.crypto.flexiprovider.descriptors.algorithms.AlgorithmDescriptor)

Example 7 with AlgorithmDescriptor

use of org.jcryptool.crypto.flexiprovider.descriptors.algorithms.AlgorithmDescriptor in project core by jcryptool.

the class AlgorithmsManager method performAsymmetricBlockCipherCalled.

private static void performAsymmetricBlockCipherCalled(IMetaAlgorithm algorithm) {
    if (algorithm.getParameterSpecClassName() != null && !algorithm.isParameterSpecDisabled()) {
        algorithmWizard = new AlgorithmWizard(algorithm);
        dialog = new WizardDialog(shell, algorithmWizard);
        dialog.setMinimumPageSize(300, 100);
        int result = dialog.open();
        if (result == Window.OK) {
            // $NON-NLS-1$
            LogUtil.logInfo("adding asymmetric block cipher");
            NewOperationManager.getInstance().fireNewOperation(algorithmWizard.getDescriptor());
        }
    } else {
        // $NON-NLS-1$
        LogUtil.logInfo("adding asymmetric block cipher w/o parameter spec");
        NewOperationManager.getInstance().fireNewOperation(new AlgorithmDescriptor(algorithm.getName(), RegistryType.ASYMMETRIC_BLOCK_CIPHER, null));
    }
}
Also used : AlgorithmWizard(org.jcryptool.crypto.flexiprovider.algorithms.ui.wizards.AlgorithmWizard) WizardDialog(org.eclipse.jface.wizard.WizardDialog) BlockCipherWizardDialog(org.jcryptool.crypto.flexiprovider.algorithms.ui.wizards.blockcipher.BlockCipherWizardDialog) AlgorithmDescriptor(org.jcryptool.crypto.flexiprovider.descriptors.algorithms.AlgorithmDescriptor)

Example 8 with AlgorithmDescriptor

use of org.jcryptool.crypto.flexiprovider.descriptors.algorithms.AlgorithmDescriptor in project core by jcryptool.

the class AlgorithmsManager method performSignatureCalled.

private static void performSignatureCalled(IMetaAlgorithm algorithm) {
    if (algorithm.getParameterSpecClassName() != null) /*
                                                           * && !algorithm. isParameterSpecDisabled ()
                                                           */
    {
        // $NON-NLS-1$
        LogUtil.logInfo("has paramspec: " + algorithm.getParameterSpecClassName());
        // open wizard
        signatureWizard = new SignatureWizard(algorithm);
        dialog = new WizardDialog(shell, signatureWizard);
        dialog.setMinimumPageSize(300, 175);
        int result = dialog.open();
        if (result == Window.OK) {
            NewOperationManager.getInstance().fireNewOperation(signatureWizard.getDescriptor());
        }
    } else {
        // $NON-NLS-1$
        LogUtil.logInfo("has no paramspec");
        NewOperationManager.getInstance().fireNewOperation(new AlgorithmDescriptor(algorithm.getName(), RegistryType.SIGNATURE, null));
    }
}
Also used : SignatureWizard(org.jcryptool.crypto.flexiprovider.algorithms.ui.wizards.signature.SignatureWizard) WizardDialog(org.eclipse.jface.wizard.WizardDialog) BlockCipherWizardDialog(org.jcryptool.crypto.flexiprovider.algorithms.ui.wizards.blockcipher.BlockCipherWizardDialog) AlgorithmDescriptor(org.jcryptool.crypto.flexiprovider.descriptors.algorithms.AlgorithmDescriptor)

Example 9 with AlgorithmDescriptor

use of org.jcryptool.crypto.flexiprovider.descriptors.algorithms.AlgorithmDescriptor in project core by jcryptool.

the class AlgorithmsManager method performMacCalled.

private static void performMacCalled(IMetaAlgorithm algorithm) {
    if (algorithm.getBlockCipherName() != null) {
        IMetaAlgorithm bc = null;
        // $NON-NLS-1$
        LogUtil.logInfo("BC name: " + algorithm.getBlockCipherName());
        if (algorithm.getBlockCipherOID() != null) {
            // $NON-NLS-1$
            LogUtil.logInfo("BC oid: " + algorithm.getBlockCipherOID());
            bc = AlgorithmsXMLManager.getInstance().getBlockCipher(algorithm.getBlockCipherOID());
        } else {
            bc = AlgorithmsXMLManager.getInstance().getBlockCipher(algorithm.getBlockCipherName());
        }
        // $NON-NLS-1$
        LogUtil.logInfo("BC mode: " + algorithm.getBlockCipherMode());
        if (bc != null) {
            blockCipherWizard = new BlockCipherWizard(bc, algorithm.getBlockCipherMode());
            dialog = new BlockCipherWizardDialog(shell, blockCipherWizard);
            dialog.setMinimumPageSize(300, 175);
            int result = dialog.open();
            if (result == Window.OK) {
                AlgorithmDescriptor blockCipherDescriptor = blockCipherWizard.getDescriptor();
                AlgorithmDescriptor macDescriptor = new AlgorithmDescriptor(algorithm.getName(), RegistryType.MAC, blockCipherDescriptor.getAlgorithmParameterSpec());
                NewOperationManager.getInstance().fireNewOperation(macDescriptor);
                return;
            }
        }
    }
    if (algorithm.getParameterSpecClassName() != null && !algorithm.isParameterSpecDisabled()) {
        algorithmWizard = new AlgorithmWizard(algorithm);
        dialog = new WizardDialog(shell, algorithmWizard);
        dialog.setMinimumPageSize(300, 100);
        int result = dialog.open();
        if (result == Window.OK) {
            // $NON-NLS-1$
            LogUtil.logInfo("adding mac");
            NewOperationManager.getInstance().fireNewOperation(algorithmWizard.getDescriptor());
        } else {
            // $NON-NLS-1$
            LogUtil.logInfo("adding mac w/o parameter spec");
            // $NON-NLS-1$
            LogUtil.logInfo("has param generator: " + (algorithm.getParameterGeneratorClassName() != null));
            if (algorithm.getParameterGeneratorClassName() != null) {
                AlgorithmParameterSpec generatedSpec = Reflector.getInstance().generateDefaultParameterSpec(algorithm);
                NewOperationManager.getInstance().fireNewOperation(new AlgorithmDescriptor(algorithm.getName(), RegistryType.MAC, generatedSpec));
            } else {
                NewOperationManager.getInstance().fireNewOperation(new AlgorithmDescriptor(algorithm.getName(), RegistryType.MAC, null));
            }
        }
    }
}
Also used : BlockCipherWizardDialog(org.jcryptool.crypto.flexiprovider.algorithms.ui.wizards.blockcipher.BlockCipherWizardDialog) IMetaAlgorithm(org.jcryptool.crypto.flexiprovider.descriptors.meta.interfaces.IMetaAlgorithm) AlgorithmWizard(org.jcryptool.crypto.flexiprovider.algorithms.ui.wizards.AlgorithmWizard) BlockCipherWizard(org.jcryptool.crypto.flexiprovider.algorithms.ui.wizards.blockcipher.BlockCipherWizard) AlgorithmDescriptor(org.jcryptool.crypto.flexiprovider.descriptors.algorithms.AlgorithmDescriptor) WizardDialog(org.eclipse.jface.wizard.WizardDialog) BlockCipherWizardDialog(org.jcryptool.crypto.flexiprovider.algorithms.ui.wizards.blockcipher.BlockCipherWizardDialog) AlgorithmParameterSpec(de.flexiprovider.api.parameters.AlgorithmParameterSpec)

Example 10 with AlgorithmDescriptor

use of org.jcryptool.crypto.flexiprovider.descriptors.algorithms.AlgorithmDescriptor in project core by jcryptool.

the class OperationsViewEntryRootElement method getEntryNodes.

@SuppressWarnings("unchecked")
public List<EntryNode> getEntryNodes() {
    List<EntryNode> nodes = new ArrayList<EntryNode>();
    // $NON-NLS-1$
    Iterator<Element> it = getChildren("Entry").iterator();
    while (it.hasNext()) {
        Element element = it.next();
        // $NON-NLS-1$
        String name = element.getAttributeValue("name");
        // $NON-NLS-1$
        long timestamp = Long.valueOf(element.getAttributeValue("timestamp"));
        // algorithm
        AlgorithmDescriptor descriptor = null;
        if (element.getChild("AlgorithmDescriptor") != null) {
            // $NON-NLS-1$
            // $NON-NLS-1$
            AlgorithmDescriptorElement descriptorElement = new AlgorithmDescriptorElement(element.getChild("AlgorithmDescriptor"));
            descriptor = descriptorElement.getDescriptor();
        } else if (element.getChild("SecureRandomDescriptor") != null) {
            // $NON-NLS-1$
            // $NON-NLS-1$
            SecureRandomDescriptorElement descriptorElement = new SecureRandomDescriptorElement(element.getChild("SecureRandomDescriptor"));
            descriptor = descriptorElement.getDescriptor();
        } else if (element.getChild("BlockCipherDescriptor") != null) {
            // $NON-NLS-1$
            // $NON-NLS-1$
            BlockCipherDescriptorElement descriptorElement = new BlockCipherDescriptorElement(element.getChild("BlockCipherDescriptor"));
            descriptor = descriptorElement.getDescriptor();
        }
        EntryNode entryNode = new EntryNode(name, timestamp, descriptor);
        nodes.add(entryNode);
        // supplemental information below
        // key
        KeyStoreAlias alias = null;
        if (element.getChild("Key") != null) {
            // $NON-NLS-1$
            // $NON-NLS-1$
            KeyElement keyElement = new KeyElement(element.getChild("Key"));
            alias = keyElement.getAlias();
            entryNode.setKeyStoreAlias(alias);
        }
        // operation
        OperationType type = null;
        if (element.getChild("Operation") != null) {
            // $NON-NLS-1$
            // $NON-NLS-1$
            OperationElement opsElement = new OperationElement(element.getChild("Operation"));
            type = opsElement.getOperationType();
            if (!type.equals(OperationType.UNKNOWN)) {
                entryNode.setOperation(type);
            }
        }
        // i/o
        String input = null;
        String output = null;
        String signature = null;
        if (element.getChild("Output") != null) {
            // $NON-NLS-1$
            // $NON-NLS-1$
            OutputElement outElement = new OutputElement(element.getChild("Output"));
            output = outElement.getOutput();
            entryNode.setOutput(output);
        } else if (element.getChild("InputOutput") != null) {
            // $NON-NLS-1$
            // $NON-NLS-1$
            InputOutputElement inOutElement = new InputOutputElement(element.getChild("InputOutput"));
            input = inOutElement.getInput();
            output = inOutElement.getOutput();
            entryNode.setInput(input);
            entryNode.setOutput(output);
        } else if (element.getChild("InputSignature") != null) {
            // $NON-NLS-1$
            // $NON-NLS-1$
            InputSignatureElement inSigElement = new InputSignatureElement(element.getChild("InputSignature"));
            input = inSigElement.getInput();
            signature = inSigElement.getSignature();
            entryNode.setInput(input);
            entryNode.setSignature(signature);
        }
    }
    return nodes;
}
Also used : AlgorithmDescriptorElement(org.jcryptool.crypto.flexiprovider.operations.xml.algorithms.AlgorithmDescriptorElement) OperationElement(org.jcryptool.crypto.flexiprovider.operations.xml.ops.OperationElement) KeyStoreAlias(org.jcryptool.crypto.keystore.backend.KeyStoreAlias) SecureRandomDescriptorElement(org.jcryptool.crypto.flexiprovider.operations.xml.algorithms.SecureRandomDescriptorElement) AlgorithmDescriptorElement(org.jcryptool.crypto.flexiprovider.operations.xml.algorithms.AlgorithmDescriptorElement) InputSignatureElement(org.jcryptool.crypto.flexiprovider.operations.xml.io.InputSignatureElement) InputOutputElement(org.jcryptool.crypto.flexiprovider.operations.xml.io.InputOutputElement) BlockCipherDescriptorElement(org.jcryptool.crypto.flexiprovider.operations.xml.algorithms.BlockCipherDescriptorElement) OperationElement(org.jcryptool.crypto.flexiprovider.operations.xml.ops.OperationElement) KeyElement(org.jcryptool.crypto.flexiprovider.operations.xml.keys.KeyElement) OutputElement(org.jcryptool.crypto.flexiprovider.operations.xml.io.OutputElement) Element(org.jdom.Element) EntryNode(org.jcryptool.crypto.flexiprovider.operations.ui.views.nodes.EntryNode) ArrayList(java.util.ArrayList) InputOutputElement(org.jcryptool.crypto.flexiprovider.operations.xml.io.InputOutputElement) AlgorithmDescriptor(org.jcryptool.crypto.flexiprovider.descriptors.algorithms.AlgorithmDescriptor) SecureRandomDescriptorElement(org.jcryptool.crypto.flexiprovider.operations.xml.algorithms.SecureRandomDescriptorElement) KeyElement(org.jcryptool.crypto.flexiprovider.operations.xml.keys.KeyElement) InputOutputElement(org.jcryptool.crypto.flexiprovider.operations.xml.io.InputOutputElement) OutputElement(org.jcryptool.crypto.flexiprovider.operations.xml.io.OutputElement) InputSignatureElement(org.jcryptool.crypto.flexiprovider.operations.xml.io.InputSignatureElement) BlockCipherDescriptorElement(org.jcryptool.crypto.flexiprovider.operations.xml.algorithms.BlockCipherDescriptorElement) OperationType(org.jcryptool.crypto.flexiprovider.types.OperationType)

Aggregations

AlgorithmDescriptor (org.jcryptool.crypto.flexiprovider.descriptors.algorithms.AlgorithmDescriptor)12 WizardDialog (org.eclipse.jface.wizard.WizardDialog)6 BlockCipherWizardDialog (org.jcryptool.crypto.flexiprovider.algorithms.ui.wizards.blockcipher.BlockCipherWizardDialog)5 AlgorithmWizard (org.jcryptool.crypto.flexiprovider.algorithms.ui.wizards.AlgorithmWizard)4 BlockCipherDescriptor (org.jcryptool.crypto.flexiprovider.descriptors.algorithms.BlockCipherDescriptor)3 SecureRandomDescriptor (org.jcryptool.crypto.flexiprovider.descriptors.algorithms.SecureRandomDescriptor)3 AlgorithmParameterSpec (de.flexiprovider.api.parameters.AlgorithmParameterSpec)2 ActionItem (org.jcryptool.actions.core.types.ActionItem)2 EntryNode (org.jcryptool.crypto.flexiprovider.operations.ui.views.nodes.EntryNode)2 AlgorithmDescriptorElement (org.jcryptool.crypto.flexiprovider.operations.xml.algorithms.AlgorithmDescriptorElement)2 BlockCipherDescriptorElement (org.jcryptool.crypto.flexiprovider.operations.xml.algorithms.BlockCipherDescriptorElement)2 SecureRandomDescriptorElement (org.jcryptool.crypto.flexiprovider.operations.xml.algorithms.SecureRandomDescriptorElement)2 KeyStoreAlias (org.jcryptool.crypto.keystore.backend.KeyStoreAlias)2 MessageDigest (de.flexiprovider.api.MessageDigest)1 NoSuchAlgorithmException (de.flexiprovider.api.exceptions.NoSuchAlgorithmException)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 ExecutionException (org.eclipse.core.commands.ExecutionException)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1