@andros@twtxt.andros.dev I have really tried to get behind it. For an implementation for my TwtxtReader (PHP) I simply lack the knowledge of the standard-openssl parameters.
All my solution approaches require “nonce” or “initialization vector” on one or the other side. In addition, the “magic numbers” (“Salted__”) were not consistent in my tests.
If I keep the “nonce”, I can decrypt a message with the shared key, like in the direct message specs.
But that is not how it should work. 😒
⤋ Read More
But that is not how it should work. 😒
@arne@uplegger.eu Well, just for my understanding. The command:
echo "Lorem ipsum" | openssl enc -aes-256-cbc -pbkdf2 -iter 100000 -out message.enc -pass file:shared_key.bin
will take the input string from echo
to openssl
. It then will
- use the content of
shared_key.bin
as password
- use
PBKDF2
with an iteration of 100000 to generate a encryption key from the given password (shared_key.bin
)
- use the
PBKDF2
generated key for anaes-256-cbc
encryption
The final result is encrypted data with the prepended salt (which was generated by runtime), e.g.: Salted__q�;��-�T���"h%��5�� ...
.
With a dummy script I now can generate a valide shared key within PHP ‘openssl_pkey_derive()’ - identical to OpenSSL.
I also can en-/decrypt salted data within my script, but not with OpenSSL. There are several parameters of PBKDF2
unknown to me.
Question:
- Is the salt, used by
aes-256-cbc
andPBKDF2
the same, prepended in the encrypted data?
- Witch algorithm/cipher is used within
PBKDF2
: sha1, sha256, …?
- What is the desired key length of
PBKDF2
(https://www.php.net/manual/en/function.openssl-pbkdf2.php)?
To be continued …