コード例 #1
0
ファイル: md2.c プロジェクト: sunfirefox/est
/*
    MD2 final digest
 */
void md2_finish(md2_context *ctx, uchar output[16])
{
    uchar   x;
    int     i;

    x = (uchar)(16 - ctx->left);
    for (i = ctx->left; i < 16; i++) {
        ctx->buffer[i] = x;
    }
    md2_process(ctx);
    memcpy(ctx->buffer, ctx->cksum, 16);
    md2_process(ctx);
    memcpy(output, ctx->state, 16);
}
コード例 #2
0
ファイル: md2.c プロジェクト: Bibamaru/showtime
/*
 * MD2 final digest
 */
void md2_finish( md2_context *ctx, unsigned char output[16] )
{
    size_t i;
    unsigned char x;

    x = (unsigned char)( 16 - ctx->left );

    for( i = ctx->left; i < 16; i++ )
        ctx->buffer[i] = x;

    md2_process( ctx );

    memcpy( ctx->buffer, ctx->cksum, 16 );
    md2_process( ctx );

    memcpy( output, ctx->state, 16 );
}
コード例 #3
0
/*
 * MD2 final digest
 */
EXP_FUNC void STDCALL ICACHE_FLASH_ATTR MD2_Final(uint8_t *output, MD2_CTX *ctx)
{
    int i;
    uint8_t x;

    x = (uint8_t)(16 - ctx->left);

    for (i = ctx->left; i < 16; i++)
        ctx->buffer[i] = x;

    md2_process(ctx);

    memcpy(ctx->buffer, ctx->cksum, 16);
    md2_process(ctx);

    memcpy(output, ctx->state, 16);
}
コード例 #4
0
ファイル: md2.c プロジェクト: ybendan/libtomcrypt
/**
  Self-test the hash
  @return CRYPT_OK if successful, CRYPT_NOP if self-tests have been disabled
*/
int md2_test(void)
{
 #ifndef LTC_TEST
    return CRYPT_NOP;
 #else
   static const struct {
        const char *msg;
        unsigned char hash[16];
   } tests[] = {
      { "",
        {0x83,0x50,0xe5,0xa3,0xe2,0x4c,0x15,0x3d,
         0xf2,0x27,0x5c,0x9f,0x80,0x69,0x27,0x73
        }
      },
      { "a",
        {0x32,0xec,0x01,0xec,0x4a,0x6d,0xac,0x72,
         0xc0,0xab,0x96,0xfb,0x34,0xc0,0xb5,0xd1
        }
      },
      { "message digest",
        {0xab,0x4f,0x49,0x6b,0xfb,0x2a,0x53,0x0b,
         0x21,0x9f,0xf3,0x30,0x31,0xfe,0x06,0xb0
        }
      },
      { "abcdefghijklmnopqrstuvwxyz",
        {0x4e,0x8d,0xdf,0xf3,0x65,0x02,0x92,0xab,
         0x5a,0x41,0x08,0xc3,0xaa,0x47,0x94,0x0b
        }
      },
      { "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
        {0xda,0x33,0xde,0xf2,0xa4,0x2d,0xf1,0x39,
         0x75,0x35,0x28,0x46,0xc3,0x03,0x38,0xcd
        }
      },
      { "12345678901234567890123456789012345678901234567890123456789012345678901234567890",
        {0xd5,0x97,0x6f,0x79,0xd8,0x3d,0x3a,0x0d,
         0xc9,0x80,0x6c,0x3c,0x66,0xf3,0xef,0xd8
        }
      }
   };

   int i;
   unsigned char tmp[16];
   hash_state md;

   for (i = 0; i < (int)(sizeof(tests) / sizeof(tests[0])); i++) {
       md2_init(&md);
       md2_process(&md, (unsigned char*)tests[i].msg, (unsigned long)strlen(tests[i].msg));
       md2_done(&md, tmp);
       if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "MD2", i)) {
          return CRYPT_FAIL_TESTVECTOR;
       }
   }
   return CRYPT_OK;
  #endif
}
コード例 #5
0
ファイル: md2.c プロジェクト: Miyurz/SuperNET
void calc_md2(char *str,uint8_t *digest,uint8_t *message,int32_t len)
{
    int init_hexbytes_noT(char *hexbytes,unsigned char *message,long len);
    hash_state md;
    md2_init(&md);
    md2_process(&md,message,len);
    md2_done(&md,digest);
    if ( str != 0 )
        init_hexbytes_noT(str,digest,16);
}
コード例 #6
0
ファイル: md2.c プロジェクト: sunfirefox/est
/*
    MD2 process buffer
 */
void md2_update(md2_context *ctx, uchar *input, int ilen)
{
    int fill;

    while (ilen > 0) {
        if (ctx->left + ilen > 16) {
            fill = 16 - ctx->left;
        } else {
            fill = ilen;
        }
        memcpy(ctx->buffer + ctx->left, input, fill);
        ctx->left += fill;
        input += fill;
        ilen -= fill;
        if (ctx->left == 16) {
            ctx->left = 0;
            md2_process(ctx);
        }
    }
}
コード例 #7
0
ファイル: md2.c プロジェクト: Bibamaru/showtime
/*
 * MD2 process buffer
 */
void md2_update( md2_context *ctx, const unsigned char *input, size_t ilen )
{
    size_t fill;

    while( ilen > 0 )
    {
        if( ctx->left + ilen > 16 )
            fill = 16 - ctx->left;
        else
            fill = ilen;

        memcpy( ctx->buffer + ctx->left, input, fill );

        ctx->left += fill;
        input += fill;
        ilen  -= fill;

        if( ctx->left == 16 )
        {
            ctx->left = 0;
            md2_process( ctx );
        }
    }
}
コード例 #8
0
/*
 * MD2 process buffer
 */
EXP_FUNC void STDCALL ICACHE_FLASH_ATTR MD2_Update(MD2_CTX *ctx, const uint8_t *input, int ilen)
{
    int fill;

    while (ilen > 0)
    {
        if (ctx->left + ilen > 16)
            fill = 16 - ctx->left;
        else
            fill = ilen;

        memcpy(ctx->buffer + ctx->left, input, fill);

        ctx->left += fill;
        input += fill;
        ilen  -= fill;

        if (ctx->left == 16)
        {
            ctx->left = 0;
            md2_process(ctx);
        }
    }
}
コード例 #9
0
ファイル: md_wrap.c プロジェクト: 0ryuO/dolphin-avsync
static void md2_process_wrap( void *ctx, const unsigned char *data )
{
    ((void) data);

    md2_process( (md2_context *) ctx );
}