您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ BN_GENCB_call函数代码示例

51自学网 2021-06-01 19:51:34
  C++
这篇教程C++ BN_GENCB_call函数代码示例写得很实用,希望能帮到您。

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

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

示例1: BN_is_prime_fasttest_ex

int BN_is_prime_fasttest_ex(const BIGNUM *a, int checks, BN_CTX *ctx,                            int do_trial_division, BN_GENCB *cb) {  if (BN_cmp(a, BN_value_one()) <= 0) {    return 0;  }  /* first look for small factors */  if (!BN_is_odd(a)) {    /* a is even => a is prime if and only if a == 2 */    return BN_is_word(a, 2);  }  /* Enhanced Miller-Rabin does not work for three. */  if (BN_is_word(a, 3)) {    return 1;  }  if (do_trial_division) {    for (int i = 1; i < NUMPRIMES; i++) {      BN_ULONG mod = BN_mod_word(a, primes[i]);      if (mod == (BN_ULONG)-1) {        return -1;      }      if (mod == 0) {        return BN_is_word(a, primes[i]);      }    }    if (!BN_GENCB_call(cb, 1, -1)) {      return -1;    }  }  int ret = -1;  BN_CTX *ctx_allocated = NULL;  if (ctx == NULL) {    ctx_allocated = BN_CTX_new();    if (ctx_allocated == NULL) {      return -1;    }    ctx = ctx_allocated;  }  enum bn_primality_result_t result;  if (!BN_enhanced_miller_rabin_primality_test(&result, a, checks, ctx, cb)) {    goto err;  }  ret = (result == bn_probably_prime);err:  BN_CTX_free(ctx_allocated);  return ret;}
开发者ID:ThomasWo,项目名称:proto-quic,代码行数:54,


示例2: bn_x931_derive_pi

static int bn_x931_derive_pi(BIGNUM *pi, const BIGNUM *Xpi, BN_CTX *ctx,                             BN_GENCB *cb){    int i = 0;    if (!BN_copy(pi, Xpi))        return 0;    if (!BN_is_odd(pi) && !BN_add_word(pi, 1))        return 0;    for (;;) {        i++;        BN_GENCB_call(cb, 0, i);        /* NB 27 MR is specificed in X9.31 */        if (BN_is_prime_fasttest_ex(pi, 27, ctx, 1, cb))            break;        if (!BN_add_word(pi, 2))            return 0;    }    BN_GENCB_call(cb, 2, i);    return 1;}
开发者ID:AndreV84,项目名称:openssl,代码行数:20,


示例3: BN_is_prime_fasttest_ex

/* See FIPS 186-4 C.3.1 Miller Rabin Probabilistic Primality Test. */int BN_is_prime_fasttest_ex(const BIGNUM *w, int checks, BN_CTX *ctx_passed,                            int do_trial_division, BN_GENCB *cb){    int i, status, ret = -1;    BN_CTX *ctx = NULL;    /* w must be bigger than 1 */    if (BN_cmp(w, BN_value_one()) <= 0)        return 0;    /* w must be odd */    if (BN_is_odd(w)) {        /* Take care of the really small prime 3 */        if (BN_is_word(w, 3))            return 1;    } else {        /* 2 is the only even prime */        return BN_is_word(w, 2);    }    /* first look for small factors */    if (do_trial_division) {        for (i = 1; i < NUMPRIMES; i++) {            BN_ULONG mod = BN_mod_word(w, primes[i]);            if (mod == (BN_ULONG)-1)                return -1;            if (mod == 0)                return BN_is_word(w, primes[i]);        }        if (!BN_GENCB_call(cb, 1, -1))            return -1;    }    if (ctx_passed != NULL)        ctx = ctx_passed;    else if ((ctx = BN_CTX_new()) == NULL)        goto err;    ret = bn_miller_rabin_is_prime(w, checks, ctx, cb, 0, &status);    if (!ret)        goto err;    ret = (status == BN_PRIMETEST_PROBABLY_PRIME);err:    if (ctx_passed == NULL)        BN_CTX_free(ctx);    return ret;}
开发者ID:Ana06,项目名称:openssl,代码行数:47,


示例4: BN_generate_prime_ex

int BN_generate_prime_ex(BIGNUM *ret, int bits, int safe,	const BIGNUM *add, const BIGNUM *rem, BN_GENCB *cb)	{	BIGNUM *t;	int found=0;	int i,j,c1=0;	BN_CTX *ctx;	int checks = BN_prime_checks_for_size(bits);	if (bits < 2)		{		/* There are no prime numbers this small. */		BNerr(BN_F_BN_GENERATE_PRIME_EX, BN_R_BITS_TOO_SMALL);		return 0;		}	else if (bits == 2 && safe)		{		/* The smallest safe prime (7) is three bits. */		BNerr(BN_F_BN_GENERATE_PRIME_EX, BN_R_BITS_TOO_SMALL);		return 0;		}	ctx=BN_CTX_new();	if (ctx == NULL) goto err;	BN_CTX_start(ctx);	t = BN_CTX_get(ctx);	if(!t) goto err;loop: 	/* make a random number and set the top and bottom bits */	if (add == NULL)		{		if (!probable_prime(ret,bits)) goto err;		}	else		{		if (safe)			{			if (!probable_prime_dh_safe(ret,bits,add,rem,ctx))				 goto err;			}		else			{			if (!bn_probable_prime_dh(ret,bits,add,rem,ctx))				goto err;			}		}	/* if (BN_mod_word(ret,(BN_ULONG)3) == 1) goto loop; */	if(!BN_GENCB_call(cb, 0, c1++))		/* aborted */		goto err;	if (!safe)		{		i=BN_is_prime_fasttest_ex(ret,checks,ctx,0,cb);		if (i == -1) goto err;		if (i == 0) goto loop;		}	else		{		/* for "safe prime" generation,		 * check that (p-1)/2 is prime.		 * Since a prime is odd, We just		 * need to divide by 2 */		if (!BN_rshift1(t,ret)) goto err;		for (i=0; i<checks; i++)			{			j=BN_is_prime_fasttest_ex(ret,1,ctx,0,cb);			if (j == -1) goto err;			if (j == 0) goto loop;			j=BN_is_prime_fasttest_ex(t,1,ctx,0,cb);			if (j == -1) goto err;			if (j == 0) goto loop;			if(!BN_GENCB_call(cb, 2, c1-1))				goto err;			/* We have a safe prime test pass */			}		}	/* we have a prime :-) */	found = 1;err:	if (ctx != NULL)		{		BN_CTX_end(ctx);		BN_CTX_free(ctx);		}	bn_check_top(ret);	return found;	}
开发者ID:Acidburn0zzz,项目名称:openssl,代码行数:91,


示例5: generate_prime

// generate_prime sets |out| to a prime with length |bits| such that |out|-1 is// relatively prime to |e|. If |p| is non-NULL, |out| will also not be close to// |p|. |sqrt2| must be 
C++ BN_GENCB_set函数代码示例
C++ BN_CTX_start函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。