.\" 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 2018\-04\-30 "" "Linux Programmer's Manual" .SH 名前 crypt, crypt_r \- パスワードとデータの暗号化 .SH 書式 .nf \fB#define _XOPEN_SOURCE\fP /* feature_test_macros(7) 参照 */ \fB#include \fP .PP \fBchar *crypt(const char *\fP\fIkey\fP\fB, const char *\fP\fIsalt\fP\fB);\fP \fB#define _GNU_SOURCE\fP /* feature_test_macros(7) 参照 */ \fB#include \fP .PP \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 .PP \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 ライブラリのひとつを 手にいれるべきだ。 .PP \fBcrypt_r\fP() は \fBcrypt\fP() の再入可能版である。 \fIdata\fP で示される構造体は結果データの保存と情報の管理に使われる。 この構造体に対して(メモリーを割り当てること以外に)呼び出し元がするべき唯一の ことは、 \fBcrypt_r\fP() の初回の呼び出しの前に \fIdata\->initialized\fP をゼロにすることだけである。 .SH 返り値 成功の場合には、暗号化されたパスワードへのポインターが返される。 エラーの場合には NULL が返される。 .SH エラー .TP \fBEINVAL\fP \fIsalt\fP が間違ったフォーマットである。 .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 属性 この節で使用されている用語の説明については、 \fBattributes\fP(7) を参照。 .TS allbox; lb lb lb l l l. インターフェース 属性 値 T{ \fBcrypt\fP() T} Thread safety MT\-Unsafe race:crypt T{ \fBcrypt_r\fP() T} Thread safety MT\-Safe .TE .SH 準拠 \fBcrypt\fP(): POSIX.1\-2001, POSIX.1\-2008, SVr4, 4.3BSD. \fBcrypt_r\fP() は GNU 拡張である。 .SH 注意 .SS "Availability in glibc" The \fBcrypt\fP(), \fBencrypt\fP(3), and \fBsetkey\fP(3) functions are part of the POSIX.1\-2008 XSI Options Group for Encryption and are optional. If the interfaces are not available, then the symbolic constant \fB_XOPEN_CRYPT\fP is either not defined, or it is defined to \-1 and availability can be checked at run time with \fBsysconf\fP(3). This may be the case if the downstream distribution has switched from glibc crypt to \fIlibxcrypt\fP. When recompiling applications in such distributions, the programmer must detect if \fB_XOPEN_CRYPT\fP is not available and include \fI\fP for the function prototypes; otherwise \fIlibxcrypt\fP is an ABI\-compatible drop\-in replacement. .SS "Features in glibc" この関数の glibc 版は追加の暗号化アルゴリズムに対応している。 .PP If \fIsalt\fP is a character string starting with the characters "$\fIid\fP$" followed by a string optionally terminated by "$", then the result has the form: .RS .PP $\fIid\fP$\fIsalt\fP$\fIencrypted\fP .RE .PP 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 .PP Thus, $5$\fIsalt\fP$\fIencrypted\fP and $6$\fIsalt\fP$\fIencrypted\fP contain the password encrypted with, respectively, functions based on SHA\-256 and SHA\-512. .PP "\fIsalt\fP" stands for the up to 16 characters following "$\fIid\fP$" in the salt. The "\fIencrypted\fP" part of the password string is the actual computed password. The size of this string is fixed: .TS l l. MD5 | 22 characters SHA\-256 | 43 characters SHA\-512 | 86 characters .TE .sp 1 "\fIsalt\fP" と "\fIencrypted\fP" の文字は [\fBa\-zA\-Z0\-9./\fP] の集合から 選ばれる。 MD5 と SHA の実装では、 \fIkey\fP 全体が意味がある (DES の場合には最初の 8 文字だけに意味がある)。 .PP .\" glibc commit 9425cb9eea6a62fc21d99aafe8a60f752b934b05 Since glibc 2.7, the SHA\-256 and SHA\-512 implementations support a user\-supplied number of hashing rounds, defaulting to 5000. If the "$\fIid\fP$" characters in the salt are followed by "rounds=\fIxxx\fP$", where \fIxxx\fP is an integer, then the result has the form .RS .PP $\fIid\fP$\fIrounds=yyy\fP$\fIsalt\fP$\fIencrypted\fP .RE .PP where \fIyyy\fP is the number of hashing rounds actually used. The number of rounds actually used is 1000 if \fIxxx\fP is less than 1000, 999999999 if \fIxxx\fP is greater than 999999999, and is equal to \fIxxx\fP otherwise. .SH 関連項目 \fBlogin\fP(1), \fBpasswd\fP(1), \fBencrypt\fP(3), \fBgetpass\fP(3), \fBpasswd\fP(5) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は \%https://www.kernel.org/doc/man\-pages/ に書かれている。