1 .\" Copyright 2000 Nicolás Lichtmaier <nick@debian.org>
2 .\" Created 2000-07-22 00:52-0300
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.
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.
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.
19 .\" Modified 2002-07-23 19:21:35 CEST 2002 Walter Harms
20 .\" <walter.harms@informatik.uni-oldenburg.de>
22 .\" Modified 2003-04-04, aeb
24 .\"*******************************************************************
26 .\" This file was generated with po4a. Translate the source file.
28 .\"*******************************************************************
29 .TH ENCRYPT 3 2003\-04\-04 "" "Linux Programmer's Manual"
31 encrypt, setkey, encrypt_r, setkey_r \- 64 ビットのメッセージを暗号化する
33 \fB#define _XOPEN_SOURCE\fP /* feature_test_macros(7) 参照 */
35 \fB#include <unistd.h>\fP
37 \fBvoid encrypt(char \fP\fIblock\fP\fB[64], int \fP\fIedflag\fP\fB);\fP
39 \fB#define _XOPEN_SOURCE\fP /* feature_test_macros(7) 参照 */
41 \fB#include <stdlib.h>\fP
43 \fBvoid setkey(const char *\fP\fIkey\fP\fB);\fP
45 \fB#define _GNU_SOURCE\fP /* feature_test_macros(7) 参照 */
47 \fB#include <crypt.h>\fP
49 \fBvoid setkey_r(const char *\fP\fIkey\fP\fB, struct crypt_data *\fP\fIdata\fP\fB);\fP
51 \fBvoid encrypt_r(char *\fP\fIblock\fP\fB, int \fP\fIedflag\fP\fB, struct crypt_data
52 *\fP\fIdata\fP\fB);\fP
54 これらの関数は \fI\-lcrypt\fP でリンクする必要がある。
56 これらの関数は、64 ビットのメッセージの暗号化と復号化を行う。 \fBsetkey\fP() 関数は \fBencrypt\fP()
57 によって使われる暗号鍵を設定する。 ここで使われる引き数 \fIkey\fP は 64 バイトの配列であり、各バイトは数値 1 または 0 である。
58 n=8*i\-1 に対するバイト key[n] は無視されるので、 有効な暗号鍵の長さは 56 ビットになる。
60 \fBencrypt\fP() 関数は、 \fIedflag\fP が 0 の場合は暗号化し、1 が渡された場合は復号化するというように、
61 渡されたバッファを変更する。 引き数 \fIkey\fP と同様に、 \fIblock\fP はエンコードされた実際の値を表現するビットの配列である。
64 これら 2 つの関数はリエントラント (reentrant) ではない。 つまり暗号鍵データは静的な領域に保存される。 関数 \fBsetkey_r\fP()
65 と \fBencrypt_r\fP() はリエントラントなバージョンである。 これらの関数は暗号鍵データを保持するために以下のような構造体を使う。
70 char keysched[16 * 8];
77 long int current_saltbits;
84 \fBsetkey_r\fP() を呼び出す前には、 \fIdata\->initialized\fP を 0 に設定すること。
88 上記の関数を呼び出す前に \fIerrno\fP を 0 に設定すること。 成功した場合、この値は変更されない。
91 (例えば以前のアメリカ合衆国輸出規制などにより) この関数が提供されていない。
93 関数 \fBencrypt\fP() と \fBsetkey\fP() は SVr4, SUSv2, and POSIX.1\-2001 に準拠する。 関数
94 \fBencrypt_r\fP() と \fBsetkey_r\fP() は GNU 拡張である。
96 glibc 2.2 では、これらの関数は DES アルゴリズムを使う。
98 この例を glibc でコンパイルするには libcrypt とリンクする必要がある。 実際に動作させるためには、配列 \fIkey[]\fP と
99 \fItxt[]\fP に有効なビットパターンを指定しなければならない。
102 #define _XOPEN_SOURCE
109 char key[64]; /* bit pattern for key */
110 char txt[64]; /* bit pattern for messages */
113 encrypt(txt, 0); /* encode */
114 encrypt(txt, 1); /* decode */
118 \fBcbc_crypt\fP(3), \fBcrypt\fP(3), \fBecb_crypt\fP(3)