@@ -751,9 +751,10 @@ struct DiffieHellman::DHImpl {
751751 byte* publicKey_;
752752 byte* privateKey_;
753753 byte* agreedKey_;
754+ uint pubKeyLength_;
754755
755756 DHImpl (TaoCrypt::RandomNumberGenerator& r) : ranPool_(r), publicKey_(0 ),
756- privateKey_ (0 ), agreedKey_(0 ) {}
757+ privateKey_ (0 ), agreedKey_( 0 ), pubKeyLength_ (0 ) {}
757758 ~DHImpl ()
758759 {
759760 ysArrayDelete (agreedKey_);
@@ -762,7 +763,7 @@ struct DiffieHellman::DHImpl {
762763 }
763764
764765 DHImpl (const DHImpl& that) : dh_(that.dh_), ranPool_(that.ranPool_),
765- publicKey_ (0 ), privateKey_(0 ), agreedKey_(0 )
766+ publicKey_ (0 ), privateKey_(0 ), agreedKey_( 0 ), pubKeyLength_ (0 )
766767 {
767768 uint length = dh_.GetByteLength ();
768769 AllocKeys (length, length, length);
@@ -810,7 +811,7 @@ DiffieHellman::DiffieHellman(const byte* p, unsigned int pSz, const byte* g,
810811 using TaoCrypt::Integer;
811812
812813 pimpl_->dh_ .Initialize (Integer (p, pSz).Ref (), Integer (g, gSz ).Ref ());
813- pimpl_->publicKey_ = NEW_YS opaque[pubSz];
814+ pimpl_->publicKey_ = NEW_YS opaque[pimpl_-> pubKeyLength_ = pubSz];
814815 memcpy (pimpl_->publicKey_ , pub, pubSz);
815816}
816817
@@ -869,6 +870,10 @@ const byte* DiffieHellman::get_agreedKey() const
869870 return pimpl_->agreedKey_ ;
870871}
871872
873+ uint DiffieHellman::get_publicKeyLength () const
874+ {
875+ return pimpl_->pubKeyLength_ ;
876+ }
872877
873878const byte* DiffieHellman::get_publicKey () const
874879{
0 commit comments