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

🐛Bug: Cannot run Kryptor binary on NixOS #71

Closed
c0gn1tion opened this issue May 1, 2024 · 15 comments
Closed

🐛Bug: Cannot run Kryptor binary on NixOS #71

c0gn1tion opened this issue May 1, 2024 · 15 comments
Assignees
Labels
bug Houston, we've got a problem

Comments

@c0gn1tion
Copy link

Description

After trying to run the binary with all the dynamic libraries (this being libz and libstdc++), the program works fine but when trying to generate keys or verify a signature, it gives the error "Illegal Instruction (core dumped)". The missing dynamic libraries was found by running ldd kryptor in the directory of the binary.

Steps to reproduce

  1. Have the lines in configuration.nix
    programs.nix-ld.enable = true
    programs.nix-ld.libraries = with pkgs; [ libz libstdcxx5 icu ]
  2. Run ./kryptor -g and select any of the key pair type.
  3. See "Illegal instruction (core dumped)"

Expected behavior

Successfully generate a key pair.

Platform info

  • OS: Nixos unstable
  • Kryptor version: 4.1.0
@c0gn1tion c0gn1tion added the bug Houston, we've got a problem label May 1, 2024
@samuel-lucas6
Copy link
Owner

Thanks for reporting this. Unfortunately, I know nothing about NixOS. I wonder if this is a .NET problem on NixOS as there was an issue before about that (#59).

After trying to run the binary with all the dynamic libraries (this being libz and libstdc++), the program works fine

What do you mean by this? That it executes? Which binary are you using or did you build from source?

when trying to generate keys or verify a signature, it gives the error "Illegal Instruction (core dumped)".

Do other commands also produce that error, even stuff like -h|--help?

@c0gn1tion
Copy link
Author

Thanks for reporting this. Unfortunately, I know nothing about NixOS. I wonder if this is a .NET problem on NixOS as there was an issue before about that (#59).

Thanks for reading my issue. This probably is a .NET problem, but I compiled binary from source and the problem still persisted. Won't say much about this as I don't know anything about C# or .NET like you with NixOS.

What do you mean by this? That it executes? Which binary are you using or did you build from source?

Basically, running any command that doesn't require any cryptography works such as kryptor -h or kryptor --version will work fine, but commands such as kryptor -g will work fine till it actually starts generating the key, then the error pops up. And what I meant by the 'dynamic libraries', well in NixOS, you cannot run a random binary that you see online because the OS doesn't follow the File system Hierarchy Standard (FHS) and doesn't have a global library path it can use. There are a few ways to get around this, and the one I used was using nix-ld. To find the missing libraries, I used ldd kryptor and added it to the nix-ld libraries section but even then popped out an error of not having an ICU package (which is needed for proper globalization, don't know if that's needed for Kryptor or not) either way, I then added the ICU package, and then it was able to run help commands as mentioned before, but cryptographical tasks produced errors.

@samuel-lucas6
Copy link
Owner

Basically, running any command that doesn't require any cryptography works such as kryptor -h or kryptor --version will work fine, but commands such as kryptor -g will work fine till it actually starts generating the key, then the error pops up.

Thanks for getting back to me. It sounds like it might be libsodium then, the cryptographic library. Not sure where to go from here.

I'd be interested to know whether Cahir or Milva built from source work. The former uses Monocypher and the latter uses Monocypher and Bouncy Castle instead of libsodium.

@c0gn1tion
Copy link
Author

Sorry for getting back a bit late, had some problems with my computer.

I'd be interested to know whether Cahir or Milva built from source work. The former uses Monocypher and the latter uses Monocypher and Bouncy Castle instead of libsodium.

Well, don't know about Cahir as it has no pre-built binary and I don't know how to compile it, but Milva's binary seems to work out of the box with no issues. So, the problem as you said may lie in libsodium. The libsodium library also seems to be available as a nixpkg, so there should be a way to get it working on NixOS (probably using flakes).

@samuel-lucas6
Copy link
Owner

don't know about Cahir as it has no pre-built binary

Sorry, it's still in development and haven't written up build instructions yet.

Milva's binary seems to work out of the box with no issues

Cool, thanks for testing that out.

The libsodium library also seems to be available as a nixpkg, so there should be a way to get it working on NixOS (probably using flakes).

Let me know if you get it working.

@samuel-lucas6
Copy link
Owner

I should've said actually that only BLAKE2b uses Monocypher on Milva (e.g., --blake2b-256). It's less surprising if the other options work because they're either .NET or Bouncy Castle, which means C# code.

@c0gn1tion
Copy link
Author

I should've said actually that only BLAKE2b uses Monocypher on Milva (e.g., --blake2b-256). It's less surprising if the other options work because they're either .NET or Bouncy Castle, which means C# code.

Just tried the --blake2b-256 hash function and it worked with no issues.

@arthsmn
Copy link

arthsmn commented Jul 11, 2024

Created a package for Kryptor in nixpkgs: NixOS/nixpkgs#326334

@c0gn1tion
Copy link
Author

Created a package for Kryptor in nixpkgs: NixOS/nixpkgs#326334

Guess that fixes it then, I will close this issue once it gets merged.

@arthsmn
Copy link

arthsmn commented Jul 16, 2024

The package is now merged. @samuel-lucas6 maybe you want to add it to the available package managers. If you need any help with nix I'm here :)

@samuel-lucas6
Copy link
Owner

Thanks @arthsmn! What link should I use? Searching here doesn't find anything at the moment.

@arthsmn
Copy link

arthsmn commented Jul 16, 2024

Thanks @arthsmn! What link should I use? Searching here doesn't find anything at the moment.

This is because it was merged on the master branch of the repository, it'll take two or three days to get into nixos-unstable (the rolling release), here is the link of the search in the unstable channel. For the stable release it'll have to wait until the next one, as nixos doesn't add new packages in a stable channel. I'll ping you here when it arrives in unstable.

@arthsmn
Copy link

arthsmn commented Jul 18, 2024

@samuel-lucas6 kryptor is now in the unstable branch!

@samuel-lucas6
Copy link
Owner

@arthsmn Thanks for letting me know. I've updated the website and credited you in the Acknowledgements.

@arthsmn
Copy link

arthsmn commented Jul 18, 2024

@arthsmn Thanks for letting me know. I've updated the website and credited you in the Acknowledgements.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Houston, we've got a problem
Projects
None yet
Development

No branches or pull requests

3 participants