File: encrypt.3

package info (click to toggle)
manpages-ja 0.5.0.0.20210215%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 28,568 kB
  • sloc: perl: 161; makefile: 58
file content (143 lines) | stat: -rw-r--r-- 5,980 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
.\" Copyright 2000 Nicolás Lichtmaier <nick@debian.org>
.\" Created 2000-07-22 00:52-0300
.\"
.\" %%%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
.\" <http://www.gnu.org/licenses/>.
.\" %%%LICENSE_END
.\"
.\" Modified 2002-07-23 19:21:35 CEST 2002 Walter Harms
.\" <walter.harms@informatik.uni-oldenburg.de>
.\"
.\" Modified 2003-04-04, aeb
.\"
.\"*******************************************************************
.\"
.\" This file was generated with po4a. Translate the source file.
.\"
.\"*******************************************************************
.\"
.\" Japanese Version Copyright (c) 2000-2004 Yuichi SATO
.\"         all rights reserved.
.\" Translated Sun Sep 24 06:18:14 JST 2000
.\"         by Yuichi SATO <sato@complex.eng.hokudai.ac.jp>
.\" Updated & Modified Sun Sep  7 13:20:43 JST 2003
.\"         by Yuichi SATO <ysato444@yahoo.co.jp>
.\" Updated & Modified Sat Jan 17 01:27:31 JST 2004 by Yuichi SATO
.\"
.TH ENCRYPT 3 2013\-07\-22 "" "Linux Programmer's Manual"
.SH 名前
encrypt, setkey, encrypt_r, setkey_r \- 64 ビットのメッセージを暗号化する
.SH 書式
\fB#define _XOPEN_SOURCE\fP /* feature_test_macros(7) 参照 */
.br
\fB#include <unistd.h>\fP
.sp
\fBvoid encrypt(char \fP\fIblock\fP\fB[64], int \fP\fIedflag\fP\fB);\fP
.sp
\fB#define _XOPEN_SOURCE\fP /* feature_test_macros(7) 参照 */
.br
\fB#include <stdlib.h>\fP
.sp
\fBvoid setkey(const char *\fP\fIkey\fP\fB);\fP
.sp
\fB#define _GNU_SOURCE\fP /* feature_test_macros(7) 参照 */
.br
\fB#include <crypt.h>\fP
.sp
\fBvoid setkey_r(const char *\fP\fIkey\fP\fB, struct crypt_data *\fP\fIdata\fP\fB);\fP
.br
\fBvoid encrypt_r(char *\fP\fIblock\fP\fB, int \fP\fIedflag\fP\fB, struct crypt_data
*\fP\fIdata\fP\fB);\fP
.sp
これらの関数は \fI\-lcrypt\fP でリンクする必要がある。
.SH 説明
これらの関数は、64 ビットのメッセージの暗号化と復号化を行う。 \fBsetkey\fP()  関数は \fBencrypt\fP()
によって使われる暗号鍵を設定する。 ここで使われる引き数 \fIkey\fP は 64 バイトの配列であり、各バイトは数値 1 または 0 である。
n=8*i\-1 に対するバイト key[n] は無視されるので、 有効な暗号鍵の長さは 56 ビットになる。
.PP
\fBencrypt\fP()  関数は、 \fIedflag\fP が 0 の場合は暗号化し、1 が渡された場合は復号化するというように、
渡されたバッファーを変更する。 引き数 \fIkey\fP と同様に、 \fIblock\fP はエンコードされた実際の値を表現するビットの配列である。
結果はこの同じ配列を使って返される。
.PP
これら 2 つの関数はリエントラント (reentrant) ではない。 つまり暗号鍵データは静的な領域に保存される。 関数 \fBsetkey_r\fP()
と \fBencrypt_r\fP()  はリエントラントなバージョンである。 これらの関数は暗号鍵データを保持するために以下のような構造体を使う。
.in +4n
.nf

struct crypt_data {
    char     keysched[16 * 8];
    char     sb0[32768];
    char     sb1[32768];
    char     sb2[32768];
    char     sb3[32768];
    char     crypt_3_buf[14];
    char     current_salt[2];
    long int current_saltbits;
    int      direction;
    int      initialized;
};
.fi
.in
.PP
\fBsetkey_r\fP()  を呼び出す前には、 \fIdata\->initialized\fP を 0 に設定すること。
.SH 返り値
これらの関数は、なにも値を返さない。
.SH エラー
上記の関数を呼び出す前に \fIerrno\fP を 0 に設定すること。 成功した場合、この値は変更されない。
.TP 
\fBENOSYS\fP
(例えば以前のアメリカ合衆国輸出規制などにより)  この関数が提供されていない。
.SH 属性
.SS "マルチスレッディング (pthreads(7) 参照)"
関数 \fBencrypt\fP() と \fBsetkey\fP() はスレッドセーフではない。
.LP
関数 \fBencrypt_r\fP() と \fBsetkey_r\fP() はスレッドセーフである。
.SH 準拠
関数 \fBencrypt\fP()  と \fBsetkey\fP()  は SVr4, SUSv2, and POSIX.1\-2001 に準拠する。 関数
\fBencrypt_r\fP()  と \fBsetkey_r\fP()  は GNU 拡張である。
.SH 注意
glibc 2.2 では、これらの関数は DES アルゴリズムを使う。
.SH 例
この例を glibc でコンパイルするには libcrypt とリンクする必要がある。 実際に動作させるためには、配列 \fIkey[]\fP と
\fItxt[]\fP に有効なビットパターンを指定しなければならない。
.sp
.nf
#define _XOPEN_SOURCE
#include <unistd.h>
#include <stdlib.h>

int
main(void)
{
    char key[64];      /* bit pattern for key */
    char txt[64];      /* bit pattern for messages */

    setkey(key);
    encrypt(txt, 0);   /* encode */
    encrypt(txt, 1);   /* decode */
}
.fi
.SH 関連項目
.\" .BR fcrypt (3)
\fBcbc_crypt\fP(3), \fBcrypt\fP(3), \fBecb_crypt\fP(3)
.SH この文書について
この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.79 の一部
である。プロジェクトの説明とバグ報告に関する情報は
http://www.kernel.org/doc/man\-pages/ に書かれている。