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.
サポートしているオプションは、次のとおりです。
暗号化または復号化プロセスで使用するアルゴリズムの名前を指定します。Note that some weak algorithms may be available for use with the decrypt command only and not for encryption.詳細については、「使用法」の「アルゴリズム」を参照してください。
入力ファイルを指定します。The default is standard input if –i is not specified.
暗号化アルゴリズムのキー値を含むファイルを指定します。PKCS#11 仕様で規定されているように、各アルゴリズムには固有のキー素材要件があります。–k が指定されていない場合、encrypt は getpassphrase(3C) を使用してキー素材の入力を要求します。鍵ファイルのサイズにより鍵の長さが決まります。また、可変長鍵を使用した暗号化用の 128 ビット長鍵の生成には、端末から設定されたパスフレーズが常に使用されます。
鍵ファイルの生成については、pktool(1) の genkey サブコマンドを参照してください。Alternatively, dd(8) can be used to read data from the random(4D) device to generate a key file.
PKCS#11 トークン内で対称トークンキーのラベルを指定します。
システムで利用可能なアルゴリズムの一覧を表示します。この一覧は、暗号化フレームワークの構成によって変わります。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.キーサイズはビット単位で表示されます。
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.
–K が指定されている場合に、デフォルトのソフトトークンオブジェクトストア以外の PKCS#11 トークンを指定します。
token_spec は次の形式になります。
token_name [:manuf_id [:serial_no]]
トークンラベルの末尾にスペースがある場合でも、このオプションではユーザーがスペースを入力する必要はありません。
Colon separated token identification string.いずれかの部分に文字としてコロン (:) を含める場合、そのコロンをバックスラッシュで (\) でエスケープする必要があります。コロン (:) がない場合、文字列全体が (最大 32 文字) がトークンラベルと見なされます。コロンが (:) 1 つだけある場合、文字列はトークンラベルと作成者となります。
Display verbose information.See Verbose section.
The supported algorithms are displayed with their minimum and maximum key sizes by the –l option.これらのアルゴリズムは、暗号化フレームワークによって提供されます。サポートされる各アルゴリズムは PKCS #11 メカニズムの別名であり、特定のアルゴリズムタイプでもっともよく使用され、もっとも制限が少ないバージョンです。たとえば、aes は CKM_AES_CBC_PAD の別名であり、3des は CKM_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.
コマンドに入力ファイルが指定されている場合、進行状況が画面に表示されます。進行状況の表示では、25% 完了するごとにパイプ記号 (|) が表示されます。 標準入力からの入力の場合は、40KB 読み取られるたびにピリオド (.) が表示されます。両方の入力方法が完了すると、「Done」が出力されます。
次の例では、使用できるアルゴリムが一覧表示されます。
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
次の終了ステータスが返されます。
正常終了。
An error occurred.
属性についての詳細は、マニュアルページの attributes(7) を参照してください。
|
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/
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.