Go to main content

マニュアルページ セクション 1: ユーザーコマンド

印刷ビューの終了

更新: 2022年7月27日
 
 

decrypt(1)

名前

encrypt, decrypt - ファイルの暗号化または復号化

形式

/usr/bin/encrypt -l
/usr/bin/encrypt -a algorithm [-v]
     [-k key_file | -K key_label [-T token_spec]]
     [-i input_file] [-o output_file]
/usr/bin/decrypt -l
/usr/bin/decrypt -a algorithm [-v]
     [-k key_file | -K key_label [-T token_spec]]
     [-i input_file] [-o output_file]

説明

These utilities encrypt or decrypt the given input file using the algorithm specified.If no input file is specified, input is read from standard input.If no output file is specified, output is printed to standard output.

If the –i and –o options specify the same file, the output is written to a temporary work file in the same file system and then renamed to replace the original input file.

encrypt の出力ファイルと decrypt の入力ファイルには、次の情報が含まれています。

  • 出力形式バージョン番号 (ネットワークバイトオーダーの 4 バイト)。現在のバージョンは 1 です。

  • 鍵生成関数で使用される繰り返し (ネットワークバイトオーダーの 4 バイト)。

  • IV (ivlen bytes)[1].IV data is generated by random bytes equal to one block size.

  • 鍵生成に使用される salt データ (16 バイト)。

  • Cipher text data.

オプション

サポートしているオプションは、次のとおりです。

–a algorithm

暗号化または復号化プロセスで使用するアルゴリズムの名前を指定します。Note that some weak algorithms may be available for use with the decrypt command only and not for encryption.詳細については、「使用法」の「アルゴリズム」を参照してください。

–i input_file

入力ファイルを指定します。The default is standard input if –i is not specified.

–k key_file

暗号化アルゴリズムのキー値を含むファイルを指定します。PKCS#11 仕様で規定されているように、各アルゴリズムには固有のキー素材要件があります。–k が指定されていない場合、encryptgetpassphrase(3C) を使用してキー素材の入力を要求します。鍵ファイルのサイズにより鍵の長さが決まります。また、可変長鍵を使用した暗号化用の 128 ビット長鍵の生成には、端末から設定されたパスフレーズが常に使用されます。

鍵ファイルの生成については、pktool(1)genkey サブコマンドを参照してください。Alternatively, dd(8) can be used to read data from the random(4D) device to generate a key file.

–K key_label

PKCS#11 トークン内で対称トークンキーのラベルを指定します。

–l

システムで利用可能なアルゴリズムの一覧を表示します。この一覧は、暗号化フレームワークの構成によって変わります。The list is also likely to be different for the encrypt and decrypt commands, as some algorithms such as arcfour and des can no longer be used for encryption, but only for decryption.キーサイズはビット単位で表示されます。

–o output_file

Specify output file.The default is standard output if –o is not specified.If standard output is used without redirecting to a file, the terminal window can appear to hang because the raw encrypted or decrypted data has disrupted the terminal emulation, much like viewing a binary file can do at times.

–T token_spec

–K が指定されている場合に、デフォルトのソフトトークンオブジェクトストア以外の PKCS#11 トークンを指定します。

token_spec は次の形式になります。

token_name [:manuf_id [:serial_no]]

トークンラベルの末尾にスペースがある場合でも、このオプションではユーザーがスペースを入力する必要はありません。

Colon separated token identification string.いずれかの部分に文字としてコロン (:) を含める場合、そのコロンをバックスラッシュで (\) でエスケープする必要があります。コロン (:) がない場合、文字列全体が (最大 32 文字) がトークンラベルと見なされます。コロンが (:) 1 つだけある場合、文字列はトークンラベルと作成者となります。

–v

Display verbose information.See Verbose section.

使用法

Algorithms

The supported algorithms are displayed with their minimum and maximum key sizes by the –l option.これらのアルゴリズムは、暗号化フレームワークによって提供されます。サポートされる各アルゴリズムは PKCS #11 メカニズムの別名であり、特定のアルゴリズムタイプでもっともよく使用され、もっとも制限が少ないバージョンです。たとえば、aesCKM_AES_CBC_PAD の別名であり、3desCKM_DES3_CBC_PAD の別名です。パディングや ECB のない派生アルゴリズムは、サポートされていません。

