Skip to content

Commit

Permalink
Merge pull request #408 from Yubico/release/1.3.1
Browse files Browse the repository at this point in the history
Release/1.3.1
  • Loading branch information
Greg Domzalski authored Apr 13, 2022
2 parents e3cfd7d + 05c6213 commit ab4f01d
Show file tree
Hide file tree
Showing 20 changed files with 225 additions and 164 deletions.
5 changes: 3 additions & 2 deletions Yubico.Core/src/Yubico.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ limitations under the License. -->
<RootNamespace></RootNamespace>

<!-- Multi-target build -->
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>

<!-- Suppressed warnings-->
Expand Down Expand Up @@ -101,7 +101,8 @@ limitations under the License. -->
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" />
<PackageReference Include="System.Memory" Version="4.5.4" />
<PackageReference Include="Yubico.NativeShims" Version="1.3.0-prerelease.36.1">
<PackageReference Include="System.Security.Principal.Windows" Version="5.0.0" />
<PackageReference Include="Yubico.NativeShims" Version="1.3.1">
<IncludeAssets>native</IncludeAssets>
</PackageReference>
<ProjectReference Include="..\..\Yubico.DotNetPolyfills\src\Yubico.DotNetPolyfills.csproj" />
Expand Down
2 changes: 2 additions & 0 deletions Yubico.Core/src/Yubico/Core/Devices/Hid/WindowsHidDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Linq;
using Yubico.PlatformInterop;
Expand Down Expand Up @@ -63,6 +64,7 @@ internal WindowsHidDevice(CmDevice device) :
UsagePage = (HidUsagePage)device.HidUsagePage;
}

[SuppressMessage("Globalization", "CA1307:Specify StringComparison for clarity", Justification = "Method needs to compile for both netstandard 2.0 and 2.1")]
private void ResolveIdsFromInstancePath(string instancePath)
{
// \\?\HID#VID_1050&PID_0407&MI_00#7
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Threading;
using Yubico.Core.Logging;
Expand Down Expand Up @@ -430,6 +431,7 @@ private class ReaderStateComparer : IEqualityComparer<SCARD_READER_STATE>
{
public bool Equals(SCARD_READER_STATE x, SCARD_READER_STATE y) => x.ReaderName == y.ReaderName;

[SuppressMessage("Globalization", "CA1307:Specify StringComparison for clarity", Justification = "Method needs to compile for both netstandard 2.0 and 2.1")]
public int GetHashCode(SCARD_READER_STATE obj) => obj.ReaderName.GetHashCode();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ using (OtpSession otp = new OtpSession(yKey))
.UseInitialMovingFactor(4096)
.Use8Digits()
.UseKey(_key)
.ExecuteOperation();
.Execute();
otp.ConfigureNdef(Slot.LongPress)
.AsText("AgentSmith:")
.ExecuteOperation();
.Execute();
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ using (OtpSession otp = new OtpSession(yKey))
{
otp.DeleteSlot(Slot.LongPress)
.UseCurrentAccessCode(_currentAccessCode)
.ExecuteOperation();
.Execute();
}

```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@ using (OtpSession otp = new OtpSession(yKey))
.UseHmacSha1()
.UseKey(hmacKey)
.UseButton()
.ExecuteOperation();
.Execute();
}
```
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ using (OtpSession otp = new OtpSession(yKey))
.WithKeyboard(KeyboardLayout.en_US)
.AppendCarriageReturn()
.SetPassword("You'll never guess this!".ToCharArray())
.ExecuteOperation();
.Execute();
}
```

Expand All @@ -50,7 +50,7 @@ using (OtpSession otp = new OtpSession(yKey))
operation = operation.AppendCarriageReturn();
}
operation.SetPassword("You'll never guess this!".ToCharArray())
.ExecuteOperation();
.Execute();
}
```

Expand All @@ -63,7 +63,7 @@ using (OtpSession otp = new OtpSession(yKey))
.WithKeyboard(KeyboardLayout.en_US)
.AppendCarriageReturn(addCR)
.SetPassword("You'll never guess this!".ToCharArray())
.ExecuteOperation();
.Execute();
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ using (OtpSession otp = new OtpSession(yKey))
.UseSerialNumberAsPublicId()
.UsePrivateId(privateId)
.UseKey(aesKey)
.ExecuteOperation();
.Execute();
}
```

Expand All @@ -67,7 +67,7 @@ using (OtpSession otp = new OtpSession(yKey))
.UseSerialNumberAsPublicId()
.GeneratePrivateId(privateId)
.GenerateKey(aesKey)
.ExecuteOperation();
.Execute();

// Do whatever is needed with privateId and aesKey, and clear them.
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,6 @@ using (OtpSession otp = new OtpSession(_yubiKey))
.SetUse20msPacing(_use20msPacing)
.SetAllowUpdate(_allowUpdate)
.ProtectLongPressSlot(_protectLongPressSlot)
.ExecuteOperation();
.Execute();
}
```
14 changes: 14 additions & 0 deletions Yubico.YubiKey/docs/users-manual/getting-started/whats-new.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,20 @@ Here you can find all of the updates and release notes for published versions of

