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

xxd is now required? #138

Closed
ljm42 opened this issue Jun 15, 2022 · 3 comments
Closed

xxd is now required? #138

ljm42 opened this issue Jun 15, 2022 · 3 comments

Comments

@ljm42
Copy link
Contributor

ljm42 commented Jun 15, 2022

Hi, I'm back to this and I see there was an update just yesterday :)

It failed on my Unraid system though because I didn't have the "xxd" binary. I was able to get past that by installing vim.

It looks like xxd was added in this commit:
c6ec80e

It would be ideal if xxd wasn't required, but if it is now a requirement, the transcrypt install should probably check to confirm it is available before setting up the repo?

@jmurty
Copy link
Collaborator

jmurty commented Jun 16, 2022

Yes, xxd is now required to make transcrypt work with OpenSSL version 3+ (#133). We use it to convert hex-encoded salt data back to binary.

Is there a better option, ideally one that is available by default on most (or all) nixy systems? It would be a shame to add xxd as a requirement for the tiny job we use it for, if there is an alternative we could use instead.

cc @Erotemic

@Erotemic
Copy link

Agh, I should have checked if xxd was a common tool or not. I wasn't even thinking.

I do remember finding a tool to get the conversion to work was a huge PIA. I wroteup a note file on the best ways I found to do the conversion in bash: https://github.com/Erotemic/misc/blob/main/learn/bash_base_conversions.sh which is in large part based on this blog https://boubakr92.wordpress.com/2012/12/14/numeral-systems-conversion-in-bash/

One confounding factor is that bash variables can't contain raw bytes, so the conversion has to be done entirely in a stream.

@lmj42 do you know of a more common unix tool that can do the conversion from hex to raw bytes? Most things I'm seeing are just pointing to xxd.

If xxd is the most widely available program for accomplishing the task (which is 100% necessary for transcrypt to function with OpenSSL3), then we have to bite the bullet, but one mitigation could be to support OpenSSL1.x when xxd is not installed, via:

    openssl_major_version=$($openssl_path version  | cut -d' ' -f2 | cut -d'.' -f1)
    if [ "$openssl_major_version" -ge "3" ]; then
        # openssl 3.x usage that requires xxd
    else
        # openssl 1.x usage that does not need xxd. 
    fi

That in addition to checking that xxd is available on install. But the best option would be to find a more native solution (does one exist?)

@jmurty
Copy link
Collaborator

jmurty commented Jun 27, 2022

After looking around I think we might be stuck with xxd as a new requirement for compatibility with OpenSSL 3+ but I like @Erotemic's idea of making it a requirement only when it's really needed for that compatibility.

I have made these changes, and documented the new requirement, in commit a258dc4 on the main branch.

@jmurty jmurty closed this as completed Jun 27, 2022
jmurty added a commit to Erotemic/transcrypt that referenced this issue Jun 27, 2022
# By Adrian Dimitrov (1) and James Murty (1)
# Via GitHub
* main:
  Use core attributesFile from worktree (elasticdog#137)
  Document `xxd` requirement, and make optional with OpenSSL < 3 (elasticdog#138)

# Conflicts:
#	transcrypt
jmurty added a commit that referenced this issue Oct 15, 2022
# By James Murty (18) and others
# Via GitHub (1) and James Murty (1)
* main: (26 commits)
  Centralise load and save of password into functions #141
  Fix date of 2.2.0 release
  Ensure tests use "main" as default branch name #143
  Use OpenSSL for B64 encoding not `base64` which differs between Linux and Mac #140
  Use core attributesFile from worktree (#137)
  Document `xxd` requirement, and make optional with OpenSSL < 3 (#138)
  Prepare for 2.2.0 release
  Fix when using OpenSSL 3 which no longer embeds salt in output (#135)
  Consolidate all git operation scripts into a single transcrypt script
  Fix handling of small files and files with null in first 8 bytes (#116)
  Improve command hint to fix secret files not encrypted in index (#120) (#130)
  Remove Ubuntu 16.04 LTS from test matrix (#123)
  Configure default Git branch name for macOS tests in GitHub
  Handle rename of primary branch from "master" to "main"
  Ensure Git index is up-to-date before dirty repo  check #37 (#109)
  Fix incorrect salt when partially staged files are commited (#119)
  Use shorthand for grep options for broader compatibility (#121)
  Let user set a custom path to openssl #108
  Install entire transcrypt script into repository
  Change version to indicate development "pre-release" status
  ...

# Conflicts:
#	README.md
#	tests/_test_helper.bash
#	tests/test_cleanup.bats
#	tests/test_crypt.bats
#	tests/test_init.bats
#	tests/test_not_inited.bats
#	transcrypt
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