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

C++ BF_set_key函数代码示例

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

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



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

示例1: malloc

static void *blowfish_init(u_char *sesskey, int len)
{
   struct blowfish_state *state;

   state = malloc(sizeof(*state));
   BF_set_key(&state->key, len, sesskey);
   memset(state->iv, 0, 8);
   return (state);
}
开发者ID:SpiderLabs,项目名称:ettercap,代码行数:9,代码来源:ec_ssh.c


示例2: blowfish_set_key

/* the wrapper functions for blowfish */
static int blowfish_set_key(struct crypto_struct *cipher, void *key){
  if (cipher->key == NULL) {
    if (alloc_key(cipher) < 0) {
      return -1;
    }
    BF_set_key(cipher->key, 16, key);
  }

  return 0;
}
开发者ID:BackupTheBerlios,项目名称:libssh-svn,代码行数:11,代码来源:wrapper.c


示例3: BF_set_key

void CSporeEncrypt::BF_decrypt(const unsigned char *keydata, int keydatalen, unsigned char *in, unsigned char *out, unsigned int inlen)
{
    BF_KEY key;
    unsigned char ivec[32];
    int num = 0;
    // set up for decryption
    BF_set_key(&key, keydatalen, keydata);
    memset(ivec, '\0', 32);
    BF_cfb64_encrypt(in, out, inlen, &key, ivec, &num, BF_DECRYPT);
}
开发者ID:bestustc,项目名称:cpp-common,代码行数:10,代码来源:CSporeEncrypt.cpp


示例4: blowfish_set_key

/* the wrapper functions for blowfish */
static int blowfish_set_key(struct ssh_cipher_struct *cipher, void *key, void *IV){
  if (cipher->key == NULL) {
    if (alloc_key(cipher) < 0) {
      return -1;
    }
    BF_set_key(cipher->key, 16, key);
  }
  cipher->IV = IV;
  return 0;
}
开发者ID:SHLD,项目名称:node-libssh,代码行数:11,代码来源:libcrypto.c


示例5: decrypt_chal

void decrypt_chal(char *chal, char *pwd)
{ 
   register int i;
   BF_KEY key;

   BF_set_key(&key, 16, MD5(pwd,strlen(pwd),NULL));

   for(i=0; i < VTUN_CHAL_SIZE; i += 8 )
      BF_ecb_encrypt(chal + i,  chal + i, &key, BF_DECRYPT);
}
开发者ID:huangmingyou,项目名称:vtun,代码行数:10,代码来源:auth.c


示例6: bf_ssh1_init

static void bf_ssh1_init (EVP_CIPHER_CTX * ctx, const unsigned char *key,
			  const unsigned char *iv, int enc)
{
	if (iv != NULL)
		memcpy (&(ctx->oiv[0]), iv, 8);
	memcpy (&(ctx->iv[0]), &(ctx->oiv[0]), 8);
	if (key != NULL)
		BF_set_key (&(ctx->c.bf_ks), EVP_CIPHER_CTX_key_length (ctx),
			    key);
}
开发者ID:andreiw,项目名称:polaris,代码行数:10,代码来源:cipher.c


示例7: calloc

