[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

FW: Using SFL to verify (SIMPLE TEST EXAMPLE)



Margaret:

I created a test program to test RSA verification with the suggested code.
There are a few modifications necessary to execute.


1) It would appear that the constructors for CSM_MsgToVerify that you chose
do not work the same as those demonstrated in sm_CLMsgToVerify.cpp.  This
will be fixed at some point in the future; for now use the example in the
test program (which properly loads the SignerInfo class structures for
verification).  This is the result of poor test programs; we only test 1
interface fully.


2)The parameters to the CSM_Free3 class constructor are fine, but the
construction of the instance must be defaulted to indicate a name and a
certificate.  These are also in the test program.
        pTokenInterface  = CSM_Free3::AddLoginStatic(pFree, CertBuf,
                NULL, NULL, lszID, NULL);
        GLOBALAddLoginFinish(Csmime, pTokenInterface, lszID, CertBuf);


3) IT IS IMPORTANT TO DEFINE "SM_FREE3_RSA_INCLUDED" for proper RSA
execution within the Free3 CTIL; my initial code had this logic disabled.
The next release will have a special configuration item to build with this
flag.


4.) A mistake was discovered in the sm_free3.cpp source file that must be
fixed to process the enclosed message.  It is necessary to modify the
"sm_free3.cpp" to fix an error on "md5" hash checks as follows (in
"sm_free3.cpp" approximately line 330, add "(" and ")" to properly check
"sha_1" with OIDs that do not specify the hash OID):

