Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

openssl_seal() in Python

Tags:

python

openssl

To connect a server, I've found that, using PHP, I need to use openssl_seal(). That's OK, but I want to use Python. I'm not able to convert openssl_seal() in an equivalent function.

Can you help me?

This is what openssl_seal() does:

Description 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.
like image 603
elledienne Avatar asked May 04 '10 15:05

elledienne


1 Answers

this blogpost has a very detailed description of what's going on inside openssl_seal(). It also has an implementation in java.

From this, I would think it should be relatively straightforward ("the proof left as an exercise to the reader" kind of straightforward) to do an equivalent implementation in python using pyopenssl, which includes RC4, or the newer, but for these purposes more focused tlslite.

like image 68
Steen Avatar answered Oct 06 '22 16:10

Steen