int MDC2_Update(MDC2_CTX *c, const unsigned char *in, size_t len) { size_t i,j; i=c->num; if (i != 0) { if (i+len < MDC2_BLOCK) { /* partial block */ memcpy(&(c->data[i]),in,len); c->num+=(int)len; return 1; } else { /* filled one */ j=MDC2_BLOCK-i; memcpy(&(c->data[i]),in,j); len-=j; in+=j; c->num=0; mdc2_body(c,&(c->data[0]),MDC2_BLOCK); } } i=len&~((size_t)MDC2_BLOCK-1); if (i > 0) mdc2_body(c,in,i); j=len-i; if (j > 0) { memcpy(&(c->data[0]),&(in[i]),j); c->num=(int)j; } return 1; }
void MDC2_Update(MDC2_CTX *c, const unsigned char *in, unsigned long len) { int i,j; i=c->num; if (i != 0) { if (i+len < MDC2_BLOCK) { /* partial block */ memcpy(&(c->data[i]),in,(int)len); c->num+=(int)len; return; } else { /* filled one */ j=MDC2_BLOCK-i; memcpy(&(c->data[i]),in,j); len-=j; in+=j; c->num=0; mdc2_body(c,&(c->data[0]),MDC2_BLOCK); } } i=(int)(len&(unsigned long)~(MDC2_BLOCK-1)); if (i > 0) mdc2_body(c,in,i); j=(int)len-i; if (j > 0) { memcpy(&(c->data[0]),&(in[i]),j); c->num=j; } }
void MDC2_Final(unsigned char *md, MDC2_CTX *c) { int i,j; i=c->num; j=c->pad_type; if ((i > 0) || (j == 2)) { if (j == 2) c->data[i++]=0x80; memset(&(c->data[i]),0,MDC2_BLOCK-i); mdc2_body(c,c->data,MDC2_BLOCK); } memcpy(md,(char *)c->h,MDC2_BLOCK); memcpy(&(md[MDC2_BLOCK]),(char *)c->hh,MDC2_BLOCK); }
int JtR_MDC2_Final(unsigned char *md, JtR_MDC2_CTX *c) { unsigned int i; int j; i=c->num; j=c->pad_type; if ((i > 0) || (j == 2)) { if (j == 2) c->data[i++]=0x80; memset(&(c->data[i]),0,JtR_MDC2_BLOCK-i); mdc2_body(c,c->data,JtR_MDC2_BLOCK); } memcpy(md,(char *)c->h,JtR_MDC2_BLOCK); memcpy(&(md[JtR_MDC2_BLOCK]),(char *)c->hh,JtR_MDC2_BLOCK); return 1; }
int MDC2_Final(unsigned char *md, MDC2_CTX *c) { unsigned int i; int j; i=c->num; j=c->pad_type; if ((i > 0) || (j == 2)) { if (j == 2) c->data[i++]=0x80; TINYCLR_SSL_MEMSET(&(c->data[i]),0,MDC2_BLOCK-i); mdc2_body(c,c->data,MDC2_BLOCK); } TINYCLR_SSL_MEMCPY(md,(char *)c->h,MDC2_BLOCK); TINYCLR_SSL_MEMCPY(&(md[MDC2_BLOCK]),(char *)c->hh,MDC2_BLOCK); return 1; }