Problem Encrypting with RSA and Crypto++ 3.1
Jonathan Schulze-Hewett <[email protected]>
| Newsgroups | gmane.ietf.sfl |
|---|---|
| Organization | Information Security Corporation |
| Message-ID | <[email protected]> |
Hi All,
I have tried to write a very simple encryption routine with the SFL
and I'm getting "Assertion failed: modulus.IsOdd(), file
..\crypto31\integer.cpp, line 2250 with the code below when encrypt is
called. I would really appreciate help in getting this to work! :) I
have spent several days trying different things. The one thing that sort
of works (i.e. it doesn't crash) is to use a DSA cert for the login but
then it won't let an RSA cert be a recipient!
TIA
-Jonathan
-----------------------------------------------------------------------------
// construct message to encrypt.
char *msgStr = "Content-Type: Text/Plain\nContent-Transfer-Encoding:
7bit\n\rTestMessage\n\r";
// Login and setup our instance.
AppLogin = new CSM_AppLogin();
AppLogin->AddLogin("sm_free3DLLd", "sm_free3DLL ./certs/DaisyRsaExts.out
NULL NULL sm_FREE3");
CSM_CSInst *tmpInst =NULL;
for (tmpInst = AppLogin->m_pCSInsts->FirstL(); tmpInst != NULL;tmpInst =
AppLogin->m_pCSInsts->NextL())
{
tmpInst->SetUseThis();
}
// Set up content.
CSM_Content mycontent(msgStr);
CSM_MsgToEncrypt myencrypt;
myencrypt.SetEncapContent(mycontent);
// Set content type and content encryption type.
CSM_OID tmpoid("1.2.840.113549.1.7.1"); // PKCS#7 DATA
myencrypt.setContentType(tmpoid);
CSM_OID tmp2oid("1.2.840.113549.3.2"); // # rc2 cbc // old def for MSEO
interop.
myencrypt.SetContentEncryptOID(&tmp2oid);
// Set whether to include original certs, IssOrSki,
myencrypt.SetIncludeOrigCertsFlag(false);
myencrypt.m_bIssOrSki = false; // True if SUBJECT KEY IDENTIFIER is
used.
// Do NOT Add originator as recipient
myencrypt.SetAddOriginatorAsRecipient(false);
// Setup recipients.
CSM_RecipientInfo *pRecipInfo = NULL;
CSM_Buffer *pbufCert = new CSM_Buffer("./certs/DaisyRsaExts.out");
pbufCert->ConvertFileToMemory();
pRecipInfo = new CSM_RecipientInfo(*pbufCert);
myencrypt.m_pRecipients = new CSM_RecipientInfoLst;
myencrypt.m_pRecipients->AppendL(pRecipInfo);
// Encrypt
myencrypt.Encrypt(AppLogin);
------------------------------------------------------------------------------
==============================================================================
Jonathan C. Schulze-Hewett Email: [email protected]
Software Engineer
Information Security Corporation Voice: 708-445-1704
1011 W. Lake Street, Suite 212 Fax: 708-455-9705
Oak Park, IL 60301 WWW: http://www.infoseccorp.com