Re: DEREncode issue when upgrading from 5.6.3 to 8.2.0.

Jeffrey Walton <[email protected]>
Newsgroups gmane.comp.encryption.cryptopp
Message-ID <CAH8yC8=r+9be2eUAu9eRAi+cEsGyuYQBZutqsEo0FmVpB0ev7g@mail.gmail.com>
On Wed, Feb 24, 2021 at 4:16 PM Bart Vandewoestyne
<[email protected]> wrote:
>
> Hello list,
>
> I am currently upgrading our Crypto++ from 5.6.3 to 8.2.0.  We have some code that compiled fine under 5.6.3, but breaks under 8.2.0.  To me, it looks like code that creates a Base64 encoded private/public keypair or something:
>
>         CryptoPP::RSAES_OAEP_SHA_Decryptor Decryptor(rng, nrOfBits /*, e */);
>         CryptoPP::Base64Encoder priv(new
>             CryptoPP::StringSink(privateKey)); // Base64 Encoder
>         Decryptor.DEREncode(priv);
>         priv.MessageEnd();
>
>         CryptoPP::RSAES_OAEP_SHA_Encryptor Encryptor(Decryptor);
>         CryptoPP::Base64Encoder pub(new
>             CryptoPP::StringSink(publicKey)); // Base64 Encoder
>         Encryptor.DEREncode(pub);
>         pub.MessageEnd();
>
> The problem is the calls to DEREncode that worked with 5.6.3 but with 8.2.0 give the error:
>
> 1>... blabla.../PPKStringEncryption.cpp(32,13): error C2039: 'DEREncode': is not a member of 'CryptoPP::PK_FinalTemplate<CryptoPP::TF_DecryptorImpl<CryptoPP::TF_CryptoSchemeOptions<ALG_INFO,KEYS,CryptoPP::OAEP<CryptoPP::SHA1,CryptoPP::P1363_MGF1>>>>'
> 1>        with
> 1>        [
> 1>            ALG_INFO=CryptoPP::TF_ES<CryptoPP::RSA,CryptoPP::OAEP<CryptoPP::SHA1,CryptoPP::P1363_MGF1>,int>,
> 1>            KEYS=CryptoPP::RSA
> 1>        ]
> 1>...blabla...\ThirdParty\CryptoPP\CryptoPP-custom\pubkey.h(2238): message : see declaration of 'CryptoPP::PK_FinalTemplate<CryptoPP::TF_DecryptorImpl<CryptoPP::TF_CryptoSchemeOptions<ALG_INFO,KEYS,CryptoPP::OAEP<CryptoPP::SHA1,CryptoPP::P1363_MGF1>>>>'
> 1>        with
> 1>        [
> 1>            ALG_INFO=CryptoPP::TF_ES<CryptoPP::RSA,CryptoPP::OAEP<CryptoPP::SHA1,CryptoPP::P1363_MGF1>,int>,
> 1>            KEYS=CryptoPP::RSA
> 1>        ]
>
> I think it has to do with this GitHub issue about removing AsymmetricAlgorithm::BERDecode:
>
> https://github.com/weidai11/cryptopp/issues/569
>
> but since the code is heavily templatized and I do not consider myself a template expert, I don't know with what to replace the DEREncode calls...  Any help on that would be appreciated!

I vaguely remember that change. According to the change in
https://github.com/weidai11/cryptopp/commit/9b174e84de7a, you should
be able to:

    AccessMaterial().Load(bt)
or
    AccessMaterial().Save(bt)

In you case, use the Encryptor object:

    Encryptor.AccessMaterial().Save(pub);

Jeff

-- 
You received this message because you are subscribed to "Crypto++ Users". More information about Crypto++ and this group is available at http://www.cryptopp.com and http://groups.google.com/forum/#!forum/cryptopp-users.
--- 
You received this message because you are subscribed to the Google Groups "Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/cryptopp-users/CAH8yC8%3Dr%2B9be2eUAu9eRAi%2BcEsGyuYQBZutqsEo0FmVpB0ev7g%40mail.gmail.com.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.