Skip to content

Set temporary touch sensitivity #95

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 29, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File SetDeviceInfoBaseCommsnd.cs line 36, Where do all these tag number coming from? and 0x85 is very different then the other tags

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi! They typically come from the internal documentation of the management application which would be provided by the firmware team.

Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ public class SetDeviceInfoBaseCommand
private const byte ResetAfterConfigTag = 0x0c;
private const byte NfcEnabledCapabilitiesTag = 0x0e;
private const byte NfcRestrictedTag = 0x17;
private const byte TempTouchThresholdTag = 0x85;

private byte[]? _lockCode;
private byte[]? _unlockCode;
private ushort? _autoEjectTimeout;

/// <summary>
/// The length that a configuration lock code must be.
Expand All @@ -60,8 +62,6 @@ public class SetDeviceInfoBaseCommand
/// </summary>
public byte? ChallengeResponseTimeout { get; set; }

private ushort? _autoEjectTimeout;

/// <summary>
/// The CCID auto-eject timeout (in seconds). This field is only meaningful if the
/// TouchEject flag in DeviceFlags is set. <see langword="null"/> to leave unchanged.
Expand Down Expand Up @@ -106,6 +106,26 @@ public int? AutoEjectTimeout
/// </summary>
public bool RestrictNfc { get; set; }

/// <summary>
/// Temporarily set the threshold at which a capacitive touch should be considered active.
/// </summary>
/// <remarks>
/// <para>
/// The field is using arbitrary units and has a default value of `6`. A higher value increases the sensor
/// threshold which has the effect of decreasing the sensitivity of the sensor. Lower values increase the
/// sensitivity, but callers cannot reduce the threshold below the default value of `6` which is locked in at
/// manufacturing time.
/// </para>
/// <para>
/// The value set here is only valid until the next time the YubiKey is power cycled. It does not persist.
/// </para>
/// <para>
/// You should typically not ever need to adjust this value. This is primarily used in the context of automatic
/// provisioning and testing where the YubiKey is being "touched" by electrically grounding the sensor.
/// </para>
/// </remarks>
public int? TemporaryTouchThreshold { get; set; }

/// <summary>
/// Initializes a new instance of the <see cref="SetDeviceInfoBaseCommand"/> class.
/// </summary>
Expand Down Expand Up @@ -257,6 +277,11 @@ private byte[] GetTlvData()
buffer.WriteByte(NfcRestrictedTag, 1);
}

if (TemporaryTouchThreshold.HasValue)
{
buffer.WriteByte(TempTouchThresholdTag, (byte)TemporaryTouchThreshold.Value);
}

return buffer.Encode();
}
}
Expand Down