Skip to content

Commit cb1aba4

Browse files
committed
added new param to read_first callback. This allows to pass a hash instead of a rpId.
1 parent 9777056 commit cb1aba4

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

example/authenticator.zig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,12 @@ pub fn my_up(
223223
pub fn my_read_first(
224224
id: ?dt.ABS64B,
225225
rp: ?dt.ABS128T,
226+
hash: ?[32]u8,
226227
) CallbackError!Credential {
228+
// The hash is mostly relevant for credential management
229+
// because the client will only send a SHA256(rpId).
230+
_ = hash;
231+
227232
std.log.info("my_first_read: {s}, {s}", .{
228233
if (id) |uid| uid.get() else "n.a.",
229234
if (rp) |rpid| rpid.get() else "n.a.",

lib/ctap/auth/Callbacks.zig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ pub const UvCallback = ?*const fn (
128128
pub const ReadFirstCallback = *const fn (
129129
id: ?dt.ABS64B,
130130
rp: ?dt.ABS128T,
131+
hash: ?[32]u8,
131132
) CallbackError!fido.ctap.authenticator.Credential;
132133

133134
/// This function can be called multiple times after calling the ReadFirstCallback to obtain the remaining credentials.

lib/ctap/commands/authenticator/authenticatorGetAssertion.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ pub fn authenticatorGetAssertion(
174174
// ++++++++++++++++++++++++++++++++++++++++++++++++
175175
var selected_credential: ?fido.ctap.authenticator.Credential = null;
176176
var total_credentials: usize = 0;
177-
var credential = auth.callbacks.read_first(null, gap.rpId) catch {
177+
var credential = auth.callbacks.read_first(null, gap.rpId, null) catch {
178178
return fido.ctap.StatusCodes.ctap2_err_no_credentials;
179179
};
180180

@@ -215,7 +215,7 @@ pub fn authenticatorGetAssertion(
215215

216216
// We previously iterated over all credentials, now we have to get back to the
217217
// first one, so we can iterate over the remaining ones using getNextAssertion.
218-
credential = auth.callbacks.read_first(null, gap.rpId) catch {
218+
credential = auth.callbacks.read_first(null, gap.rpId, null) catch {
219219
return fido.ctap.StatusCodes.ctap2_err_no_credentials;
220220
};
221221

lib/ctap/commands/authenticator/authenticatorMakeCredential.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ pub fn authenticatorMakeCredential(
244244

245245
if (mcp.excludeList) |ecllist| {
246246
for (ecllist.get()) |item| {
247-
const cred = auth.callbacks.read_first(item.id, null) catch {
247+
const cred = auth.callbacks.read_first(item.id, null, null) catch {
248248
continue;
249249
};
250250
// If the credential was created by this authenticator: Return.
@@ -392,7 +392,7 @@ pub fn authenticatorMakeCredential(
392392
std.log.info("MakeCredential: creating resident key", .{});
393393
entry.discoverable = true;
394394

395-
var credential = auth.callbacks.read_first(null, mcp.rp.id) catch {
395+
var credential = auth.callbacks.read_first(null, mcp.rp.id, null) catch {
396396
break :outer;
397397
};
398398

0 commit comments

Comments
 (0)