Skip to content

Commit

Permalink
Test implementation of provider selection in Signature (see DSA) algos
Browse files Browse the repository at this point in the history
  • Loading branch information
simlei committed Aug 25, 2020
1 parent a6cf43f commit 82e3b99
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.ProviderMismatchException;
import java.security.UnrecoverableEntryException;
import java.security.cert.Certificate;
import java.util.ArrayList;
Expand All @@ -22,6 +23,7 @@
import org.eclipse.jface.dialogs.MessageDialog;
import org.jcryptool.core.logging.dialogs.JCTMessageDialog;
import org.jcryptool.core.logging.utils.LogUtil;
import org.jcryptool.core.operations.providers.ProviderManager2;
import org.jcryptool.crypto.flexiprovider.descriptors.IFlexiProviderOperation;
import org.jcryptool.crypto.flexiprovider.engines.FlexiProviderEngine;
import org.jcryptool.crypto.flexiprovider.engines.FlexiProviderEnginesPlugin;
Expand Down Expand Up @@ -50,6 +52,8 @@ public KeyObject init(IFlexiProviderOperation operation) {
char[] password = null;
KeyObject usedKey = null;
try {
// this tries to
ProviderManager2.getInstance().setProviders__flexiPromoted();
signature = Registry.getSignature(operation.getAlgorithmDescriptor().getAlgorithmName());
AlgorithmParameterSpec spec = operation.getAlgorithmDescriptor().getAlgorithmParameterSpec();
if (spec != null) {
Expand All @@ -74,7 +78,9 @@ public KeyObject init(IFlexiProviderOperation operation) {
operation.setPassword(password); // save in the operation if no exception occurred
} else {
Certificate certificate = KeyStoreManager.getInstance().getCertificate(operation.getKeyStoreAlias());

Key publicKey = (Key) certificate.getPublicKey();

signature.initVerify((PublicKey) publicKey);
usedKey = new KeyObject(publicKey, password);
}
Expand All @@ -97,6 +103,8 @@ public KeyObject init(IFlexiProviderOperation operation) {
} catch (Exception e) {
LogUtil.logError(FlexiProviderEnginesPlugin.PLUGIN_ID, "Exception while initializing a signature", e, true); //$NON-NLS-1$
return null;
} finally {
ProviderManager2.getInstance().setProviders__sunPromoted();
}
return usedKey;
}
Expand Down

0 comments on commit 82e3b99

Please sign in to comment.