-
Niels De Graef authored
Fixed this after a hint from someone in #52. So, why do we need to substract the magic number 23? We assume that we're dealing with a key file that follows [RFC4716]. That means that if we base64-decode this, we find the following fields: * the string "ssh-rsa" 7 bytes * ... prefixed by its length 4 bytes * the exponent (usually 65537) 3 bytes * ... prefixed by its length 4 bytes * the modulus X bytes * ... prefixed by its length 4 bytes --------------------------------- ------------ + Total length: X + 22 bytes So we need to substract at least 22 bytes from the total key length. But then why do you substract 23 you say? Because this all is base64 encoded, which requires the total bytes to be a multitude of 3. Since this is most of the time not the case (22 isn't divisible by 3 and the modulus length very often is a power of 2 so even), we need to pad with another byte. Fixes #52. Now, we will only get strange results when people use a non-conventional exponent or modulus. [RFC4716]: http://tools.ietf.org/html/rfc4716
19431ea8