unsigned char *bf_str_encrypt(unsigned char * str)
{

    if(!strlen(str))
        return ".";

    unsigned char *ptr=str;
    unsigned char *encrypt=(unsigned char *)malloc(sizeof(char)*512);
    unsigned char *tmp=(unsigned char *)malloc(sizeof(char)*9);
    unsigned char *out = calloc(9, sizeof(unsigned char *));

    BF_KEY *key = calloc(9, 9);
    BF_set_key(key, SIZE, (const unsigned char*)"TestKey" );

    unsigned int jmp=0,counter=0;

    bzero(encrypt,512);

    while(*ptr != '\0' && counter != 512)
    {
        *(tmp+jmp)=*ptr;
        if(jmp==7)
        {
            BF_ecb_encrypt(tmp, out, key, BF_ENCRYPT);
            strcat(encrypt,out);
            bzero(out,9);
            bzero(tmp,9);
            jmp=-1;
        }
        ptr++;
        jmp++;
        counter++;
    }

    if(strlen(tmp)<=8)
    {
        bzero(out,9);
        while(strlen(tmp)<7)
            strcat(tmp,".");
        BF_ecb_encrypt(tmp, out, key, BF_ENCRYPT);
        strcat(encrypt,out);
    }


    bzero(out,9);
    bzero(tmp,9);
    if(out)
        free(out);
    if(tmp)
        free(tmp);

    fprintf(stdout,"Result %s\n",encrypt);

    return encrypt;
}
开发者ID:CoolerVoid,项目名称:libopenssl_study,代码行数:55,代码来源:blowfish_encrypt_decrypt_str.c


示例8: blf_setkey

static int
blf_setkey(u_int8_t **sched, const u_int8_t *key, int len)
{

	*sched = malloc(sizeof(BF_KEY),
		M_CRYPTO_DATA, M_NOWAIT|M_ZERO);
	if (*sched == NULL)
		return ENOMEM;
	BF_set_key((BF_KEY *) *sched, len, key);
	return 0;
}
开发者ID:ryo,项目名称:netbsd-src,代码行数:11,代码来源:cryptosoft_xform.c


示例9: malloc

static void *blowfish_init(u_char *sesskey, int len)
{
   struct blowfish_state *state;

   state = malloc(sizeof(*state));
   if (state == NULL) /* oops, couldn't allocate memory */
      return NULL;
   BF_set_key(&state->key, len, sesskey);
   memset(state->iv, 0, 8);
   return (state);
}
开发者ID:NickSampanis,项目名称:ettercap,代码行数:11,代码来源:ec_ssh.c


示例10: getPacketSize

bool Packet::encodeBlowfish( bool bUseStaticBFKey )
{
	unsigned char *buf = this->b.getBytesPtr();
	if( !buf ) return false;
	unsigned int blen = getPacketSize();
	if( blen < 1 ) return false;

	BF_KEY bfkey;
	if( bUseStaticBFKey )
		BF_set_key( &bfkey, (int)this->STATIC_BLOWFISH_KEY_LEN,
			this->STATIC_BLOWFISH_KEY );
	else
		BF_set_key( &bfkey, (int)this->NEW_BLOWFISH_KEY_LEN,
			this->NEW_BLOWFISH_KEY );
	
	unsigned int offset = 0;
	int nPasses = 0;

	unsigned char outbuf [1024];

/*	if( !outbuf )
	{
		return false;
	}
*/
	memset( outbuf, 0, blen );
	outbuf[0] = buf[0];
	outbuf[1] = buf[1];

	for( offset=2; offset<real_size-2; offset+=8 )
	{
		unsigned char data[8] = {0,0,0,0,0,0,0,0};
		memcpy( data, buf+offset, 8 );
		BF_encrypt( (BF_LONG *)data, &bfkey );
		memcpy( outbuf+offset, data, 8 );
		nPasses++;
	}	
	this->setBytes( outbuf, blen );

	return true;
}
开发者ID:aronarts,项目名称:FireNET,代码行数:41,代码来源:Packets.cpp


示例11: main

