RE: CSM_MsgToSign::Sign

"Colestock, Robert" <[email protected]>
Newsgroups gmane.ietf.sfl
Message-ID <[email protected]>
Arnaud:

I recently ran into this myself when attempting to use the CSM_MsgToSign
class.  It ends up there are 2 variables that designate usage of the login
classes (at this point the reasons are fuzzy).  On variable designates a
specific login as "usable" (CSM_CSInst::m_UseThis) for verification or
general crypto algorithms (in theory all logins should be designated usable,
but we originally wanted some fine grain control over CTIL usage).  This
variable is set to "1" by "UseAll()".  The other variable designates a
specific login as "applicable" (CSM_CSInst::m_Applicable) for encryption,
decryption and signing operations where specific logins MUST be designated.
It is not likely that a client application would wish that all signers from
a list would sign encrypt a message, so the logic forces users to
explicitely specify a very precise user to sign with (by setting
CSM_CSInst::SetApplicable()).  Part of this reasoning is for security and
liability purposes; we wanted to ensure that applications understood the
implications of signing/encrypting with a very specific login.

For your case, the "UseAll()" is adequate for verification.  Unfortunately
for signing it is necessary to loop through each of the logins specifying
the actual login(s) to sign with.  The following loop, called before the
CSM_MsgToSign::Sign(...) call will work fine (be sure to change the "Csmime"
variable to your local definition or pointer):

      for (CSM_CSInst *tmpCSInst = Csmime.m_pCSInsts->SetCurrToFirst();
tmpCSInst;
           tmpCSInst = Csmime.m_pCSInsts->GoNext())
      {
         if (tmpCSInst->IsSigner())
         {
           tmpCSInst->SetUseThis(); 
           tmpCSInst->SetApplicable(true);
         }
      }

Bob Colestock

-----Original Message-----
From: Arnaud De Timmerman [mailto:[email protected]]
Sent: Tuesday, May 02, 2000 8:03 AM
To: [email protected]
Cc: [email protected]
Subject: CSM_MsgToSign::Sign




Bob,

In libsrc\hilevel\sm_Sign.cpp, line 93 says :
***************************************
//  It is expected that at least one session is valid for processing (as
many
//  SignerInfos will be added to the resulting SignedData ASN.1 structure as
//  there are flagged sessions in the pCsmime structure).
***************************************

I wonder that it means I have to set the "m_pCSInsts->SetUseThis" to true
but
even if I use the UseAll() function, the SignerInfos aren't
added. I send the input file I use and the output file I get. Please tell me
what's wrong here :

***************************************
 CSM_Buffer *m_pBuf=new CSM_Buffer("input");
 CSM_MsgToSign sig(m_pBuf);
 sig.SetEncapContent(m_pBuf,CSM_Content::CONTENT_DATA_DATA);
 CSMIME pCsmime;
 CSM_AppLogin AppLog("libsm_free3DLL","sm_free3DLL DSAFreeGroup1User2.out
dsaFreeGroup1_User2X_8.dat ElmoRocks sm_FREE3");
 if (pCsmime.m_pCSInsts && AppLog.m_pCSInsts)
     {
     pCsmime.m_pCSInsts->AppendL(AppLog.m_pCSInsts);
     sm_CfgClearLogin(AppLog);// Prevent destruction
           // since we took memory.
     }
 else if (AppLog.m_pCSInsts)   // is there something to add.
     {
     pCsmime.m_pCSInsts = AppLog.m_pCSInsts;
     AppLog.m_pCSInsts = NULL;
     }
 pCsmime.UseAll();
 SM_RET_VAL lStatus = SM_NO_ERROR;
 lStatus=sig.Sign(&pCsmime);
 printf("error %d\n",lStatus);
 CSM_Buffer *pbufContent = sig.GetEncodedContentInfo();
 pbufContent->ConvertMemoryToFile("output");
 delete pbufContent;
 delete m_pBuf;
***************************************

(See attached file: input)(See attached file: output)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.