BeRTOS
Functions
md2.c File Reference

MD2 Message-Digest algorithm. More...

#include "md2.h"
#include <string.h>
#include <cfg/compiler.h>
#include <cfg/debug.h>
#include <cfg/macros.h>
#include <cpu/pgm.h>

Go to the source code of this file.

Defines

#define K1   5
 Md2_perm() function generate an array of 256 "casual" permutation.
#define K2   3
 Md2_perm() function generate an array of 256 "casual" permutation.
#define R   2
 Md2_perm() function generate an array of 256 "casual" permutation.
#define X   172
 Md2_perm() function generate an array of 256 "casual" permutation.

Functions

static void md2_pad (void *_block, size_t len_pad)
 Pad function.
void md2_init (Md2Context *context)
 Algorithm initialization.
void md2_update (Md2Context *context, const void *_block_in, size_t block_len)
 Update block.
uint8_t * md2_end (Md2Context *context)
 Ends an MD2 message digest operation.
bool md2_test (void)
 MD2 test fuction.

Detailed Description

MD2 Message-Digest algorithm.

The MD2 algorithm work with a constant array of 256 permutationt defined in RFC1319. If you don't want to use a standard array of permutatione you can use a md2_perm() function that generate an array of 256 "casual" permutation. To swich from a standard array to md2_perm function you must chanche CONFIG_MD2_STD_PERM defined in appconfig.h. If you need to store array in program memory you must define a macro _PROGMEM (for more info see cpu/pgm.h).

Author:
Daniele Basile <asterix@develer.com>

Definition in file md2.c.


Define Documentation

#define K1   5

Md2_perm() function generate an array of 256 "casual" permutation.

Costant define for computing an array of 256 "casual" permutation.

Definition at line 94 of file md2.c.

#define K2   3

Md2_perm() function generate an array of 256 "casual" permutation.

Costant define for computing an array of 256 "casual" permutation.

Definition at line 95 of file md2.c.

#define R   2

Md2_perm() function generate an array of 256 "casual" permutation.

Costant define for computing an array of 256 "casual" permutation.

Definition at line 96 of file md2.c.

#define X   172

Md2_perm() function generate an array of 256 "casual" permutation.

Costant define for computing an array of 256 "casual" permutation.

Definition at line 97 of file md2.c.


Function Documentation

uint8_t* md2_end ( Md2Context context)

Ends an MD2 message digest operation.

This fuction take an context and return a pointer to context state.

Parameters:
contextin input.
Returns:
a pointer to context state (message digest).

Definition at line 256 of file md2.c.

void md2_init ( Md2Context context)

Algorithm initialization.

Parameters:
contextempty context.

Definition at line 196 of file md2.c.

static void md2_pad ( void *  _block,
size_t  len_pad 
) [static]

Pad function.

Put len_pad unsigned char in input block.

Definition at line 120 of file md2.c.

bool md2_test ( void  )

MD2 test fuction.

This function test MD2 algorithm with a standard string specified in RFC 1319.

Note:
This test work with official array of 256 byte pemutation contructed from digits of pi, defined in the RFC 1319.

Definition at line 288 of file md2.c.