int main(void)
{
    int     i;
    BF_KEY  key;
    BIO*    bio_out;

    static unsigned char key_data[BF_KEY_LENGTH] = {
        0x52,0x69,0xf1,0x49,0xd4,0x1b,0xa0,0x15,
        0x24,0x97,0x57,0x4d,0x7f,0x15,0x31,0x25
    };

    unsigned char   ciphertext[BF_BLOCK];
    unsigned char   plaintext[BF_BLOCK];

    /* Open SSL's DES ECB encrypt/decrypt function only handles 8 bytes of data */
    char* data_to_encrypt = "8 Bytes.";

    /* set the key structure using the predefined key */
    BF_set_key(&key, BF_KEY_LENGTH, key_data);

    BF_ecb_encrypt(data_to_encrypt, ciphertext, &key, BF_ENCRYPT); 

    bio_out = BIO_new_fp(stdout, BIO_NOCLOSE);

    BIO_printf(bio_out, "Original plaintext: %s\n", data_to_encrypt);

    BIO_printf(bio_out, "Ciphertext: ");

    /* print out the ciphertext */
    for (i = 0; i < BF_BLOCK; i++)
        BIO_printf(bio_out, "%02x", ((unsigned char*)ciphertext)[i]);

    BIO_printf(bio_out, "\n");

    /* start the decryption process */
    BF_ecb_encrypt(ciphertext, plaintext, &key, BF_DECRYPT);

    BIO_printf(bio_out, "Recovered plaintext: ");
    
    /* print out the plaintext */
    for (i = 0; i < BF_BLOCK; i++)
        BIO_printf(bio_out, "%c", ((unsigned char*)plaintext)[i]);

    BIO_printf(bio_out, "\n");

    BIO_free(bio_out);

	free(ciphertext);
	free(plaintext);
   
    return 0;

}
开发者ID:akandiah,项目名称:openssl-samples,代码行数:53,代码来源:bf_ecb_128.c


示例12: blf_setkey

static int
blf_setkey(u_int8_t **sched, u_int8_t *key, int len)
{
	int err;

	*sched = kmalloc(sizeof(BF_KEY), M_CRYPTO_DATA, M_INTWAIT | M_ZERO);
	if (*sched != NULL) {
		BF_set_key((BF_KEY *) *sched, len, key);
		err = 0;
	} else
		err = ENOMEM;
	return err;
}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:13,代码来源:xform.c


示例13: blowfish_init

void *
blowfish_init(u_char *sesskey, int len)
{
	struct blowfish_state *state;

	if ((state = malloc(sizeof(*state))) == NULL)
		err(1, "malloc");
	
	BF_set_key(&state->key, len, sesskey);
	memset(state->iv, 0, 8);

	return (state);
}
开发者ID:IFGHou,项目名称:dsniff,代码行数:13,代码来源:sshcrypto.c


示例14: bf_init

static int
bf_init(PX_Cipher * c, const uint8 *key, unsigned klen, const uint8 *iv)
{
	ossldata   *od = c->ptr;

	BF_set_key(&od->u.bf.key, klen, key);
	if (iv)
		memcpy(od->iv, iv, BF_BLOCK);
	else
		memset(od->iv, 0, BF_BLOCK);
	od->u.bf.num = 0;
	return 0;
}
开发者ID:jaiminpan,项目名称:bizgres,代码行数:13,代码来源:openssl.c


示例15: test_bf_set_key

static int test_bf_set_key(int n)
{
    int ret = 1;
    BF_KEY key;
    unsigned char out[8];

    BF_set_key(&key, n+1, key_test);
    BF_ecb_encrypt(key_data, out, &key, BF_ENCRYPT);
    /* mips-sgi-irix6.5-gcc  vv  -mabi=64 bug workaround */
    if (!TEST_mem_eq(out, 8, &(key_out[n][0]), 8))
        ret = 0;

    return ret;
}
开发者ID:lookfun,项目名称:openssl,代码行数:14,代码来源:bftest.c


示例16: main

