issues while trying to encrypt payload/raw audio data only

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

 



hi,
I want to only encrypr the raw audio data / payload using AES in pjsip. Can anyone plase help me where to do it in the code.Right now i am encrypting the data in 
rec_cb in sound_port.c? as follows
?
SampleEncrypter(frame->buf,&dLength);
where 
SampleEncrypter is a function that uses AES as follows
?
? void SampleEncrypter(void *opaque,unsigned *opaque_len)
{
? aes_cbc_ctx_t aes_ctx;
? hmac_ctx_t hmac_ctx;
? unsigned char enc_key[ENC_KEY_LEN] ;? 
? err_status_t status;
??? /* derive encryption and authentication keys from the input key */
?? char key [] = "encryption";
??? status = hmac_init(&hmac_ctx, key, KEY_LEN);
??? if (status) return ;
??? status = hmac_compute(&hmac_ctx, "ENC", 3, ENC_KEY_LEN, enc_key);
??? if (status) return ;?? 
??? /* set aes key */
??? status = aes_cbc_context_init(&aes_ctx, key, direction_encrypt);
??? if (status) return ;??? 
??? /* encrypt the opaque data? */
??? status = aes_cbc_nist_encrypt(&aes_ctx, opaque, opaque_len);
??? if (status) return ;???? 
}
?
?
and decrypting it in 
play_cb as follows
?
?
status = pjmedia_port_get_frame(port, frame);
// calling decrypt after get_frame
SampleDecrypter(frame->buf,&dLength);
?
?
? void SampleDecrypter(void *opaque,unsigned *opaque_len) 
{
? aes_cbc_ctx_t aes_ctx;
? hmac_ctx_t hmac_ctx;
? unsigned char enc_key[ENC_KEY_LEN]; 
? err_status_t status;
??? /* derive encryption and authentication keys from the input key */
?char key [] = "encryption";
? status = hmac_init(&hmac_ctx, key, KEY_LEN);
??? if (status) return ;
??? status = hmac_compute(&hmac_ctx, "ENC", 3, ENC_KEY_LEN, enc_key);
??? if (status) return;
??? /* set aes key */
??? status = aes_cbc_context_init(&aes_ctx, key, direction_decrypt);
??? if (status) return;
??? /* encrypt the opaque data? */
??? status = aes_cbc_nist_decrypt(&aes_ctx, opaque, opaque_len);
??? if (status) return;? 
}
?
The result is a noise and nothing else.
?
Thanks and Regards
susheel tickoo
?


      The INTERNET now has a personality. YOURS! See your Yahoo! Homepage. http://in.yahoo.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20100114/6c487397/attachment.html>


[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux