@@ -748,9 +748,10 @@ struct DiffieHellman::DHImpl {
748748 byte* publicKey_;
749749 byte* privateKey_;
750750 byte* agreedKey_;
751+ uint pubKeyLength_;
751752
752753 DHImpl (TaoCrypt::RandomNumberGenerator& r) : ranPool_(r), publicKey_(0 ),
753- privateKey_ (0 ), agreedKey_(0 ) {}
754+ privateKey_ (0 ), agreedKey_( 0 ), pubKeyLength_ (0 ) {}
754755 ~DHImpl ()
755756 {
756757 ysArrayDelete (agreedKey_);
@@ -759,7 +760,7 @@ struct DiffieHellman::DHImpl {
759760 }
760761
761762 DHImpl (const DHImpl& that) : dh_(that.dh_), ranPool_(that.ranPool_),
762- publicKey_ (0 ), privateKey_(0 ), agreedKey_(0 )
763+ publicKey_ (0 ), privateKey_(0 ), agreedKey_( 0 ), pubKeyLength_ (0 )
763764 {
764765 uint length = dh_.GetByteLength ();
765766 AllocKeys (length, length, length);
@@ -807,7 +808,7 @@ DiffieHellman::DiffieHellman(const byte* p, unsigned int pSz, const byte* g,
807808 using TaoCrypt::Integer;
808809
809810 pimpl_->dh_ .Initialize (Integer (p, pSz).Ref (), Integer (g, gSz ).Ref ());
810- pimpl_->publicKey_ = NEW_YS opaque[pubSz];
811+ pimpl_->publicKey_ = NEW_YS opaque[pimpl_-> pubKeyLength_ = pubSz];
811812 memcpy (pimpl_->publicKey_ , pub, pubSz);
812813}
813814
@@ -866,6 +867,10 @@ const byte* DiffieHellman::get_agreedKey() const
866867 return pimpl_->agreedKey_ ;
867868}
868869
870+ uint DiffieHellman::get_publicKeyLength () const
871+ {
872+ return pimpl_->pubKeyLength_ ;
873+ }
869874
870875const byte* DiffieHellman::get_publicKey () const
871876{
0 commit comments