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)


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


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

     SFVInit(SFV_CTX *ctx);

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

     SFVPad(SFV_CTX *ctx);

     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);


     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.


     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);

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

           /* print the digest as one long sedecimal value */
           for (n = 0; n < SFV_DIGEST_LENGTH; n++)
                   printf("%02X", result[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));


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



     The SFV functions appeared in MirOS #10.


     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 2015-10-25 00:47:46 by $MirOS: src/scripts/roff2htm,v 1.81 2015/10/16 13:19:09 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–2015 The MirOS Project, Germany.
This product includes material provided by mirabilos.

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