how are variable key sizes produced? I am current learning the internal working of several Symmetric key Cryptographic algorithms, and came across DES and AES.


  DES takes in input a 64 bit key and AES-128 takes in input a 128 bit key


My question is, since the user provides these algorithms inputs of variable size (or bits), then how is it able to upscale/downscale it to lower bits in order to feed it to the algorithm. Does it uses KDF (key Derivation function)? If yes, then is the KDF capable of decreasing the size of bits too?

By decreasing I mean, If the User Inputs a key = APPLE PIES, and gives it as an input to DES. Then how is DES able to convert this (80 bit) key into a 64 bit one?
Does it use KDF (key Derivation function)? If yes, then is the KDF capable of decreasing the size of bits too?
...how is DES able to convert this (80 bit) key into a 64 bit one?

AES and DES do not perform this task. The specification states that AES uses two sequence of 128 bits as input.
&quot;key&quot; means &quot;cryptographically strong bits&quot;.
Something like APPLE PIES is a password rather than a key.

how is it able to upscale/downscale it to lower bits in order to feed it to the algorithm. Does it uses KDF (key Derivation function)? If yes, then is the KDF capable of decreasing the size of bits too?

The key derivation process may involve multiple invocations and iterations to generate output larger then the output size of the hash function, and the application may truncate keys down to the correct size when necessary.
How to derive a key from a password
This question has already been asked: see this answer.
A KDF is used to turn a password into a suitable key, but this is a separate process that is not performed  by the AES/DES algorithms.