Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flexiprovider Integration: Hybrid Ciphers in Operations View not working #49

Closed
antidote2 opened this issue Feb 11, 2013 · 2 comments
Closed

Comments

@antidote2
Copy link
Contributor

Hybrid Cyphers, e.g. McEliece cryptosystem does not work in operations view, as you cannot select whether you want to encrypt or decrypt.

The reason should be: you provide a key pair which preselects encrypt for public key and decrypt for private key, this seems to fail for hybrid ciphers

@ghost
Copy link

ghost commented Dec 29, 2013

The problem is probably caused by a mix-up of calling initEncrypt(...) and initDecrypt(...) in
org.jcryptool.crypto.flexiprovider.engines.cipher.AsymmetricHybridCipherEngine.init(...).

In the decrypt-Branch in lines 54/55 it should be initDecrypt(...) insteadof initEncrypt and in the else-branch in line 59 it should be initEncrypt instead of initDecrypt.

@Override public KeyObject init(IFlexiProviderOperation operation) { LogUtil.logInfo("initializing asymmetric hybrid cipher engine"); //$NON-NLS-1$ this.operation = operation; char[] password = null; Key key = null; try { cipher = Registry.getAsymmetricHybridCipher(operation.getAlgorithmDescriptor().getAlgorithmName()); if (operation.getOperation().equals(OperationType.DECRYPT)) {
            // password may be contained in the ActionItem, otherwise prompt
            if (operation.getPassword() != null) {
                password = operation.getPassword();
            } else {
                password = promptPassword();
            }

            if (password == null) {
                return null;
            }

            key = (Key) KeyStoreManager.getInstance().getPrivateKey(operation.getKeyStoreAlias(), password);
            cipher.initEncrypt(key, operation.getAlgorithmDescriptor().getAlgorithmParameterSpec(), 
                    FlexiProviderEnginesPlugin.getSecureRandom()); //<----- should be initDecrypt
        } else {
            Certificate certificate = KeyStoreManager.getInstance().getCertificate(operation.getKeyStoreAlias());
            key = (Key) certificate.getPublicKey();
            cipher.initDecrypt(key, operation.getAlgorithmDescriptor().getAlgorithmParameterSpec());  //<----- should be initEncrypt
        }
    ...
    return new KeyObject(key, password);
}

@ghost ghost assigned dschadow Dec 29, 2013
@dschadow
Copy link
Member

Fixed, set context menu to visible for hybrid ciphers too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants