OSDN Git Service

Convert release and draft pages to UTF-8.
[linuxjm/jm.git] / manual / LDP_man-pages / draft / man3 / encrypt.3
1 .\" Copyright 2000 Nicolas Lichtmaier <nick@debian.org>
2 .\" Created 2000-07-22 00:52-0300
3 .\"
4 .\" This is free documentation; you can redistribute it and/or
5 .\" modify it under the terms of the GNU General Public License as
6 .\" published by the Free Software Foundation; either version 2 of
7 .\" the License, or (at your option) any later version.
8 .\"
9 .\" The GNU General Public License's references to "object code"
10 .\" and "executables" are to be interpreted as the output of any
11 .\" document formatting or typesetting system, including
12 .\" intermediate and printed output.
13 .\"
14 .\" This manual is distributed in the hope that it will be useful,
15 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
16 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 .\" GNU General Public License for more details.
18 .\"
19 .\" Modified 2002-07-23 19:21:35 CEST 2002 Walter Harms
20 .\" <walter.harms@informatik.uni-oldenburg.de>
21 .\"
22 .\" Modified 2003-04-04, aeb
23 .\"
24 .\" Japanese Version Copyright (c) 2000-2004 Yuichi SATO
25 .\"         all rights reserved.
26 .\" Translated Sun Sep 24 06:18:14 JST 2000
27 .\"         by Yuichi SATO <sato@complex.eng.hokudai.ac.jp>
28 .\" Updated & Modified Sun Sep  7 13:20:43 JST 2003
29 .\"         by Yuichi SATO <ysato444@yahoo.co.jp>
30 .\" Updated & Modified Sat Jan 17 01:27:31 JST 2004 by Yuichi SATO
31 .\"
32 .\"WORD:        encrypt         暗号化
33 .\"WORD:        decrypt         復号化
34 .\"
35 .TH ENCRYPT 3 2003-04-04 "" "Linux Programmer's Manual"
36 .\"O .SH NAME
37 .SH 名前
38 .\"O encrypt, setkey, encrypt_r, setkey_r \- encrypt 64-bit messages
39 encrypt, setkey, encrypt_r, setkey_r \- 64 ビットのメッセージを暗号化する
40 .\"O .SH SYNOPSIS
41 .SH 書式
42 .\"O .BR "#define _XOPEN_SOURCE" "       /* See feature_test_macros(7) */"
43 .BR "#define _XOPEN_SOURCE" "       /* feature_test_macros(7) 参照 */"
44 .br
45 .B #include <unistd.h>
46 .sp
47 .BI "void encrypt(char " block "[64], int " edflag );
48 .sp
49 .\"O .BR "#define _XOPEN_SOURCE" "       /* See feature_test_macros(7) */"
50 .BR "#define _XOPEN_SOURCE" "       /* feature_test_macros(7) 参照 */"
51 .br
52 .B #include <stdlib.h>
53 .sp
54 .BI "void setkey(const char *" key );
55 .sp
56 .\"O .BR "#define _GNU_SOURCE" "         /* See feature_test_macros(7) */"
57 .BR "#define _GNU_SOURCE" "         /* feature_test_macros(7) 参照 */"
58 .br
59 .B #include <crypt.h>
60 .sp
61 .BI "void setkey_r(const char *" key ", struct crypt_data *" data );
62 .br
63 .BI "void encrypt_r(char *" block ", int " edflag \
64 ", struct crypt_data *" data );
65 .sp
66 .\"O Each of these requires linking with \fI\-lcrypt\fP.
67 これらの関数は \fI\-lcrypt\fP でリンクする必要がある。
68 .\"O .SH DESCRIPTION
69 .SH 説明
70 .\"O These functions encrypt and decrypt 64-bit messages.
71 .\"O The
72 .\"O .BR setkey ()
73 .\"O function sets the key used by
74 .\"O .BR encrypt ().
75 これらの関数は、64 ビットのメッセージの暗号化と復号化を行う。
76 .BR setkey ()
77 関数は
78 .BR encrypt ()
79 によって使われる暗号鍵を設定する。
80 .\"O The
81 .\"O .I key
82 .\"O argument used here is an array of 64 bytes, each of which has
83 .\"O numerical value 1 or 0.
84 .\"O The bytes key[n] where n=8*i-1 are ignored,
85 .\"O so that the effective key length is 56 bits.
86 ここで使われる引き数
87 .I key
88 は 64 バイトの配列であり、各バイトは数値 1 または 0 である。
89 n=8*i-1 に対するバイト key[n] は無視されるので、
90 有効な暗号鍵の長さは 56 ビットになる。
91 .PP
92 .\"O The
93 .\"O .BR encrypt ()
94 .\"O function modifies the passed buffer, encoding if
95 .\"O .I edflag
96 .\"O is 0, and decoding if 1 is being passed.
97 .\"O Like the
98 .\"O .I key
99 .\"O argument, also
100 .\"O .I block
101 .\"O is a bit vector representation of the actual value that is encoded.
102 .\"O The result is returned in that same vector.
103 .BR encrypt ()
104 関数は、
105 .I edflag
106 が 0 の場合は暗号化し、1 が渡された場合は復号化するというように、
107 渡されたバッファを変更する。
108 引き数
109 .I key
110 と同様に、
111 .I block
112 はエンコードされた実際の値を表現するビットの配列である。
113 結果はこの同じ配列を使って返される。
114 .PP
115 .\"O These two functions are not reentrant, that is, the key data is
116 .\"O kept in static storage.
117 .\"O The functions
118 .\"O .BR setkey_r ()
119 .\"O and
120 .\"O .BR encrypt_r ()
121 .\"O are the reentrant versions.
122 .\"O They use the following
123 .\"O structure to hold the key data:
124 これら 2 つの関数はリエントラント (reentrant) ではない。
125 つまり暗号鍵データは静的な領域に保存される。
126 関数
127 .BR setkey_r ()
128
129 .BR encrypt_r ()
130 はリエントラントなバージョンである。
131 これらの関数は暗号鍵データを保持するために以下のような構造体を使う。
132 .in +4n
133 .nf
134
135 struct crypt_data {
136     char     keysched[16 * 8];
137     char     sb0[32768];
138     char     sb1[32768];
139     char     sb2[32768];
140     char     sb3[32768];
141     char     crypt_3_buf[14];
142     char     current_salt[2];
143     long int current_saltbits;
144     int      direction;
145     int      initialized;
146 };
147 .fi
148 .in
149 .PP
150 .\"O Before calling
151 .\"O .BR setkey_r ()
152 .\"O set
153 .\"O .I data\->initialized
154 .\"O to zero.
155 .BR setkey_r ()
156 を呼び出す前には、
157 .I data\->initialized
158 を 0 に設定すること。
159 .\"O .SH "RETURN VALUES"
160 .SH 返り値
161 .\"O These functions do not return any value.
162 これらの関数は、なにも値を返さない。
163 .\"O .SH ERRORS
164 .SH エラー
165 .\"O Set
166 .\"O .I errno
167 .\"O to zero before calling the above functions.
168 上記の関数を呼び出す前に
169 .I errno
170 を 0 に設定すること。
171 .\"O On success, it is unchanged.
172 成功した場合、この値は変更されない。
173 .TP
174 .B ENOSYS
175 .\"O The function is not provided.
176 .\"O (For example because of former USA export restrictions.)
177 (例えば以前のアメリカ合衆国輸出規制などにより)
178 この関数が提供されていない。
179 .\"O .SH "CONFORMING TO"
180 .SH 準拠
181 .\"O The functions
182 .\"O .BR encrypt ()
183 .\"O and
184 .\"O .BR setkey ()
185 .\"O conform to SVr4, SUSv2, and POSIX.1-2001.
186 関数
187 .BR encrypt ()
188
189 .BR setkey ()
190 は SVr4, SUSv2, and POSIX.1-2001 に準拠する。
191 .\"O The functions
192 .\"O .BR encrypt_r ()
193 .\"O and
194 .\"O .BR setkey_r ()
195 .\"O are GNU extensions.
196 関数
197 .BR encrypt_r ()
198
199 .BR setkey_r ()
200 は GNU 拡張である。
201 .\"O .SH NOTES
202 .SH 注意
203 .\"O In glibc 2.2 these functions use the DES algorithm.
204 glibc 2.2 では、これらの関数は DES アルゴリズムを使う。
205 .\"O .SH EXAMPLE
206 .SH 例
207 .\"O You need to link with libcrypt to compile this example with glibc.
208 .\"O To do useful work the
209 .\"O .I key[]
210 .\"O and
211 .\"O .I txt[]
212 .\"O arrays must be filled with a useful bit pattern.
213 この例を glibc でコンパイルするには libcrypt とリンクする必要がある。
214 実際に動作させるためには、配列
215 .I key[]
216
217 .I txt[]
218 に有効なビットパターンを指定しなければならない。
219 .sp
220 .nf
221 #define _XOPEN_SOURCE
222 #include <unistd.h>
223 #include <stdlib.h>
224
225 int
226 main(void)
227 {
228     char key[64];      /* bit pattern for key */
229     char txt[64];      /* bit pattern for messages */
230
231     setkey(key);
232     encrypt(txt, 0);   /* encode */
233     encrypt(txt, 1);   /* decode */
234 }
235 .fi
236 .\"O .SH "SEE ALSO"
237 .SH 関連項目
238 .BR cbc_crypt (3),
239 .BR crypt (3),
240 .BR ecb_crypt (3)
241 .\" .BR fcrypt (3)