int sha1Update(sha1Param* sp, const byte* data, size_t size) { register uint32_t proclength; #if (MP_WBITS == 64) mpw add[1]; mpsetw(1, add, size); mplshift(1, add, 3); (void) mpadd(1, sp->length, add); #elif (MP_WBITS == 32) mpw add[2]; mpsetw(2, add, size); mplshift(2, add, 3); (void) mpadd(2, sp->length, add); #else # error #endif while (size > 0) { proclength = ((sp->offset + size) > 64U) ? (64U - sp->offset) : size; memcpy(((byte *) sp->data) + sp->offset, data, proclength); size -= proclength; data += proclength; sp->offset += proclength; if (sp->offset == 64U) { sha1Process(sp); sp->offset = 0; } } return 0; }
int sha384Update(register sha384Param* sp, const byte* data, size_t size) { register size_t proclength; #if (MP_WBITS == 64) mpw add[2]; mpsetw(2, add, size); mplshift(2, add, 3); mpadd(2, sp->length, add); #elif (MP_WBITS == 32) mpw add[4]; mpsetws(4, add, size); mplshift(4, add, 3); mpadd(4, sp->length, add); #else # error #endif while (size > 0) { proclength = ((sp->offset + size) > 128U) ? (128U - sp->offset) : size; memcpy(((byte *) sp->data) + sp->offset, data, proclength); size -= proclength; data += proclength; sp->offset += proclength; if (sp->offset == 128U) { sha384Process(sp); sp->offset = 0; } } return 0; }
int ripemd256Update(ripemd256Param* mp, const byte* data, size_t size) { register uint32_t proclength; #if (MP_WBITS == 64) mpw add[1]; mpsetw(1, add, size); mplshift(1, add, 3); mpadd(1, mp->length, add); #elif (MP_WBITS == 32) mpw add[2]; mpsetw(2, add, size); mplshift(2, add, 3); (void) mpadd(2, mp->length, add); #else # error #endif while (size > 0) { proclength = ((mp->offset + size) > 64U) ? (64U - mp->offset) : size; /*@-mayaliasunique@*/ memcpy(((byte *) mp->data) + mp->offset, data, proclength); /*@=mayaliasunique@*/ size -= proclength; data += proclength; mp->offset += proclength; if (mp->offset == 64U) { ripemd256Process(mp); mp->offset = 0; } } return 0; }
int md2Update(md2Param *mp, const byte *data, size_t size) { uint32_t proclength; #if (MP_WBITS == 64) mpw add[1]; mpsetw(1, add, size); mplshift(1, add, 3); mpadd(1, mp->length, add); #elif (MP_WBITS == 32) mpw add[2]; mpsetw(2, add, size); mplshift(2, add, 3); (void) mpadd(2, mp->length, add); #else # error #endif while (size > 0) { proclength = ((mp->offset + size) > 16U) ? (16U - mp->offset) : size; /*@-mayaliasunique@*/ memcpy(((byte *)mp->buf) + mp->offset, data, proclength); /*@=mayaliasunique@*/ size -= proclength; data += proclength; mp->offset += proclength; /* is 16 bytes full? */ if (mp->offset == 16U) { md2_compress(mp); md2_update_chksum(mp); mp->offset = 0; } } return 0; }