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

C++ RAND_get_rand_method函数代码示例

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

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



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

示例1: RAND_add

void RAND_add(const void *buf, int num, double randomness)
{
    const RAND_METHOD *meth = RAND_get_rand_method();

    if (meth->add != NULL)
        meth->add(buf, num, randomness);
}
开发者ID:nmathewson,项目名称:openssl,代码行数:7,代码来源:rand_lib.c


示例2: RAND_status

int RAND_status(void)
{
    const RAND_METHOD *meth = RAND_get_rand_method();
    if (meth && meth->status)
        return meth->status();
    return 0;
}
开发者ID:vathpela,项目名称:mallory,代码行数:7,代码来源:rand_lib.c


示例3: init_openssl_rand

/*
 * OpenSSL random should re-feeded occasionally. From /dev/urandom
 * preferably.
 */
static void
init_openssl_rand(void)
{
	if (RAND_get_rand_method() == NULL)
		RAND_set_rand_method(RAND_SSLeay());
	openssl_random_init = 1;
}
开发者ID:Epictetus,项目名称:postgres,代码行数:11,代码来源:openssl.c


示例4: RAND_cleanup

void RAND_cleanup(void)
{
    const RAND_METHOD *meth = RAND_get_rand_method();
    if (meth && meth->cleanup)
        meth->cleanup();
    RAND_set_rand_method(NULL);
}
开发者ID:GarikRC,项目名称:openssl,代码行数:7,代码来源:rand_lib.c


示例5: RAND_seed

void RAND_seed(const void *buf, int num)
{
    const RAND_METHOD *meth = RAND_get_rand_method();

    if (meth->seed != NULL)
        meth->seed(buf, num);
}
开发者ID:nmathewson,项目名称:openssl,代码行数:7,代码来源:rand_lib.c


示例6: verify_rng

 void verify_rng()
 {
   auto* rm = RAND_get_rand_method();
   int random_value = 0;
   int rc = RAND_bytes((uint8_t*) &random_value, sizeof(random_value));
   assert(rc == 0 || rc == 1);
 }
开发者ID:RicoAntonioFelix,项目名称:IncludeOS,代码行数:7,代码来源:init.cpp


示例7: RAND_pseudo_bytes

int RAND_pseudo_bytes(unsigned char *buf, int num)
{
    const RAND_METHOD *meth = RAND_get_rand_method();
    if (meth && meth->pseudorand)
        return meth->pseudorand(buf, num);
    return (-1);
}
开发者ID:vathpela,项目名称:mallory,代码行数:7,代码来源:rand_lib.c


示例8: RAND_add

void RAND_add(const void *buf, int num, long entropy)
#endif
	{
	const RAND_METHOD *meth = RAND_get_rand_method();
	if (meth && meth->add)
		meth->add(buf,num,entropy);
	}
开发者ID:imgits,项目名称:rkanalyzer,代码行数:7,代码来源:rand_lib.c


示例9: RAND_bytes

int RAND_bytes(unsigned char *buf, int num)
{
    const RAND_METHOD *meth = RAND_get_rand_method();
    memset(buf, 0, num);
    if (meth && meth->bytes)
        return meth->bytes(buf,num);
    return(-1);
}
开发者ID:peterlingoal,项目名称:openssl,代码行数:8,代码来源:rand_lib.c


示例10: RAND_bytes

int RAND_bytes(unsigned char *buf, int num)
{
    const RAND_METHOD *meth = RAND_get_rand_method();

    if (meth->bytes != NULL)
        return meth->bytes(buf, num);
    RANDerr(RAND_F_RAND_BYTES, RAND_R_FUNC_NOT_IMPLEMENTED);
    return -1;
}
开发者ID:nmathewson,项目名称:openssl,代码行数:9,代码来源:rand_lib.c


示例11: RAND_cleanup

void RAND_cleanup(void)
	{
	const RAND_METHOD *meth = RAND_get_rand_method();
	if (meth && meth->cleanup)
		meth->cleanup();
#ifndef OPERA_SMALL_VERSION
	RAND_set_rand_method(NULL);
#endif // !OPERA_SMALL_VERSION
	}
开发者ID:prestocore,项目名称:browser,代码行数:9,代码来源:rand_lib.c


示例12: init_rand

  static bool
  init_rand ()
  {
#define BUFSZ 40
    unsigned char foo[BUFSZ];
    RAND_get_rand_method() ->bytes (foo, BUFSZ);
#undef BUFSZ
    return true;
  }
