• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ deskey函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中deskey函数的典型用法代码示例。如果您正苦于以下问题:C++ deskey函数的具体用法?C++ deskey怎么用?C++ deskey使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了deskey函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: dencrypt_3des

int	__stdcall dencrypt_3des(unsigned char* key,long keylen,unsigned char *data,short datalen,unsigned char *Des_result)
{
	unsigned char szkey[9];
	unsigned char szplain[9];
	unsigned char szcipher[9];
	if(keylen != 16)
		return INVALID_KEY_LEN;
	if(datalen != 8)
		return INVALID_DATA_LEN;

	memset(szkey,0,sizeof(szkey));
	memset(szplain,0,sizeof(szplain));
	memset(szcipher,0,sizeof(szcipher));

	memcpy(szkey,key,8);
	memcpy(szcipher,data,8);

	deskey(szkey,1);
	Ddes(szcipher,szplain);

	memcpy(szkey,key+8,8);
	deskey(szkey,0);
	Ddes(szplain,szcipher);

	memcpy(szkey,key,8);
	deskey(szkey,1);
	Ddes(szcipher,szplain);

	memcpy(Des_result,szplain,8);
	return 0;
}
开发者ID:nykma,项目名称:ykt4sungard,代码行数:31,代码来源:desdll.cpp


示例2: vncDecryptPasswdFromFile

char *
vncDecryptPasswdFromFile(char *fname)
{
    FILE *fp;
    int i, ch;
    unsigned char *passwd = (unsigned char *)malloc(9);

    if (strcmp(fname, "-") != 0) {
	if ((fp = fopen(fname,"r")) == NULL)
	    return NULL;
    } else {
	fp = stdin;
    }

    for (i = 0; i < 8; i++) {
	ch = getc(fp);
	if (ch == EOF)
	    break;
	passwd[i] = ch;
    }

    if (fp != stdin)
	fclose(fp);

    if (i != 8)                 /* Could not read eight bytes */
	return NULL;

    deskey(s_fixedkey, DE1);
    des(passwd, passwd);

    passwd[8] = 0;

    return (char *)passwd;
}
开发者ID:gvsurenderreddy,项目名称:AlmostVPNPro,代码行数:34,代码来源:vncauth.c


示例3: vncDecryptPasswdFromFile

char *
vncDecryptPasswdFromFile(char *fname)
{
    FILE *fp;
    int i, ch;
    unsigned char *passwd = (unsigned char *)malloc(9);

    if ((fp = fopen(fname,"r")) == NULL) return NULL;

    for (i = 0; i < 8; i++) {
        ch = getc(fp);
        if (ch == EOF) {
            fclose(fp);
            return NULL;
        }
        passwd[i] = ch;
    }

    fclose(fp);

    deskey(fixedkey, DE1);
    des(passwd, passwd);

    passwd[8] = 0;

    return (char *)passwd;
}
开发者ID:OS2World,项目名称:APP-INTERNET-PMVNC-Client,代码行数:27,代码来源:vncauth.c


示例4: vncEncryptAndStorePasswd

int
vncEncryptAndStorePasswd(char *passwd, char *fname)
{
    FILE *fp;
    int i;
    unsigned char encryptedPasswd[8];

    if ((fp = fopen(fname,"w")) == NULL) return 1;

    chmod(fname, S_IRUSR|S_IWUSR);

    /* pad password with nulls */

    for (i = 0; i < 8; i++) {
        if (i < strlen(passwd)) {
            encryptedPasswd[i] = passwd[i];
        } else {
            encryptedPasswd[i] = 0;
        }
    }

    /* Do encryption in-place - this way we overwrite our copy of the plaintext
       password */

    deskey(fixedkey, EN0);
    des(encryptedPasswd, encryptedPasswd);

    for (i = 0; i < 8; i++) {
        putc(encryptedPasswd[i], fp);
    }

    fclose(fp);
    return 0;
}
开发者ID:OS2World,项目名称:APP-INTERNET-PMVNC-Client,代码行数:34,代码来源:vncauth.c


示例5: main

