.\" Michael Haardt (michael@cantor.informatik.rwth.aachen.de) .\" Sat Sep 3 22:00:30 MET DST 1994 .\" .\" %%%LICENSE_START(GPLv2+_DOC_FULL) .\" This is free documentation; you can redistribute it and/or .\" modify it under the terms of the GNU General Public License as .\" published by the Free Software Foundation; either version 2 of .\" the License, or (at your option) any later version. .\" .\" The GNU General Public License's references to "object code" .\" and "executables" are to be interpreted as the output of any .\" document formatting or typesetting system, including .\" intermediate and printed output. .\" .\" This manual is distributed in the hope that it will be useful, .\" but WITHOUT ANY WARRANTY; without even the implied warranty of .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the .\" GNU General Public License for more details. .\" .\" You should have received a copy of the GNU General Public .\" License along with this manual; if not, see .\" . .\" %%%LICENSE_END .\" .\" Sun Feb 19 21:32:25 1995, faith@cs.unc.edu edited details away .\" .\" TO DO: This manual page should go more into detail how DES is perturbed, .\" which string will be encrypted, and what determines the repetition factor. .\" Is a simple repetition using ECB used, or something more advanced? I hope .\" the presented explanations are at least better than nothing, but by no .\" means enough. .\" .\" added _XOPEN_SOURCE, aeb, 970705 .\" added GNU MD5 stuff, aeb, 011223 .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .\" .\" Japanese Version Copyright (c) 1998 Hiroaki Nagoya and MAEHARA Kouichi all rights reserved. .\" Translated Sun Sep 27 JST 1998 by Hiroaki Nagoya and MAEHARA Kouichi .\" Updated 2002-01-19 by Kentaro Shirakata .\" Updated 2007-01-01 by Kentaro Shirakata .\" Updated 2008-07-30 by Kentaro Shirakata .\" Updated 2009-09-28 by Kentaro Shirakata .\" .TH CRYPT 3 2014\-02\-26 "" "Linux Programmer's Manual" .SH 名前 crypt, crypt_r \- パスワードとデータの暗号化 .SH 書式 .nf \fB#define _XOPEN_SOURCE\fP /* feature_test_macros(7) 参照 */ .br \fB#include \fP .sp \fBchar *crypt(const char *\fP\fIkey\fP\fB, const char *\fP\fIsalt\fP\fB);\fP .sp \fB#define _GNU_SOURCE\fP /* See feature_test_macros(7) */ .br \fB#include \fP .sp \fBchar *crypt_r(const char *\fP\fIkey\fP\fB, const char *\fP\fIsalt\fP\fB,\fP \fB struct crypt_data *\fP\fIdata\fP\fB);\fP .fi .sp \fI\-lcrypt\fP でリンクする。 .SH 説明 \fBcrypt\fP() はパスワード暗号化関数である。 鍵探索のハードウェアによる実装を妨げるように(その他にもいろいろ) 変更した Data Encryption Standard アルゴリズムを元にしている。 .PP \fIkey\fP はユーザーが入力するパスワードである。 .PP \fIsalt\fP は集合 [\fBa\-zA\-Z0\-9./\fP] から選ばれた 2 文字の文字列である。 この文字列はアルゴリズムの出力を 4096 通りにかき乱すのに使われる。 .PP \fIkey\fP の最初の 8 文字の各文字から下位 7 ビットをとって 56 ビットの鍵が得られる。 この 56 ビットの鍵は特定の文字列(ふつうはすべて 0 の文字列) を繰り返し暗号化するのに用いられる。 返り値は暗号化されたパスワードへのポインターで、13 の印字可能な ASCII 文字 からなる(最初の 2 文字は salt そのもの)。 返り値は、関数呼出しのたびに上書きされる静的なデータへのポインターである。 .PP 警告: 鍵空間は .if t 2\s-2\u56\s0\d .if n 2**56 = 7.2e16 の可能な値から成る。 この鍵空間の全探索は強力な並列計算機を使えば可能である。また \fBcrack\fP(1) のようなソフトウェアはこの鍵空間の中で、多くの人にパスワードとして 使われるような鍵についての全探索が可能である。 それゆえ、パスワードを選択するときには、すくなくとも、 一般的に使われる単語と名前は避けるべきである。 \fBpasswd\fP(1) を使う時にはクラックされうるパスワードについての検査をすることが 推奨される。 .PP DES アルゴリズムにはいくつかの癖があり、それによってパスワード認証以外に \fBcrypt\fP() を使うのはたいへんよくない選択となっている。もし \fBcrypt\fP() を暗号プロジェクトに使おうという案をもっているならば、それはやめたほうが よい。暗号化についてのよい本と誰でも入手できる DES ライブラリのひとつを 手にいれるべきだ。 \fBcrypt_r\fP() は \fBcrypt\fP() の再入可能版である。 \fIdata\fP で示される構造体は結果データの保存と情報の管理に使われる。 この構造体に対して(メモリーを割り当てること以外に)呼び出し元がするべき唯一の ことは、 \fBcrypt_r\fP() の初回の呼び出しの前に \fIdata\->initialized\fP をゼロにすることだけである。 .SH 返り値 成功の場合には、暗号化されたパスワードへのポインターが返される。 エラーの場合には NULL が返される。 .SH エラー .TP \fBEINVAL\fP \fIsalt\fP が間違ったフォーマットである。 .TP \fB .TP \fBENOSYS\fP .\" This level of detail is not necessary in this man page. . . .\" .PP .\" When encrypting a plain text P using DES with the key K results in the .\" encrypted text C, then the complementary plain text P' being encrypted .\" using the complementary key K' will result in the complementary encrypted .\" text C'. .\" .PP .\" Weak keys are keys which stay invariant under the DES key transformation. .\" The four known weak keys 0101010101010101, fefefefefefefefe, .\" 1f1f1f1f0e0e0e0e and e0e0e0e0f1f1f1f1 must be avoided. .\" .PP .\" There are six known half weak key pairs, which keys lead to the same .\" encrypted data. Keys which are part of such key clusters should be .\" avoided. .\" Sorry, I could not find out what they are. .\"" .\" .PP .\" Heavily redundant data causes trouble with DES encryption, when used in the .\" .I codebook .\" mode that .\" .BR crypt () .\" implements. The .\" .BR crypt () .\" interface should be used only for its intended purpose of password .\" verification, and should not be used as part of a data encryption tool. .\" .PP .\" The first and last three output bits of the fourth S-box can be .\" represented as function of their input bits. Empiric studies have .\" shown that S-boxes partially compute the same output for similar input. .\" It is suspected that this may contain a back door which could allow the .\" NSA to decrypt DES encrypted data. .\" .PP .\" Making encrypted data computed using crypt() publicly available has .\" to be considered insecure for the given reasons. \fBcrypt\fP() 関数が実装されていない。多分アメリカの輸出規制のために。 .TP \fBEPERM\fP \fI/proc/sys/crypto/fips_enabled\fP が 0 でない値で、 DES などの弱い暗号タイプを利用しようとした。 .SH 属性 .SS "マルチスレッディング (pthreads(7) 参照)" \fBcrypt\fP() 関数はスレッドセーフではない。 .LP \fBcrypt_r\fP() 関数はスレッドセーフである。 .SH 準拠 \fBcrypt\fP(): SVr4, 4.3BSD, POSIX.1\-2001. \fBcrypt_r\fP() は GNU 拡張である。 .SH 注意 .SS "glibc での注意" この関数の glibc2 版は追加の暗号化アルゴリズムに対応している。 もし \fIsalt\fP の文字列が "$\fIid\fP$" で始まっていて、"$" で終わっている文字列が 続いている場合: .RS $\fIid\fP$\fIsalt\fP$\fIencrypted\fP .RE DES を使う代わりに、 \fIid\fP で使用する暗号化手法を識別し、これがパスワード文字列の残りの部分を解釈する 方法を決定する。 \fIid\fP の値として、以下の値に対応している: .RS .TS l l. ID | Method _ 1 | MD5 2a | Blowfish (本流の glibc には入っていない; | いくつかの Linux ディストリビューションで追加されている) .\" openSUSE has Blowfish, but AFAICS, this option is not supported .\" natively by glibc -- mtk, Jul 08 .\" .\" md5 | Sun MD5 .\" glibc doesn't appear to natively support Sun MD5; I don't know .\" if any distros add the support. 5 | SHA\-256 (glibc 2.7 以降) 6 | SHA\-512 (glibc 2.7 以降) .TE .RE 従って、$5$\fIsalt\fP$\fIencrypted\fP は SHA\-256 でエンコードされた パスワードであり、$6$\fIsalt\fP$\fIencrypted\fP は SHA\-512 で エンコードされたパスワードである。 "\fIsalt\fP" は salt における "$\fIid\fP$" に引き続く 16 文字以下の 文字列である。 パスワード文字列の暗号化部分は実際に計算されたパスワードである。 この文字列のサイズは固定である: .TS l l. MD5 | 22 characters SHA\-256 | 43 characters SHA\-512 | 86 characters .TE "\fIsalt\fP" と "\fIencrypted\fP" の文字は [\fBa\-zA\-Z0\-9./\fP] の集合から 選ばれる。 MD5 と SHA の実装では、 \fIkey\fP 全体が意味がある (DES の場合には最初の 8 文字だけに意味がある)。 .SH 関連項目 \fBlogin\fP(1), \fBpasswd\fP(1), \fBencrypt\fP(3), \fBgetpass\fP(3), \fBpasswd\fP(5) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.79 の一部 である。プロジェクトの説明とバグ報告に関する情報は http://www.kernel.org/doc/man\-pages/ に書かれている。