FW: MsgToDecrypt usage (how-to...)

"Pawling, John" <[email protected]> Wed, 1 Aug 2001 14:03:18 -0400
Newsgroups gmane.ietf.sfl
Message-ID <[email protected]>

-----Original Message-----
From: Colestock, Robert 
Sent: Monday, July 30, 2001 8:44 AM
To: 'Simon Blanchet'
Subject: RE: MsgToDecrypt usage (how-to...)


Simon:

I used your exact code snippet below and passed by the failure point; I
failed on the decrypt attempt itself.  Please check that the CSM_Buffer
truely contains valid data.  I hardcoded the file name (correctly) and
properly processed the data (I am using our internal baseline, but this
logic has not been modified).

ERROR INFORMATION AND STACK:

 ERROR INFORMATION: couldn't decrypt EMEK
        ERROR CODE: 1006        SOURCE LINE NUMBER: 684
        FILE: I:\devel.d\vda_snacc.d\SMIME\libsrc\hilevel\sm_Decrypt.cpp
        FUNCTION: CSM_DataToDecrypt::Decrypt

CSM_MsgToDecrypt::Decrypt IN
I:\devel.d\vda_snacc.d\SMIME\libsrc\hilevel\sm_Decr
ypt.cpp, line 106.
main IN i:\devel.d\vda_snacc.d\smime\testsrc\hilevel\sm_reporttest.cpp, line
-1.

I also ran your file through the "report_tool" utililty and failed on the
decrypt similarly.  (The command arguments I used are
"./hilevel/mimemsgs/Simon.d/CMSEnvelopedDataBinary.dat
login=./LoginsAlld.cfg flag=decrypt" in the ../../test default directory).

Bob Colestock
VDA.

-----Original Message-----
From: Simon Blanchet [mailto:[email protected]]
Sent: Thursday, July 26, 2001 2:14 PM
To: Colestock, Robert
Subject: RE: MsgToDecrypt usage (how-to...)


I'm almost 100% sure that the data itself is good.  Why? because I had
successfully decrypted the same E-Mail using Outlook Express and Outlook 2K.
The E-Mail itself was encrypted using SFL (Yes I'm able to Encrypt, Sign and
Verify with SFL...).  More then that, I did use dumpasn utility from Peter
Gutmann to interpret the binary file (CMSEnvelopedData.dat) to make sure
that
the file is truelly a fully compliant CMS Enveloped Data
(pkcs-7-envelopedData).

The E-Mail Source itself: EnvelopedData.msg
The binary CMS part (base64 decoding of the content of the previous mail):
CMSEnvelopedDataBinary.dat
The result of the interpretation by dumpasn (ASN decoding):
CMSEnvelopedDataInterpreted.txt

I'll know that you'll eventually need my PrivateKey [and Certificate] to be
able
to decrypt it but that's not the problem...  The problem occurs before that
(in
PreProc()).  Anyways, if you really need those files tell me I'll send them
to
you (anyways they are only test files.. . ;-)).

The code used is the same that I've sent you this morning.  The problem
itself
is that within PreProc() m_SnaccEnvelopedData.encryptedContentInfo is NULL.
So
an Exception is thrown (contentEncryptionAlgorithm missing).  By the way,
sorry
I misused a word: it don't [crash] it [throws] an Exception.  So the real
question is HOW to use the MsgToDecrypt class in order to decrypt a given
message.  I would likes to have a real description of the steps to fallow
because now I think that I'm not using this class correctly because
obviously it
don't works like I'm expecting it to work...

When I catch the Exception and I use the method on the Exception I get this:

contentEncryptionAlgorithm missing
FUNCTION: CSM_DataToDecrypt::PreProc csmime
FILENAME: C:\CVS_HOME\external\SFL\SMIME\libsrc\hilevel\sm_Decrypt.cpp
STACK:
ERROR INFORMATION: contentEncryptionAlgorithm missing
	ERROR CODE: 2001	SOURCE LINE NUMBER: 324
	FILE: C:\CVS_HOME\external\SFL\SMIME\libsrc\hilevel\sm_Decrypt.cpp
	FUNCTION: CSM_DataToDecrypt::PreProc csmime