开发者ID:Keloran,项目名称:okws,代码行数:9,代码来源:util.C


示例13: __shadow_plugin_init__

/* called after g_module_check_init(), after shadow searches for __shadow_plugin_init__ */
void __shadow_plugin_init__(ShadowFunctionTable* shadowlibFuncs) {
	/* save the shadow functions we will use */
	scallion.shadowlibFuncs = shadowlibFuncs;

	/* tell shadow which functions it should call to manage nodes */
	shadowlibFuncs->registerPlugin(&_scallion_new, &_scallion_free, &_scallion_notify);

	shadowlibFuncs->log(SHADOW_LOG_LEVEL_INFO, __FUNCTION__, "finished registering scallion plug-in state");

	/* setup openssl locks */

#define OPENSSL_THREAD_DEFINES
#include <openssl/opensslconf.h>
#if defined(OPENSSL_THREADS)
	/* thread support enabled */

	/* make sure openssl uses Shadow's random sources and make crypto thread-safe */
	const RAND_METHOD* shadowRandomMethod = NULL;
	CRYPTO_lock_func shadowLockFunc = NULL;
	CRYPTO_id_func shadowIdFunc = NULL;
	int nLocks = CRYPTO_num_locks();

	gboolean success = shadowlibFuncs->cryptoSetup(nLocks, (gpointer*)&shadowLockFunc,
			(gpointer*)&shadowIdFunc, (gconstpointer*)&shadowRandomMethod);
	if(!success) {
		/* ok, lets see if we can get shadow function pointers through LD_PRELOAD */
		shadowRandomMethod = RAND_get_rand_method();
		shadowLockFunc = CRYPTO_get_locking_callback();
		shadowIdFunc = CRYPTO_get_id_callback();
	}

	CRYPTO_set_locking_callback(shadowLockFunc);
	CRYPTO_set_id_callback(shadowIdFunc);
	RAND_set_rand_method(shadowRandomMethod);

	shadowlibFuncs->log(SHADOW_LOG_LEVEL_INFO, __FUNCTION__, "finished initializing crypto thread state");
#else
    /* no thread support */
	shadowlibFuncs->log(SHADOW_LOG_LEVEL_CRITICAL, __FUNCTION__, "please rebuild openssl with threading support. expect segfaults.");
#endif

	/* setup libevent locks */

#ifdef EVTHREAD_USE_PTHREADS_IMPLEMENTED
	if(evthread_use_pthreads()) {
		shadowlibFuncs->log(SHADOW_LOG_LEVEL_CRITICAL, __FUNCTION__, "error in evthread_use_pthreads()");
	}
	shadowlibFuncs->log(SHADOW_LOG_LEVEL_MESSAGE, __FUNCTION__, "finished initializing event thread state evthread_use_pthreads()");
#else
	shadowlibFuncs->log(SHADOW_LOG_LEVEL_CRITICAL, __FUNCTION__, "please rebuild libevent with threading support, or link with event_pthread. expect segfaults.");
#endif
}
开发者ID:Wegi,项目名称:shadow-plugin-tor,代码行数:53,代码来源:tor-plugin.c


示例14: RAND_priv_bytes

/*
 * This function is not part of RAND_METHOD, so if we're not using
 * the default method, then just call RAND_bytes().  Otherwise make
 * sure we're instantiated and use the private DRBG.
 */
int RAND_priv_bytes(unsigned char *buf, int num)
{
    const RAND_METHOD *meth = RAND_get_rand_method();

    if (meth != RAND_OpenSSL())
        return RAND_bytes(buf, num);

    if (priv_drbg.state == DRBG_UNINITIALISED
            && RAND_DRBG_instantiate(&priv_drbg, NULL, 0) == 0)
        return 0;
    return RAND_DRBG_generate(&priv_drbg, buf, num, 0, NULL, 0);

}
开发者ID:Vonage,项目名称:openssl,代码行数:18,代码来源:rand_lib.c


示例15: init_openssl_rand

/*
 * OpenSSL random should re-feeded occasionally. From /dev/urandom
 * preferably.
 */
static void
init_openssl_rand(void)
{
	if (RAND_get_rand_method() == NULL)
	{
#ifdef HAVE_RAND_OPENSSL
		RAND_set_rand_method(RAND_OpenSSL());
#else
		RAND_set_rand_method(RAND_SSLeay());
#endif
	}
	openssl_random_init = 1;
}
开发者ID:cconvey,项目名称:postgres,代码行数:17,代码来源:openssl.c


