1
$\begingroup$

I may not be asking the right question. I am fairly new to data encryption.

I am currently being sent encrypted data that's stored as follows: [ [keysize] [key encrypted with public key] [ivsize] [iv] [data encrypted with supplied key earlier in file] ]

To decrypt (in my C# code), I have to first read the key out. I then decrypt that key using my certificate's private key. Afterwards, I read the IV and use it with the newly decrypted key to decrypt the data using Rijndael AES decryption. (to note: it uses AES/CBC/PKCS7 padding)

This works great for receiving the encrypted data and decrypting it. However, I would like to generate the exact same type of encrypted file they are sending me and have exhausted myself to the point of total confusion with my various trial and errors. I was told by a colleague that this is a common encryption tactic.

I would like to know if it would be possible to generate the encrypted file using the openssl utility rather than writing code?

$\endgroup$
  • $\begingroup$ What's the format of the public key? Could you post one? It's quite doable (using some shell utilities) but the format of the public key matters for the openssl options and possibilities. $\endgroup$ – Henno Brandsma Apr 27 '16 at 5:18
  • $\begingroup$ What exactly are you given? Do you need to apply the AES encryption as well? How does a line of input look like? $\endgroup$ – eins6180 Apr 27 '16 at 5:24
  • $\begingroup$ Also: sizes are stored how? binary, Little-Endian or Big-Endian? All in one continuguous binary file? Length of iv seems superfluous given that we're using AES (so 16 is the only value). Example files (also of PK, see other comment) please! $\endgroup$ – Henno Brandsma Apr 27 '16 at 7:32
  • $\begingroup$ The answer also depends on the padding method used for RSA (OAEP? KEM? PKCS1v1.5?) $\endgroup$ – SEJPM Apr 27 '16 at 11:41
  • $\begingroup$ I am curious: is there a reason anyone would use that specific format for anything other than educational purposes, rather than in a standard format such as PKCS12 ("openssl pkcs12 ...") or S/MIME ("openssl smime ...") or the OpenPGP format ("gpg --output doc.gpg --encrypt --recipient someone@example.org doc.txt" and decoded by "gpg --output doc_copy.txt --decrypt doc.gpg")? $\endgroup$ – David Cary Apr 27 '16 at 15:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.