MirOS Manual: sfv(3), SFVData(3), SFVEnd(3), SFVFile(3), SFVFileChunk(3), SFVFinal(3), SFVInit(3), SFVPad(3), SFVUpdate(3)

SFV(3)                     BSD Programmer's Manual                      SFV(3)

NAME

     SFVInit, SFVUpdate, SFVPad, SFVFinal, SFVEnd, SFVFile, SFVFileChunk,
     SFVData - calculate the SFV checksum

SYNOPSIS

     #include <sys/types.h>
     #include <sfv.h>

     void
     SFVInit(SFV_CTX *ctx);

     void
     SFVUpdate(SFV_CTX *ctx, const uint8_t *data, size_t noctets);

     void
     SFVPad(SFV_CTX *ctx);

     void
     SFVFinal(uint8_t digest[SFV_DIGEST_LENGTH], SFV_CTX *ctx);

     char *
     SFVEnd(SFV_CTX *ctx, char *digest);

     char *
     SFVFile(const char *filename, char *digest);

     char *
     SFVFileChunk(const char *filename, char *digest, off_t offset,
             off_t length);

     char *
     SFVData(const uint8_t *data, size_t len, char *digest);

DESCRIPTION

     The SFV functions implement the 32-bit SFV cyclic redundancy checksum. It
     is often vulgarly known as CRC or CRC32. They share a similar API to the
     md5(3) interface.

     The SFVInit() function initialises a SFV_CTX context for use with SFVUp-
     date() and SFVFinal(). The SFVUpdate() function adds (condenses) data of
     length noctets to the context. SFVFinal() is called after processing and
     stores a message digest in the digest parameter.

     For a description of the other functions, please refer e.g. the rmd160(3)
     manual page.

EXAMPLES

     The follow code fragment will calculate the checksum for the string
     "abc", which is "352441C2".

           SFV_CTX context;
           uint8_t result[SFV_DIGEST_LENGTH];
           const char buf[] = "abc";
           size_t n = strlen(buf);

           SFVInit(&context);
           SFVUpdate(&context, buf, n);
           SFVFinal(result, &context);

           /* print the digest as one long sedecimal value */
           printf("0x");
           for (n = 0; n < SFV_DIGEST_LENGTH; n++)
                   printf("%02X", result[n]);
           putchar('\n');
     Alternately, the helper functions could be used in the following way:

           SFV_CTX context;
           uint8_t output[SFV_DIGEST_STRING_LENGTH];
           const char buf[] = "abc";

           printf("0x%s\n", SFVData(buf, strlen(buf), output));

SEE ALSO

     cksum(1), adler32(3), md4(3), md5(3), rmd160(3), sha1(3), sha2(3),
     suma(3), tiger(3), whirlpool(3)

     http://www.fodder.org/cksfv/

HISTORY

     The SFV functions appeared in MirOS #10.

AUTHORS

     This implementation of SFV was written by Thorsten Glaser <tg@mirbsd.de>
     and is compatible with Bryan Call's cksfv.

     The SFVEnd(), SFVFile(), SFVFileChunk(), and SFVData() helper functions
     are derived from code written by Poul-Henning Kamp.

MirOS BSD #10-current         November 22, 2009                              1

Generated on 2014-07-04 21:17:45 by $MirOS: src/scripts/roff2htm,v 1.79 2014/02/10 00:36:11 tg Exp $

These manual pages and other documentation are copyrighted by their respective writers; their source is available at our CVSweb, AnonCVS, and other mirrors. The rest is Copyright © 2002‒2014 The MirOS Project, Germany.
This product includes material provided by Thorsten Glaser.

This manual page’s HTML representation is supposed to be valid XHTML/1.1; if not, please send a bug report – diffs preferred.