<<<<<< In "./sm_algs/sm_free3/sm_free3.cpp" >>>>>>>
#ifdef SM_FREE3_RSA_INCLUDED
//////////////////////////////////////////////////////////////////////////
SM_RET_VAL CSM_Free3::SMTI_VerifyRSA(
            CSM_Buffer *pSignerKey, // input
            CSM_Alg    *pDigestAlg, // input
            CSM_Alg    *pSignatureAlg, // input
            CSM_Buffer *pData, // input
            CSM_Buffer *pSignature) // input
{
...
   // determine rsa algorithm
   if (*palgoid == sha_1WithRSAEncryption || 
       *palgoid == sha_1WithRSAEncryption_ALT || 
       (/**RWC;5/11/00*/
        (*palgoid == rsaEncryption ||
        *palgoid == rsa ||
        *palgoid == CSM_OID("1.2.840.113549.1.2")/**RWC;5/11/00*/) &&
*pdigoid == sha_1) )
...

These changes will allow the enclosed message to be verified with the
enclosed test program and test certificate.  Be careful about using some of
our old RSA certificates, the OIDs are incorrect.  Also be careful in
testing with some of our old SignedDeta test messages.  They all work fine
with the BSafe CTIL, but not with the newer Free3 CTIL RSA logic.  The Free3
CTIL RSA logic only handles the proper OIDs (these test messages work fine).





The project settings for the test program can be copied from the "AutoAlg"
project (since this project directly links the Free3 CTIL).  The test
program, with this data and certificate resulted in a proper verification
and the following output:

Hello World!
CSM_MsgToVerify::ReportMsgData(ostream &os)
CSM_MsgSignerInfos::ReportMsgData(ostream &os)
  Number 1 signer info WAS VERIFIED.
    CSM_MsgSignerInfo::ReportMsgData(ostream &os)
      CSM_RecipientIdentifier::Report(IssuerAndSerialNumber)
      Issuer = C=US@O=US Government@OU=VDA Site@OU=VDA@CN=Daisy RSA
Exts@xxxxxxx
.113549.1.9.1=rwc@xxxxxxxxxxxxx
      Serial Number = 07
      digestAlgorithm OID=1.2.840.113549.2.5
      signatureAlgorithm OID=1.2.840.113549.1.1.1
Finished.....
Press any key to continue

It works equally well with a DSA signature.  Sorry about the inconvenience
of requiring a Certificate for logins.


Bob Colestock
-----Original Message-----
From: Colestock, Robert [mailto:Robert.Colestock@xxxxxxxx] 
Sent: Wednesday, May 10, 2000 2:21 PM
To: 'Margaret Cyrzan'; imc-sfl@xxxxxxx
Subject: RE: Using SFL to verify


Margaret:

You are correct, it does nothing.  The CTIL, or instance reference, does not
contain any OIDs to associate an algorithm for verification.

Creative use of the CTIL constructor.  It was not intended to be used in
this fashion, but it can work.  The creation of your TokenInterface is
incomplete, there is a lot more information necessary, like the OIDs, name,
functionality, etc.  This is done by the individual CTIL library when loaded
dynamically.  Our design intent is to dynamically load the CTIL DLLs as a
string, with a startup string.

It is possible to link and manipulate the CTIL directly.  The following
logic is modified from "sm_free3.cpp":

		CSM_Buffer CertBuf("DaisyRsaExts.out");	// Be sure to
specify the path.
            CSM_TokenInterface  *pTokenInterface;
		CSM_Free3 *pFree = new CSM_Free3(rsa);
            pTokenInterface  = CSM_Free3::AddLoginStatic(pFree, CertBuf,
                NULL, NULL, NULL, NULL);
            GLOBALAddLoginFinish(Csmime, pTokenInterface, argv1[4],
pCertPath);
		// AT THIS POINT, the Csmime instance is read to verify.

Unfortunately, at this time the library requires a certificate to align the
OIDs; even for verification (where an originator certificate is
unnecessary).  The logic for simple verification logic is partially
implemented, but the library requires at least a dummy certificate for the
instance; the dummy certificate MUST be an RSA certificate.

As to building with RSA, you will need to construct the sm_free3 CTIL with
the "SM_FREE3_RSA_INCLUDED" define.  (Be aware of the RSA licensing
restrictions, even if using the Crypto++ implementation, this logic should
not be used in commercial applications unless a license is granted by RSA).

As to certificates, they are probably already in the SignedData of the
message (this is generally the case).  If not, then it is up to the
application to extract the certificates and load them into the
CSM_MsgToVerify instance for processing.  Normally they are not a separate
attachment in an e-mail where they must be extracted, but it is common that
they are not sent as part of the SignedData (or sent only the 1st time,
expecting the e-mail client to extract them and associate the certificate(s)
with a particular e-mail recipient in the address book for later use).  If
you do not have the certificate within the SignedData, I would suggest you
re-generate the SignedData with the certificate(s) contained (usually a flag
in the options of e-mail clients).

I will attempt to create a test case this week, and modify the CTIL for a
future release to accommodate a missing certificate.  In the meantime, this
certificate will do fine for a dummy login to use for RSA verification.

Bob.

-----Original Message-----
From: Margaret Cyrzan [mailto:cyrzan@xxxxxxxxxxx]
Sent: Wednesday, May 10, 2000 1:29 PM
To: imc-sfl@xxxxxxx
Subject: Using SFL to verify



I'm having some trouble using SFL to verify a message that I received. I'm 
using the Crypto++ library, and verify is failing. Here is my code:

	// put it in the instance list in pCSMIME
	if (pCSMIME->m_pCSInsts == NULL)
	{
		if ((pCSMIME->m_pCSInsts = new CSM_CSInstLst) == NULL)
			return E_OUTOFMEMORY;
	}

	// Set up a RSA instance
	if ((pNewInstance = new CSM_CSInst) == NULL)
		return E_OUTOFMEMORY;
	pCSMIME->m_pCSInsts->AppendL(pNewInstance);

	// generate a new FREE CTI class
	if ((pFree = new CSM_Free3(rsa)) == NULL)
		return E_OUTOFMEMORY;
	// CSM_Free3 constructor sets Alg IDs
	// now, fill in what we can in the instance
	// store token interface pointer
	pNewInstance->SetTokenInterface((CSM_TokenInterface *)pFree);

	// Create the contentInfoMsg class with the content which was
	// loaded in a buffer earlier.
	CSM_ContentInfoMsg contentInfo(&buf);
	if(contentInfo.IsSignedData())
	{
		CSM_MsgToVerify msg(&contentInfo);
		msg.PreProc(pCSMIME);
		long l = msg.Verify(pCSMIME);
	}


Maybe someone can suggest what I'm missing or using incorrectly. Right now 
verify doesn't look like it does anything.  Do I have to load certificates 
into the instance? If so, how do I extract them from the e-mail and put them

into the instance?

Thanks,

Margaret

________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com


Attachment: DaisyRsaExts.out
Description: Binary data

Attachment: test2.cpp
Description: Binary data

Attachment: sd
Description: Binary data