本文整理汇总了C++中BN_print_fp函数的典型用法代码示例。如果您正苦于以下问题:C++ BN_print_fp函数的具体用法?C++ BN_print_fp怎么用?C++ BN_print_fp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了BN_print_fp函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: test
/**
* \brief Test for a pair of moduluses having a prime factor in common.
*
*/
int test(BIGNUM *n, BIGNUM *m)
{
BIGNUM *g;
BN_CTX *ctx;
int ret = 0;
if (!BN_cmp(n, m)) return 1;
g = BN_new();
ctx = BN_CTX_new();
BN_gcd(g, n, m, ctx);
if (!BN_is_one(g)) {
fprintf(stdout, "%-8s: ", PRIME);
BN_print_fp(stdout, n);
fprintf(stdout, " ");
BN_print_fp(stdout, m);
fprintf(stdout, "\n");
ret = 1;
}
BN_CTX_free(ctx);
BN_free(g);
return ret;
}
开发者ID:fxfactorial,项目名称:bachelor,代码行数:30,代码来源:stranamore.c
示例2: dump_dsa_sig
void dump_dsa_sig(const char *message, DSA_SIG *sig)
{
fprintf(stderr,"%s\nR=",message);
BN_print_fp(stderr,sig->r);
fprintf(stderr,"\nS=");
BN_print_fp(stderr,sig->s);
fprintf(stderr,"\n");
}
开发者ID:DmitryOlshansky,项目名称:openssl,代码行数:8,代码来源:gost_sign.c
示例3: dump_dsa_sig
void dump_dsa_sig(const char *message, DSA_SIG *sig)
{
TINYCLR_SSL_FPRINTF(OPENSSL_TYPE__FILE_STDERR,"%s\nR=",message);
BN_print_fp(OPENSSL_TYPE__FILE_STDERR,sig->r);
TINYCLR_SSL_FPRINTF(OPENSSL_TYPE__FILE_STDERR,"\nS=");
BN_print_fp(OPENSSL_TYPE__FILE_STDERR,sig->s);
TINYCLR_SSL_FPRINTF(OPENSSL_TYPE__FILE_STDERR,"\n");
}
开发者ID:Wampamba-Nooh,项目名称:MicroFrameworkSDK-Mono,代码行数:8,代码来源:gost_sign.cpp
示例4: test_lshift
int test_lshift(BIO *bp,BN_CTX *ctx,BIGNUM *a_)
{
BIGNUM *a,*b,*c,*d;
int i;
b=BN_new();
c=BN_new();
d=BN_new();
BN_one(c);
if(a_)
a=a_;
else
{
a=BN_new();
BN_bntest_rand(a,200,0,0); /**/
a->neg=rand_neg();
}
for (i=0; i<num0; i++)
{
BN_lshift(b,a,i+1);
BN_add(c,c,c);
if (bp != NULL)
{
if (!results)
{
BN_print(bp,a);
BIO_puts(bp," * ");
BN_print(bp,c);
BIO_puts(bp," - ");
}
BN_print(bp,b);
BIO_puts(bp,"\n");
}
BN_mul(d,a,c,ctx);
BN_sub(d,d,b);
if(!BN_is_zero(d))
{
fprintf(stderr,"Left shift test failed!\n");
fprintf(stderr,"a=");
BN_print_fp(stderr,a);
fprintf(stderr,"\nb=");
BN_print_fp(stderr,b);
fprintf(stderr,"\nc=");
BN_print_fp(stderr,c);
fprintf(stderr,"\nd=");
BN_print_fp(stderr,d);
fprintf(stderr,"\n");
return 0;
}
}
BN_free(a);
BN_free(b);
BN_free(c);
BN_free(d);
return(1);
}
开发者ID:froggatt,项目名称:edimax-br-6528n,代码行数:57,代码来源:bntest.c
示例5: bn8_cmp_bn
void bn8_cmp_bn(bn8 a, uint8_t size, BIGNUM *b, int i)
{
BIGNUM *aBN = BN_new();
BN_bin2bn(a, size, aBN);
if(BN_cmp(aBN, b) != 0) {
printf("cmp fail %d\n", i);
BN_print_fp(stdout, aBN); printf("\n");
BN_print_fp(stdout, b); printf("\n");
}
}
开发者ID:12019,项目名称:bitcoin-smartcard,代码行数:10,代码来源:bn8_misc.c
示例6: a_is_zero_mod_one
/*
* Test that r == 0 in test_exp_mod_zero(). Returns one on success,
* returns zero and prints debug output otherwise.
*/
static int a_is_zero_mod_one(const char *method, const BIGNUM *r,
const BIGNUM *a) {
if (!BN_is_zero(r)) {
fprintf(stderr, "%s failed:\n", method);
fprintf(stderr, "a ** 0 mod 1 = r (should be 0)\n");
fprintf(stderr, "a = ");
BN_print_fp(stderr, a);
fprintf(stderr, "\nr = ");
BN_print_fp(stderr, r);
fprintf(stderr, "\n");
return 0;
}
return 1;
}
开发者ID:Castaglia,项目名称:openssl,代码行数:18,代码来源:exptest.c
示例7: main
int main(int argc, char **argv)
{
FILE *fp;
RSA *rsa;
int proc, procs;
int i;
QA_library_init();
MPI_Comm_rank(MPI_COMM_WORLD, &proc);
MPI_Comm_size(MPI_COMM_WORLD, &procs);
if (argc < 1) return EXIT_FAILURE;
if (!(fp = fopen(argv[argc-1], "r"))) return EXIT_FAILURE;
rsa = RSA_new();
rsa->n = BN_new();
rsa->e = BN_new();
for (i=0; next_pkey(rsa, fp); i = (i+1) % procs) {
if (i != proc) continue;
if (run_question(question, NULL, rsa) == 1) {
BN_print_fp(stdout, rsa->n);
fprintf(stdout, "\t broken\n");
}
}
MPI_Finalize();
return EXIT_SUCCESS;
}
开发者ID:fxfactorial,项目名称:bachelor,代码行数:28,代码来源:despicable.c
示例8: 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 void
pr_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,代码来源:factor.c
示例9: main
int main(int argc, char* argv[]){
int res;
int toGet;
std::vector<RSA*> allPrivateKeys;
uint32_t allPublicKeys[100][32];
if(argc != 3){
puts("wrong number of args. takes db to open, num to get");
return 0;
}
puts("Starting key printer...");
toGet = atoi(argv[2]);
//run through the DB passed in and get all they keys from it
res = getAllKeys(argv[1], toGet, &allPrivateKeys, allPublicKeys);
printf("Asked for %d keys, got %d\n", toGet, res);
printf("after, vector of private keys was %d\n", (int)allPrivateKeys.size());
printf("after, vector of public keys was %d\n", res);
//RSA_print_fp(stdout, allPrivateKeys.at(0), 0);
//0 is MSB for our 1024
BIGNUM *n = allPrivateKeys.at(0)->n;
BN_print_fp(stdout, n);
printf("\ntop = %d and 0th is\t%02x\n", n->dmax, (uint32_t)n->d[0]);
printf("bottom = \t\t%02x\n", allPublicKeys[0][31]);
return 0;
}
开发者ID:Stavrosnco,项目名称:PARIS,代码行数:33,代码来源:getKeysTest.cpp
示例10: showbn
static void showbn(const char *name, const BIGNUM *bn)
{
fputs(name, stdout);
fputs(" = ", stdout);
BN_print_fp(stdout, bn);
putc('\n', stdout);
}
开发者ID:Acidburn0zzz,项目名称:openssl,代码行数:7,代码来源:srptest.c
示例11: test_exp_mod_zero
/*
* test_exp_mod_zero tests that x**0 mod 1 == 0. It returns zero on success.
*/
static int test_exp_mod_zero()
{
BIGNUM a, p, m;
BIGNUM r;
BN_CTX *ctx = BN_CTX_new();
int ret = 1;
BN_init(&m);
BN_one(&m);
BN_init(&a);
BN_one(&a);
BN_init(&p);
BN_zero(&p);
BN_init(&r);
BN_mod_exp(&r, &a, &p, &m, ctx);
BN_CTX_free(ctx);
if (BN_is_zero(&r))
ret = 0;
else {
printf("1**0 mod 1 = ");
BN_print_fp(stdout, &r);
printf(", should be 0\n");
}
BN_free(&r);
BN_free(&a);
BN_free(&p);
BN_free(&m);
return ret;
}
开发者ID:1564143452,项目名称:kbengine,代码行数:38,代码来源:exptest.c
示例12: pkey_gost01_cp_verify
static int pkey_gost01_cp_verify(EVP_PKEY_CTX *ctx, const unsigned char *sig,
size_t siglen, const unsigned char *tbs, size_t tbs_len)
{
int ok = 0;
EVP_PKEY* pub_key = EVP_PKEY_CTX_get0_pkey(ctx);
DSA_SIG *s=unpack_cp_signature(sig,siglen);
if (!s) return 0;
#ifdef DEBUG_SIGN
TINYCLR_SSL_FPRINTF(OPENSSL_TYPE__FILE_STDERR,"R=");
BN_print_fp(OPENSSL_TYPE__FILE_STDERR,s->r);
TINYCLR_SSL_FPRINTF(OPENSSL_TYPE__FILE_STDERR,"\nS=");
BN_print_fp(OPENSSL_TYPE__FILE_STDERR,s->s);
TINYCLR_SSL_FPRINTF(OPENSSL_TYPE__FILE_STDERR,"\n");
#endif
if (pub_key) ok = gost2001_do_verify(tbs,tbs_len,s,(EC_KEY*)EVP_PKEY_get0(pub_key));
DSA_SIG_free(s);
return ok;
}
开发者ID:AustinWise,项目名称:Netduino-Micro-Framework,代码行数:18,代码来源:gost_pmeth.cpp
示例13: pkey_gost01_cp_verify
static int pkey_gost01_cp_verify(EVP_PKEY_CTX *ctx, const unsigned char *sig,
size_t siglen, const unsigned char *tbs, size_t tbs_len)
{
int ok = 0;
EVP_PKEY* pub_key = EVP_PKEY_CTX_get0_pkey(ctx);
DSA_SIG *s=unpack_cp_signature(sig,siglen);
if (!s) return 0;
#ifdef DEBUG_SIGN
fprintf(stderr,"R=");
BN_print_fp(stderr,s->r);
fprintf(stderr,"\nS=");
BN_print_fp(stderr,s->s);
fprintf(stderr,"\n");
#endif
if (pub_key) ok = gost2001_do_verify(tbs,tbs_len,s,EVP_PKEY_get0(pub_key));
DSA_SIG_free(s);
return ok;
}
开发者ID:Chenhx,项目名称:moai-dev,代码行数:18,代码来源:gost_pmeth.c
示例14: pr_print
static void
pr_print(BIGNUM *val)
{
if (hflag) {
fputs(" 0x", stdout);
BN_print_fp(stdout, val);
} else {
putchar(' ');
BN_print_dec_fp(stdout, val);
}
}
开发者ID:juanfra684,项目名称:DragonFlyBSD,代码行数:11,代码来源:factor.c
示例15: fill_GOST2001_params
/*
* Fills EC_KEY structure hidden in the app_data field of DSA structure
* with parameter information, extracted from parameter array in
* params.c file.
*
* Also fils DSA->q field with copy of EC_GROUP order field to make
* DSA_size function work
*/
int fill_GOST2001_params(EC_KEY *eckey, int nid)
{
R3410_2001_params *params = R3410_2001_paramset;
EC_GROUP *grp = NULL;
BIGNUM *p = NULL, *q = NULL, *a = NULL, *b = NULL, *x = NULL, *y = NULL;
EC_POINT *P = NULL;
BN_CTX *ctx = BN_CTX_new();
int ok = 0;
BN_CTX_start(ctx);
p = BN_CTX_get(ctx);
a = BN_CTX_get(ctx);
b = BN_CTX_get(ctx);
x = BN_CTX_get(ctx);
y = BN_CTX_get(ctx);
q = BN_CTX_get(ctx);
while (params->nid != NID_undef && params->nid != nid)
params++;
if (params->nid == NID_undef) {
GOSTerr(GOST_F_FILL_GOST2001_PARAMS,
GOST_R_UNSUPPORTED_PARAMETER_SET);
goto err;
}
BN_hex2bn(&p, params->p);
BN_hex2bn(&a, params->a);
BN_hex2bn(&b, params->b);
grp = EC_GROUP_new_curve_GFp(p, a, b, ctx);
P = EC_POINT_new(grp);
BN_hex2bn(&x, params->x);
BN_hex2bn(&y, params->y);
EC_POINT_set_affine_coordinates_GFp(grp, P, x, y, ctx);
BN_hex2bn(&q, params->q);
#ifdef DEBUG_KEYS
fprintf(stderr, "Set params index %d oid %s\nq=",
(params - R3410_2001_paramset), OBJ_nid2sn(params->nid));
BN_print_fp(stderr, q);
fprintf(stderr, "\n");
#endif
EC_GROUP_set_generator(grp, P, q, NULL);
EC_GROUP_set_curve_name(grp, params->nid);
EC_KEY_set_group(eckey, grp);
ok = 1;
err:
EC_POINT_free(P);
EC_GROUP_free(grp);
BN_CTX_end(ctx);
BN_CTX_free(ctx);
return ok;
}
开发者ID:4872866,项目名称:node,代码行数:62,代码来源:gost2001.c
示例16: test_hash
/* test the function of hashpassword */
void test_hash()
{
const char *pwd1 = "123456";
const char *pwd2 = "123457";
BIGNUM *secret = BN_new();
BN_CTX *ctx = BN_CTX_new();
BIGNUM *q = BN_new();
BN_set_word(q, 0xFFFFFF);
printf("test hash start!\n");
hashpassword(secret, pwd1, ctx, q);
BN_print_fp(stdout, secret);
printf("\n");
hashpassword(secret, pwd2, ctx, q);
BN_print_fp(stdout, secret);
printf("\n");
printf("test hash end!\n");
}
开发者ID:qzhouayi,项目名称:New_graduation_thesis,代码行数:22,代码来源:pspake.c
示例17: input_kex_dh_gex_group
static int
input_kex_dh_gex_group(int type, u_int32_t seq, void *ctxt)
{
struct ssh *ssh = ctxt;
struct kex *kex = ssh->kex;
BIGNUM *p = NULL, *g = NULL;
int r, bits;
debug("got SSH2_MSG_KEX_DH_GEX_GROUP");
if ((p = BN_new()) == NULL ||
(g = BN_new()) == NULL) {
r = SSH_ERR_ALLOC_FAIL;
goto out;
}
if ((r = sshpkt_get_bignum2(ssh, p)) != 0 ||
(r = sshpkt_get_bignum2(ssh, g)) != 0 ||
(r = sshpkt_get_end(ssh)) != 0)
goto out;
if ((bits = BN_num_bits(p)) < 0 ||
(u_int)bits < kex->min || (u_int)bits > kex->max) {
r = SSH_ERR_DH_GEX_OUT_OF_RANGE;
goto out;
}
if ((kex->dh = dh_new_group(g, p)) == NULL) {
r = SSH_ERR_ALLOC_FAIL;
goto out;
}
p = g = NULL; /* belong to kex->dh now */
/* generate and send 'e', client DH public key */
if ((r = dh_gen_key(kex->dh, kex->we_need * 8)) != 0 ||
(r = sshpkt_start(ssh, SSH2_MSG_KEX_DH_GEX_INIT)) != 0 ||
(r = sshpkt_put_bignum2(ssh, kex->dh->pub_key)) != 0 ||
(r = sshpkt_send(ssh)) != 0)
goto out;
debug("SSH2_MSG_KEX_DH_GEX_INIT sent");
#ifdef DEBUG_KEXDH
DHparams_print_fp(stderr, kex->dh);
fprintf(stderr, "pub= ");
BN_print_fp(stderr, kex->dh->pub_key);
fprintf(stderr, "\n");
#endif
ssh_dispatch_set(ssh, SSH2_MSG_KEX_DH_GEX_GROUP, NULL);
ssh_dispatch_set(ssh, SSH2_MSG_KEX_DH_GEX_REPLY, &input_kex_dh_gex_reply);
r = 0;
out:
if (p)
BN_clear_free(p);
if (g)
BN_clear_free(g);
return r;
}
开发者ID:ajinkya93,项目名称:netbsd-src,代码行数:53,代码来源:kexgexc.c
示例18: print_bn
void print_bn( const char *name, const BIGNUM *bn)
{
print_indent();
printf("%s=",name);
if(bn)
{
BN_print_fp(stdout,bn);
putchar('\n');
}
else
puts("(unset)");
}
开发者ID:MrKID,项目名称:RetroShare,代码行数:12,代码来源:packet-print.c
示例19: check_bn
static int check_bn(const char *name, const BIGNUM *bn, const char *hexbn)
{
BIGNUM *tmp = NULL;
int rv;
if (BN_hex2bn(&tmp, hexbn) == 0)
return 0;
rv = BN_cmp(bn, tmp);
if (rv == 0) {
printf("%s = ", name);
BN_print_fp(stdout, bn);
printf("\n");
BN_free(tmp);
return 1;
}
printf("Unexpected %s value\n", name);
printf("Expecting: ");
BN_print_fp(stdout, tmp);
printf("\nReceived: ");
BN_print_fp(stdout, bn);
printf("\n");
BN_free(tmp);
return 0;
}
开发者ID:AlexanderPankiv,项目名称:node,代码行数:23,代码来源:srptest.c
示例20: kexdh_client
int
kexdh_client(struct ssh *ssh)
{
struct kex *kex = ssh->kex;
int r;
/* generate and send 'e', client DH public key */
switch (kex->kex_type) {
case KEX_DH_GRP1_SHA1:
kex->dh = dh_new_group1();
break;
case KEX_DH_GRP14_SHA1:
case KEX_DH_GRP14_SHA256:
kex->dh = dh_new_group14();
break;
case KEX_DH_GRP16_SHA512:
kex->dh = dh_new_group16();
break;
case KEX_DH_GRP18_SHA512:
kex->dh = dh_new_group18();
break;
default:
r = SSH_ERR_INVALID_ARGUMENT;
goto out;
}
if (kex->dh == NULL) {
r = SSH_ERR_ALLOC_FAIL;
goto out;
}
debug("sending SSH2_MSG_KEXDH_INIT");
if ((r = dh_gen_key(kex->dh, kex->we_need * 8)) != 0 ||
(r = sshpkt_start(ssh, SSH2_MSG_KEXDH_INIT)) != 0 ||
(r = sshpkt_put_bignum2(ssh, kex->dh->pub_key)) != 0 ||
(r = sshpkt_send(ssh)) != 0)
goto out;
#ifdef DEBUG_KEXDH
DHparams_print_fp(stderr, kex->dh);
fprintf(stderr, "pub= ");
BN_print_fp(stderr, kex->dh->pub_key);
fprintf(stderr, "\n");
#endif
debug("expecting SSH2_MSG_KEXDH_REPLY");
ssh_dispatch_set(ssh, SSH2_MSG_KEXDH_REPLY, &input_kex_dh);
r = 0;
out:
return r;
}
开发者ID:antonyantony,项目名称:openssh,代码行数:47,代码来源:kexdhc.c
注:本文中的BN_print_fp函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论