int main() {
    char *key = "browsers";
    unsigned char data[16];
    int j;
    FILE *in, *out;

    deskey(key, EN0);
    
    in = fopen("challenge", "r");
    if (!in) {
        printf("failed opening challenge\n");
        exit(1);
    }
    fread(data, 1, 16, in);
    fclose(in);

    for (j=0; j<16; j += 8) {
        des(data+j, data+j);
    }

    out = fopen("out", "w+");
    if (!out) {
        printf("failed opening out\n");
        exit(1);
    }
    fwrite(data, 1, 16, out);
    fclose(out);

    return 0;
}
开发者ID:HoTaeWang,项目名称:node-des,代码行数:30,代码来源:main.c


示例6: deskey

int DES::decrypt ( char key[8], char* data, int blocks )
{
   if ((!data)||(blocks<1))
	  return 0;
   deskey ( (unsigned char *)key, DECRYPT );
   des ( (unsigned char *)data, (unsigned char *)data, blocks);
   return 1;
};
开发者ID:nykma,项目名称:ykt4sungard,代码行数:8,代码来源:mydes.cpp


示例7: memcpy

int CHttpDes::des_cbc_pkcs7_decrypt(uchar* from, int nLength,  uchar * to, uchar key[], uchar iv[])
{
	if(nLength % 8)
	{
		return 0;		//数据不正确
	}

	//XOR
	uchar preEnc[8],buffer[8];
	memcpy(preEnc,iv,8);

	deskey(key,DE1);

	int i = 0;
	for(; i<nLength; i+=8)
	{
		uchar* ps = from + i;
		uchar* pd = to + i;

		des(ps,buffer);

		//XOR
		for(int j = 0; j < 8; ++j)
		{
			buffer[j] ^= preEnc[j];
		}

		if(nLength - i > 8)
		{
			//保存前一个输出
			memcpy(preEnc, ps,8);
			memcpy(pd,buffer,sizeof(buffer));
		}
		else
		{
			//去除数据尾
			uchar chEnd = buffer[sizeof(buffer) - 1];
			if(chEnd > 0 && chEnd < 9)
			{
				//有可能是填充字符,去除掉
				for(int j = sizeof(buffer) - 1; j >= (int)(sizeof(buffer) - chEnd); --j)
				{
					if(buffer[j] != chEnd)
						return 0;
				}
				int nSize =nLength - chEnd;
				memcpy(pd, buffer, sizeof(buffer) - chEnd);
				return nLength - chEnd;
			}
			else
			{
				//数据格式不正确
				return 0;
			}
		}
	}
	return 0;
}
开发者ID:huos3203,项目名称:SISpeciesNotes,代码行数:58,代码来源:HttpDes.cpp


示例8: rfb_crypt

void rfb_crypt(CARD8 *dst_buf, CARD8 *src_buf, unsigned char *password)
{
  unsigned char key[8];

  memset(key, 0, 8);
  strncpy((char *)key, (char *)password, 8);
  deskey(key, EN0);
  des(src_buf, dst_buf);
  des(src_buf + 8, dst_buf + 8);
}
开发者ID:hanzhaogang,项目名称:chromium-1,代码行数:10,代码来源:rfblib.c


示例9: dencrypt_des

int	__stdcall dencrypt_des(unsigned char* key,long keylen,unsigned char *data,short datalen,unsigned char *Des_result)
{
	if(keylen != 8)
		return INVALID_KEY_LEN;
	if(datalen != 8)
		return INVALID_DATA_LEN;
	deskey(key,1);
	Ddes(data,Des_result);
	return 0;
}
开发者ID:nykma,项目名称:ykt4sungard,代码行数:10,代码来源:desdll.cpp


示例10: dynatab_freeze_encrypted

