メインページ | アルファベット順一覧 | 構成 | ファイル一覧 | 構成メンバ | ファイルメンバ | 関連ページ

md5.h

http://sourceforge.net/projects/libmd5-rfc/ [詳細]

このグラフは、どのファイルから直接、間接的にインクルードされているかを示しています。

Included by dependency graph

ソースコードを見る。

構成

struct  md5_state_s

型定義

typedef unsigned char md5_byte_t
typedef unsigned int md5_word_t
typedef md5_state_s md5_state_t

関数

void md5_init (md5_state_t *pms)
void md5_append (md5_state_t *pms, const md5_byte_t *data, int nbytes)
void md5_finish (md5_state_t *pms, md5_byte_t digest[16])
void md5_finalize (md5_state_t *pms)
void md5_get_digest (md5_state_t *pms, md5_byte_t digest[16])
void md5_get_str_digest (md5_state_t *pms, char digest[32+1])


説明

http://sourceforge.net/projects/libmd5-rfc/

Copyright (C) 1999, 2002 Aladdin Enterprises. All rights reserved.

This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.

Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:

1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution.

L. Peter Deutsch ghost@aladdin.com

Id
md5.h,v 1.1 2004/07/11 09:46:28 studiokingyonet Exp

Independent implementation of MD5 (RFC 1321).

This code implements the MD5 Algorithm defined in RFC 1321, whose text is available at http://www.ietf.org/rfc/rfc1321.txt The code is derived from the text of the RFC, including the test suite (section A.5) but excluding the rest of Appendix A. It does not include any code or documentation that is identified in the RFC as being copyrighted.

The original and principal author of md5.h is L. Peter Deutsch <ghost@aladdin.com>. Other authors are noted in the change history that follows (in reverse chronological order):

2002-04-13 lpd Removed support for non-ANSI compilers; removed references to Ghostscript; clarified derivation from RFC 1321; now handles byte order either statically or dynamically. 1999-11-04 lpd Edited comments slightly for automatic TOC extraction. 1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5); added conditionalization for C++ compilation from Martin Purschke <purschke@bnl.gov>. 1999-05-03 lpd Original version.

This package supports both compile-time and run-time determination of CPU byte order. If ARCH_IS_BIG_ENDIAN is defined as 0, the code will be compiled to run only on little-endian CPUs; if ARCH_IS_BIG_ENDIAN is defined as non-zero, the code will be compiled to run only on big-endian CPUs; if ARCH_IS_BIG_ENDIAN is not defined, the code will be compiled to run on either big- or little-endian CPUs, but will run slightly less efficiently on either one than if ARCH_IS_BIG_ENDIAN is defined.

覚え書き:
reconstruct by d金魚

md5.h で定義されています。


型定義

typedef unsigned char md5_byte_t
 

md5.h68 行で定義されています。

参照元 md5_append(), md5_finalize(), md5_finish(), md5_get_digest(), md5_get_str_digest(), と md5_process().

typedef struct md5_state_s md5_state_t
 

参照元 md5_append(), md5_finalize(), md5_finish(), md5_get_digest(), md5_get_str_digest(), md5_init(), と md5_process().

typedef unsigned int md5_word_t
 

md5.h69 行で定義されています。

参照元 md5_append(), と md5_process().


関数

void md5_append md5_state_t pms,
const md5_byte_t data,
int  nbytes
 

Append a string to the message.

md5.c322 行で定義されています。

参照先 md5_state_s::buf, md5_state_s::count, md5_byte_t, md5_process(), md5_state_t, と md5_word_t.

参照元 dkcMD5LoadStandard(), と md5_finalize().