これらの別名は –a オプションとともに使用され、大文字と小文字が区別されます。

パスフレーズ

–k オプションが暗号化および復号化タスクで使用されない場合、ユーザーはパスフレーズの入力を求められます。パスフレーズは、PKCS #5 で指定されている PBKDF2 アルゴリズムを使用して処理され、より安全な鍵に変換されます。

When a passphrase is used with encrypt and decrypt, the user entered passphrase is turned into an encryption key using the PBKDF2 algorithm as defined in PKCS #5 v2.0.

Verbose

コマンドに入力ファイルが指定されている場合、進行状況が画面に表示されます。進行状況の表示では、25% 完了するごとにパイプ記号 (|) が表示されます。 標準入力からの入力の場合は、40KB 読み取られるたびにピリオド (.) が表示されます。両方の入力方法が完了すると、「Done」が出力されます。

使用例 1 encrypt で使用可能なアルゴリズムの一覧表示

次の例では、使用できるアルゴリムが一覧表示されます。

example$ encrypt -l
     Algorithm       Keysize:  Min   Max (bits)
     -----------------------------------
     aes                       128   256
     3des                      128   192
     camellia                  128   256
使用例 2 Encrypting Using AES

The following example encrypts using AES and prompts for a passphrase:

example$ encrypt -a aes -i myfile.txt -o secretstuff
使用例 3 鍵ファイルの作成後に AES を使用して暗号化する

次の例では、鍵ファイルの作成後に AES を使用して暗号化します。

example$ pktool genkey keystore=file keytype=aes keylen=128 \
            outkey=key
example$ encrypt -a aes -k key -i myfile.txt -o secretstuff
使用例 4 Using Pipes to Provide Encrypted Tape Backup

The following example uses pipes to provide encrypted tape backup:

example$ tar xcf - mydata | encrypt -a aes \
     -k ./backup.key | dd of=/dev/rmt/0
使用例 5 Using Pipes to Restore Tape Backup

The following example uses pipes to restore a tape backup:

example$ decrypt -a aes -k ./backup.key \
     -i /dev/rmt/0 | tar zxvf -
使用例 6 3DES アルゴリズムを使用して入力ファイルを暗号化する

次の例では、des3key ファイルに格納された 192 ビット鍵を使用して inputfile ファイルを暗号化します。

example$ encrypt -a 3des -k des3key -i inputfile -o outputfile
使用例 7 AES トークン鍵を使用した入力ファイルの暗号化

次の例では、ソフトトークンキーストア内の AES トークン鍵を使用して入力ファイルを暗号化します。AES トークン鍵は、pktool(1) で生成できます。

example$ encrypt -a aes -K myaeskey \
     -T "Sun Software PKCS#11 softtoken" -i inputfile \
     -o outputfile
使用例 8 decrypt で使用可能なアルゴリズムの一覧表示

次の例では、decrypt コマンドで使用可能なアルゴリズムを一覧表示します。

$ decrypt -l
Algorithm       Keysize:         Min   Max (bits)
------------------------------------------
aes                       128   256
arcfour                     8  2048
des                        64    64
3des                      128   192
camellia                  128   256

終了ステータス

次の終了ステータスが返されます。

0

正常終了。

>0

An error occurred.

属性

属性についての詳細は、マニュアルページの attributes(7) を参照してください。

属性タイプ
属性値
使用条件
system/core-os
インタフェースの安定性
確実

関連項目

digest(1), mac(1), pktool(1), getpassphrase(3C), libpkcs11(3LIB), attributes(7), pkcs11_softtoken(7), dd(8)

Kaliski, B., RFC 2898, PKCS #5: Password-Based Cryptography Specification, Version 2.0, September 2000. https://tools.ietf.org/html/rfc2898

https://www.oasis-open.org/committees/pkcs11/

History

The –K and –T options were added in Oracle Solaris 11.0.

The encrypt and decrypt commands, and all other options, were added in Solaris 10 3/05.