Skip to content

RSA encryption without private key #2367

@Archivist062

Description

@Archivist062

Expected behavior

RSA Cipher requires only the public key to generate a valid ciphertext

Actual behavior

Without a private key supplied on encryption, the ciphertext generated is not decipherable. An exception whose .what() is I/O Error is thrown by decryptString.

Steps to reproduce the problem

    auto decrypt_key = new Poco::Crypto::RSAKey(
        std::string("./key.pub"),
        std::string("./key.priv"),
        std::string("")
    );
    auto encrypt_key = new Poco::Crypto::RSAKey(
        std::string("./key.pub")
    );

    Poco::Crypto::CipherFactory factory;
    auto iengine= factory.createCipher(*encrypt_key);
    auto oengine= factory.createCipher(*decrypt_key);

    std::string SS = "test_str";
    auto enc = iengine->encryptString(SS);
    auto SS2 = oengine->decryptString(enc);
    assert(SS==SS2);

    delete decrypt_key;
    delete encrypt_key;

key.pub being a valid public key for key.priv

POCO version

1.9.0

Compiler and version

GCC 7.3.0

Operating system and version

Debian/Linux testing x64

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions