I am trying to port some python code to C and the python code uses some 
encryption algorithms so I want to use openssl's algorithms.  

python code:
hmac_md5 = HMAC.new(nlkm,ch)
rc4key = hmac_md5.digest()
rc4 = ARC4.new(rc4key)
data = rc4.encrypt(edata)

c code:
HMAC_CTX hmac;
RC4_KEY rc4;
unsigned char nlkm[64];
unsigned char ch[16];
unsigned char *encrypteddata=NULL;
unsigned char md[16];
unsigned int md_len=0;

HMAC_CTX_init(&hmac);
(void) HMAC(EVP_md5(), nlkm, 64, ch, 16, md, &md_len);
HMAC_CTX_cleanup(&hmac);
RC4_set_key(&rc4, 16, md);
RC4(&rc4, (unsigned long)sizeofedata, encrypteddata, encrypteddata);

When I print the value for rc4key in the python code everything is right.  When 
I print md which should be the same value in C, I get something different.  
Everything up to the encryption point is the same for the C and python code.  
Did I use the openssl functions correctly?  Do the 4 C lines corresponded to 
the 4 python lines? 

Thanks,

_________________________________________________________________
Store, manage and share up to 5GB with Windows Live SkyDrive.
http://skydrive.live.com/welcome.aspx?provision=1?ocid=TXT_TAGLM_WL_skydrive_102008______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to