[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: pki_private_key_from_base64: key flags issue


>> I found that `pki_private_key_from_base64' procedure returns a key with
>> both private and public flag set.  It makes it impossible to determine
>> whether the key is public or private with `ssh_key_is_private' and
>> `ssh_key_is_public' predicates because they both return 1 (true) for the
>> key.
>>
>> The issue was found in libssh 0.6.3 and as far as I can see it persists
>> in the latest commits in the repository.
>>
>> Is it done intentionally?
> A key is always a public key but it may have be a private key too. You can get 
> a public key from a private key, see ssh_pki_export_privkey_to_pubkey():
>
> http://api.libssh.org/stable/group__libssh__pki.html#ga5777bc537da6a447b2a9aa9eceff9877
>
I agree with Andreas. There's nothing wrong in having the private key
being also a public key, it actually makes some things much easier, and
it's also very easy technically, as all key algorithms I have worked
with till today need the public key elements even in the private key part.
The functions could have had better names, like
"ssh_key_contains_public", but I'm sure you will work around this :)
Only take into account the output of ssh_key_is_private() for your needs.

Regards,

Aris


Follow-Ups:
Re: pki_private_key_from_base64: key flags issue [SOLVED]Artyom Poptsov <poptsov.artyom@xxxxxxxxx>
References:
pki_private_key_from_base64: key flags issueArtyom Poptsov <poptsov.artyom@xxxxxxxxx>
Re: pki_private_key_from_base64: key flags issueAndreas Schneider <asn@xxxxxxxxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org