Noté que la mayoría de las claves privadas de DSA a menudo comienzan con los mismos pocos caracteres, MIIBvAIBAAKBgQD
.
Por ejemplo, genere una clave privada en Ubuntu ejecutando:
ssh-keygen -t dsa -N '' -f /tmp/id_dsa
Esto da como resultado un archivo de clave privada que comienza con algo como:
-----BEGIN DSA PRIVATE KEY-----
MIIBvAIBAAKBgQD...
Los primeros 16 caracteres son sospechosamente similares.
Espero que ssh-keygen
esté utilizando un nonce aleatorio antes de comenzar el cifrado. Suponiendo que ssh-keygen
está utilizando una fuente aleatoria, ¿por qué los primeros caracteres de los archivos de clave privada DSA son similares?
Al usar un script, descubrí que la singularidad ("aleatoriedad", buena entropía, etc.) comienza en el carácter 17 °.
leading char count 1 - unique combinations 1 among 100 generated keys leading char count 2 - unique combinations 1 among 100 generated keys leading char count 3 - unique combinations 1 among 100 generated keys leading char count 4 - unique combinations 1 among 100 generated keys leading char count 5 - unique combinations 2 among 100 generated keys leading char count 6 - unique combinations 4 among 100 generated keys leading char count 7 - unique combinations 6 among 100 generated keys leading char count 8 - unique combinations 5 among 100 generated keys leading char count 9 - unique combinations 4 among 100 generated keys leading char count 10 - unique combinations 4 among 100 generated keys leading char count 11 - unique combinations 4 among 100 generated keys leading char count 12 - unique combinations 4 among 100 generated keys leading char count 13 - unique combinations 4 among 100 generated keys leading char count 14 - unique combinations 4 among 100 generated keys leading char count 15 - unique combinations 7 among 100 generated keys leading char count 16 - unique combinations 87 among 100 generated keys leading char count 17 - unique combinations 100 among 100 generated keys leading char count 18 - unique combinations 100 among 100 generated keys leading char count 19 - unique combinations 100 among 100 generated keys leading char count 20 - unique combinations 100 among 100 generated keys leading char count 21 - unique combinations 100 among 100 generated keys ...
Usé el siguiente código de bash para determinar esto
keyf=/tmp/id_dsa-${RANDOM} for upto in {1..35} ; do keys="${keyf}-${upto}" rm -f "${keys}" &>/dev/null for i in {0..99} ; do rm "${keyf}" &>/dev/null ssh-keygen -t dsa -N '' -f "${keyf}" &>/dev/null sed '2q;d' "${keyf}" | cut -b 1-"${upto}" >> "${keys}" done keys_count_all=$(cat "${keys}" | wc -l) keys_count_uniq=$(sort -u "${keys}" | wc -l) printf "leading char count %2d - unique combinations %3d among %3d generated keys\n" ${upto} ${keys_count_uniq} ${keys_count_all} done rm "${keyf}"