当前位置: 首页>>代码示例>>C++>>正文


C++ BF_set_key函数代码示例

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


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


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