File: mhash.xml

package info (click to toggle)
phpdoc 20020310-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 35,272 kB
  • ctags: 354
  • sloc: xml: 799,767; php: 1,395; cpp: 500; makefile: 200; sh: 140; awk: 51
file content (309 lines) | stat: -rw-r--r-- 10,417 bytes parent folder | download
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision: 1.12 $ -->
 <reference id="ref.mhash">
  <title>Mhash関数</title>
  <titleabbrev>mhash</titleabbrev>
  
  <partintro>
   <para>
    これらの関数は、<ulink url="&url.mhash;">mhash</ulink>と組み合わせ
    て動作することを前提としています。
   </para>
   <para>
    この関数は、mhashライブラリへのインターフェースです。
    mhashは、MD5,SHAl,GOSTや他の多くの方法といった広範なハッシュ
    アルゴリズムをサポートします。
   </para>
   <para>
    これを使用するには、mhashの配布ファイルを
    <ulink url="&url.mhash;">mhashのWebサイト</ulink>から
    ダウンロードし、その中のインストール用の指示に従って下さい。
    この拡張機能を使用するには、PHPに
    <option role="configure">--with-mhash</option>パラメータを付けて
    コンパイルする必要があります。
   </para>
   <para>
    mhash は、チェックサム, メッセージダイジェスト、メッセージ認証コー
    ド等を作成するために使用可能です。
   </para>
   <para>
    <example>
     <title>MD5ダイジェストとhmacを計算し、16進数で出力する</title>
     <programlisting role="php">
<![CDATA[
<?php
$input = "what do ya want for nothing?";
$hash = mhash (MHASH_MD5, $input);
print "The hash is ".bin2hex ($hash)."<br />\n";
$hash = mhash (MHASH_MD5, $input, "Jefe");
print "The hmac is ".bin2hex ($hash)."<br />\n";
?>
]]>
     </programlisting>
     <para>
      この例の出力は次のようになります。
      <screen>
<![CDATA[
The hash is d03cb659cbf9192dcd066272249f8412 
The hmac is 750c783e6ab0b503eaa86e310a5db738 
]]>
      </screen>
     </para>
    </example>
    サポートされるハッシュの完全なリストについては、mhashのドキュメ
    ントを参照下さい。PHPから特定のハッシュアルゴリズムにアクセスす
    るには、「MHASH_ハッシュ名」を指定します。例えば、TIGERにアクセ
    スするには、PHP定数 MHASH_TIGERを使用します。
   </para>
   <para>
    以下に現在mhashによりサポートされているハッシュの一覧を示します。
    mhashにサポートされているハッシュが、このリストにない場合は、こ
    のドキュメントが古いと仮定して下さい。
    <itemizedlist>
     <listitem>
      <simpara>
       MHASH_MD5
      </simpara>
     </listitem>
     <listitem>
      <simpara>
       MHASH_SHA1
      </simpara>
     </listitem>
     <listitem>
      <simpara>
       MHASH_HAVAL256
      </simpara>
     </listitem>
     <listitem>
      <simpara>
       MHASH_HAVAL192
      </simpara>
     </listitem>
     <listitem>
      <simpara>
       MHASH_HAVAL160
      </simpara>
     </listitem>
     <listitem>
      <simpara>
       MHASH_HAVAL128
      </simpara>
     </listitem>
     <listitem>
      <simpara>
       MHASH_RIPEMD160
      </simpara>
     </listitem>
     <listitem>
      <simpara>
       MHASH_GOST
      </simpara>
     </listitem>
     <listitem>
      <simpara>
       MHASH_TIGER
      </simpara>
     </listitem>
     <listitem>
      <simpara>
       MHASH_CRC32
      </simpara>
     </listitem>
     <listitem>
      <simpara>
       MHASH_CRC32B
      </simpara>
     </listitem>
    </itemizedlist>
   </para>
  </partintro>
  
  <refentry id="function.mhash-get-hash-name">
   <refnamediv>
    <refname>mhash_get_hash_name</refname>
    <refpurpose>指定したハッシュの名前を得る</refpurpose>
   </refnamediv>
   <refsect1>
    <title>説明</title>
     <methodsynopsis>
      <type>string</type><methodname>mhash_get_hash_name</methodname>
      <methodparam><type>int</type><parameter>hash</parameter></methodparam>
     </methodsynopsis>
    <para>
     <function>mhash_get_hash_name</function>は指定した(hash)の
     名前を得るために使用されます。
    </para>
    <para>
     <function>mhash_get_hash_name</function>は引数としてハッシュIDをとり、
     ハッシュの名前を返します。そのハッシュが存在しない場合は、&false;を
     返します。
    </para>
    <para>
     <example>
      <title><function>mhash_get_hash_name</function>の例</title>
      <programlisting>
<![CDATA[
<?php
$hash = MHASH_MD5;

print mhash_get_hash_name ($hash);
?>
]]>
      </programlisting>
      <para>
       上の例の出力は次のようになります。
       <screen>