int main(int argc, char *argv[]) {
    char *interface;
    pcap_t *p;
    int i;

    if (argc < 3 || strncmp(argv[1], "-h", 2) == 0)
        help(argv[0]);

    while ((i = getopt(argc, argv, "rk:")) >= 0) {
        switch (i) {
        case 'r':
            rawmode = 1;
            thc_ipv6_rawmode(1);
            break;
        case 'k':
            key = optarg;
            break;
        default:
            fprintf(stderr, "Unknown option\n");
            exit(-1);
        }
    }

    interface = argv[optind];
    if ((f = fopen(argv[optind + 1], "w")) == NULL) {
        fprintf(stderr, "Error: file %s cout not be created\n", argv[optind + 1]);
        exit(-1);
    }

    if (key != NULL) {
        memset(&bfkey, 0, sizeof(bfkey));
        SHA1((unsigned char *) key, strlen(key), (unsigned char *) hash);
        BF_set_key(&bfkey, sizeof(hash), (unsigned char *) hash);
        memset(vec, 0, sizeof(vec));
        num = 0;
    }

    if ((p = thc_pcap_init(interface, "ip6")) == NULL) {
        fprintf(stderr, "Error: could not capture on interface %s\n", interface);
        exit(-1);
    }

    while (1) {
        thc_pcap_check(p, (char *) check_packets, NULL);
        usleep(50);
    }

    return 0;
}
开发者ID:security-geeks,项目名称:thc-ipv6,代码行数:49,代码来源:covert_send6d.c


示例17: bf_chunk

static void bf_chunk(unsigned char *dst, const unsigned char *src,
		const unsigned char *secret, int enc)
{
	BF_KEY bf_key;
	int i;

	BF_set_key(&bf_key, CHUNK_SIZE, secret);

	/* BF_ecb_encrypt works with 64bits at a time */
	for (i = 0; i < CHUNK_SIZE/8; i ++) {
		BF_ecb_encrypt(src, dst, &bf_key, enc);
		src += 8;
		dst += 8;
	}
}
开发者ID:dayne,项目名称:zunkfs,代码行数:15,代码来源:dir.c


示例18: OS_BF_Str

int OS_BF_Str(char *input, char *output, char *charkey, 
                long size, short int action)
{
    BF_KEY key;
    static unsigned char cbc_iv [8]={0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10};
    unsigned char iv[8];

    memcpy(iv,cbc_iv,sizeof(iv));

    BF_set_key(&key, strlen(charkey), (uchar *)charkey);

    BF_cbc_encrypt((uchar *)input, (uchar *)output, size,
            &key, iv, action);

    return(1);
}
开发者ID:alexoslabs,项目名称:ossec-hids,代码行数:16,代码来源:bf_op.c


示例19: do_encrypt

static
void do_encrypt(apr_pool_t *p, const char *key, char *str, int len, int enc)
{
	apr_md5_ctx_t my_md5;
	unsigned char *hash = apr_pcalloc(p, APR_MD5_DIGESTSIZE);

	apr_md5_init(&my_md5);
	apr_md5_update(&my_md5, key, (unsigned int)len);
	apr_md5_final(hash, &my_md5);

	BF_KEY my_bf;
	BF_set_key(&my_bf, APR_MD5_DIGESTSIZE, hash);

	int num = 0;
	unsigned char iv[8] = {0,0,0,0,0,0,0,0};
	BF_cfb64_encrypt(str, str, len, &my_bf, iv, &num, enc);
}
开发者ID:hollow,项目名称:mod_log_spread2,代码行数:17,代码来源:mod_log_spread2.c


示例20: SRNG_init

unsigned int SRNG_init(struct SRNG_st *st)
{
	if(!st)
		goto end;

	if(!RAND_bytes(st->keydata, sizeof(st->keydata))
	|| !RAND_bytes(st->rnd, sizeof(st->rnd))) {
		ERR_print_errors_fp(stderr);
		Throw(lib_crypto_exception);
	}

	BF_set_key(&st->key, sizeof(st->keydata), st->keydata);
	st->idx = 0;

end:
	return sizeof(struct SRNG_st);
}
开发者ID:itoffshore,项目名称:secpwgen,代码行数:17,代码来源:secure_random_openssl.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ BG函数代码示例发布时间:2022-05-30
下一篇:
C++ BF_WriteByte函数代码示例发布时间: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