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

Dislocker On Mac with homebrew #321

Open
asegner opened this issue Oct 30, 2023 · 11 comments
Open

Dislocker On Mac with homebrew #321

asegner opened this issue Oct 30, 2023 · 11 comments

Comments

@asegner
Copy link

asegner commented Oct 30, 2023

Hello! First i would like to say thanks for the excellent work on making dislocker. I have been using it to work with my encrypted windows drives on my mac and it seems to do quite well. I had trouble finding any UIs for it so i made a little free one for the mac menu bar called Perch at https://dancingparrots.com/ - any feedback is appreciated. This is where my questions come in.

I am not distributing dislocker with Perch but am asking that it be installed on the system beforehand. I have found that running "brew install dislocker" does not result in a clean install. Something about needing linux which i'm not sure how thats intended to be resolved. Additionally running "brew install src/dislocker.rb" from the cloned repo does not immediately result in a clean build.

I include manual instructions on the site above (and pasted below) to help guide end users on installing dislocker that seem to work on intel and silicon macs. However, manual steps add a bit of friction to the install process that may turn some people away -- i'm writing to you to find out if there is a better way to install or if i'm misusing the brew command in some way? Thanks for any help!


Manual Installation Steps for Mac Intel and Silicon

git clone https://github.com/Aorimn/dislocker.git && cd dislocker
xcode-select --install
brew unlink mbedtls
brew install macfuse cmake mbedtls@2 pkg-config
brew link mbedtls@2
SDKROOT=`xcrun --show-sdk-path` cmake .
make
sudo make install
brew unlink mbedtls@2 # only unlink, not uninstall, required for running dislocker
brew link mbedtls
@GoelBiju
Copy link

GoelBiju commented Nov 7, 2023

Thanks @asegner, I haven't tested these steps to get it working. The steps in #239 is what I used.

I like the UI you have built for it, any plans on making it open-source on GitHub (with a license) and including a build of dislocker included with it instead of having it on the path? Also is it worth just using mbedtls 3 instead of 2?

@asegner
Copy link
Author

asegner commented Nov 7, 2023

Hi @GoelBiju -- Thanks for the feedback! I intend to add an open license and open-source it on GitLab (thats where it currently lives now) after i have fleshed it out a bit more. Its currently very new. And, as you mentioned, I will consider packaging dislocker inside of Perch when i get to that state. Pls "star" the project if you find it useful. Thanks!

To your second point -- I do realize dislocker will work with mbedtls@3 however I was not able to get a clean compile with mbedtls 3 and homebrew without making source modifications which in my opinion is not ideal. the cmake line works but on make command on version 3 i get the following:

[ 19%] Building C object src/CMakeFiles/dislocker.dir/accesses/stretch_key.c.o
In file included from /Users/aaron/dislocker/src/accesses/stretch_key.c:25:
In file included from /Users/aaron/dislocker/include/dislocker/accesses/stretch_key.h:29:
/Users/aaron/dislocker/include/dislocker/ssl_bindings.h:29:10: fatal error: 'mbedtls/config.h' file not found
#include "mbedtls/config.h"
         ^~~~~~~~~~~~~~~~~~
1 error generated.
make[2]: *** [src/CMakeFiles/dislocker.dir/accesses/stretch_key.c.o] Error 1
make[1]: *** [src/CMakeFiles/dislocker.dir/all] Error 2
make: *** [all] Error 2

I don't get this with version 2. I use homebrew and not macports. I understand they can both be installed on the same system, however I already have brew installed across my macs and did not want to install macports on my macs just for dislocker. Currently, for the time being, dislocker appears stable with version 2.

My hope, ideally, is that the brew command will be fixed eventually allowing dislocker to simply be installed with brew install dislocker allowing us to get moving quickly without the extra steps. After this works I intend to distribute Perch on homebrew too.

@asegner
Copy link
Author

asegner commented Nov 7, 2023

i get the following on brew

brew install dislocker
==> Downloading https://formulae.brew.sh/api/formula.jws.json
########################################################################################################################################################################################################### 100.0%
==> Downloading https://formulae.brew.sh/api/cask.jws.json
########################################################################################################################################################################################################### 100.0%
dislocker: Linux is required for this software.

@asegner asegner changed the title Dislocker On Mac Dislocker On Mac with homebrew Nov 7, 2023
@subratappt
Copy link

git clone https://github.com/Aorimn/dislocker.git 
cd dislocker
cmake .

Do a small fix after cmake in the generated file ssl_bindings.h, replace the config.h and version.h with build_info.h and rename the function mbedtls_sha256_ret to mbedtls_sha256

The following part of the code

#include "mbedtls/config.h"
#include "mbedtls/version.h"
#include "mbedtls/aes.h"

// Function's name changed
#if defined(MBEDTLS_SHA256_C)
#include "mbedtls/sha256.h"
#if MBEDTLS_VERSION_NUMBER >= 0x02070000
#define SHA256(input, len, output)         mbedtls_sha256_ret(input, len, output, 0)
#else
#define SHA256(input, len, output)         mbedtls_sha256(input, len, output, 0)
#endif /* POLARSSL_VERSION_NUMBER >= 0x02070000 */
#else /* defined(MBEDTLS_SHA256_C) */