/*-------------------------------------------------------------------------
  Write the dynatab to the given file in a format encrypted with key,
  suitable for restoration with dynatab_thaw_encrypted.
-------------------------------------------------------------------------*/
void dynatab_freeze_encrypted(dynatab_t *tab, FILE *fp, const unsigned char key[8])
{
	dynatab_encrypted_freeze_t d;
	size_t encrypted_unit;
	int nwritten;
	int n;
	size_t chunk;
	char buf[crypttab_RW_BUFFER_SIZE];
	char *pbuf;
	char unitbuf[crypttab_RW_BUFFER_SIZE];
	
	d.magic = dynatab_encrypted_MAGIC;
	d.n_used = tab->n_used;
	d.unit = tab->unit;
	/* round up to nearest multiple of 8 */
	encrypted_unit = d.unit + 7 - (d.unit + 7) % 8;

	assert(encrypted_unit <= crypttab_RW_BUFFER_SIZE);
	assert(d.n_used <= 5000);
	DPRINT(("dynatab_freeze_encrypted: Saving %d elements of size %d (%d encrypted).\n", d.n_used, tab->unit, encrypted_unit));

	nwritten = fwrite(&d, sizeof(d), 1, fp);
	if (nwritten != 1) {
		DPRINT(("dynatab_freeze_encrypted: Error writing info.\n"));
		return;
	}
	
	pbuf = buf;
	memset(unitbuf, 0, encrypted_unit);
	deskey(key, EN0);
	for (n = 0; n < tab->n_used; n++) {
		if (pbuf - buf + encrypted_unit > crypttab_RW_BUFFER_SIZE) {
			/* if the write buffer is full, write it to disk, then start
			 * adding at the beginning of the buffer again
			 */
			nwritten = fwrite(buf, (pbuf - buf), 1, fp);
			if (nwritten != 1) {
				DPRINT(("dynatab_freeze_encrypted: Error writing unit %d (wrote %d x %d).\n", n, (pbuf - buf), nwritten));
				return;  /* need an error code? */
			}
			pbuf = buf;
		}
		/* encrypt the entry and add it to the write buffer in 8 byte chunks */
		memcpy(unitbuf, (char *)tab->buf + n * tab->unit, tab->unit);
		for (chunk = 0; chunk < encrypted_unit; chunk += 8, pbuf += 8)
			des(unitbuf + chunk, pbuf);
	}
	
	/* Write the last partial buffer to disk */
	nwritten = fwrite(buf, (pbuf - buf), 1, fp);
	if (nwritten != 1) {
		DPRINT(("dynatab_freeze_encrypted: Error writing unit %d.\n", n));
		return;  /* need an error code? */
	}
}
开发者ID:BygoneWorlds,项目名称:anet,代码行数:59,代码来源:crypttab.c


示例11: desired

/*!
 Initialize the LTC_DES block cipher
 @param key The symmetric key you wish to pass
 @param keylen The key length in bytes
 @param num_rounds The number of rounds desired (0 for default)
 @param skey The key in as scheduled by this function.
 @return CRYPT_OK if successful
 */
static int ltc_des_setup(const unsigned char *key, unsigned long keylen, int num_rounds,
                        ccecb_ctx *skey)
{
    ltc_des_keysched *des;

    des = (ltc_des_keysched *)skey;

    if (num_rounds != 0 && num_rounds != 16) {
        return -1; /* CRYPT_INVALID_ROUNDS; */
    }

     if (keylen != 8) {
        return -1; /* CRYPT_INVALID_KEYSIZE; */
    }

    deskey(key, EN0, des->ek);
    deskey(key, DE1, des->dk);

    return 0; /* CRYPT_OK; */
}
开发者ID:randombit,项目名称:hacrypto,代码行数:28,代码来源:ccdes_ltc_common.c


示例12: vncDecryptPasswd

/*
 *   Decrypt a password.  Returns a pointer to a newly allocated
 *   string containing the password or a null pointer if the password could
 *   not be retrieved for some reason.
 */
char *
vncDecryptPasswd(unsigned char *inouttext)
{
    unsigned char *passwd = (unsigned char *)malloc(9);

    deskey(fixedkey, DE1);
    des(inouttext, passwd);

    passwd[8] = 0;

    return (char *)passwd;
}
开发者ID:daniel-lucio,项目名称:vncrepeater,代码行数:17,代码来源:vncauth.cpp


示例13: desired

/*!
 Initialize the 3LTC_DES-EDE block cipher
 @param key The symmetric key you wish to pass
 @param keylen The key length in bytes
 @param num_rounds The number of rounds desired (0 for default)
 @param skey The key in as scheduled by this function.
 @return CRYPT_OK if successful
 */
