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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? loki89.c

?? LOKI加密算法
?? C
字號:
/* *	loki89.c - library routines for a 64 bit LOKI89 implementation * *  Author:	Lawrence Brown <lpb@csadfa.oz>		Aug 1989 *		Computer Science, UC UNSW, ADFA, Canberra, ACT 2600, Australia. * *  Modifications: *		v1.0 - original set of code (based on des64.c v4.0) 9/89 lpb *		v2.0 - include conditionals for various speed/sizes 4/90 lpb *		v2.1 - use RCS system for production control	5/90 lpb *		v3.0 - support both LOKI89 & LOKI91 versions   10/92 lpb * *  Copyright 1989 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 LOKI89 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 LOKI89 Permutation, Subs & Key tables*//* *	string specifying version and copyright message */char	*loki_lib_ver = "LOKI89 library v3.0, Copyright (C) 1990 Lawrence Brown & UNSW";static Long	f();	/* declare LOKI89 function f		     */static short	s();	/* declare LOKI89 s-box routine (for small ver) *//* *	lokikey - the 64-bit key for the LOKI89 library routines */Long	lokikey[2] = {0, 0};/* *	ROL12(b) - macro to rotate 32-bit block b left  by 12 bits *	ROR12(b) - macro to rotate 32-bit block b right by 12 bits */#define ROL12(b) b = ((b << 12) | (b >> 20));#define ROR12(b) b = ((b >> 12) | (b << 20));/* *      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 */voidsetlokikey(key)char	key[LOKIBLK];		/* Key to use, stored as an array of Longs    */{#ifdef LITTLE_ENDIAN	bswap(key);			/* swap bytes round if little-endian */#endif	lokikey[0] = ((Long *)key)[0];	lokikey[1] = ((Long *)key)[1];#if	TRACE >= 1	fprintf(stderr,"  keyinit(%08lx, %08lx)\n", lokikey[0], lokikey[1]);#endif#ifdef LITTLE_ENDIAN	bswap(key);			/* swap bytes back if little-endian */#endif}/* *	enloki(b) - main LOKI89 encryption routine, this routine encrypts one  *		64-bit block b using the LOKI89 algorithm with lokikey * *		The encryption operation involves XOR'ing the input block with *		the key, applying a LOKI89 round sixteen times *		(which ensures the output is a complex function of the input, *		and the key), and finally XOR'ing the input block with the key * *		Each round performs the following calculation using a 48-bit *		subkeys: *			L(i) = R(i-1) *			R(i) = L(i-1) XOR f(R(i-1), K(i)) * *		To save swapping, alternate calls to f use L & R respectively * *		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 Long	L, R;			/* left & right data halves  */	register Long	KL, KR;			/* left & right key  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	KL = lokikey[0];			/* load keys in register vars */	KR = lokikey[1];	L = ((Long *)b)[0] ^ KL;		/* LR = X XOR K */	R = ((Long *)b)[1] ^ KR;	/* Perform the 16 rounds using sub-keys in usual order               */	L ^= f(R, KL);	ROL12(KL);			R ^= f(L, KR);	ROL12(KR);	L ^= f(R, KL);	ROL12(KL);			R ^= f(L, KR);	ROL12(KR);	L ^= f(R, KL);	ROL12(KL);			R ^= f(L, KR);	ROL12(KR);	L ^= f(R, KL);	ROL12(KL);			R ^= f(L, KR);	ROL12(KR);	L ^= f(R, KL);	ROL12(KL);			R ^= f(L, KR);	ROL12(KR);	L ^= f(R, KL);	ROL12(KL);			R ^= f(L, KR);	ROL12(KR);	L ^= f(R, KL);	ROL12(KL);			R ^= f(L, KR);	ROL12(KR);	L ^= f(R, KL);	ROL12(KL);			R ^= f(L, KR);	ROL12(KR);	((Long *)b)[0] = R ^ KR;		/* Y = swap(LR) XOR K */	((Long *)b)[1] = L ^ KL;#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 LOKI89 decryption routine, this routine decrypts one  *		64-bit block b using the LOKI89 algorithm with lokikey * *		Decryption uses the same algorithm as encryption, except that *		the subkeys are used in reverse order. */voiddeloki(b)char	b[LOKIBLK];{	register Long	L, R;			/* left & right data halves  */	register Long	KL, KR;			/* left & right key  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	KL = lokikey[0];			/* load keys in register vars */	KR = lokikey[1];	L = ((Long *)b)[0] ^ KR;		/* LR = X XOR K */	R = ((Long *)b)[1] ^ KL;	/* Perform the 16 rounds using sub-keys in usual order               */	ROR12(KR);	L ^= f(R, KR);	ROR12(KL);	R ^= f(L, KL);	ROR12(KR);	L ^= f(R, KR);	ROR12(KL);	R ^= f(L, KL);	ROR12(KR);	L ^= f(R, KR);	ROR12(KL);	R ^= f(L, KL);	ROR12(KR);	L ^= f(R, KR);	ROR12(KL);	R ^= f(L, KL);	ROR12(KR);	L ^= f(R, KR);	ROR12(KL);	R ^= f(L, KL);	ROR12(KR);	L ^= f(R, KR);	ROR12(KL);	R ^= f(L, KL);	ROR12(KR);	L ^= f(R, KR);	ROR12(KL);	R ^= f(L, KL);	ROR12(KR);	L ^= f(R, KR);	ROR12(KL);	R ^= f(L, KL);	((Long *)b)[0] = R ^ KL;		/* Y = LR XOR K */	((Long *)b)[1] = L ^ KR;#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 LOKI89 function, whose output *		is a complex function of both input data and sub-key. *		The input data R(i-1) is: *			added modulo 2 to the key K(i) *			expanded to 48-bits via expansion fn E *			substituted into the S-boxes *			permuted by P. *		ie the calculation is: *			A = E(R(i-1) XOR K(i))		(a 48-bit value) *			B = S(A)			(a 32-bit value) *			f = P(B)			(a 32-bit value) * *	nb: the 12-bit S-box input value [x x x x 11 10 9 ... 3 2 1 0] *	    is interpreted as: *		bits [11 10 1 0] select 1 of 16 rows within each box, *		bits [9 8 ... 3 2] then select a column within that row */#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 */	c = (i>>2) & 0xff;			/* column value */	t = c ^ r;				/* 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);}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日韩情趣电影| 国精产品一区一区三区mba视频 | 亚洲日本护士毛茸茸| 日韩一区二区在线观看| 欧美调教femdomvk| 丁香六月综合激情| 国内精品第一页| 九九精品一区二区| 免费在线观看一区二区三区| 亚洲一区二区av电影| 亚洲色图在线看| 亚洲视频 欧洲视频| 国产精品区一区二区三区| 日韩一区二区在线看片| 在线播放91灌醉迷j高跟美女 | 日韩av一区二区在线影视| 一区二区久久久| 亚洲精品高清视频在线观看| 国产亚洲欧美一区在线观看| 久久久久九九视频| 久久色在线观看| 久久综合久久鬼色中文字| 日韩欧美一二三区| 日韩欧美一级精品久久| 欧美成人在线直播| 日韩精品在线一区二区| 欧美猛男gaygay网站| 欧美色综合影院| 亚洲欧美另类图片小说| 亚洲女爱视频在线| 丝袜脚交一区二区| 国产精品影音先锋| thepron国产精品| 欧美日韩国产成人在线91| 精品免费99久久| 专区另类欧美日韩| 蜜桃视频一区二区三区| 国产99久久久国产精品潘金| 91行情网站电视在线观看高清版| 欧美日韩高清影院| 国产欧美一区二区三区鸳鸯浴| 中文字幕亚洲欧美在线不卡| 亚洲www啪成人一区二区麻豆| 狠狠狠色丁香婷婷综合激情| 色屁屁一区二区| 精品蜜桃在线看| 综合分类小说区另类春色亚洲小说欧美| 午夜电影一区二区| 国产ts人妖一区二区| 欧美三级午夜理伦三级中视频| 精品欧美一区二区在线观看| 亚洲欧美另类久久久精品 | 国产91在线观看| 欧美亚洲一区三区| 国产亚洲欧美日韩日本| 亚洲综合色噜噜狠狠| 国产毛片精品国产一区二区三区| 在线精品视频一区二区| 国产三级久久久| 日韩经典中文字幕一区| 99久精品国产| 精品国产污网站| 亚洲观看高清完整版在线观看 | 欧美卡1卡2卡| 国产精品国产三级国产aⅴ入口| 蜜臀久久99精品久久久久久9| 色综合天天综合色综合av | 午夜婷婷国产麻豆精品| a亚洲天堂av| 久久久久久久综合| 日韩高清一区二区| 在线观看av不卡| 国产精品短视频| 精品在线播放免费| 777xxx欧美| 一区二区三区国产精品| 成人黄色电影在线| 欧美精品一区二区三区蜜臀| 亚洲成av人片| 欧美在线视频不卡| 综合久久国产九一剧情麻豆| 国产成人在线免费| 欧美精品一区二区三区一线天视频| 亚洲高清视频中文字幕| 色综合咪咪久久| 国产精品不卡一区| 国产91高潮流白浆在线麻豆| 精品欧美久久久| 麻豆专区一区二区三区四区五区| 欧美日韩午夜在线| 一区二区三区成人| 色婷婷国产精品综合在线观看| 国产精品午夜久久| 国产91精品精华液一区二区三区| 欧美精品一区二区在线观看| 紧缚奴在线一区二区三区| 日韩欧美区一区二| 麻豆成人免费电影| 日韩视频一区二区三区在线播放 | 日韩精品亚洲一区二区三区免费| 欧美中文字幕一区二区三区| 亚洲乱码精品一二三四区日韩在线| 波多野结衣在线一区| 中文字幕欧美国产| 波多野结衣中文字幕一区 | 免费在线视频一区| 日韩一级黄色片| 六月婷婷色综合| 亚洲精品一区二区三区福利| 激情久久五月天| 国产校园另类小说区| 国产成人精品影视| 中文字幕在线观看一区二区| 99麻豆久久久国产精品免费优播| 国产精品久久久久久久久动漫 | 亚洲国产va精品久久久不卡综合| 欧美性受xxxx黑人xyx性爽| 亚洲午夜一区二区三区| 欧美日韩国产电影| 美女一区二区视频| 久久婷婷一区二区三区| 岛国精品一区二区| 亚洲蜜臀av乱码久久精品蜜桃| 色94色欧美sute亚洲线路一久| 亚洲国产日韩在线一区模特| 欧美一区二区免费观在线| 精品一区二区三区免费| 亚洲国产高清aⅴ视频| 色综合天天综合狠狠| 天使萌一区二区三区免费观看| 日韩一级视频免费观看在线| 国产成人精品一区二区三区四区| 日韩理论片中文av| 欧美一区国产二区| 国产v综合v亚洲欧| 亚洲午夜精品网| www日韩大片| 91麻豆高清视频| 日日摸夜夜添夜夜添精品视频| 精品电影一区二区| 99re视频这里只有精品| 偷拍亚洲欧洲综合| 国产色爱av资源综合区| 91福利小视频| 韩国女主播一区二区三区| 中文字幕日本乱码精品影院| 欧美久久一二区| 国产精品白丝av| 亚洲综合一二区| 精品91自产拍在线观看一区| 色香蕉久久蜜桃| 精品在线免费观看| 亚洲综合一区二区三区| 久久久久久久久久久黄色| 91国偷自产一区二区使用方法| 久久精品国产精品亚洲红杏| 亚洲欧洲av另类| 日韩欧美国产一区二区三区| 99国产精品国产精品毛片| 久久精品国产久精国产| 亚洲精品免费在线观看| 久久综合色综合88| 欧美日韩一卡二卡三卡| 成+人+亚洲+综合天堂| 蜜桃在线一区二区三区| 亚洲影院久久精品| 国产亚洲成aⅴ人片在线观看| 欧美老肥妇做.爰bbww| 99久久国产综合精品女不卡| 精品一区二区三区的国产在线播放| 一区二区三区国产| 国产精品免费视频一区| 日韩精品中午字幕| 欧美日韩一区高清| 91偷拍与自偷拍精品| 国产成人午夜视频| 免费的成人av| 亚洲第一电影网| 1024精品合集| 亚洲国产精品黑人久久久| 日韩亚洲欧美成人一区| 欧美午夜精品久久久久久孕妇| 成人v精品蜜桃久久一区| 激情久久五月天| 秋霞影院一区二区| 亚洲成人午夜影院| 一区二区三区在线免费播放 | 日本aⅴ免费视频一区二区三区| 亚洲青青青在线视频| 国产欧美日韩精品一区| 精品国产免费人成电影在线观看四季| 欧美乱妇23p| 欧美群妇大交群中文字幕| 91成人网在线| 色综合久久中文字幕| 99久久久久免费精品国产| 成人av在线影院| eeuss鲁片一区二区三区在线观看 eeuss鲁片一区二区三区在线看 | 国产在线日韩欧美| 日本午夜一本久久久综合|