## 1.3.x Releases

### 1.3.1

Release date: April 13th, 2022

Bug fixes:

- Applications targeting .NET Core 3.x, .NET 5, or higher would encounter an exception that said
`Microsoft.BCL.HashCode` could not be found. Adding that NuGet reference manually would work around
the issue. This issue has now been addressed and a work around is no longer required.
- An exception would be thrown if a YubiKey with a non-visible serial number was plugged in. This was
a regression in behavior and has now been fixed.
- The reference to the newly introduced assembly `Yubico.NativeShims` was pinned to a pre-release version. This
has been fixed and now points to the latest publicly listed package.

### 1.3.0

Release date: March 31st, 2022
Expand Down
10 changes: 5 additions & 5 deletions Yubico.YubiKey/src/Yubico.YubiKey.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ limitations under the License. -->
As of 2020, netstandard2.0 allows us to reach the widest audience while providing a large
enough set of the .NET library to be productive.
-->
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>

<RootNamespace></RootNamespace>

Expand Down Expand Up @@ -49,7 +49,7 @@ limitations under the License. -->
<AssemblyOriginatorKeyFile>..\..\Yubico.NET.SDK.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>

<PropertyGroup Label="DocFX settings" Condition="$(Configuration.Contains('WithDocs'))">
<PropertyGroup Label="DocFX settings" Condition="$(Configuration.Contains('WithDocs')) and $(TargetFramework)=='netstandard2.0'">
<LogFile>..\docs\log.txt</LogFile>
<LogLevel>Warning</LogLevel>
<DocParameters>--warningsAsErrors</DocParameters>
Expand Down Expand Up @@ -102,10 +102,10 @@ limitations under the License. -->

<ItemGroup Label="Package references specific to Yubico.YubiKey.dll">

<PackageReference Include="docfx.console" Condition="$(Configuration.Contains('WithDocs'))" Version="$(DocFxVersion)" PrivateAssets="all" IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive" />
<PackageReference Include="docfx.console" Condition="$(Configuration.Contains('WithDocs')) and $(TargetFramework)=='netstandard2.0'" Version="$(DocFxVersion)" PrivateAssets="all" IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive" />

<!-- This is a DocFX plugin and tempate separates class and struct members into their own documentation pages. -->
<PackageReference Include="memberpage" Version="$(DocFxVersion)" PrivateAssets="all" IncludeAssets="contentfiles" GeneratePathProperty="true" />
<PackageReference Include="memberpage" Condition="$(Configuration.Contains('WithDocs')) and $(TargetFramework)=='netstandard2.0'" Version="$(DocFxVersion)" PrivateAssets="all" IncludeAssets="contentfiles" GeneratePathProperty="true" />

