Imported from previous forum
Hello,
Has anybody implemented Signature using MD5. I’m using PGP-DES-MD5. There is a problem with Signature verification. How do you generally create a signature. Is there any specific way. I use Morgan Stanley Library of MD5. MD5_Init(),MD5_Update(),MD5_Final() etc. I pass the fix message string from 8=FIX.4.1 till 91 tag (SecureData) inclusive of that to MD5 engine with fix session key to get the signature. Is this the way or is there any other. I’m doing this way.
Basically how do you initialize the session_info structure and the key_info structure and with what. Do you have any samples or examples of how to do it.
Should the CHANBINDING always contain the port number of the server. Can it be any thing other than that. Can the DES_Key(Session key) and the IVEC(Initialization vector be the same).
Thanks in Advance
Hari
The chunk of the FIX message which you should run through the MD5 signature calculation should include the SecureData contents as well. Your statement “till 91 tag (SecureData)” doesn’t sound correct, unless the “inclusive” is referring to being inclusive of the SecureData field as well.
Think of it this way, the entire FIX Standard Header (which SecureData is a part of) and Body (if applicable (should not be)) is what the Signature computation is based upon.
The primary tricky issue with computing the Signature is that the Signature computation is inclusive of the BodyLength (tag 9) field and value in the StandardHeader, however, the BodyLength computed value (up to CheckSum) needs to include SignatureLength (tag 90) and Signature (tag 89). The Signature computation always has a length of 16. Thus, your BodyLength prior to Signature computation, recognizing the Signature piece will be appended, must account for an additional 26 bytes (90=16^89=1234567890123456^).
Regarding your "How do you initialize" question:
- Populate PGP_MD5_pub_info (see details below)
- Invoke: FIX_fill_session_info(&PGP_MD5_pub_info, &PGP_MD5_session_info);
- Invoke: FIX_init_key_info(&PGP_MD5_session_info, &PGP_MD5_key_info);
- Construct and send your Logon with PGP encrypted section in RawData (tag 96)
#1 can be broken down as (example in C and Hungarian notation to give a sense of data type):
PGP_MD5_pub_info.mechanism = sEncryptType; /* 5 /
PGP_MD5_pub_info.sender = szPrivateKeyName; / szSenderCompID /
PGP_MD5_pub_info.recipient = szPublicKeyName; / szTargetCompID or PGP key hex name /
PGP_MD5_pub_info.password = szPrivateKeyPass; / top secret /
/ – Ensure that chanbinding field does not end with ‘\0’ and pad with trailing spaces – */
sprintf(szPortNumber, “%d”, lPortNumber);
char szChanbindingTemp[10];
sprintf(szChanbindingTemp, “%8s”, szPortTemp);
memcpy(PGP_MD5_pub_info.chanbinding, szChanbindingTemp, 8);
PGP_MD5_pub_info.inifile[0] = ‘\0’;
PGP_MD5_pub_info.epffile[0] = ‘\0’
Hope this helps you and others.
> Hello,
>
> Has anybody implemented Signature using MD5. I’m using PGP-DES-MD5. There is a problem with Signature verification. How do you generally create a signature. Is there any specific way. I use Morgan Stanley Library of MD5. MD5_Init(),MD5_Update(),MD5_Final() etc. I pass the fix message string from 8=FIX.4.1 till 91 tag (SecureData) inclusive of that to MD5 engine with fix session key to get the signature. Is this the way or is there any other. I’m doing this way.
>
> Basically how do you initialize the session_info structure and the key_info structure and with what. Do you have any samples or examples of how to do it.
>
> Should the CHANBINDING always contain the port number of the server. Can it be any thing other than that. Can the DES_Key(Session key) and the IVEC(Initialization vector be the same).
>
> Thanks in Advance
> Hari
>
[ original email was from Anand Kumar - anand.kumar@nssmb.com ]
Hi,
I am following almost same method to initialize my sessionInfo structure but no matter how many times I call FIX_fill_session_info(), the sessionInfo structure (and hence the DES key generated) remains same. I fill the pubInfo structure using same sender and receipient (password is "" for me and chanbinding, inifile and epffile are nil). I expect the DES key and i-vector to be different each time I call FIX_fill_session_info() as it uses ppid(), pid() and time() to initialize MS5 context.
Also, once I have got the value of i-vector from FIX_fill_session_info(), I fill it in my FIX_key_info structure. Should I set enc_ivec and dec_ivec with the same value?
Is there any book/writing/study material on Net about "how to do PGP-DES encryption", I mean how to write the code, sample code etc.?
Lots of thanks well in advance.
Regards,
Anand
> The chunk of the FIX message which you should run through the MD5 signature calculation should include the SecureData contents as well. Your statement “till 91 tag (SecureData)” doesn’t sound correct, unless the “inclusive” is referring to being inclusive of the SecureData field as well.
>
> Think of it this way, the entire FIX Standard Header (which SecureData is a part of) and Body (if applicable (should not be)) is what the Signature computation is based upon.
>
> The primary tricky issue with computing the Signature is that the Signature computation is inclusive of the BodyLength (tag 9) field and value in the StandardHeader, however, the BodyLength computed value (up to CheckSum) needs to include SignatureLength (tag 90) and Signature (tag 89). The Signature computation always has a length of 16. Thus, your BodyLength prior to Signature computation, recognizing the Signature piece will be appended, must account for an additional 26 bytes (90=16^89=1234567890123456^).
>
> Regarding your “How do you initialize” question:
> 1) Populate PGP_MD5_pub_info (see details below)
> 2) Invoke: FIX_fill_session_info(&PGP_MD5_pub_info, &PGP_MD5_session_info);
> 3) Invoke: FIX_init_key_info(&PGP_MD5_session_info, &PGP_MD5_key_info);
> 4) Construct and send your Logon with PGP encrypted section in RawData (tag 96)
>
> #1 can be broken down as (example in C and Hungarian notation to give a sense of data type):
> PGP_MD5_pub_info.mechanism = sEncryptType; /* 5 /
> PGP_MD5_pub_info.sender = szPrivateKeyName; / szSenderCompID /
> PGP_MD5_pub_info.recipient = szPublicKeyName; / szTargetCompID or PGP key hex name /
> PGP_MD5_pub_info.password = szPrivateKeyPass; / top secret /
> / – Ensure that chanbinding field does not end with ‘\0’ and pad with trailing spaces – */
> sprintf(szPortNumber, “%d”, lPortNumber);
> char szChanbindingTemp[10];
> sprintf(szChanbindingTemp, “%8s”, szPortTemp);
> memcpy(PGP_MD5_pub_info.chanbinding, szChanbindingTemp, 8);
> PGP_MD5_pub_info.inifile[0] = ‘\0’;
> PGP_MD5_pub_info.epffile[0] = ‘\0’
>
>
> Hope this helps you and others.
>
>
>
> > Hello,
> >
> > Has anybody implemented Signature using MD5. I’m using PGP-DES-MD5. There is a problem with Signature verification. How do you generally create a signature. Is there any specific way. I use Morgan Stanley Library of MD5. MD5_Init(),MD5_Update(),MD5_Final() etc. I pass the fix message string from 8=FIX.4.1 till 91 tag (SecureData) inclusive of that to MD5 engine with fix session key to get the signature. Is this the way or is there any other. I’m doing this way.
> >
> > Basically how do you initialize the session_info structure and the key_info structure and with what. Do you have any samples or examples of how to do it.
> >
> > Should the CHANBINDING always contain the port number of the server. Can it be any thing other than that. Can the DES_Key(Session key) and the IVEC(Initialization vector be the same).
> >
> > Thanks in Advance
> > Hari
> >
>