亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? loki91.c

?? LOKI算法:LOKI89、LOKI91加密解密算法
?? C
字號:
/* *	loki91.c - library routines for a 64 bit LOKI89 implementation * * Designed by  Matthew Kwan <mkwan@crypto.cs.adfa.oz.au> and *		Lawrence Brown <lpb@cs.adfa.oz.au> *  Modifications: *		v2.0 - original set of code by mkwan 9/91 *		v3.0 - support both LOKI89 & LOKI91 versions   10/92 lpb * *  Copyright 1991 by Lawrence Brown and UNSW. All rights reserved. *      This program may not be sold or used as inducement to buy a *      product without the written permission of the author. * *	nb: if this program is compiled on a little-endian machine (eg Vax) *		#define LITTLE_ENDIAN *		in order to enable the byte swapping  routines  * *	    if a detailed trace of LOKI91 function f is required for debugging *		#define TRACE=n		n=1 print blocks, n=2 print fn f also *                                      n=3 print individual S-box calcs also * *	    these routines assume that the 8-byte char arrays used to pass *		the 64-bit blocks fall on a word boundary, so that the blocks *		may be read as longwords for efficiency reasons. If this is *		not true, the load & save of the parameters will need changing. */#include <stdio.h>#include "loki.h"	/* include Interface Specification header file */#include "loki.i"	/* include Interface Specification header file *//* *	string specifying version and copyright message */char	*loki_lib_ver = "LOKI91 library v3.0, Copyright (C) 1991 Lawrence Brown & UNSW";Long	loki_subkeys[ROUNDS];		/* subkeys at the 16 rounds */static Long	f();			/* declare LOKI function f */static short	s();			/* declare LOKI S-box fn s *//* *	ROL12(b) - macro to rotate 32-bit block b left by 12 bits *	ROL13(b) - macro to rotate 32-bit block b left by 13 bits */#define ROL12(b) b = ((b << 12) | (b >> 20));#define ROL13(b) b = ((b << 13) | (b >> 19));/* *      bswap(b) - exchanged bytes in each longword of a 64-bit data block *                      on little-endian machines where byte order is reversed */#ifdef  LITTLE_ENDIAN#define bswap(cb) {                             \        register char   c;                      \        c = cb[0]; cb[0] = cb[3]; cb[3] = c;    \        c = cb[1]; cb[1] = cb[2]; cb[2] = c;    \        c = cb[4]; cb[4] = cb[7]; cb[7] = c;    \        c = cb[5]; cb[5] = cb[6]; cb[6] = c;    \}#endif/* *	setlokikey(key) - save 64-bit key for use in encryptions & decryptions *			  and compute sub-keys using the key schedule  */voidsetlokikey(key)char	key[LOKIBLK];		/* Key to use, stored as an array of Longs    */{	register	i;	register Long	KL, KR;#ifdef LITTLE_ENDIAN	bswap(key);			/* swap bytes round if little-endian */#endif#if	TRACE >= 1	fprintf(stderr,"  keyinit(%08lx, %08lx)\n", ((Long *)key)[0], ((Long *)key)[1]);#endif	KL = ((Long *)key)[0];	KR = ((Long *)key)[1];	for (i=0; i<ROUNDS; i+=4) {	/* Generate the 16 subkeys */	    loki_subkeys[i] = KL;	    ROL12 (KL);	    loki_subkeys[i+1] = KL;	    ROL13 (KL);	    loki_subkeys[i+2] = KR;	    ROL12 (KR);	    loki_subkeys[i+3] = KR;	    ROL13 (KR);	}#ifdef LITTLE_ENDIAN	bswap(key);			/* swap bytes back if little-endian */#endif}/* *	enloki(b) - main LOKI91 encryption routine, this routine encrypts one  *		64-bit block b using the LOKI91 algorithm with loki_subkeys * *		nb: The 64-bit block is passed as two longwords. For the *			purposes of the LOKI89 algorithm, the bits are numbered: *			    [63 62 .. 33 32] [31 30 ... 1 0] *			The L (left) half is b[0], the R (right) half is b[1] * */voidenloki (b)char	b[LOKIBLK];{	register	i;	register Long	L, R;		/* left & right data halves  */#ifdef LITTLE_ENDIAN	bswap(b);			/* swap bytes round if little-endian */#endif#if	TRACE >= 1	fprintf(stderr,"  enloki(%08lx, %08lx)\n", ((Long *)b)[0], ((Long *)b)[1]);#endif	L = ((Long *)b)[0];	R = ((Long *)b)[1];	for (i=0; i<ROUNDS; i+=2) {	/* Encrypt with the 16 subkeys */	    L ^= f (R, loki_subkeys[i]);	    R ^= f (L, loki_subkeys[i+1]);	}	((Long *)b)[0] = R;		/* Y = swap(LR) */	((Long *)b)[1] = L;#if	TRACE >= 1	fprintf(stderr,"  enloki returns %08lx, %08lx\n", ((Long *)b)[0], ((Long *)b)[1]);#endif#ifdef LITTLE_ENDIAN	bswap(b);			/* swap bytes round if little-endian */#endif}/* *	deloki(b) - main LOKI91 decryption routine, this routine decrypts one  *		64-bit block b using the LOKI91 algorithm with loki_subkeys * *		Decryption uses the same algorithm as encryption, except that *		the subkeys are used in reverse order. */voiddeloki(b)char	b[LOKIBLK];{	register	i;	register Long	L, R;			/* left & right data halves  */#ifdef LITTLE_ENDIAN	bswap(b);			/* swap bytes round if little-endian */#endif#if	TRACE >= 1	fprintf(stderr,"  deloki(%08lx, %08lx)\n", ((Long *)b)[0], ((Long *)b)[1]);#endif	L = ((Long *)b)[0];			/* LR = X XOR K */	R = ((Long *)b)[1];	for (i=ROUNDS; i>0; i-=2) {		/* subkeys in reverse order */	    L ^= f(R, loki_subkeys[i-1]);	    R ^= f(L, loki_subkeys[i-2]);	}	((Long *)b)[0] = R;			/* Y = LR XOR K */	((Long *)b)[1] = L;#if	TRACE >= 1	fprintf(stderr,"  deloki returns %08lx, %08lx\n", ((Long *)b)[0], ((Long *)b)[1]);#endif#ifdef LITTLE_ENDIAN	bswap(b);			/* swap bytes round if little-endian */#endif}/* *	f(r, k) - is the complex non-linear LOKI function, whose output *		is a complex function of both input data and sub-key. * *	The data is XORed with the subkey, then expanded into 4 x 12-bit *	values, which are fed into the S-boxes. The 4 x 8-bit outputs *	from the S-boxes are permuted together to form the 32-bit value *	which is returned. * *	In this implementation the outputs from the S-boxes have been *	pre-permuted and stored in lookup tables. */#define MASK12	0x0fff			/* 12 bit mask for expansion E */static Longf(r, k)register Long	r;	/* Data value R(i-1) */Long		k;	/* Key     K(i)   */{	Long	a, b, c;		/* 32 bit S-box output, & P output */	a = r ^ k;			/* A = R(i-1) XOR K(i) */	/* want to use slow speed/small size version */	b = ((Long)s((a         & MASK12))      ) | /* B = S(E(R(i-1))^K(i)) */	    ((Long)s(((a >>  8) & MASK12)) <<  8) |	    ((Long)s(((a >> 16) & MASK12)) << 16) |	    ((Long)s((((a >> 24) | (a << 8)) & MASK12)) << 24);	perm32(&c, &b, P);		/* C = P(S( E(R(i-1)) XOR K(i))) */#if	TRACE >= 2	/* If Tracing, dump A, K(i), and f(R(i-1),K(i)) */	fprintf(stderr,"  f(%08lx, %08lx) = P.S(%08lx) = P(%08lx) = %08lx\n",		r, k, a, b, c);#endif	return(c);			/* f returns the result C */}/* *	s(i) - return S-box value for input i */static short s(i)register Long i;	/* return S-box value for input i */{	register short	r, c, v, t;	short	exp8();		/* exponentiation routine for GF(2^8) */		r = ((i>>8) & 0xc) | (i & 0x3);		/* row value-top 2 & bottom 2 */	c = (i>>2) & 0xff;			/* column value-middle 8 bits */	t = (c + ((r * 17) ^ 0xff)) & 0xff;	/* base value for Sfn */	v = exp8(t, sfn[r].exp, sfn[r].gen);	/* Sfn[r] = t ^ exp mod gen */#if TRACE >= 3	fprintf(stderr, "   s(%lx=[%d,%d]) = %x sup %d mod %d = %x\n",			i, r, c, t, sfn[r].exp, sfn[r].gen, v);#endif	return(v);}/* *	perm32(out, in, perm) is the general permutation of a 32-bit input *		block to a 32-bit output block, under the control of a  *		permutation array perm. Each element of perm specifies which *		input bit is to be permuted to the output bit with the same *		index as the array element. * *	nb: to set bits in the output word, as mask with a single 1 in it is *		used. On each step, the 1 is shifted into the next location */#define	MSB	0x80000000L		/* MSB of 32-bit word */perm32(out, in , perm)Long	*out;		/* Output 32-bit block to be permuted                */Long	*in;		/* Input  32-bit block after permutation             */char	perm[32]; 	/* Permutation array                                 */{	Long	mask = MSB;		/* mask used to set bit in output    */	register int	i, o, b;	/* input bit no, output bit no, value */	register char	*p = perm;	/* ptr to permutation array  */	*out = 0;			/* clear output block */	for (o=0; o<32; o++) {		/* For each output bit position o */			i =(int)*p++;		/* get input bit permuted to output o */		b = (*in >> i) & 01;	/* value of input bit i */		if (b)			/* If the input bit i is set */			*out |= mask;		/*  OR in mask to output i */		mask >>= 1;			/* Shift mask to next bit    */	}}/* *	mult8(a, b, gen) - returns the product of two binary *		strings a and b using the generator gen as the modulus *			mult = a * b mod gen *		gen generates a suitable Galois field in GF(2^8) */#define SIZE 256		/* 256 elements in GF(2^8) */short mult8(a, b, gen)short	a, b;		/* operands for multiply */short	gen;		/* irreducible polynomial generating Galois Field */{	short	product = 0;		/* result of multiplication */	while(b != 0) {			/* while multiplier is non-zero */		if (b & 01)			product ^= a;	/*   add multiplicand if LSB of b set */		a <<= 1;		/*   shift multiplicand one place */		if (a >= SIZE)			a ^= gen;	/*   and modulo reduce if needed */		b >>= 1;		/*   shift multiplier one place  */	}	return(product);}/* *	exp8(base, exponent, gen) - returns the result of *		exponentiation given the base, exponent, generator of GF, *			exp = base ^ exp mod gen */short exp8(base, exponent, gen)short	base;		/* base of exponentiation 	*/short	exponent;	/* exponent			*/short	gen;		/* irreducible polynomial generating Galois Field */{	short	accum = base;	/* superincreasing sequence of base */	short	result = 1;	/* result of exponentiation	    */	if (base == 0)		/* if zero base specified then      */		return(0);	/* the result is "0" if base = 0    */	while (exponent != 0) {	/* repeat while exponent non-zero */		if (( exponent & 0x0001) == 0x0001)	/* multiply if exp 1 */			result = mult8(result, accum, gen);		exponent >>= 1;		/* shift exponent to next digit */		accum = mult8(accum, accum, gen);	/* & square  */	}	return(result);}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日本va欧美va精品| 日本不卡视频一二三区| 久久久噜噜噜久久中文字幕色伊伊| 日本道色综合久久| 成人午夜激情影院| av亚洲精华国产精华| 成人免费看视频| 99国产精品99久久久久久| 久久99蜜桃精品| 国产麻豆精品一区二区| 国产一区二区免费视频| 国产电影精品久久禁18| 99久久婷婷国产综合精品| 99re8在线精品视频免费播放| 亚洲欧美国产77777| 国产精品日韩精品欧美在线| 亚洲三级免费电影| 午夜不卡在线视频| 久久精品国产精品亚洲精品| 国产激情视频一区二区三区欧美| 国产精品国产自产拍高清av王其| 日本韩国一区二区三区| 91麻豆视频网站| 91精品国产91久久久久久一区二区| 国产精品 欧美精品| 成人avav影音| 欧美三区免费完整视频在线观看| 国产一区二区影院| 91免费看片在线观看| 欧美顶级少妇做爰| 精品成人一区二区| 亚洲视频一二三区| 久久99精品国产.久久久久| 不卡的看片网站| 91麻豆精品国产91久久久更新时间| 91视频在线观看免费| 欧美精品久久99久久在免费线| 成人性生交大片免费| 欧美日韩在线播放一区| 国产精品无码永久免费888| 国产欧美一区二区三区在线看蜜臀| 欧美日韩综合色| 日本一区二区三级电影在线观看| 91麻豆精品久久久久蜜臀| xfplay精品久久| 亚洲一区免费在线观看| 成人激情黄色小说| 91精品国产一区二区| 亚洲男人的天堂av| 国产99久久久国产精品免费看| 国产在线精品免费| 色国产综合视频| 国产女主播一区| 精品在线免费视频| 91麻豆精品91久久久久同性| 亚洲精品国产高清久久伦理二区| 自拍偷在线精品自拍偷无码专区| 欧美国产日韩在线观看| 舔着乳尖日韩一区| 一本一本大道香蕉久在线精品 | 成人国产精品免费观看视频| 欧美性极品少妇| 中文字幕不卡三区| 国产九色精品成人porny| 日韩一级完整毛片| 日本欧美大码aⅴ在线播放| 欧美日韩一区在线| 一级做a爱片久久| 色婷婷久久99综合精品jk白丝| 在线看国产日韩| 亚洲永久免费视频| 欧美性感一区二区三区| 亚洲欧美日韩在线| 色综合咪咪久久| 一区二区视频在线看| 91麻豆高清视频| 亚洲黄色在线视频| 欧美日韩激情一区二区三区| 一区二区三区加勒比av| 欧美熟乱第一页| 日韩在线播放一区二区| 欧美一级国产精品| 国产制服丝袜一区| 国产午夜久久久久| 99久久精品免费看国产免费软件| 欧美日韩美女一区二区| 午夜激情一区二区| 26uuu另类欧美亚洲曰本| 国产成人午夜视频| 亚洲精品免费在线观看| 欧美体内she精高潮| 日韩电影在线观看电影| ww久久中文字幕| 99re视频这里只有精品| 香蕉加勒比综合久久| 日韩精品最新网址| caoporm超碰国产精品| 亚洲精品美腿丝袜| 欧美一区二区久久久| 国产91精品久久久久久久网曝门| 91久久线看在观草草青青| 一区二区在线观看视频| 91精品在线观看入口| 国产精品99久久久久久久vr| 亚洲理论在线观看| 日韩免费观看高清完整版 | 99re这里都是精品| 亚洲色图视频网站| 日韩一区国产二区欧美三区| 韩国精品久久久| 亚洲综合久久久| 久久久www成人免费毛片麻豆 | 激情五月婷婷综合| 中文字幕一区二区三中文字幕| 乱中年女人伦av一区二区| 国产欧美日韩激情| 欧美另类久久久品| 国产99久久久国产精品潘金| 亚洲图片一区二区| 国产精品丝袜黑色高跟| 日韩天堂在线观看| 欧美三级电影在线观看| 成人高清av在线| 激情五月婷婷综合| 午夜精品久久久久久久久久| 中文字幕av一区二区三区高| 日韩午夜在线影院| 欧美亚洲国产一区二区三区| 丰满亚洲少妇av| 国内精品伊人久久久久av一坑| 日韩一区二区麻豆国产| 在线亚洲免费视频| 91影院在线免费观看| 国产成人精品一区二区三区四区 | 天天综合天天综合色| 久久久777精品电影网影网| 欧美日韩亚州综合| 色94色欧美sute亚洲线路二| 成人一区二区三区视频| 精品亚洲国产成人av制服丝袜 | 北条麻妃一区二区三区| 国产一区欧美一区| 九九视频精品免费| 五月天激情小说综合| 亚洲欧美偷拍卡通变态| 国产精品不卡视频| 国产精品成人免费在线| 国产精品久久久久久久久晋中| 91丨porny丨户外露出| 粉嫩欧美一区二区三区高清影视| 国产欧美一区二区三区网站| 日韩精品一区二区三区蜜臀| 91麻豆精品国产自产在线观看一区| 久草这里只有精品视频| 亚洲成av人片在www色猫咪| 一区二区在线观看免费视频播放| 欧美一区二区三区免费在线看| 久久aⅴ国产欧美74aaa| 美女网站色91| 麻豆久久久久久| 国产在线精品一区二区三区不卡 | 久久99热这里只有精品| 久久精品国产精品青草| 国产最新精品精品你懂的| 国产麻豆一精品一av一免费| 国产99久久久国产精品| 99re这里只有精品6| 欧美色图天堂网| 日韩一区二区三区视频在线| 精品美女一区二区| 亚洲国产精品成人综合| 中文字幕在线免费不卡| 亚洲国产成人tv| 狠狠色综合播放一区二区| 国产ts人妖一区二区| 色综合久久久久| 日韩精品一区二区三区中文精品| 色综合夜色一区| 欧美一区二区精品在线| 日本一区二区三区免费乱视频 | 精品久久五月天| 中文一区二区完整视频在线观看| 欧洲人成人精品| 精品免费日韩av| 亚洲日本青草视频在线怡红院| 日韩欧美国产系列| 欧美国产日本韩| 日本vs亚洲vs韩国一区三区| 国产69精品久久99不卡| 91久久一区二区| 久久久久99精品一区| 亚洲二区视频在线| 成人短视频下载| 欧美电影免费观看完整版| 国产精品福利影院| 久久99久久久欧美国产| 97精品国产露脸对白| 精品国产乱码久久久久久久久| 欧美一级午夜免费电影| 亚洲图片另类小说|