djiparsetxt
Functions
scrambleBytes.hh File Reference
#include <sys/types.h>
Include dependency graph for scrambleBytes.hh:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void getScrambleBytes (u_int8_t recordType, u_int8_t keyByte, u_int8_t *resultScrambleBytes)
 

Function Documentation

◆ getScrambleBytes()

void getScrambleBytes ( u_int8_t  recordType,
u_int8_t  keyByte,
u_int8_t *  resultScrambleBytes 
)

Definition at line 127 of file scrambleBytes.cpp.

128  {
129  // Set up the (8-byte) buffer to compute the CRC over:
130  u_int64_t dataForBuffer = 0x123456789ABCDEF0*keyByte;
131  u_int8_t bufferToCRC[8];
132  // Fill in the buffer in little-endian order:
133  for (unsigned i = 0; i < sizeof bufferToCRC; ++i) {
134  bufferToCRC[i] = dataForBuffer; // low 8 bits
135  dataForBuffer >>= 8;
136  }
137 
138  // Compute a CRC over this buffer, using our "recordType" and "keyByte" parameters as salt:
139  u_int64_t crcResult = crc64(recordType + keyByte, bufferToCRC, sizeof bufferToCRC);
140 
141  // Unpack this into "resultScrambleBytes", in little-endian order:
142  for (unsigned i = 0; i < 8; ++i) {
143  resultScrambleBytes[i] = crcResult; // low 8 bits
144  crcResult >>= 8;
145  }
146 }
static u_int64_t crc64(u_int8_t seed, u_int8_t const *buffer, unsigned bufferSize)

References crc64().

Referenced by RecordAndDetailsParser::parseRecord().

Here is the caller graph for this function: