Commit 60150f0b authored by Davide Galassi's avatar Davide Galassi

Removed trivial lrc and cs8 checksums

parent fbbf4ca1
Pipeline #52085385 passed with stages
in 1 minute and 36 seconds
/**
* @file sum.h
* @brief Common checksum algorithms.
*/
#ifndef CRY_SUM_H_
#define CRY_SUM_H_
#include <stddef.h>
#ifdef __cplusplus
extern "C"{
#endif
/**
* Trivial checksum.
*
* @param in Input buffer.
* @param n Size of input buffer.
* @return Checksum value.
*/
unsigned char cry_cs8(const unsigned char *in, size_t n);
/**
* Longitudinal redundancy check (LRC).
*
* @param in Input buffer.
* @param n Size of input buffer.
* @return LRC value.
*/
unsigned char cry_lrc(const unsigned char *in, size_t n);
#ifdef __cplusplus
}
#endif
#endif /* CRY_SUM_H_ */
#include <cry/sum.h>
unsigned char cry_cs8(const unsigned char *in, size_t n)
{
unsigned char cs = 0;
while (n-- > 0)
cs += *in++;
return cs;
}
#include <cry/sum.h>
unsigned char cry_lrc(const unsigned char *in, size_t n)
{
unsigned char cs = 0;
while (n-- > 0)
cs += *in++;
return ~cs + 1;
}
......@@ -6,6 +6,4 @@ objects-y := \
crc16_ibm.o \
crc16_dnp.o \
crc32.o \
crc32_eth.o \
cs8.o \
lrc.o
crc32_eth.o
......@@ -23,7 +23,6 @@ objs := \
cmac_test.o \
# md5_test.o \
sha256_test.o \
sum_test.o \
rsa_test.o \
rand_test.o \
dh_test.o \
......
#include "test.h"
#include <cry/sum.h>
#define MSG "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define CS8 0xdf
#define LRC 0x21
void sum_test(void)
{
unsigned char cs;
TRACE("msg: %s\n", MSG);
cs = cry_cs8(MSG, strlen(MSG));
TRACE("cs8 = 0x%02x\n", cs);
ASSERT_EQ(cs, CS8);
cs = cry_lrc(MSG, strlen(MSG));
TRACE("lrc = 0x%02x\n", cs);
ASSERT_EQ(cs, LRC);
}
......@@ -43,7 +43,6 @@ struct sub_test g_tests[] = {
#if 0
TEST_ELEM(md5),
TEST_ELEM(sha256),
TEST_ELEM(sum),
TEST_ELEM(rsa),
TEST_ELEM(dh),
TEST_ELEM(dsa),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment