feat(pki): add support for user ID in ssh_key structure

Signed-off-by: Praneeth Sarode <praneethsarode@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Eshan Kelkar <eshankelkar@galorithm.com>
This commit is contained in:
Praneeth Sarode
2025-08-30 01:50:59 +05:30
parent 97e71606e0
commit 14bd26e71c
2 changed files with 16 additions and 0 deletions

View File

@@ -95,6 +95,9 @@ struct ssh_key_struct {
uint8_t sk_flags;
ssh_string sk_key_handle;
ssh_string sk_reserved;
/* Resident key specific metadata */
ssh_string sk_user_id;
};
struct ssh_signature_struct {

View File

@@ -166,6 +166,13 @@ ssh_key pki_key_dup_common_init(const ssh_key key, int demote)
goto fail;
}
if (key->sk_user_id != NULL) {
new->sk_user_id = ssh_string_copy(key->sk_user_id);
if (new->sk_user_id == NULL) {
goto fail;
}
}
if (!demote) {
new->sk_flags = key->sk_flags;
@@ -232,6 +239,8 @@ void ssh_key_clean (ssh_key key)
ssh_string_free(key->sk_key_handle);
ssh_string_burn(key->sk_reserved);
ssh_string_free(key->sk_reserved);
ssh_string_burn(key->sk_user_id);
ssh_string_free(key->sk_user_id);
key->sk_flags = 0;
}
key->cert_type = SSH_KEYTYPE_UNKNOWN;
@@ -787,6 +796,10 @@ int ssh_key_cmp(const ssh_key k1,
return 1;
}
if (ssh_string_cmp(k1->sk_user_id, k2->sk_user_id) != 0) {
return 1;
}
if (what == SSH_KEY_CMP_PRIVATE) {
if (k1->sk_flags != k2->sk_flags) {
return 1;