示例16: RAND_priv_bytes

/*
 * This function is not part of RAND_METHOD, so if we're not using
 * the default method, then just call RAND_bytes().  Otherwise make
 * sure we're instantiated and use the private DRBG.
 */
int RAND_priv_bytes(unsigned char *buf, int num)
{
    const RAND_METHOD *meth = RAND_get_rand_method();
    RAND_DRBG *drbg;

    if (meth != RAND_OpenSSL())
        return RAND_bytes(buf, num);

    drbg = RAND_DRBG_get0_priv_global();
    if (drbg == NULL)
        return 0;

    return RAND_DRBG_generate(drbg, buf, num, 0, NULL, 0);
}
开发者ID:danielctull-forks,项目名称:openssl,代码行数:19,代码来源:rand_lib.c


示例17: genuid_rand_openssl

static gboolean
genuid_rand_openssl (guchar *buffer, int length)
{
	static RAND_METHOD *rm = NULL;

	INC_LOCK();
	if (!rm)
		rm = RAND_get_rand_method ();
	INC_UNLOCK();

	RAND_bytes (buffer, length);

	return TRUE;
}
开发者ID:OS2World,项目名称:SYSTEM-OS-Voyager,代码行数:14,代码来源:genrand.c


示例18: change_rand

static int change_rand(void)
{
    /* save old rand method */
    if (!TEST_ptr(old_rand = RAND_get_rand_method()))
        return 0;

    fake_rand = *old_rand;
    /* use own random function */
    fake_rand.bytes = fbytes;
    /* set new RAND_METHOD */
    if (!TEST_true(RAND_set_rand_method(&fake_rand)))
        return 0;
    return 1;
}
开发者ID:Vonage,项目名称:openssl,代码行数:14,代码来源:ecdsatest.c


示例19: RAND_poll

/*
 * RAND_poll() reseeds the default RNG using random input
 *
 * The random input is obtained from polling various entropy
 * sources which depend on the operating system and are
 * configurable via the --with-rand-seed configure option.
 */
int RAND_poll(void)
{
    int ret = 0;

    RAND_POOL *pool = NULL;

    const RAND_METHOD *meth = RAND_get_rand_method();

    if (meth == RAND_OpenSSL()) {
        /* fill random pool and seed the master DRBG */
        RAND_DRBG *drbg = RAND_DRBG_get0_master();

        if (drbg == NULL)
            return 0;

        CRYPTO_THREAD_write_lock(drbg->lock);
        ret = rand_drbg_restart(drbg, NULL, 0, 0);
        CRYPTO_THREAD_unlock(drbg->lock);

        return ret;

    } else {
        /* fill random pool and seed the current legacy RNG */
        pool = RAND_POOL_new(RAND_DRBG_STRENGTH,
                             RAND_DRBG_STRENGTH / 8,
                             DRBG_MINMAX_FACTOR * (RAND_DRBG_STRENGTH / 8));
        if (pool == NULL)
            return 0;

        if (RAND_POOL_acquire_entropy(pool) == 0)
            goto err;

        if (meth->add == NULL
            || meth->add(RAND_POOL_buffer(pool),
                         RAND_POOL_length(pool),
                         (RAND_POOL_entropy(pool) / 8.0)) == 0)
            goto err;

        ret = 1;
    }

err:
    RAND_POOL_free(pool);
    return ret;
}
开发者ID:nmathewson,项目名称:openssl,代码行数:52,代码来源:rand_lib.c


示例20: change_rand

int change_rand(void)
{
    /* save old rand method */
    if ((old_rand = RAND_get_rand_method()) == NULL)
        return 0;

    fake_rand.seed = old_rand->seed;
    fake_rand.cleanup = old_rand->cleanup;
    fake_rand.add = old_rand->add;
    fake_rand.status = old_rand->status;
    /* use own random function */
    fake_rand.bytes = fbytes;
    fake_rand.pseudorand = old_rand->bytes;
    /* set new RAND_METHOD */
    if (!RAND_set_rand_method(&fake_rand))
        return 0;
    return 1;
}
开发者ID:bbidd985,项目名称:IEEE_Taggant_System,代码行数:18,代码来源:ecdsatest.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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