The easiest way to decrypt JetS3t-encrypted data without relying on
specific programs is to use the EncryptionUtil class directly, such as
by using its decrypt() method to wrap an output stream.
To be honest I'm not sure what would be the right OpenSSL incantations
to decrypt one of these files. The "recipe" used by JetS3t to generate
the encryption keys etc is expressed in code in the EncryptionUtil
class, but I didn't find the OpenSSL command analogues for these steps
when I tried some experimentation.
There should be a way to use OpenSSL to generate custom Key and IV
values from a password using the same salt and iteration settings as
those in EncryptionUtils, then apply these to decrypt a
JetS3t-encrypted file.
If you figure out the recipe I would be interested to know, but I'm
afraid I don't have any solid leads.
James
> --
> You received this message because you are subscribed to the Google Groups
> "JetS3t Users" group.
> To post to this group, send email to jets3t...@googlegroups.com.
> To unsubscribe from this group, send email to
> jets3t-users...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/jets3t-users?hl=en.
>
Thanks very much for figuring this out and documenting it. I was able
to follow the steps you outlined and I'll repeat them here in detail
in case others find this useful.
Nice work!
To encrypt data with JetS3t, then decrypt it with OpenSSL:
1) Make sure you use one of the *-OPENSSL PBE cipher algorithms that
should be available in JetS3t. To list all the available algorithms on
your system, run the EncrytionUtil class
(org.jets3t.service.security.EncryptionUtil) from the command line
with all the required libraries in your classpath.
Example PBE cipher algorithms that OpenSSL can decrypt (from OSX with
Java 1.6 and BouncyCastle lib):
PBEWITHMD5AND192BITAES-CBC-OPENSSL
PBEWITHMD5AND128BITAES-CBC-OPENSSL
PBEWITHMD5AND256BITAES-CBC-OPENSSL (* this is the algorithm I used
for the example commands below)
2) Download the raw JetS3t-encrypted file from S3 using a tool other
than JetS3t's apps (which will automatically decrypt it). For example,
use Amazon's own console or curl/wget with a temporary signed URL.
3) Use OpenSSL to convert your password into the Key and
Initialization Vector (IV) values necessary to decrypt the file. Here
is an example command, and output, to generate these values for
JetS3t's salt value and the password "password":
$ openssl enc -aes256 -S A40BC834D695F313 -P -k password
salt=A40BC834D695F313
key=E0499E736012D566B475A7224E34902D5B3EDFDD48C83EA741FBE24D4A3880D0
iv =3DF92E1C79A672F40ADA758937A3DD04
4) Provide the Key and IV values generated above to OpenSSL to have it
decrypt the file 'data.enc':
$ cat data.enc | openssl enc -aes256 -d \
-K E0499E736012D566B475A7224E34902D5B3EDFDD48C83EA741FBE24D4A3880D0 \
-iv 3DF92E1C79A672F40ADA758937A3DD04
NOTE)
JetS3t's applications and tools store the cipher algorithm for each
encrypted object in the "jets3t-crypto-alg" metadata item, so it's
easy to tell which algorithm was used later on. This makes it possible
to automate decryption, even if you use different algorithms over
time. However, this won't help if you use different passwords...