<PackageReference Include="Nullable" Version="1.3.0">
<PrivateAssets>all</PrivateAssets>
Expand Down Expand Up @@ -144,7 +144,7 @@ limitations under the License. -->
</ItemGroup>

<!-- Clean up DocFX output -->
<Target Name="CleanDocFX" AfterTargets="DocClean" Condition="$(Configuration.Contains('WithDocs'))">
<Target Name="CleanDocFX" AfterTargets="DocClean" Condition="$(Configuration.Contains('WithDocs')) and $(TargetFramework)=='netstandard2.0'">
<Message Text="Cleaning up DocFX generated documentation." Importance="high" />
<RemoveDir Directories="$(ProjectDir)..\docs\_site\;$(ProjectDir)..\docs\memberpage\" />
<ItemGroup Label="DocFX Artifacts to Clean">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.

using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using Yubico.Core.Devices.SmartCard;
using Yubico.Core.Logging;

Expand All @@ -37,6 +37,7 @@ public static bool IsYubicoDevice(this ISmartCardDevice device)

// Assumes that YubiKeys connected over USB will have a reader name that contains "YubiKey".
// When connected over NFC, the reader is a third-party device and will not contain "YubiKey".
[SuppressMessage("Usage", "CA2249:Consider using \'string.Contains\' instead of \'string.IndexOf\'", Justification = "Method needs to compile for both netstandard 2.0 and 2.1")]
public static bool IsUsbTransport(this ISmartCardDevice scDevice) =>
!string.IsNullOrEmpty(scDevice.Path)
&& scDevice.Path.IndexOf("yubikey", StringComparison.OrdinalIgnoreCase) >= 0;
Expand Down
13 changes: 0 additions & 13 deletions Yubico.YubiKey/src/Yubico/YubiKey/KeyboardDeviceInfoFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

