diff options
Diffstat (limited to 'src/home/homectl-fido2.c')
-rw-r--r-- | src/home/homectl-fido2.c | 64 |
1 files changed, 32 insertions, 32 deletions
diff --git a/src/home/homectl-fido2.c b/src/home/homectl-fido2.c index 384461a1ca..332865c8d9 100644 --- a/src/home/homectl-fido2.c +++ b/src/home/homectl-fido2.c @@ -19,11 +19,11 @@ #if HAVE_LIBFIDO2 static int add_fido2_credential_id( - JsonVariant **v, + sd_json_variant **v, const void *cid, size_t cid_size) { - _cleanup_(json_variant_unrefp) JsonVariant *w = NULL; + _cleanup_(sd_json_variant_unrefp) sd_json_variant *w = NULL; _cleanup_strv_free_ char **l = NULL; _cleanup_free_ char *escaped = NULL; ssize_t escaped_size; @@ -36,9 +36,9 @@ static int add_fido2_credential_id( if (escaped_size < 0) return log_error_errno(escaped_size, "Failed to base64 encode FIDO2 credential ID: %m"); - w = json_variant_ref(json_variant_by_key(*v, "fido2HmacCredential")); + w = sd_json_variant_ref(sd_json_variant_by_key(*v, "fido2HmacCredential")); if (w) { - r = json_variant_strv(w, &l); + r = sd_json_variant_strv(w, &l); if (r < 0) return log_error_errno(r, "Failed to parse FIDO2 credential ID list: %m"); @@ -50,12 +50,12 @@ static int add_fido2_credential_id( if (r < 0) return log_oom(); - w = json_variant_unref(w); - r = json_variant_new_array_strv(&w, l); + w = sd_json_variant_unref(w); + r = sd_json_variant_new_array_strv(&w, l); if (r < 0) return log_error_errno(r, "Failed to create FIDO2 credential ID JSON: %m"); - r = json_variant_set_field(v, "fido2HmacCredential", w); + r = sd_json_variant_set_field(v, "fido2HmacCredential", w); if (r < 0) return log_error_errno(r, "Failed to update FIDO2 credential ID: %m"); @@ -63,7 +63,7 @@ static int add_fido2_credential_id( } static int add_fido2_salt( - JsonVariant **v, + sd_json_variant **v, const void *cid, size_t cid_size, const void *fido2_salt, @@ -72,7 +72,7 @@ static int add_fido2_salt( size_t secret_size, Fido2EnrollFlags lock_with) { - _cleanup_(json_variant_unrefp) JsonVariant *l = NULL, *w = NULL, *e = NULL; + _cleanup_(sd_json_variant_unrefp) sd_json_variant *l = NULL, *w = NULL, *e = NULL; _cleanup_(erase_and_freep) char *base64_encoded = NULL, *hashed = NULL; ssize_t base64_encoded_size; int r; @@ -87,29 +87,29 @@ static int add_fido2_salt( if (r < 0) return log_error_errno(errno_or_else(EINVAL), "Failed to UNIX hash secret key: %m"); - r = json_build(&e, JSON_BUILD_OBJECT( - JSON_BUILD_PAIR("credential", JSON_BUILD_BASE64(cid, cid_size)), - JSON_BUILD_PAIR("salt", JSON_BUILD_BASE64(fido2_salt, fido2_salt_size)), - JSON_BUILD_PAIR("hashedPassword", JSON_BUILD_STRING(hashed)), - JSON_BUILD_PAIR("up", JSON_BUILD_BOOLEAN(FLAGS_SET(lock_with, FIDO2ENROLL_UP))), - JSON_BUILD_PAIR("uv", JSON_BUILD_BOOLEAN(FLAGS_SET(lock_with, FIDO2ENROLL_UV))), - JSON_BUILD_PAIR("clientPin", JSON_BUILD_BOOLEAN(FLAGS_SET(lock_with, FIDO2ENROLL_PIN))))); + r = sd_json_build(&e, SD_JSON_BUILD_OBJECT( + SD_JSON_BUILD_PAIR("credential", SD_JSON_BUILD_BASE64(cid, cid_size)), + SD_JSON_BUILD_PAIR("salt", SD_JSON_BUILD_BASE64(fido2_salt, fido2_salt_size)), + SD_JSON_BUILD_PAIR("hashedPassword", SD_JSON_BUILD_STRING(hashed)), + SD_JSON_BUILD_PAIR("up", SD_JSON_BUILD_BOOLEAN(FLAGS_SET(lock_with, FIDO2ENROLL_UP))), + SD_JSON_BUILD_PAIR("uv", SD_JSON_BUILD_BOOLEAN(FLAGS_SET(lock_with, FIDO2ENROLL_UV))), + SD_JSON_BUILD_PAIR("clientPin", SD_JSON_BUILD_BOOLEAN(FLAGS_SET(lock_with, FIDO2ENROLL_PIN))))); if (r < 0) return log_error_errno(r, "Failed to build FIDO2 salt JSON key object: %m"); - w = json_variant_ref(json_variant_by_key(*v, "privileged")); - l = json_variant_ref(json_variant_by_key(w, "fido2HmacSalt")); + w = sd_json_variant_ref(sd_json_variant_by_key(*v, "privileged")); + l = sd_json_variant_ref(sd_json_variant_by_key(w, "fido2HmacSalt")); - r = json_variant_append_array(&l, e); + r = sd_json_variant_append_array(&l, e); if (r < 0) return log_error_errno(r, "Failed append FIDO2 salt: %m"); - r = json_variant_set_field(&w, "fido2HmacSalt", l); + r = sd_json_variant_set_field(&w, "fido2HmacSalt", l); if (r < 0) return log_error_errno(r, "Failed to set FDO2 salt: %m"); - r = json_variant_set_field(v, "privileged", w); + r = sd_json_variant_set_field(v, "privileged", w); if (r < 0) return log_error_errno(r, "Failed to update privileged field: %m"); @@ -118,13 +118,13 @@ static int add_fido2_salt( #endif int identity_add_fido2_parameters( - JsonVariant **v, + sd_json_variant **v, const char *device, Fido2EnrollFlags lock_with, int cred_alg) { #if HAVE_LIBFIDO2 - JsonVariant *un, *realm, *rn; + sd_json_variant *un, *realm, *rn; _cleanup_(erase_and_freep) void *secret = NULL, *salt = NULL; _cleanup_(erase_and_freep) char *used_pin = NULL; size_t cid_size, salt_size, secret_size; @@ -135,26 +135,26 @@ int identity_add_fido2_parameters( assert(v); assert(device); - un = json_variant_by_key(*v, "userName"); + un = sd_json_variant_by_key(*v, "userName"); if (!un) return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "userName field of user record is missing"); - if (!json_variant_is_string(un)) + if (!sd_json_variant_is_string(un)) return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "userName field of user record is not a string"); - realm = json_variant_by_key(*v, "realm"); + realm = sd_json_variant_by_key(*v, "realm"); if (realm) { - if (!json_variant_is_string(realm)) + if (!sd_json_variant_is_string(realm)) return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "realm field of user record is not a string"); - fido_un = strjoina(json_variant_string(un), json_variant_string(realm)); + fido_un = strjoina(sd_json_variant_string(un), sd_json_variant_string(realm)); } else - fido_un = json_variant_string(un); + fido_un = sd_json_variant_string(un); - rn = json_variant_by_key(*v, "realName"); - if (rn && !json_variant_is_string(rn)) + rn = sd_json_variant_by_key(*v, "realName"); + if (rn && !sd_json_variant_is_string(rn)) return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "realName field of user record is not a string"); @@ -164,7 +164,7 @@ int identity_add_fido2_parameters( /* rp_name= */ "Home Directory", /* user_id= */ fido_un, strlen(fido_un), /* We pass the user ID and name as the same */ /* user_name= */ fido_un, - /* user_display_name= */ rn ? json_variant_string(rn) : NULL, + /* user_display_name= */ rn ? sd_json_variant_string(rn) : NULL, /* user_icon_name= */ NULL, /* askpw_icon_name= */ "user-home", /* askpw_credential= */ "home.token-pin", |