Do not silently truncate the key if it is too long

Previously, the length argument passed to memmove was min(sizeof(buffer), input_size), which will silently truncate the key if it is larger than the buffer. This should be a hard failure instead.

It's unclear to me whether it is better to use an assertion, which might be disabled at compile time, or to return -1. Please advise.