using Yubico.Core.Devices.Hid;
using Yubico.YubiKey.DeviceExtensions;
using System.Diagnostics;
using System;
using System.Diagnostics.CodeAnalysis;
using Yubico.Core.Logging;
Expand Down Expand Up @@ -77,10 +76,6 @@ private static bool TryGetDeviceInfoFromKeyboard(IHidDevice device, [MaybeNullWh
return true;
}
}
catch (NotImplementedException e)
{
ErrorHandler(e, "The MacOSHidDevice.ConnectToFeatureReport was not implemented on MacOS.");
}
catch (KeyboardConnectionException e)
{
// KeyboardTransform.HandleSlotRequestInstruction, unexpected no reply after writing report
Expand Down Expand Up @@ -113,10 +108,6 @@ private static bool TryGetSerialNumberFromKeyboard(IHidDevice device, out int? s
return true;
}
}
catch (NotImplementedException e)
{
ErrorHandler(e, "MacOSHidDevice.ConnectToFeatureReports was not implemented on MacOS.");
}
catch (KeyboardConnectionException e)
{
// KeyboardTransform.HandleStatusInstruction, failed to read keyboard status report
Expand Down Expand Up @@ -149,10 +140,6 @@ private static bool TryGetFirmwareVersionFromKeyboard(IHidDevice device, [MaybeN
return true;
}
}
catch (NotImplementedException e)
{
ErrorHandler(e, "MacOSHidDevice.ConnectToFeatureReports was not implemented on MacOS.");
}
catch (KeyboardConnectionException e)
{
// KeyboardTransform.HandleStatusInstruction, failed to read keyboard status report
Expand Down
2 changes: 2 additions & 0 deletions Yubico.YubiKey/src/Yubico/YubiKey/Oath/Credential.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

using System;
using System.Collections.Specialized;
using System.Diagnostics.CodeAnalysis;
using System.Web;
using System.Globalization;
using System.Linq;
Expand Down Expand Up @@ -574,6 +575,7 @@ private static (string issuer, string account) ParseUriPath(string path, string
return (defaultIssuer, tempPath);
}

[SuppressMessage("Globalization", "CA1307:Specify StringComparison for clarity", Justification = "Method needs to compile for both netstandard 2.0 and 2.1")]
public override int GetHashCode()
{
int hash = base.GetHashCode();
Expand Down
18 changes: 17 additions & 1 deletion Yubico.YubiKey/src/Yubico/YubiKey/Pipelines/KeyboardTransform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using Yubico.Core.Devices.Hid;
using Yubico.Core.Iso7816;
using System.Diagnostics;
using Yubico.Core.Logging;

namespace Yubico.YubiKey.Pipelines
{
Expand All @@ -30,6 +31,8 @@ internal class KeyboardTransform : IApduTransform
{
private readonly IHidConnection _hidConnection;

private readonly Logger _log = Log.GetLogger();

/// <summary>
/// An event which is fired if the YubiKey indicates it is waiting for touch. Event handlers
/// must return as quickly as possible. If there are longer running tasks which are triggered
Expand Down Expand Up @@ -71,10 +74,12 @@ public ResponseApdu Invoke(CommandApdu commandApdu, Type commandType, Type respo
switch (commandApdu.Ins)
{
case Otp.OtpConstants.ReadStatusInstruction:
_log.LogInformation("Reading the OTP status.");
frameReader.AddStatusReport(new KeyboardReport(_hidConnection.GetReport()));
break;
case Otp.OtpConstants.RequestSlotInstruction:
bool configInstruction = responseType.IsAssignableFrom(typeof(Otp.Commands.ReadStatusResponse));
_log.LogInformation($"Handling an OTP slot request {commandApdu.P1}. Configuring = {configInstruction}");
HandleSlotRequestInstruction(commandApdu, frameReader, configInstruction);
break;
default:
Expand Down Expand Up @@ -115,7 +120,13 @@ private void HandleSlotRequestInstruction(CommandApdu apdu, KeyboardFrameReader
KeyboardReport? report = null;
foreach (KeyboardReport featureReport in apdu.GetHidReports())
{
_log.LogInformation("Wait for write pending...");

report = WaitForWriteResponse();

_log.LogInformation("Got write response [{Report}]", report);
_log.SensitiveLogInformation("Sending report [{Report}]", featureReport);

_hidConnection.SetReport(featureReport.ToArray());
}

Expand All @@ -127,10 +138,12 @@ private void HandleSlotRequestInstruction(CommandApdu apdu, KeyboardFrameReader
if (!configInstruction)
{
// This is the point we will also detect touch.
_log.LogInformation("Wait for read pending...");
report = WaitForReadPending();

do
{
_log.SensitiveLogInformation("Adding feature report [{Report}]", report);
if (!frameReader.TryAddFeatureReport(report))
{
ResetReadMode();
Expand Down Expand Up @@ -209,6 +222,7 @@ private KeyboardReport WaitFor(
sleepDurationMs *= growthFactor;

var report = new KeyboardReport(_hidConnection.GetReport());
_log.SensitiveLogInformation("Received report [{Report}]", report);

if (checkForTouch && report.TouchPending)
{
Expand All @@ -225,12 +239,13 @@ private KeyboardReport WaitFor(

if (stopCondition(report))
{
_log.SensitiveLogInformation("Stop condition encountered: [{Report}]", report);
return report;
}
}

ResetReadMode();
Debug.WriteLine($"Timed out after {stopwatch.ElapsedMilliseconds}ms.");
_log.LogWarning($"Timed out after {stopwatch.ElapsedMilliseconds}ms.");
throw new KeyboardConnectionException(timeoutMessage);
}

Expand All @@ -242,6 +257,7 @@ private void ResetReadMode()
SequenceNumber = 0xF,
};

_log.LogInformation("Reset read mode [{Report}]", resetReport);
_hidConnection.SetReport(resetReport.ToArray());

// Not strictly necessary, but it's in the spec, so here it is.
Expand Down
Loading

0 comments on commit ab4f01d

Please sign in to comment.