CSM_MsgToDecrypt::PreProc csmime IN
C:\CVS_HOME\external\SFL\SMIME\libsrc\hilevel\sm_Decrypt.cpp, line 138.
ýýýý­º
ð­º
ð­º
𭺫«««««««

Do I have to manipulate any other class (beside CSMIME at login time) before
calling PreProc() or Decrypt()?  By the way, the CSMIME itself was
constructed
successfully (I use the same one (same session) to Encrypt and Sign other
files).

Thanks for your support

-----Original Message-----
From: Colestock, Robert [mailto:[email protected]]
Sent: 26 juillet, 2001 12:52
To: 'Simon Blanchet'; [email protected]
Subject: RE: MsgToDecrypt usage (how-to...)


Simon:

If the data is good, it looks like the logic should work fine.  Please send
the actual data input to the CSM_MsgToDecrypt constructor, I will
investigate.  At the very least we should indicate an error, not "crash".

Bob Colestock
VDA

-----Original Message-----
From: Simon Blanchet [mailto:[email protected]]
Sent: Thursday, July 26, 2001 11:10 AM
To: [email protected]
Subject: MsgToDecrypt usage (how-to...)




Some informations concerning this little code snap-shot:

- pBufToDecrypt points to a CSM_Buffer constructed with a file that contain
the
(binary (base64 decoded)) CMS part of an S/MIME E-Mail (the resulting binary
file was first successfully dumped using dumpasn utility and it's a
pkcs-7-envelopedData (1 2 840 113549 1 7 3).
- m_EngineLogin.GetCSMIME() returns a CSMIME* that was previously
initialized
with SM_Free3D login using a X.509 Public Certificate, a PKCS#8
Encrypted-PrivateKey and the password (this login works and the
corresponding
CSM_CSInst has been maked as USE-THIS and APPLICABLE.
- The CSMIME* mentionned above was initialised with the E-Mail recipient's
Key-Pair (so we have in hand the right private key to decrypt the CMS part).

Since we have everything in hand to decrypt the pkcs-7-envelopedData I
wanted to
know WHY it don't works and what do I have to do in order to make this work.

[ BEGIN CODE ]
CSM_Buffer* pBufToDecrypt = new
CSM_Buffer(const_cast<char*>(sContentFilename.c_str()));

CSM_ContentInfoMsg* pContentToDecrypt = new
CSM_ContentInfoMsg(pBufToDecrypt);

CSM_MsgToDecrypt msgToDecrypt(pContentToDecrypt);

msgToDecrypt.PreProc(m_EngineLogin.GetCSMIME());

msgToDecrypt.Decrypt(m_EngineLogin.GetCSMIME());
[ END CODE ]

PROBLEM DESCRIPTION:

it crash within the CSM_MsgToDecrypt::PreProc() method (I did trace the code
to
figure out that you are trying to access memory that was not initialized
(NULL
pointer):

if ((m_SnaccEnvelopedData.encryptedContentInfo == NULL) ||
          (m_SnaccEnvelopedData.encryptedContentInfo->
            contentEncryptionAlgorithm == NULL))

In fact, m_SnaccEnvelopedData is NULL.  But looking at msgToDecrypt class
the
CSM_CommonData::m_pEncodedBlob part of it contain the right data to
process...
What do I have to do to "inform" msgToEncrypt that it's data is there.  In
other
words, what do I have to do to transform this m_pEncodedBlob to
m_SnaccEnvelopedData?????

What kind of preprocessing do I have to do before calling
MsgToDecrypt::PreProc()?

What's wrong with my logic?  Do I miss something?

Thanks a lot (a quick (and complete) answer will be truelly welcomed)

|=========================================
| Simon Blanchet
| Software Designer
|
| Email: [email protected]
|=========================================