Added load_ssh_public_key to load OpenSSH public keys (RSA support only)

As far as I can tell, there isn't currently a way to import OpenSSH (RFC 4253) formatted RSA public keys into an RSAPublicKey in cryptography. This commit adds that functionality.

Other Python cryptography libraries (notably PyCrypto) provide this sort of functionality and at least one library that I'd like to see ported to cryptography relies on that functionality.

This is my first-time contributing to cryptography. Your feedback would be very much appreciated! Thanks!
Huh. I wonder why twisted's version of this calls them netstrings. Anyways,
sounds like `_read_string` is fine, with a docstring that explains the
string is being parsed as described in the appropriate RFC.

On Sat Dec 13 2014 at 9:39:15 PM Mark Adams <notifications@github.com>
wrote:

> In src/cryptography/hazmat/primitives/serialization.py
> <https://github.com/pyca/cryptography/pull/1517#discussion-diff-21794024>:
>
> > +    return _load_ssh_rsa_public_key(data, backend)
> > +
> > +
> > +def _load_ssh_rsa_public_key(data, backend):
> > +    if not data.startswith(b'ssh-rsa '):
> > +        raise ValueError('SSH-formatted RSA keys must begin with ssh-rsa')
> > +
> > +    parts = data.split(b' ')
> > +    data = base64.b64decode(parts[1])
> > +
> > +    cert_data = []
> > +
> > +    while len(data) > 0:
> > +        str_len = struct.unpack('>I', data[0:4])[0]
> > +        cert_data.append(data[4:4 + str_len])
> > +        data = data[4 + str_len:]
>
> I agree that it probably should be something besides _read_string
>
> Looks like RFC 4251 (the one that defines string and mpint) calls them
> strings:
>
> string
>
>   Arbitrary length binary string.  Strings are allowed to contain
>   arbitrary binary data, including null characters and 8-bit
>   characters.  They are stored as a uint32 containing its length
>   (number of bytes that follow) and zero (= empty string) or more
>   bytes that are the value of the string.  Terminating null
>   characters are not used.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/pyca/cryptography/pull/1517/files#r21794024>.
>