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

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

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

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

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

示例1: pr_fact

/* * pr_fact - print the factors of a number * * Print the factors of the number, from the lowest to the highest. * A factor will be printed multiple times if it divides the value * multiple times. * * Factors are printed with leading tabs. */static voidpr_fact(BIGNUM *val){	const ubig *fact;	/* The factor found. */	/* Firewall - catch 0 and 1. */	if (BN_is_zero(val))	/* Historical practice; 0 just exits. */		exit(0);	if (BN_is_one(val)) {		printf("1: 1/n");		return;	}	/* Factor value. */	if (hflag) {		fputs("0x", stdout);		BN_print_fp(stdout, val);	} else		BN_print_dec_fp(stdout, val);	putchar(':');	for (fact = &prime[0]; !BN_is_one(val); ++fact) {		/* Look for the smallest factor. */		do {			if (BN_mod_word(val, (BN_ULONG)*fact) == 0)				break;		} while (++fact <= pr_limit);		/* Watch for primes larger than the table. */		if (fact > pr_limit) {#ifdef HAVE_OPENSSL			BIGNUM *bnfact;			bnfact = BN_new();			BN_set_word(bnfact, *(fact - 1));			if (!BN_sqr(bnfact, bnfact, ctx))				errx(1, "error in BN_sqr()");			if (BN_cmp(bnfact, val) > 0 ||			    BN_is_prime(val, PRIME_CHECKS,					NULL, NULL, NULL) == 1)				pr_print(val);			else				pollard_pminus1(val);#else			pr_print(val);#endif			break;		}		/* Divide factor out until none are left. */		do {			printf(hflag ? " 0x%lx" : " %lu", *fact);			BN_div_word(val, (BN_ULONG)*fact);		} while (BN_mod_word(val, (BN_ULONG)*fact) == 0);		/* Let the user know we're doing something. */		fflush(stdout);	}	putchar('/n');}
开发者ID:edgar-pek,项目名称:PerspicuOS,代码行数:69,


示例2: BN_mod_mul

/* slow but works */intBN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m,    BN_CTX *ctx){	BIGNUM *t;	int ret = 0;	bn_check_top(a);	bn_check_top(b);	bn_check_top(m);	BN_CTX_start(ctx);	if ((t = BN_CTX_get(ctx)) == NULL)		goto err;	if (a == b) {		if (!BN_sqr(t, a, ctx))			goto err;	} else {		if (!BN_mul(t, a,b, ctx))			goto err;	}	if (!BN_nnmod(r, t,m, ctx))		goto err;	bn_check_top(r);	ret = 1;err:	BN_CTX_end(ctx);	return (ret);}
开发者ID:Basskrapfen,项目名称:openbsd,代码行数:31,


示例3: BN_mod_sqr

int BN_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx){    if (!BN_sqr(r, a, ctx))        return 0;    /* r->neg == 0,  thus we don't need BN_nnmod */    return BN_mod(r, r, m, ctx);}
开发者ID:1234-,项目名称:openssl,代码行数:7,


示例4: BN_mod_mul_montgomery

int BN_mod_mul_montgomery(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,			  BN_MONT_CTX *mont, BN_CTX *ctx)	{	BIGNUM *tmp;	int ret=0;	BN_CTX_start(ctx);	tmp = BN_CTX_get(ctx);	if (tmp == NULL) goto err;	bn_check_top(tmp);	if (a == b)		{		if (!BN_sqr(tmp,a,ctx)) goto err;		}	else		{		if (!BN_mul(tmp,a,b,ctx)) goto err;		}	/* reduce from aRR to aR */	if (!BN_from_montgomery(r,tmp,mont,ctx)) goto err;	bn_check_top(r);	ret=1;err:	BN_CTX_end(ctx);	return(ret);	}
开发者ID:siredblood,项目名称:tree-bumpkin-project,代码行数:27,


示例5: ec_GFp_nist_field_sqr

int ec_GFp_nist_field_sqr(const EC_GROUP * group, BIGNUM * r, const BIGNUM * a,    BN_CTX * ctx){	int ret = 0;	BN_CTX *ctx_new = NULL;	if (!group || !r || !a) {		ECerr(EC_F_EC_GFP_NIST_FIELD_SQR, EC_R_PASSED_NULL_PARAMETER);		goto err;	}	if (!ctx)		if ((ctx_new = ctx = BN_CTX_new()) == NULL)			goto err;	if (!BN_sqr(r, a, ctx))		goto err;	if (!group->field_mod_func(r, r, &group->field, ctx))		goto err;	ret = 1;err:	if (ctx_new)		BN_CTX_free(ctx_new);	return ret;}
开发者ID:DiamondLovesYou,项目名称:libressl-pnacl-sys,代码行数:26,


示例6: BN_mod_mul_reciprocal

int BN_mod_mul_reciprocal(BIGNUM *r, const BIGNUM *x, const BIGNUM *y,                          BN_RECP_CTX *recp, BN_CTX *ctx){    int ret = 0;    BIGNUM *a;    const BIGNUM *ca;    BN_CTX_start(ctx);    if ((a = BN_CTX_get(ctx)) == NULL)        goto err;    if (y != NULL) {        if (x == y) {            if (!BN_sqr(a, x, ctx))                goto err;        } else {            if (!BN_mul(a, x, y, ctx))                goto err;        }        ca = a;    } else        ca = x;                 /* Just do the mod */    ret = BN_div_recp(NULL, r, ca, recp, ctx); err:    BN_CTX_end(ctx);    bn_check_top(r);    return ret;}
开发者ID:isaracorp,项目名称:openssl,代码行数:28,


示例7: BN_exp

int BN_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx) {  int i, bits, ret = 0;  BIGNUM *v, *rr;  if ((p->flags & BN_FLG_CONSTTIME) != 0) {    /* BN_FLG_CONSTTIME only supported by BN_mod_exp_mont() */    OPENSSL_PUT_ERROR(BN, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);    return 0;  }  BN_CTX_start(ctx);  if (r == a || r == p) {    rr = BN_CTX_get(ctx);  } else {    rr = r;  }  v = BN_CTX_get(ctx);  if (rr == NULL || v == NULL) {    goto err;  }  if (BN_copy(v, a) == NULL) {    goto err;  }  bits = BN_num_bits(p);  if (BN_is_odd(p)) {    if (BN_copy(rr, a) == NULL) {      goto err;    }  } else {    if (!BN_one(rr)) {      goto err;    }  }  for (i = 1; i < bits; i++) {    if (!BN_sqr(v, v, ctx)) {      goto err;    }    if (BN_is_bit_set(p, i)) {      if (!BN_mul(rr, rr, v, ctx)) {        goto err;      }    }  }  if (r != rr && !BN_copy(r, rr)) {    goto err;  }  ret = 1;err:  BN_CTX_end(ctx);  return ret;}
开发者ID:DemiMarie,项目名称:ring,代码行数:57,