will be replaced by

#if MBEDTLS_VERSION_NUMBER >= 0x03000000
#include "mbedtls/build_info.h"
#else 
#include "mbedtls/config.h"
#include "mbedtls/version.h"
#endif

#include "mbedtls/aes.h"

// Function's name changed
#if defined(MBEDTLS_SHA256_C)
#include "mbedtls/sha256.h"

#if MBEDTLS_VERSION_NUMBER >= 0x03000000
#define SHA256(input, len, output) mbedtls_sha256(input, len, output, 0)
#elif MBEDTLS_VERSION_NUMBER >= 0x02070000 && MBEDTLS_VERSION_NUMBER < 0x03000000
#define SHA256(input, len, output) mbedtls_sha256_ret(input, len, output, 0)
#else
#define SHA256(input, len, output) mbedtls_sha256(input, len, output, 0)
#endif /* POLARSSL_VERSION_NUMBER >= 0x02070000 */
#else  /* defined(MBEDTLS_SHA256_C) */

After this,

make dislocker-fuse
make install

This was fixed but reverted #305.

@linuxgnuru
Copy link

I too am working on a frontend for dislocker on Mac using swift that will let you input the key, and optional mount file and loopback mount folder but haven't had success with brew building dislocker; primarily because my work is somewhat big and restrictive so i can't just download the latest updated xcode. This frontend will still require the user to manually first install dislocker for now but eventually including it in my own code would also be ideal.

I'll try what everyone has posted here to see if I have any better luck and will share what I am able to source wise

@linuxgnuru
Copy link

Ok so everything went as planned; even found dislocker-meta -V /dev/diskX | grep Recover to get the key.

@asegner if you ever do release your code GNU / github, I'd love to help where I can

@asegner
Copy link
Author

asegner commented Jan 17, 2024

@linuxgnuru It is now released with a GPL license. Looking forward to PRs!

@jblestang
Copy link

jblestang commented Feb 3, 2024

Trying to night with a fresh install of SONOMA with the details from "https://dancingparrots.com" from @asegner and got the following :

...
-- --------------------
CMake Error at /opt/homebrew/Cellar/cmake/3.28.2/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)
Call Stack (most recent call first):
  /opt/homebrew/Cellar/cmake/3.28.2/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
  /opt/homebrew/Cellar/cmake/3.28.2/share/cmake/Modules/FindPkgConfig.cmake:99 (find_package_handle_standard_args)
  cmake/FindFUSE.cmake:12 (FIND_PACKAGE)
  src/CMakeLists.txt:152 (find_package)

@jblestang
Copy link

Using brew install src/discloker.rb I can overcome the previous issue but now there is an error when linking with macfuse stuff : /opt/homebrew/Library/Homebrew/shims/mac/super/clang -fPIC -Wall -Wextra -fstack-protector -fstrict-aliasing -D_FORTIFY_SOURCE=2 -O1 -Qunused-arguments -O3 -DNDEBUG -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names -pie -fPIE "CMakeFiles/dislocker-bek.dir/dislocker-bek.c.o" -o dislocker-bek -Wl,-rpath,/tmp/dislocker-20240204-9827-a1lwa8/dislocker-0.7.2/src libdislocker.0.7.2.dylib -lpthread /opt/homebrew/lib/libmbedcrypto.dylib -framework ruby /usr/local/lib/libfuse.dylib /opt/homebrew/Library/Homebrew/shims/mac/super/clang -fPIC -Wall -Wextra -fstack-protector -fstrict-aliasing -D_FORTIFY_SOURCE=2 -O1 -Qunused-arguments -O3 -DNDEBUG -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names -pie -fPIE "CMakeFiles/dislocker-file.dir/dislocker-file.c.o" -o dislocker-file -Wl,-rpath,/tmp/dislocker-20240204-9827-a1lwa8/dislocker-0.7.2/src libdislocker.0.7.2.dylib -lpthread /opt/homebrew/lib/libmbedcrypto.dylib -framework ruby /usr/local/lib/libfuse.dylib /opt/homebrew/Library/Homebrew/shims/mac/super/clang -fPIC -Wall -Wextra -fstack-protector -fstrict-aliasing -D_FORTIFY_SOURCE=2 -O1 -Qunused-arguments -O3 -DNDEBUG -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names -pie -fPIE "CMakeFiles/dislocker-metadata.dir/dislocker-metadata.c.o" -o dislocker-metadata -Wl,-rpath,/tmp/dislocker-20240204-9827-a1lwa8/dislocker-0.7.2/src libdislocker.0.7.2.dylib -lpthread /opt/homebrew/lib/libmbedcrypto.dylib -framework ruby /usr/local/lib/libfuse.dylib /opt/homebrew/Library/Homebrew/shims/mac/super/clang -fPIC -Wall -Wextra -fstack-protector -fstrict-aliasing -D_FORTIFY_SOURCE=2 -O1 -Qunused-arguments -O3 -DNDEBUG -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names -pie -fPIE "CMakeFiles/dislocker-fuse.dir/dislocker-fuse.c.o" -o dislocker-fuse -Wl,-rpath,/tmp/dislocker-20240204-9827-a1lwa8/dislocker-0.7.2/src -losxfuse_i64 libdislocker.0.7.2.dylib -lpthread /opt/homebrew/lib/libmbedcrypto.dylib -framework ruby /usr/local/lib/libfuse.dylib ld: library 'osxfuse_i64' not found clang: error: linker command failed with exit code 1 (use -v to see invocation)