static int ltc_des3_setup(const unsigned char *key, unsigned long keylen, int num_rounds,
                        ccecb_ctx * skey)
{
    ltc_des3_keysched *des3;

    des3 = (ltc_des3_keysched *)skey;

    if(num_rounds != 0 && num_rounds != 16) {
        return -1; /* CRYPT_INVALID_ROUNDS; */
    }

    if (keylen != 24) {
        return -1; /* CRYPT_INVALID_KEYSIZE; */
    }

    deskey(key,    EN0, des3->ek[0]);
    deskey(key+8,  DE1, des3->ek[1]);
    deskey(key+16, EN0, des3->ek[2]);

    deskey(key,    DE1, des3->dk[2]);
    deskey(key+8,  EN0, des3->dk[1]);
    deskey(key+16, DE1, des3->dk[0]);

    return 0; /* CRYPT_OK; */
}
开发者ID:randombit,项目名称:hacrypto,代码行数:33,代码来源:ccdes3_ltc_common.c


示例14: cpu_calc_descrypt1

int cpu_calc_descrypt1(u_char *factor, u_char *key, u_char key_id, size_t key_len)
{
	/* DBG("using cpu descrypt.\n"); */

	u_char keybuf[16] = {0};
	u_char factorbuf[16] = {0};

	switch(key_id)
	{
		case 0x0D:
			/* DBG("Gen key, id: 0x0D\n"); */

			memcpy(keybuf, get_netpara()->CardKey, 8);
			memcpy(factorbuf, factor, 8);

			deskey(keybuf, EN0);
			OneDes(factorbuf);
			deskey(factorbuf, EN0);
			OneDes(key);

			return 0;

		case 0x0E:
			/* DBG("Gen key, id: 0x0E\n"); */

			memcpy(keybuf, get_netpara()->CardKey, 12);
			memcpy(factorbuf, factor, 16);
			*((u_int *)(&factorbuf[8])) = ~(*((u_int *)(&factorbuf[0])));
			*((u_int *)(&factorbuf[12])) = ~(*((u_int *)(&factorbuf[4])));

			stntripdes(factorbuf,keybuf);     	/* 分散因子前8字节,密钥 */
			stntripdes(&factorbuf[8],keybuf); 	/* 分散因子后8字节,密钥 */
			stntripdes(key,factorbuf); 			/* 随机数,XdataKeyBuf中是过程密钥 */

			return 0;

		default:
			return -1;
	}
}
开发者ID:FrankSong28,项目名称:carpos-cl1306,代码行数:40,代码来源:pos_psam.c


示例15: memset

int DES::yencrypt ( char key[8], char* data, int size )
{
   if ((!data)||(size<1))
      return 0;

   // The last char of data is bitwise complemented and filled the rest
   // buffer.If size is 16, it will extend to 24,and 17 still 24.
   char lastChar = *(data+size-1);
   int  blocks = size/8+1;
   memset (data+size, ~lastChar, blocks*8-size);
   deskey ( (unsigned char *)key, ENCRYPT );
   return encrypt ( data, data, blocks);
};
开发者ID:nykma,项目名称:ykt4sungard,代码行数:13,代码来源:mydes.cpp


示例16: vncEncryptBytes2

/*
 *   [email protected]
 *   Encrypt bytes[length] in memory using key.
 *   Key has to be 8 bytes, length a multiple of 8 bytes.
*/
void
vncEncryptBytes2(unsigned char *where, const int length, unsigned char *key) {
	int i, j;
	deskey(key, EN0);
	for (i = 0; i< 8; i++)
		where[i] ^= key[i];
	des(where, where);
	for (i = 8; i < length; i += 8) {
		for (j = 0; j < 8; j++)
			where[i + j] ^= where[i + j - 8];
		des(where + i, where + i);
	}
}
开发者ID:chiradeep,项目名称:CloudStack,代码行数:18,代码来源:vncauth.c


示例17: deskey

