OpenSSL "Seal" in C (or via shell)

Posted by chpwn on Stack Overflow See other posts from Stack Overflow or by chpwn
Published on 2009-11-15T20:29:14Z Indexed on 2010/05/24 3:11 UTC
Read the original article Hit count: 338

Filed under:
|
|
|

I'm working on porting some PHP code to C, that contacts a web API.

The issue I've come across is that the PHP code uses the function openssl_seal(), but I can't seem to find any way to do the same thing in C or even via openssl in a call to system().

From the PHP manual on openssl_seal():

int openssl_seal ( string $data , string &$sealed_data , array &$env_keys , array $pub_key_ids )

openssl_seal() seals (encrypts) data by using RC4 with a randomly generated secret key. The key is encrypted with each of the public keys associated with the identifiers in pub_key_ids and each encrypted key is returned in env_keys . This means that one can send sealed data to multiple recipients (provided one has obtained their public keys). Each recipient must receive both the sealed data and the envelope key that was encrypted with the recipient's public key.

What would be the best way to implement this? I'd really prefer not to call out to a PHP script every time, for obvious reasons.

© Stack Overflow or respective owner

Related posts about php

Related posts about c