00323 {
00324   const md5_byte_t *p = data;
00325   int left = nbytes;
00326   int offset = (pms->count[0] >> 3) & 63;
00327   md5_word_t nbits = (md5_word_t)(nbytes << 3);
00328 
00329   if (nbytes <= 0)
00330         return;
00331   /* Update the message length. */
00332   pms->count[1] += nbytes >> 29;
00333   pms->count[0] += nbits;
00334   if (pms->count[0] < nbits)
00335   pms->count[1]++;
00336   /* Process an initial partial block. */
00337   if (offset) {
00338     int copy = (offset + nbytes > 64 ? 64 - offset : nbytes);
00339     memcpy(pms->buf + offset, p, copy);
00340     if (offset + copy < 64)
00341     return;
00342     p += copy;
00343     left -= copy;
00344     md5_process(pms, pms->buf);
00345   }
00346   /* Process full blocks. */
00347   for (; left >= 64; p += 64, left -= 64)
00348         md5_process(pms, p);
00349   /* Process a final partial block. */
00350   if (left)
00351         memcpy(pms->buf, p, left);
00352 }

void md5_finalize md5_state_t pms  ) 
 

finalize process

md5.c366 行で定義されています。

参照先 md5_state_s::count, md5_append(), md5_byte_t, と md5_state_t.

参照元 dkcMD5Final(), と md5_finish().

00366                                    {
00367     static const md5_byte_t pad[64] = {
00368     0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00369     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00370     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00371     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
00372   };
00373   md5_byte_t data[8];
00374   int i;
00375   /* Save the length before padding. */
00376   for (i = 0; i < 8; ++i){
00377     data[i] = (md5_byte_t)(pms->count[i >> 2] >> ((i & 3) << 3));
00378   }
00379   /* Pad to 56 bytes mod 64. */
00380   md5_append(pms, pad, ((55 - (pms->count[0] >> 3)) & 63) + 1);
00381   /* Append the length. */
00382   md5_append(pms, data, 8);
00383 }

void md5_finish md5_state_t pms,
md5_byte_t  digest[16]
 

Finish the message and return the digest. ( md5_finalize() + md5_get_digest() )

md5.c356 行で定義されています。

参照先 md5_byte_t, md5_finalize(), md5_get_digest(), と md5_state_t.

00357 {
00358   md5_finalize(pms);
00359     md5_get_digest(pms,digest);
00360 }

void md5_get_digest md5_state_t pms,
md5_byte_t  digest[16]
 

get digest binary value

md5.c385 行で定義されています。

参照先 md5_state_s::abcd, md5_byte_t, と md5_state_t.

参照元 dkcMD5Digest(), md5_finish(), と md5_get_str_digest().

00385                                                            {
00386     int i;
00387     for (i = 0; i < 16; ++i){
00388     digest[i] = (md5_byte_t)(pms->abcd[i >> 2] >> ((i & 3) << 3));
00389   }
00390 }

void md5_get_str_digest md5_state_t pms,
char  digest[32+1]
 

get digest strings

md5.c392 行で定義されています。

参照先 md5_byte_t, md5_get_digest(), と md5_state_t.

参照元 dkcMD5DigestStr().

00392                                                              {
00393     md5_byte_t temp[16];
00394     int i;
00395 
00396     md5_get_digest(pms,temp);
00397     
00398 
00399     for (i=0; i<16; i++){
00400     //wsprintf(digest+i*2, "%02x", temp[i]);
00401         sprintf(digest+i*2,"%02x", temp[i]);
00402     }
00403   digest[32]='\0';
00404 }

void md5_init md5_state_t pms  ) 
 

Initialize the algorithm.

md5.c313 行で定義されています。

参照先 md5_state_s::abcd, md5_state_s::count, md5_state_t, と T_MASK.

参照元 dkcMD5Init().

00314 {
00315   pms->count[0] = pms->count[1] = 0;
00316   pms->abcd[0] = 0x67452301;
00317   pms->abcd[1] = /*0xefcdab89*/ T_MASK ^ 0x10325476;
00318   pms->abcd[2] = /*0x98badcfe*/ T_MASK ^ 0x67452301;
00319   pms->abcd[3] = 0x10325476;
00320 }


dkutil_cに対してTue Dec 7 01:10:50 2004に生成されました。 doxygen 1.3.6