/文件名称:DFAST2 EVAL标题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算法。输入参数:Seefin:指向缓冲区,该缓冲区由Diffe-Hellman密钥交换符合16个字节种子数据。密钥亮项:指向缓冲区,该缓冲区包含DFSAT2生成的7个字节DES会话密钥。输出:更新钥匙孔(7个字节)。*************************************************************************/ void dfast2(unsigned int *seedIn, unsigned int *KeyOut); /************************************************************************* Routine: S_Substitution() Description: perform S-Box Substitution function. Input Parameters: n: loop counter that is used as the index of S-Box in this routine. 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