Remove AsymmetricAlgorithm::BERDecode (GH #569)

pull/574/head
Jeffrey Walton 2018-01-21 08:45:02 -05:00
parent 565bd844fc
commit 9b174e84de
No known key found for this signature in database
GPG Key ID: B36AB348921B1838
4 changed files with 15 additions and 5 deletions

View File

@ -2307,6 +2307,10 @@ class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CryptoParameters : public GeneratableCrypt
};
/// \brief Interface for asymmetric algorithms
/// \details BERDecode() and DEREncode() were removed under Issue 569
/// and Commit XXX. Programs should use <tt>AccessMaterial().Load(bt)</tt>
/// or <tt>AccessMaterial().Save(bt)</tt> instead.
/// \sa <A HREF="https://github.com/weidai11/cryptopp/issues/569">Issue 569</A>
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE AsymmetricAlgorithm : public Algorithm
{
public:
@ -2320,17 +2324,21 @@ public:
/// \return a const reference to the crypto material
virtual const CryptoMaterial & GetMaterial() const =0;
#if 0
/// \brief Loads this object from a BufferedTransformation
/// \param bt a BufferedTransformation object
/// \details Use of BERDecode() changed to Load() at Issue 569.
/// \deprecated for backwards compatibility, calls <tt>AccessMaterial().Load(bt)</tt>
void BERDecode(BufferedTransformation &bt)
{AccessMaterial().Load(bt);}
/// \brief Saves this object to a BufferedTransformation
/// \param bt a BufferedTransformation object
/// \details Use of DEREncode() changed to Save() at Issue 569.
/// \deprecated for backwards compatibility, calls GetMaterial().Save(bt)
void DEREncode(BufferedTransformation &bt) const
{GetMaterial().Save(bt);}
#endif
};
/// \brief Interface for asymmetric algorithms using public keys

View File

@ -64,7 +64,7 @@ private:
/// \details You should migrate away from OldRandomPool at the earliest opportunity. Use a
/// modern random number generator or key derivation function, like AutoSeededRandomPool or
/// HKDF.
/// \deprecated This class uses an old style PGP 2.6.x with MDC. The generator risks reusing
/// \warning This class uses an old style PGP 2.6.x with MDC. The generator risks reusing
/// random random numbers after state rollback. You should migrate away from OldRandomPool
/// at the earliest opportunity.
/// \sa RandomPool, AutoSeededRandomPool, HKDF, P1363_KDF2, PKCS12_PBKDF, PKCS5_PBKDF2_HMAC

View File

@ -455,17 +455,18 @@ SecByteBlock HexDecodeString(const char *hex)
void GenerateRSAKey(unsigned int keyLength, const char *privFilename, const char *pubFilename, const char *seed)
{
// DEREncode() changed to Save() at Issue 569.
RandomPool randPool;
randPool.IncorporateEntropy((byte *)seed, strlen(seed));
RSAES_OAEP_SHA_Decryptor priv(randPool, keyLength);
HexEncoder privFile(new FileSink(privFilename));
priv.DEREncode(privFile);
priv.AccessMaterial().Save(privFile);
privFile.MessageEnd();
RSAES_OAEP_SHA_Encryptor pub(priv);
HexEncoder pubFile(new FileSink(pubFilename));
pub.DEREncode(pubFile);
pub.AccessMaterial().Save(pubFile);
pubFile.MessageEnd();
}

View File

@ -898,12 +898,13 @@ bool ValidateEC2N()
{
std::cout << "\nEC2N validation suite running...\n\n";
// DEREncode() changed to Save() at Issue 569.
ECIES<EC2N>::Decryptor cpriv(GlobalRNG(), ASN1::sect193r1());
ECIES<EC2N>::Encryptor cpub(cpriv);
ByteQueue bq;
cpriv.DEREncode(bq);
cpriv.AccessMaterial().Save(bq);
cpub.AccessKey().AccessGroupParameters().SetEncodeAsOID(true);
cpub.DEREncode(bq);
cpub.AccessMaterial().Save(bq);
ECDSA<EC2N, SHA1>::Signer spriv(bq);
ECDSA<EC2N, SHA1>::Verifier spub(bq);
ECDH<EC2N>::Domain ecdhc(ASN1::sect193r1());