MirBSD manpage: suma(3), SUMAData(3), SUMAEnd(3), SUMAFile(3), SUMAFileChunk(3), SUMAFinal(3), SUMAInit(3), SUMAPad(3), SUMAUpdate(3)

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

NAME

     SUMAInit, SUMAUpdate, SUMAPad, SUMAFinal, SUMAEnd, SUMAFile,
     SUMAFileChunk, SUMAData - calculate the SUMA checksum

SYNOPSIS

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

     void
     SUMAInit(SUMA_CTX *ctx);

     void
     SUMAUpdate(SUMA_CTX *ctx, const uint8_t *data, size_t noctets);

     void
     SUMAPad(SUMA_CTX *ctx);

     void
     SUMAFinal(uint8_t digest[SUMA_DIGEST_LENGTH], SUMA_CTX *ctx);

     char *
     SUMAEnd(SUMA_CTX *ctx, char *digest);

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

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

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

DESCRIPTION

     The SUMA functions implement the 32-bit SUMA cyclic redundancy checksum.
     They share a similar API to the md5(3) interface.

     The SUMAInit() function initialises a SUMA_CTX context for use with
     SUMAUpdate() and SUMAFinal(). The SUMAUpdate() function adds (condenses)
     data of length noctets to the context. SUMAFinal() is called after pro-
     cessing 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 "73BD2F90".

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

           SUMAInit(&context);
           SUMAUpdate(&context, buf, n);
           SUMAFinal(result, &context);

           /* print the digest as one long sedecimal value */
           printf("0x");
           for (n = 0; n < SUMA_DIGEST_LENGTH; n++)
                   printf("%02X", result[n]);
           putchar('\n');

     Alternately, the helper functions could be used in the following way:

           SUMA_CTX context;
           uint8_t output[SUMA_DIGEST_STRING_LENGTH];
           const char buf[] = "abc";

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

SEE ALSO

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

HISTORY

     The SUMA functions appeared in MirBSD #10.

AUTHORS

     This implementation of SUMA was written by Thorsten Glaser
     <tg@mirbsd.de>.

     The SUMAEnd(), SUMAFile(), SUMAFileChunk(), and SUMAData() helper func-
     tions are derived from code written by Poul-Henning Kamp.

MirBSD #10-current            September 4, 2020                              1

Generated on 2022-12-24 01:00:14 by $MirOS: src/scripts/roff2htm,v 1.113 2022/12/21 23:14:31 tg Exp $ — This product includes material provided by mirabilos.

These manual pages and other documentation are copyrighted by their respective writers; their sources are available at the project’s CVSweb, AnonCVS and other mirrors. The rest is Copyright © 2002–2022 MirBSD.

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

Kontakt / Impressum & Datenschutzerklärung