@tristan-k
Copy link

tristan-k commented Sep 2, 2024

The install instructions wont work on macOS Sonoma (Intel) 14.5

$ brew install src/dislocker.rb
Error: Failed to load cask: src/dislocker.rb
Cask 'dislocker' is unreadable: wrong constant name #<Class:0x00000001284da520>
Warning: Treating src/dislocker.rb as a formula.
==> Fetching dependencies for dislocker: mbedtls and cmake
==> Fetching mbedtls
==> Downloading https://ghcr.io/v2/homebrew/core/mbedtls/manifests/3.6.1
####################################################################################################################################################### 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/mbedtls/blobs/sha256:00860dfbfe01e85918c698b95c50a40c1cd7e102ffaa548d17be6d7c1e27ab81
####################################################################################################################################################### 100.0%
==> Fetching cmake
==> Downloading https://ghcr.io/v2/homebrew/core/cmake/manifests/3.30.3
####################################################################################################################################################### 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/cmake/blobs/sha256:ddd6fc37af08738bb5d9491e73ed37be64510065278425e3726fcd1b9db87180
####################################################################################################################################################### 100.0%
==> Fetching dislocker
==> Downloading https://github.com/Aorimn/dislocker/archive/v0.7.2.zip
==> Downloading from https://codeload.github.com/Aorimn/dislocker/zip/refs/tags/v0.7.2
##O=#    #
Warning: dislocker 0.7.3 is available and more recent than version 0.7.2.
==> Installing dependencies for dislocker: mbedtls and cmake
==> Installing dislocker dependency: mbedtls
==> Downloading https://ghcr.io/v2/homebrew/core/mbedtls/manifests/3.6.1
Already downloaded: /Users/admin/Library/Caches/Homebrew/downloads/d40da23c8d5098a89de939b1183996cd2d04cd22ea893bc18fbf7a75a4e88921--mbedtls-3.6.1.bottle_manifest.json
==> Pouring mbedtls--3.6.1.sonoma.bottle.tar.gz
🍺  /usr/local/Cellar/mbedtls/3.6.1: 200 files, 11.1MB
==> Installing dislocker dependency: cmake
==> Downloading https://ghcr.io/v2/homebrew/core/cmake/manifests/3.30.3
Already downloaded: /Users/admin/Library/Caches/Homebrew/downloads/1173f026db24f4c17bdb8cc3be2e921656e9270e564c2b94630469741fe86f72--cmake-3.30.3.bottle_manifest.json
==> Pouring cmake--3.30.3.sonoma.bottle.tar.gz
🍺  /usr/local/Cellar/cmake/3.30.3: 3,424 files, 59.0MB
==> Installing dislocker
==> cmake
==> make
Last 15 lines from /Users/admin/Library/Logs/Homebrew/dislocker/02.make:
In file included from /tmp/dislocker-20240902-8037-qlz22q/dislocker-0.7.2/include/dislocker/encryption/encommon.priv.h:29:
/tmp/dislocker-20240902-8037-qlz22q/dislocker-0.7.2/include/dislocker/ssl_bindings.h:29:10: fatal error: 'mbedtls/config.h' file not found
#include "mbedtls/config.h"
         ^~~~~~~~~~~~~~~~~~
1 error generated.
make[2]: *** [src/CMakeFiles/dislocker_bundle.dir/encryption/encommon.c.o] Error 1
In file included from /tmp/dislocker-20240902-8037-qlz22q/dislocker-0.7.2/src/encryption/decrypt.c:28:
In file included from /tmp/dislocker-20240902-8037-qlz22q/dislocker-0.7.2/include/dislocker/encryption/encommon.priv.h:29:
/tmp/dislocker-20240902-8037-qlz22q/dislocker-0.7.2/include/dislocker/ssl_bindings.h:29:10: fatal error: 'mbedtls/config.h' file not found
#include "mbedtls/config.h"
         ^~~~~~~~~~~~~~~~~~
1 error generated.
make[2]: *** [src/CMakeFiles/dislocker_bundle.dir/encryption/decrypt.c.o] Error 1
make[1]: *** [src/CMakeFiles/dislocker_bundle.dir/all] Error 2
make: *** [all] Error 2

Do not report this issue to Homebrew/brew or Homebrew/homebrew-core!

@asegner
Copy link
Author

asegner commented Sep 6, 2024

@tristan-k @jblestang i missed one item in the brew install - it needs a brew install pkg-config before cmake and then follow the rest of the directions, i've updated the comment above and the dancingparrots site. I verified today that these build steps complete successfully on Intel versions of Ventura 13.6 and Sonoma 14.7

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

6 participants