Hello!
I have PKCS#3 encoded data.
   42:d=5  hl=4 l= 267 cons: SEQUENCE
   46:d=6  hl=3 l= 129 prim: INTEGER: ...
  178:d=6  hl=3 l= 128 prim: INTEGER: ...
  309:d=6  hl=2 l=   2 prim: INTEGER: ...

This data represents parameters for Diffie-Hellman key agreement
algorithm. I try to decode them by calling DH::BERDecode(). This call
is successful, but generating of common secret is failed: DH::Agree()
returns false.

I have investigate this problem. DH::BERDecode() calls the function
below. For my data this function will work strange...
void DL_GroupParameters_IntegerBased::BERDecode(BufferedTransformation
&bt)
{
        BERSequenceDecoder parameters(bt);
                Integer p(parameters);//First we decode Modulus. OK
                Integer q(parameters);//Here we should decode Generator!!!
                Integer g;//But Generator is decoded here...
                if (parameters.EndReached())
                {
                        g = q;
                        q = ComputeGroupOrder(p) / 2;
                }
                else
                                                      //In my data
Generator is equal to private key's length...
                        g.BERDecode(parameters);
        parameters.MessageEnd();

        SetModulusAndSubgroupGenerator(p/* Modulus. OK */, g/* private key's
length. BAD */);
        SetSubgroupOrder(q);
}

ASN1 description of PKCS #3 structure.
DHParameter ::= SEQUENCE {
  prime INTEGER, -- p
  base INTEGER, -- g
  privateValueLength INTEGER OPTIONAL }

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the "Crypto++ Users" 
Google Group.
To unsubscribe, send an email to [email protected].
More information about Crypto++ and this group is available at 
http://www.cryptopp.com.
-~----------~----~----~----~------~----~------~--~---

Reply via email to