示例8: openssl_bioBN_math

void openssl_bioBN_math(){	BIO *outs;	BN_CTX *ctx;	char num1[8], num2[8];	BIGNUM *bg1, *bg2, *tmp, *stp;	bg1 = BN_new();	bg2 = BN_new();	tmp = BN_new();	ctx = BN_CTX_new();	strcpy(num1, "84");	strcpy(num2, "3");	BN_hex2bn(&bg1, num1);	BN_hex2bn(&bg2, num2);	outs = BIO_new(BIO_s_file());	BIO_set_fp(outs, stdout, BIO_NOCLOSE);	printf("/nBIO_MATH as follow:/n");	BN_add(tmp, bg1, bg2);	BIO_puts(outs, "/tbn(0x84 + 0x3) = 0x");	BN_print(outs, tmp);	BIO_puts(outs, "/n");	BN_sub(tmp, bg1, bg2);	BIO_puts(outs, "/tbn(0x84 - 0x3) = 0x");	BN_print(outs, tmp);	BIO_puts(outs, "/n");	BN_mul(tmp, bg1, bg2, ctx);	BIO_puts(outs, "/tbn(0x84 * 0x3) = 0x");	BN_print(outs, tmp);	BIO_puts(outs, "/n");	BN_sqr(tmp, bg1, ctx);	BIO_puts(outs, "/tbn(sqr(0x84))  = 0x");	BN_print(outs, tmp);	BIO_puts(outs, "/n");	BN_div(tmp, stp, bg1, bg2, ctx);	BIO_puts(outs, "/tbn(0x84 / 0x3) = 0x");	BN_print(outs, tmp);	BIO_puts(outs, "/n");	BN_exp(tmp, bg1, bg2, ctx);	BIO_puts(outs, "/tbn(0x84 e 0x03)= 0x");	BN_print(outs, tmp);	BIO_puts(outs, "/n");	BN_free(bg1);	BN_free(bg2);	BN_free(tmp);	BIO_free(outs);}
开发者ID:beike2020,项目名称:source,代码行数:54,


