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!
That should probably be `_read_netstring` or so, which I believe is what
the RFC calls those? We should probably sanity check that the key-type
inside the key matches the "ssh-rsa" that the data starts with.

On Sat Dec 13 2014 at 9:22:07 PM Mark Adams <notifications@github.com>
wrote:

> In src/cryptography/hazmat/primitives/serialization.py
> <https://github.com/pyca/cryptography/pull/1517#discussion-diff-21793977>:
>
> > +    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:]
>
> One more thought though... If we went with your route for _read_mpint,
> we'd have to have another method to handle the raw string values such as
> the first value in the SSH key which is actually a normal string (ssh-rsa).
>
> key_type, rest = _read_str(data)
> e, rest = _read_mpint(rest)
> n, rest = _read_mpint(rest)
> if rest:
>    raise Exception
>
> Is this still acceptable?
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/pyca/cryptography/pull/1517/files#r21793977>.
>