文件名称:DFAST2 eval header v3.2.h版本:3.2 **************************************************************************************/ #ifndef DFAST2 #define DFAST2 #define INPUT_BYTES 16 // 16字节种子数据来自Diffe-Hellman #define OUTPUT_BYTES 7 // 7字节(56位)关键数据输出#define clk_Cycles 701 //定义DFAST应该运行的周期数//在对keystream输出进行采样之前#define DEBUG_FLAG 0 // 1 -表示打开调试模式,调试输出//被写入文本文件" Debug .log" // 0 -表示关闭调试模式。/************************************************************************ 常规:dfast2()描述:执行dfast2算法。输入参数:seedIn:指向存放差分-海尔曼密钥交换产生的16字节种子数据的缓冲区。KeyOut:指向DFSAT2生成的7字节DES会话密钥的缓冲区。输出:更新的KeyOut(7字节)。*************************************************************************/ 空白dfast2 (unsigned int * seedIn, unsigned int * KeyOut);/************************************************************************* 常规:S_Substitution()描述:执行天地盒替换功能。输入参数:n:循环计数器,用于本例程中S-Box的索引。 It is used to make sure every element in S-Box is changed. g0 & g1: intermediate results. generated from non-linear mix function I. rgA & rgB: outputs from pre-determined FSR stages. S_Box: a pointer to the buffer that holds S-Box array. Y0 & Y1: a pointer to the buffer that holds the outputs generated from S-Box Substitution function. Output: S_Box: updated S-Box array. Y0 & Y1: updated outputs generated from S-Box Substitution function. **************************************************************************/ void S_Substitution(int n, GFE g0, GFE g1, GFE rgA, GFE rgB, int *S_Box, GFE *Y0, GFE *Y1); /************************************************************************ Routine: mux() Description: perform 2:1 bitwise multiplexing function. Input Parameters: SEL: 8-bit value that selects inputs from either A or B on a bitwise basis. A: first input - each bit selected if the corresponding bit in SEL is 1. B: second input - each bit selected if the corresponding bit in SEL is 0. Return Value: 8-bit value selected from input A or B on a bitwise basis. *************************************************************************/ int mux(int sel, int A, int B); /************************************************************************ Routine: fsra() Purpose: perform feedback shift register operations for structure A (static feedback shift register). Input Parameters: reg: contents of structure A. coeff: polynomial coefficients of structure A. Output: reg: updated (shifted) structure A. *************************************************************************/ void fsra(GFE coeff[], GFE reg[]); /************************************************************************ Routine: fsrb() Purpose: perform dynamic feedback shift register operations (structure B & C). Input Parameters: coeff: polynomial coefficients of the structure B or C. reg: contents of structure B or C . codestream: codestream content (referred to as Y1 in the block diagram). Output: reg: updated (shifted) register B or C. *************************************************************************/ void fsrb(GFE coeff[], GFE reg[], GFE codestream); #endif