DEREncode issue when upgrading from 5.6.3 to 8.2.0.

168 views
Skip to first unread message

Bart Vandewoestyne

unread,
Feb 24, 2021, 4:15:38 PM2/24/21
to Crypto++ Users
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:


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!

Bart

Jeffrey Walton

unread,
Feb 24, 2021, 8:41:21 PM2/24/21
to Crypto++ Users List
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

Bart Vandewoestyne

unread,
Feb 26, 2021, 7:02:15 AM2/26/21
to Crypto++ Users
Thanks.  I fixed it indeed by replacing

        Decryptor.DEREncode(priv);
        ...
        Encryptor.DEREncode(pub);

by

        Decryptor.AccessMaterial().Save(priv);
        ...
        Encryptor.AccessMaterial().Save(pub);

Thanks!
Bart

Reply all
Reply to author
Forward
0 new messages