1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-21 20:04:02 +00:00

Clarify that Windows returns UTF-8

This commit is contained in:
Isaiah Inuwa
2026-02-20 08:18:27 -06:00
parent beb27951d7
commit b58912459b

View File

@@ -962,6 +962,8 @@ pub(super) struct WEBAUTHN_CTAPCBOR_GET_ASSERTION_REQUEST {
pub dwVersion: u32,
pub pwszRpId: *const u16, // PCWSTR
pub cbRpId: u32,
/// Raw UTF-8 bytes before conversion to UTF-16 in pwszRpId. These are the
/// bytes to be hashed in the Authenticator Data.
pub pbRpId: *const u8,
pub cbClientDataHash: u32,
pub pbClientDataHash: *const u8,
@@ -1013,9 +1015,12 @@ pub struct PluginGetAssertionRequest {
impl PluginGetAssertionRequest {
pub fn rp_id(&self) -> &str {
let inner = self.as_ref();
unsafe {
let request = &*self.inner;
let slice = std::slice::from_raw_parts(request.pbRpId, request.cbRpId as usize);
// SAFETY: we only support platforms where usize >= 32;
let len = inner.cbRpId as usize;
let slice = std::slice::from_raw_parts(inner.pbRpId, len);
// SAFETY: Windows validates that this is valid UTF-8.
str::from_utf8_unchecked(slice)
}
}