Skip to content
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

M1 mac: Unable to load shared library 'bcrypt.dll' or one of its dependencies #147

Open
tdesmet opened this issue Apr 29, 2022 · 2 comments

Comments

@tdesmet
Copy link

tdesmet commented Apr 29, 2022

I am using an M1 macbook and trying to to simulate an iot device using the Microsoft.Azure.Devices packages.
When I try to create the SecurityProviderTpmHsm I get an error Unable to load shared library 'bcrypt.dll' or one of its dependencies.

The Microsoft.Azure.Devices.Provisioning.Security.Tpm package has a dependency on this library and the error originates from this library.

It seems that this library uses bcrypt. I noticed that work has been done in #105 to make this library cross platform compatible. But since then no new nuget package has been released.

Is it possible to release a new version? And hopefully that fixes the problem...

Stack trace

Unable to load shared library 'bcrypt.dll' or one of its dependencies. In order to help diagnose loading problems, consider setting the DYLD_PRINT_LIBRARIES environment variable: dlopen(libbcrypt.dll, 0x0001): tried: 'libbcrypt.dll' (no such file), '/usr/local/lib/libbcrypt.dll' (no such file), '/usr/lib/libbcrypt.dll' (no such file), '/Users/tom/Documents/GitHub/Geras.Cloud/src/Geras.DataGenerator/bin/Debug/net6.0/libbcrypt.dll' (no such file)
   at Tpm2Lib.Native.BCryptOpenAlgorithmProvider(UIntPtr& AlgProvider, String AlgId, String Implementation, UInt32 Flags)
   at Tpm2Lib.BCryptAlgorithm.Open(String algName, UInt32 flags)
   at Tpm2Lib.BCryptAlgorithm..ctor(String algName, UInt32 flags)
   at Tpm2Lib.CryptoLib.Hmac(TpmAlgId hashAlgId, Byte[] key, Byte[] data)
   at Tpm2Lib.KDF.KDFa(TpmAlgId hmacHash, Byte[] hmacKey, String label, Byte[] contextU, Byte[] contextV, Int32 numBitsRequired)
   at Tpm2Lib.PRNG.FillRandBuf()
   at Tpm2Lib.PRNG.SetRngRandomSeed()
   at Tpm2Lib.PRNG.GetRandomBytes(Int32 numBytes)
   at Tpm2Lib.Tpm2.CancelSafeStartAuthSession(TpmSe sessionType, TpmAlgId authHash, Int32 nonceCallerSize)
   at Tpm2Lib.Tpm2.PrepareRequestSessions(CommandInfo commandInfo, TpmHandle[] inHandles)
   at Tpm2Lib.Tpm2.DispatchMethod(TpmCc ordinal, TpmStructureBase inParms, Type expectedResponseType, TpmStructureBase& outParms, Int32 numInHandlesNotUsed, Int32 numOutHandlesNotUsed)
   at Tpm2Lib.Tpm2.CreatePrimary(TpmHandle primaryHandle, SensitiveCreate inSensitive, TpmPublic inPublic, Byte[] outsideInfo, PcrSelection[] creationPCR, TpmPublic& outPublic, CreationData& creationData, Byte[]& creationHash, TkCreation& creationTicket)
   at Microsoft.Azure.Devices.Provisioning.Security.SecurityProviderTpmHsm.ReadOrCreatePersistedKey(TpmHandle persHandle, TpmHandle hierarchy, TpmPublic template)
   at Microsoft.Azure.Devices.Provisioning.Security.SecurityProviderTpmHsm.CacheEkAndSrk()
   at Microsoft.Azure.Devices.Provisioning.Security.SecurityProviderTpmHsm..ctor(String registrationId, Tpm2Device tpm)

Code

var tpmDevice = new TcpTpmDevice("127.0.0.1", 2321);
    tpmDevice.Connect();
    tpmDevice.PowerCycle();
    using (var tpm2 = new Tpm2(tpmDevice))
    {
      tpm2.Startup(Su.Clear);
    }
    new SecurityProviderTpmHsm(GetRegistrationID(), tpmDevice);

Issue on azure iot sdk csharp: Azure/azure-iot-sdk-csharp#2362

@chrisfenner
Copy link
Contributor

Hi Tom,

(Not a maintainer, so can't speak authoritatively about future NuGet package releases of this library)

Since this repository is open source, one workaround to the NuGet problem would be to submodule this repo from yours, and then link the csproj from your csproj:

<ProjectReference Include="..\TSS.MSR\TSS.NET\TSS.Net\TSS.Net.csproj" />

That way you can depend on this library from any commit (or fork).

@LuKePicci
Copy link

LuKePicci commented Aug 3, 2023

I confirm the same happens on FreeBSD and Linux using the latest but ancient nuget package 2.1.1. We also managed to workaround this by ProjectReferencing TSS.Net.csproj and Microsoft.Azure.Devices.Provisioning.Security.Tpm.csproj in chain from our device project

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants