シンプルな暗号化ツールのEncpipe

Minisignでファイルに署名,検証 🏛️」のMinisignで紹介されていたEncpipeを少し試してみました.

build
$ git clone https://github.com/jedisct1/encpipe
$ cd encpipe
$ make
Usage
$ ./encpipe
Usage:
    encpipe -G
    encpipe {-e | -d} {-p <string> | -P <file>} [-i <file>] [-o <file>]

Options:
    -G, --passgen          generate a random password
    -e, --encrypt          encryption mode
    -d, --decrypt          decryption mode
    -p, --pass <password>  use <password>
    -P, --passfile <file>  read password from <file>
    -i, --in <file>        read input from <file>
    -o, --out <file>       write output to <file>
    -h, --help             print this message
ランダムなパスワードを生成
$ ./encpipe -G
208294fbcff996f8c859d54d1c8f7d8ac4c0c813a0867abb5b76830c2aa8ac1a
$ ./encpipe -G
311259951f2bfdf5464be05e7eedb88159bf23fdc066adbf89266effea2f9556
$ ./encpipe -G | wc -c
65
暗号化
$ ./encpipe --encrypt \ (1)
  -p 'fcfd940ac76997530341232fa3ee32f39a6b40a0477af1c138e6d21d921ae97a' \ (2)
  -i ./README.md \ (3)
  -o ./README.md.encpipe (4)
  $ cat ./README.md.encpipe | od -xc | head -4
0000000    0474    0000    fb09    d6fb    2524    8820    9261    b74c
          t 004  \0  \0  \t 373 373 326   $   %     210   a 222   L 267
0000020    fb04    c95f    0df6    218c    1ff5    4a4a    5272    685f
        004 373   _ 311 366  \r 214   ! 365 037   J   J   r   R   _   h
  1. 暗号化モード

  2. パスワード文字列指定

  3. 暗号化対象ファイル

  4. 暗号化出力ファイル

復号化
$ ./encpipe --decrypt \ (1)
  -p 'fcfd940ac76997530341232fa3ee32f39a6b40a0477af1c138e6d21d921ae97a' \ (2)
  -i ./README.md.encpipe \ (3)
  -o - | \ (4)
  head -6
![CodeQL scan](https://github.com/jedisct1/encpipe/workflows/CodeQL%20scan/badge.svg)

Encpipe
=======

The dum^H^H^Hsimplest encryption tool in the world.
  1. 復号化モード

  2. パスワード文字列

  3. 入力ファイル

  4. 出力ファイル(-で標準出力に)

パイプ経由で圧縮しつつ暗号化,パイプ経由で復号化しつつ展開
$ cat README.md | zstd | ./encpipe -e -p 'easy-pass' -i - -o - > README.md.zstd.encpipe
$ cat README.md.zstd.encpipe | ./encpipe -d -p 'easy-pass' -i - -o - | zstdcat | head -4
![CodeQL scan](https://github.com/jedisct1/encpipe/workflows/CodeQL%20scan/badge.svg)

Encpipe
=======
ネットワーク経路を暗号化
$ nc -l 6666 | ./encpipe -d -p 'pass' (1)
$ ./encpipe -e -p 'pass' -i ./README.md | nc 127.0.0.1 6666 (2)
  1. 受け取り側の準備,ncでtcp:6666で待ち受けて結果をEncpipeで復号

  2. 送信側,Encpipeで暗号化,ncに流し込み

速度比較
$ time dd if=/dev/zero bs=1M count=1024 2>/dev/null | ./encpipe -e -p `./encpipe -G` > /dev/null

real    0m53.818s
user    0m53.378s
sys     0m0.720s
$ time dd if=/dev/zero bs=1M count=1024 2>/dev/null | GPG_TTY=$(tty) gpg -e -r matoken@gmail.com > /dev/null

real    0m5.883s
user    0m5.574s
sys     0m0.644s

Encpipeは案外遅い 🏛️

Note
このときのgpgの暗号方式はAES256.CFB.

なぜこのツールを作ったのかというとGnuPGやOpenSSLの利用方法を覚えるより使ったほうが速いからだそうです.たしかにこれらのツールはオプションが多く大変ですね…….

環境
$ git log --pretty=oneline -1
7156490a5fa8e0cd1da748451840dfed2d82fe4b (HEAD -> master, origin/master, origin/HEAD) Bump year
$ dpkg-query -W gcc make gpg zstd
gcc     4:14.2.0-1
gpg     2.2.45-2
make    4.4.1-1
zstd    1.5.6+dfsg-2
$ lsb_release -dr
Description:    Debian GNU/Linux trixie/sid
Release:        n/a
$ arch
x86_64

Reposts

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

To respond on your own website, enter the URL of your response which should contain a link to this post's permalink URL. Your response will then appear (possibly after moderation) on this page. Want to update or remove your response? Update or delete your post and re-enter your post's URL again. (Find out more about Webmentions.)