int CHttpDes::des_cbc_pkcs7_encrypt(uchar* from, int nLength,  uchar * to, uchar key[],uchar iv[])
{
	//uchar buffer[8];
	int nSize = nLength % 8 ?(nLength + 7) / 8 * 8 : nLength + 8;
	if(to == NULL)
	{
		//计算长度
		return nSize;
	}
	else
	{
		deskey(key,EN0);
		uchar preEnc[8];
		memcpy(preEnc,iv,8);

		//加密块
		int i=0;
		for(; i < nSize; i+=8)
		{
			uchar*     ps = from + i;
			uchar*     pd = to + i;

			if(nSize - i > 8)
			{
				//XOR
				for(int j = 0; j < 8; ++j)
				{
					preEnc[j] ^= *(ps + j);
				}
			}
			else
			{
				//XOR
				for(int j = 0; j < nLength - i; ++j)
				{
					preEnc[j] ^= *(ps + j);
				}

				for(int j = nLength - i; j < 8; ++j)
				{
					preEnc[j] ^= nSize - nLength;
				}
			}

			des(preEnc,pd);
			//保存前一个输出
			memcpy(preEnc, pd,8);
		}
		return i;
	}
}
开发者ID:huos3203,项目名称:SISpeciesNotes,代码行数:51,代码来源:HttpDes.cpp


示例18: vncDecryptBytes

/*
 *   [email protected]
 *   Decrypt bytes[length] in memory using key.
 *   Key has to be 8 bytes, length a multiple of 8 bytes.
 */
void
vncDecryptBytes(unsigned char *where, const int length, const unsigned char *key) {
	int i, j;
	deskey((unsigned char*) key, DE1);
	for (i = length - 8; i > 0; i -= 8) {
		des(where + i, where + i);
		for (j = 0; j < 8; j++)
			where[i + j] ^= where[i + j - 8];
	}
	/* i = 0 */
	des (where, where);
	for (i = 0; i < 8; i++)
		where[i] ^= key[i];
}
开发者ID:FrantisekKlika,项目名称:UltraVncAsDll,代码行数:19,代码来源:vncauth.c


示例19: vncDecryptPasswdFromFile2

int
vncDecryptPasswdFromFile2(char *fname,
			  char *passwdFullControl, char *passwdViewOnly)
{
    FILE *fp;
    int i, ch;
    char passwd[16];

    if (strcmp(fname, "-") != 0) {
	if ((fp = fopen(fname,"r")) == NULL)
	    return 0;		/* Could not open the file */
    } else {
	fp = stdin;
    }

    for (i = 0; i < 16; i++) {
	ch = getc(fp);
	if (ch == EOF)
	    break;
	passwd[i] = ch;
    }

    if (fp != stdin)
	fclose(fp);

    if (i < 8)
	return 0;		/* Could not read eight bytes */

    deskey(s_fixedkey, DE1);

    /* Decoding first (full-control) password */
    if (passwdFullControl != NULL) {
	des(passwd, passwd);
	memcpy(passwdFullControl, passwd, 8);
	passwdFullControl[8] = '\0';
    }

    /* Decoding second (view-only) password if available */
    if (i == 16 && passwdViewOnly != NULL) {
	des(&passwd[8], &passwd[8]);
	memcpy(passwdViewOnly, &passwd[8], 8);
	passwdViewOnly[8] = '\0';
    }

    /* Destroying our copy of clear-text passwords */
    memset(passwd, 0, 16);

    return (i < 16) ? 1 : 2;
}
开发者ID:alerque,项目名称:fbvnc,代码行数:49,代码来源:vncauth.c


示例20: des3key

void des3key(uchar *hexkey, short mode, void **ksa)
{
	ulong *ks;
	uchar *first, *third;
	short revmod;

	*ksa = ks = (ulong *)pgp_malloc(96 * sizeof(ulong));

	if(mode == EN0)
	{
		revmod = DE1;
		first = hexkey;
		third = &hexkey[16];
	}
	else
	{
		revmod = EN0;
		first = &hexkey[16];
		third = hexkey;
	}
    deskey(first, mode, ks);
    deskey(&hexkey[8], revmod, &ks[32]);
    deskey(third, mode, &ks[64]);
}
开发者ID:ysangkok,项目名称:pgpfone,代码行数:24,代码来源:des3_68K.c



注:本文中的deskey函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ dest函数代码示例发布时间:2022-05-30
下一篇:
C++ deserializeToken函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap