how does openssl works with key as it is taking any size of key (1 byte to any size). What is the procedure to go to actual key here ..
openssl enc -d -des-ecb -in cipher.txt -out text.out -K '530343412312345445123345677812345678812324'
how does openssl works with key as it is taking any size of key (1 byte to any size). What is the procedure to go to actual key here ..
openssl enc -d -des-ecb -in cipher.txt -out text.out -K '530343412312345445123345677812345678812324'
My observation to the case gave following conclusion:
It depends on the program, but procedures are usually consistent across the library. In you example, you are using the
openssl dec
, so you are using thedec
sub-program. The source code is available in<openssl dir>/apps/enc.c
(enc
anddec
are part ofenc.c
).Here's the relevant parts:
The argument to
-K
is stored inhkey
:Then, around line 580:
set_hex
is shown below and hex decodes the argument passed in through-K
. It back fills the unused length with 0's via thememset
. The unused length isEVP_MAX_KEY_LENGTH
minus the length-K
argument (after hex decoding).Finally, around line 610:
Note:
-k
(smallk
) takes a different code path and usesEVP_BytesToKey
to derive the key.