<![CDATA[
      MD5
]]>
       </screen>
      </para>
     </example>
    </para>
   </refsect1>
  </refentry>
  
  <refentry id="function.mhash-get-block-size">
   <refnamediv>
    <refname>mhash_get_block_size</refname>
    <refpurpose>指定したハッシュのブロックサイズを得る</refpurpose>
   </refnamediv>
   <refsect1>
    <title>説明</title>
     <methodsynopsis>
      <type>int</type><methodname>mhash_get_block_size</methodname>
      <methodparam><type>int</type><parameter>hash</parameter></methodparam>
     </methodsynopsis>
    <para>
     <function>mhash_get_block_size</function>は、
     指定した<parameter>hash</parameter>のブロックサイズを得るために
     使用します。
    </para>
    <para>
     <function>mhash_get_block_size</function>は、引数 
     <parameter>hash</parameter>をとり、サイズをバイト数で返します。
     <parameter>hash</parameter>が存在しない場合には、&false;を返します。
    </para>
   </refsect1>
  </refentry>
  
  <refentry id="function.mhash-count">
   <refnamediv>
    <refname>mhash_count</refname>
    <refpurpose>利用可能なハッシュIDの最大値を得る</refpurpose>
   </refnamediv>
   <refsect1>
    <title>説明</title>
     <methodsynopsis>
      <type>int</type><methodname>mhash_count</methodname>
      <void/>
     </methodsynopsis>
    <para>
     <function>mhash_count</function> は、利用可能なハッシュIDの最大値を
     返します。ハッシュは、0からこのハッシュIDまでの数字となります。
    </para>
    <para>
     <example>
      <title>全ハッシュをループする</title>
      <programlisting role="php">
<![CDATA[
<?php

$nr = mhash_count();

for ($i = 0; $i <= $nr; $i++) {
    echo sprintf ("The blocksize of %s is %d\n", 
        mhash_get_hash_name ($i),
        mhash_get_block_size ($i));
}
?>
]]>
      </programlisting>
     </example>
    </para>
   </refsect1>
  </refentry>
    
  <refentry id="function.mhash">
   <refnamediv>
    <refname>mhash</refname>
    <refpurpose>ハッシュ値を計算する</refpurpose>
   </refnamediv>
   <refsect1>
    <title>説明</title>
     <methodsynopsis>
      <type>string</type><methodname>mhash</methodname>
      <methodparam><type>int</type><parameter>hash</parameter></methodparam>
      <methodparam><type>string</type><parameter>data</parameter></methodparam>
      <methodparam><type>string</type><parameter>
	<replaceable><optional>key</optional></replaceable>
       </parameter></methodparam>
     </methodsynopsis>
    <para>
     <function>mhash</function>は、<parameter>data</parameter>に
     <parameter>hash</parameter>で指定したハッシュ関数を適用し、
     (ダイジェストとも呼ばれる)ハッシュを返します。
     <parameter>key</parameter> が指定されていた場合、結果としてHMAC
     が返されます。HMACは、メッセージ認証時はキーに基づくハッシュ、また
     は指定したキーに基づく単なるメッセージダイジェストです。mhashでサ
     ポートされている全てのアルゴリズムがHMACモードで使用できるわけで
     はありません。エラーの場合はエラーが返されます。
    </para>
   </refsect1>
  </refentry>

  <refentry id="function.mhash-keygen-s2k">
   <refnamediv>
    <refname>mhash_keygen_s2k</refname>
    <refpurpose>キーを生成する</refpurpose>
   </refnamediv>
   <refsect1>
    <title>説明</title>
     <methodsynopsis>
      <type>string</type><methodname>mhash_keygen_s2k</methodname>
      <methodparam><type>int</type><parameter>hash</parameter></methodparam>
      <methodparam><type>string</type><parameter>password</parameter></methodparam>
      <methodparam><type>string</type><parameter>salt</parameter></methodparam>
      <methodparam><type>int</type><parameter>bytes</parameter></methodparam>
     </methodsynopsis>
    <para>
     <function>mhash_keygen_s2k</function> は、指定したパスワードから
     長さが <parameter>bytes</parameter> のキーを生成します。これは、
     OpenPGP のドキュメント (RFC 2440) で規定された Salted S2K アルゴ
     リズムによります。このアルゴリズムは、キーを生成する際に指定した
     <parameter>hash</parameter> アルゴリズムを使用します。異なったキー
     を生成するためにキーを生成する度毎に <parameter>salt</parameter>
     は毎回異なり十分にランダムである必要があります。 キーを調べる際に
     salt を知っている必要があるため、キーを salt に付加するというのは
     良い発想です。salt は8バイト固定長で、これより少ない場合はゼロで
     埋められます。ユーザが指定したパスワードが暗号化アルゴリズムのキー
     として実際には使用できないことに注意して下さい。これは、ユーザは
     通常キーボードから入力可能なキーを選択するからです。これらのパス
     ワードは文字当たり6から7ビットのみ(もしくはそれ以下)を使用してい
     ます。このようなパスワードは、ユーザの指定したキーに(この関数のよ
     うな)ある種の変換を行うことが強く推奨されます。
    </para>
   </refsect1>
  </refentry>

 </reference> 

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
-->