示例9: pr_fact

/* * pr_fact - print the factors of a number * * If the number is 0 or 1, then print the number and return. * If the number is < 0, print -1, negate the number and continue * processing. * * Print the factors of the number, from the lowest to the highest. * A factor will be printed numtiple times if it divides the value * multiple times. * * Factors are printed with leading tabs. */static voidpr_fact(BIGNUM *val){	const ubig *fact;		/* The factor found. */	/* Firewall - catch 0 and 1. */	if (BN_is_zero(val) || BN_is_one(val))		errx(1, "numbers <= 1 aren't permitted.");	/* Factor value. */	BN_print_dec_fp(stdout, val);	putchar(':');	for (fact = &prime[0]; !BN_is_one(val); ++fact) {		/* Look for the smallest factor. */		while (fact <= pr_limit) {			if (BN_mod_word(val, (BN_ULONG)*fact) == 0)				break;			fact++;		}		/* Watch for primes larger than the table. */		if (fact > pr_limit) {#ifdef HAVE_OPENSSL			BIGNUM *bnfact;			bnfact = BN_new();			BN_set_word(bnfact, (BN_ULONG)*(fact - 1));			BN_sqr(bnfact, bnfact, ctx);			if (BN_cmp(bnfact, val) > 0			    || BN_is_prime(val, PRIME_CHECKS, NULL, NULL,					   NULL) == 1) {				putchar(' ');				BN_print_dec_fp(stdout, val);			} else				pollard_rho(val);#else			printf(" %s", BN_bn2dec(val));#endif			break;		}		/* Divide factor out until none are left. */		do {			printf(" %lu", *fact);			BN_div_word(val, (BN_ULONG)*fact);		} while (BN_mod_word(val, (BN_ULONG)*fact) == 0);		/* Let the user know we're doing something. */		fflush(stdout);	}	putchar('/n');}
开发者ID:Hooman3,项目名称:minix,代码行数:66,


示例10: fermat_question_ask

static RSA *fermat_question_ask(const RSA *rsa){  BIGNUM    *a = BN_new(),    *b = BN_new(),    *a2 = BN_new(),    *b2 = BN_new();  BIGNUM *n = rsa->n;  BIGNUM    *tmp = BN_new(),    *rem = BN_new(),    *dssdelta = BN_new();  BN_CTX *ctx = BN_CTX_new();  RSA *ret = NULL;  BN_sqrtmod(tmp, rem, n, ctx);  /* Δ = |p - q| = |a + b - a + b| = |2b| > √N  2
C++ BN_sub_word函数代码示例
C++ BN_set_word函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。