SUMA(3) BSD Programmer's Manual SUMA(3)
SUMAInit, SUMAUpdate, SUMAPad, SUMAFinal, SUMAEnd, SUMAFile, SUMAFileChunk, SUMAData - calculate the SUMA checksum
#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);
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.
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));
cksum(1), adler32(3), md4(3), md5(3), rmd160(3), sfv(3), sha1(3), sha2(3), tiger(3), whirlpool(3)
The SUMA functions appeared in MirBSD #10.
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