RE: Problem Encrypting with RSA and Crypto++ 3.1
"Colestock, Robert" <[email protected]>
| Newsgroups | gmane.ietf.sfl |
|---|---|
| Message-ID | <[email protected]> |
Jonathan:
First, let me mention I have not tried to build a message in such a way. It
would seem there is a lot of logic missing dealing with the construction of
the RecipientInfo, I would have to analyze what the sm_Encrypt.cpp logic
does to tell what might be missing.
Preliminaries: you have provided very little information, did you compile
the SMTI for sm_free3 with the SM_FREE3_RSA_INCLUDED flag defined?
Have you tried performing the operation with a
private key (I realise it should not be necessary for RSA, but I have never
tried to perform an encryption operation without a key, even for the DH)?
This should be easy to add since the file is present in the release
("./test/certs/private.d/DaisyRsaF3X_8.dat"). You probably realise this
already, but you will not be able to decrypt the message without this file.
Are you using the same version of the Crypto++ 3.1
library? I have some subtle differences in the library releases that might
affect operations.
If the private key does not make this work for encryption, please let me
know the full stack of the crash, I will attempt to build an encryption
operation (it works in our releases using the configuration test logic to
build a message, of course with the private key intact in the login).
Bob Colestock
VDA
-----Original Message-----
From: Jonathan Schulze-Hewett [mailto:[email protected]]
Sent: Monday, June 26, 2000 4:15 PM
To: [email protected]
Subject: Problem Encrypting with RSA and Crypto++ 3.1
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