OSDN Git Service

80d11bdbffafc11eb156c550dd581be6e782a55d
[linuxjm/LDP_man-pages.git] / release / man3 / encrypt.3
1 .\" Copyright 2000 Nicolás Lichtmaier <nick@debian.org>
2 .\" Created 2000-07-22 00:52-0300
3 .\"
4 .\" %%%LICENSE_START(GPLv2+_DOC_FULL)
5 .\" This is free documentation; you can redistribute it and/or
6 .\" modify it under the terms of the GNU General Public License as
7 .\" published by the Free Software Foundation; either version 2 of
8 .\" the License, or (at your option) any later version.
9 .\"
10 .\" The GNU General Public License's references to "object code"
11 .\" and "executables" are to be interpreted as the output of any
12 .\" document formatting or typesetting system, including
13 .\" intermediate and printed output.
14 .\"
15 .\" This manual is distributed in the hope that it will be useful,
16 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
17 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 .\" GNU General Public License for more details.
19 .\"
20 .\" You should have received a copy of the GNU General Public
21 .\" License along with this manual; if not, see
22 .\" <http://www.gnu.org/licenses/>.
23 .\" %%%LICENSE_END
24 .\"
25 .\" Modified 2002-07-23 19:21:35 CEST 2002 Walter Harms
26 .\" <walter.harms@informatik.uni-oldenburg.de>
27 .\"
28 .\" Modified 2003-04-04, aeb
29 .\"
30 .\"*******************************************************************
31 .\"
32 .\" This file was generated with po4a. Translate the source file.
33 .\"
34 .\"*******************************************************************
35 .TH ENCRYPT 3 2013\-07\-22 "" "Linux Programmer's Manual"
36 .SH 名前
37 encrypt, setkey, encrypt_r, setkey_r \- 64 ビットのメッセージを暗号化する
38 .SH 書式
39 \fB#define _XOPEN_SOURCE\fP /* feature_test_macros(7) 参照 */
40 .br
41 \fB#include <unistd.h>\fP
42 .sp
43 \fBvoid encrypt(char \fP\fIblock\fP\fB[64], int \fP\fIedflag\fP\fB);\fP
44 .sp
45 \fB#define _XOPEN_SOURCE\fP /* feature_test_macros(7) 参照 */
46 .br
47 \fB#include <stdlib.h>\fP
48 .sp
49 \fBvoid setkey(const char *\fP\fIkey\fP\fB);\fP
50 .sp
51 \fB#define _GNU_SOURCE\fP /* feature_test_macros(7) 参照 */
52 .br
53 \fB#include <crypt.h>\fP
54 .sp
55 \fBvoid setkey_r(const char *\fP\fIkey\fP\fB, struct crypt_data *\fP\fIdata\fP\fB);\fP
56 .br
57 \fBvoid encrypt_r(char *\fP\fIblock\fP\fB, int \fP\fIedflag\fP\fB, struct crypt_data
58 *\fP\fIdata\fP\fB);\fP
59 .sp
60 これらの関数は \fI\-lcrypt\fP でリンクする必要がある。
61 .SH 説明
62 これらの関数は、64 ビットのメッセージの暗号化と復号化を行う。 \fBsetkey\fP()  関数は \fBencrypt\fP()
63 によって使われる暗号鍵を設定する。 ここで使われる引き数 \fIkey\fP は 64 バイトの配列であり、各バイトは数値 1 または 0 である。
64 n=8*i\-1 に対するバイト key[n] は無視されるので、 有効な暗号鍵の長さは 56 ビットになる。
65 .PP
66 \fBencrypt\fP()  関数は、 \fIedflag\fP が 0 の場合は暗号化し、1 が渡された場合は復号化するというように、
67 渡されたバッファを変更する。 引き数 \fIkey\fP と同様に、 \fIblock\fP はエンコードされた実際の値を表現するビットの配列である。
68 結果はこの同じ配列を使って返される。
69 .PP
70 これら 2 つの関数はリエントラント (reentrant) ではない。 つまり暗号鍵データは静的な領域に保存される。 関数 \fBsetkey_r\fP()
71 と \fBencrypt_r\fP()  はリエントラントなバージョンである。 これらの関数は暗号鍵データを保持するために以下のような構造体を使う。
72 .in +4n
73 .nf
74
75 struct crypt_data {
76     char     keysched[16 * 8];
77     char     sb0[32768];
78     char     sb1[32768];
79     char     sb2[32768];
80     char     sb3[32768];
81     char     crypt_3_buf[14];
82     char     current_salt[2];
83     long int current_saltbits;
84     int      direction;
85     int      initialized;
86 };
87 .fi
88 .in
89 .PP
90 \fBsetkey_r\fP()  を呼び出す前には、 \fIdata\->initialized\fP を 0 に設定すること。
91 .SH 返り値
92 これらの関数は、なにも値を返さない。
93 .SH エラー
94 上記の関数を呼び出す前に \fIerrno\fP を 0 に設定すること。 成功した場合、この値は変更されない。
95 .TP 
96 \fBENOSYS\fP
97 (例えば以前のアメリカ合衆国輸出規制などにより)  この関数が提供されていない。
98 .SH 属性
99 .SS "マルチスレッディング (pthreads(7) 参照)"
100 The \fBencrypt\fP()  and \fBsetkey\fP()  functions are not thread\-safe.
101 .LP
102 The \fBencrypt_r\fP()  and \fBsetkey_r\fP()  functions are thread\-safe.
103 .SH 準拠
104 関数 \fBencrypt\fP()  と \fBsetkey\fP()  は SVr4, SUSv2, and POSIX.1\-2001 に準拠する。 関数
105 \fBencrypt_r\fP()  と \fBsetkey_r\fP()  は GNU 拡張である。
106 .SH 注意
107 glibc 2.2 では、これらの関数は DES アルゴリズムを使う。
108 .SH 例
109 この例を glibc でコンパイルするには libcrypt とリンクする必要がある。 実際に動作させるためには、配列 \fIkey[]\fP と
110 \fItxt[]\fP に有効なビットパターンを指定しなければならない。
111 .sp
112 .nf
113 #define _XOPEN_SOURCE
114 #include <unistd.h>
115 #include <stdlib.h>
116
117 int
118 main(void)
119 {
120     char key[64];      /* bit pattern for key */
121     char txt[64];      /* bit pattern for messages */
122
123     setkey(key);
124     encrypt(txt, 0);   /* encode */
125     encrypt(txt, 1);   /* decode */
126 }
127 .fi
128 .SH 関連項目
129 .\" .BR fcrypt (3)
130 \fBcbc_crypt\fP(3), \fBcrypt\fP(3), \fBecb_crypt\fP(3)
131 .SH この文書について
132 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.53 の一部
133 である。プロジェクトの説明とバグ報告に関する情報は
134 http://www.kernel.org/doc/man\-pages/ に書かれている。