MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / tiger_done

Function tiger_done

extern/libtomcrypt/src/hashes/tiger.c:682–726  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

680 @return CRYPT_OK if successful
681*/
682int tiger_done(hash_state * md, unsigned char *out)
683{
684 LTC_ARGCHK(md != NULL);
685 LTC_ARGCHK(out != NULL);
686
687 if (md->tiger.curlen >= sizeof(md->tiger.buf)) {
688 return CRYPT_INVALID_ARG;
689 }
690
691 /* increase the length of the message */
692 md->tiger.length += md->tiger.curlen * 8;
693
694 /* append the '1' bit */
695 md->tiger.buf[md->tiger.curlen++] = (unsigned char)0x01;
696
697 /* if the length is currently above 56 bytes we append zeros
698 * then compress. Then we can fall back to padding zeros and length
699 * encoding like normal. */
700 if (md->tiger.curlen > 56) {
701 while (md->tiger.curlen < 64) {
702 md->tiger.buf[md->tiger.curlen++] = (unsigned char)0;
703 }
704 tiger_compress(md, md->tiger.buf);
705 md->tiger.curlen = 0;
706 }
707
708 /* pad upto 56 bytes of zeroes */
709 while (md->tiger.curlen < 56) {
710 md->tiger.buf[md->tiger.curlen++] = (unsigned char)0;
711 }
712
713 /* store length */
714 STORE64L(md->tiger.length, md->tiger.buf+56);
715 tiger_compress(md, md->tiger.buf);
716
717 /* copy output */
718 STORE64L(md->tiger.state[0], &out[0]);
719 STORE64L(md->tiger.state[1], &out[8]);
720 STORE64L(md->tiger.state[2], &out[16]);
721#ifdef LTC_CLEAN_STACK
722 zeromem(md, sizeof(hash_state));
723#endif
724
725 return CRYPT_OK;
726}
727
728/**
729 Self-test the hash

Callers 1

tiger_testFunction · 0.85

Calls 2

tiger_compressFunction · 0.85
zeromemFunction · 0.85

Tested by

no test coverage detected