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


C++ BIO_indent函数代码示例

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


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

示例1: print_gost_94

/* --------- printing keys --------------------------------*/
static int print_gost_94(BIO *out, const EVP_PKEY *pkey, int indent,
	ASN1_PCTX *pctx, int type) 
	{
	int param_nid = NID_undef;

	if (type == 2) 
		{
		BIGNUM *key;

		if (!BIO_indent(out,indent,128)) return 0;
		BIO_printf(out,"Private key: ");
		key = gost_get0_priv_key(pkey);
		if (!key) 
			BIO_printf(out,"<undefined>");
		else 
			BN_print(out,key);
		BIO_printf(out,"\n");
		}
	if (type >= 1)
		{
		BIGNUM *pubkey;
		
		pubkey = ((DSA *)EVP_PKEY_get0((EVP_PKEY *)pkey))->pub_key;
		BIO_indent(out,indent,128);
		BIO_printf(out,"Public key: ");
		BN_print(out,pubkey);
		BIO_printf(out,"\n");
	}	

	param_nid = gost94_nid_by_params(EVP_PKEY_get0((EVP_PKEY *)pkey));
	BIO_indent(out,indent,128);
	BIO_printf(out, "Parameter set: %s\n",OBJ_nid2ln(param_nid));
	return 1;
}
开发者ID:0culus,项目名称:openssl,代码行数:35,代码来源:gost_ameth.c

示例2: print_gost_01

static int print_gost_01(BIO *out, const EVP_PKEY *pkey, int indent,
	ASN1_PCTX *pctx, int type)
	{
	int param_nid = NID_undef;
	if (type == 2) 
		{
		BIGNUM *key;

		if (!BIO_indent(out,indent,128)) return 0;
		BIO_printf(out,"Private key: ");
		key = gost_get0_priv_key(pkey);
		if (!key) 
			BIO_printf(out,"<undefined)");
		else 
			BN_print(out,key);
		BIO_printf(out,"\n");
		}
	if (type >= 1) 
		{
		BN_CTX *ctx = BN_CTX_new();
		BIGNUM *X,*Y;
		const EC_POINT *pubkey;
		const EC_GROUP *group;

		if (!ctx) 
			{
			GOSTerr(GOST_F_PRINT_GOST_01,ERR_R_MALLOC_FAILURE);
			return 0;
			}
		BN_CTX_start(ctx);
		X = BN_CTX_get(ctx);
		Y = BN_CTX_get(ctx);
		pubkey = EC_KEY_get0_public_key((EC_KEY *)EVP_PKEY_get0((EVP_PKEY *)pkey));
		group = EC_KEY_get0_group((EC_KEY *)EVP_PKEY_get0((EVP_PKEY *)pkey));
		if (!EC_POINT_get_affine_coordinates_GFp(group,pubkey,X,Y,ctx)) 
			{
			GOSTerr(GOST_F_PRINT_GOST_01,ERR_R_EC_LIB);
			BN_CTX_free(ctx);
			return 0;
			}
		if (!BIO_indent(out,indent,128)) return 0;
		BIO_printf(out,"Public key:\n");
		if (!BIO_indent(out,indent+3,128)) return 0;
		BIO_printf(out,"X:");
		BN_print(out,X);
		BIO_printf(out,"\n");
		BIO_indent(out,indent+3,128);
		BIO_printf(out,"Y:");
		BN_print(out,Y);
		BIO_printf(out,"\n");
		BN_CTX_end(ctx);
		BN_CTX_free(ctx);
		}

	param_nid = EC_GROUP_get_curve_name(EC_KEY_get0_group(EVP_PKEY_get0((EVP_PKEY *)pkey)));
	if (!BIO_indent(out,indent,128)) return 0;
	BIO_printf(out,"Parameter set: %s\n",OBJ_nid2ln(param_nid));
	return 1;
}
开发者ID:0culus,项目名称:openssl,代码行数:59,代码来源:gost_ameth.c

示例3: ASN1_bn_print

int
ASN1_bn_print(BIO *bp, const char *number, const BIGNUM *num,
    unsigned char *buf, int off)
{
	int n, i;
	const char *neg;

	if (num == NULL)
		return (1);
	neg = (BN_is_negative(num)) ? "-" : "";
	if (!BIO_indent(bp, off, 128))
		return 0;
	if (BN_is_zero(num)) {
		if (BIO_printf(bp, "%s 0\n", number) <= 0)
			return 0;
		return 1;
	}

	if (BN_num_bytes(num) <= BN_BYTES) {
		if (BIO_printf(bp, "%s %s%lu (%s0x%lx)\n", number, neg,
		    (unsigned long)num->d[0], neg,
		    (unsigned long)num->d[0]) <= 0)
			return (0);
	} else {
		buf[0] = 0;
		if (BIO_printf(bp, "%s%s", number,
		    (neg[0] == '-') ? " (Negative)" : "") <= 0)
			return (0);
		n = BN_bn2bin(num, &buf[1]);

		if (buf[1] & 0x80)
			n++;
		else
			buf++;

		for (i = 0; i < n; i++) {
			if ((i % 15) == 0) {
				if (BIO_puts(bp, "\n") <= 0 ||
				    !BIO_indent(bp, off + 4, 128))
					return 0;
			}
			if (BIO_printf(bp, "%02x%s", buf[i],
			    ((i + 1) == n) ? "" : ":") <= 0)
				return (0);
		}
		if (BIO_write(bp, "\n", 1) <= 0)
			return (0);
	}
	return (1);
}
开发者ID:2trill2spill,项目名称:nextgen,代码行数:50,代码来源:t_pkey.c

示例4: param_print_gost01

static int
param_print_gost01(BIO *out, const EVP_PKEY *pkey, int indent, ASN1_PCTX *pctx)
{
	int param_nid =
	    EC_GROUP_get_curve_name(GOST_KEY_get0_group(pkey->pkey.gost));

	if (BIO_indent(out, indent, 128) == 0)
		return 0;
	BIO_printf(out, "Parameter set: %s\n", OBJ_nid2ln(param_nid));
	if (BIO_indent(out, indent, 128) == 0)
		return 0;
	BIO_printf(out, "Digest Algorithm: %s\n",
	    OBJ_nid2ln(GOST_KEY_get_digest(pkey->pkey.gost)));
	return 1;
}
开发者ID:ajinkya93,项目名称:OpenBSD,代码行数:15,代码来源:gostr341001_ameth.c

示例5: print_unsupported

static int print_unsupported(BIO *out, const EVP_PKEY *pkey, int indent,
                             const char *kstr) {
  BIO_indent(out, indent, 128);
  BIO_printf(out, "%s algorithm \"%s\" unsupported\n", kstr,
             OBJ_nid2ln(pkey->type));
  return 1;
}
开发者ID:friends110110,项目名称:boringssl,代码行数:7,代码来源:evp.c

示例6: asn1_print_info

static int asn1_print_info(BIO *bp, int tag, int xclass, int constructed,
                           int indent)
{
    static const char fmt[] = "%-18s";
    char str[128];
    const char *p;

    if (constructed & V_ASN1_CONSTRUCTED)
        p = "cons: ";
    else
        p = "prim: ";
    if (BIO_write(bp, p, 6) < 6)
        goto err;
    BIO_indent(bp, indent, 128);

    p = str;
    if ((xclass & V_ASN1_PRIVATE) == V_ASN1_PRIVATE)
        BIO_snprintf(str, sizeof str, "priv [ %d ] ", tag);
    else if ((xclass & V_ASN1_CONTEXT_SPECIFIC) == V_ASN1_CONTEXT_SPECIFIC)
        BIO_snprintf(str, sizeof str, "cont [ %d ]", tag);
    else if ((xclass & V_ASN1_APPLICATION) == V_ASN1_APPLICATION)
        BIO_snprintf(str, sizeof str, "appl [ %d ]", tag);
    else if (tag > 30)
        BIO_snprintf(str, sizeof str, "<ASN1 %d>", tag);
    else
        p = ASN1_tag2str(tag);

    if (BIO_printf(bp, fmt, p) <= 0)
        goto err;
    return (1);
 err:
    return (0);
}
开发者ID:2007750219,项目名称:openssl,代码行数:33,代码来源:asn1_par.c

示例7: pub_print_gost01

static int
pub_print_gost01(BIO *out, const EVP_PKEY *pkey, int indent, ASN1_PCTX *pctx)
{
	BN_CTX *ctx = BN_CTX_new();
	BIGNUM *X, *Y;
	const EC_POINT *pubkey;
	const EC_GROUP *group;

	if (ctx == NULL) {
		GOSTerr(GOST_F_PUB_PRINT_GOST01, ERR_R_MALLOC_FAILURE);
		return 0;
	}
	BN_CTX_start(ctx);
	if ((X = BN_CTX_get(ctx)) == NULL)
		goto err;
	if ((Y = BN_CTX_get(ctx)) == NULL)
		goto err;
	pubkey = GOST_KEY_get0_public_key(pkey->pkey.gost);
	group = GOST_KEY_get0_group(pkey->pkey.gost);
	if (EC_POINT_get_affine_coordinates_GFp(group, pubkey, X, Y,
	    ctx) == 0) {
		GOSTerr(GOST_F_PUB_PRINT_GOST01, ERR_R_EC_LIB);
		goto err;
	}
	if (BIO_indent(out, indent, 128) == 0)
		goto err;
	BIO_printf(out, "Public key:\n");
	if (BIO_indent(out, indent + 3, 128) == 0)
		goto err;
	BIO_printf(out, "X:");
	BN_print(out, X);
	BIO_printf(out, "\n");
	BIO_indent(out, indent + 3, 128);
	BIO_printf(out, "Y:");
	BN_print(out, Y);
	BIO_printf(out, "\n");

	BN_CTX_end(ctx);
	BN_CTX_free(ctx);

	return param_print_gost01(out, pkey, indent, pctx);

err:
	BN_CTX_end(ctx);
	BN_CTX_free(ctx);
	return 0;
}
开发者ID:ajinkya93,项目名称:OpenBSD,代码行数:47,代码来源:gostr341001_ameth.c

示例8: print_gost_ec_pub

static int print_gost_ec_pub(BIO *out, const EVP_PKEY *pkey, int indent)
{
    BN_CTX *ctx;
    BIGNUM *X, *Y;
    const EC_POINT *pubkey;
    const EC_GROUP *group;
    EC_KEY *key = (EC_KEY *)EVP_PKEY_get0((EVP_PKEY *)pkey);
    int ok = 0;

    ctx = BN_CTX_new();
    if (!ctx) {
        GOSTerr(GOST_F_PRINT_GOST_EC_PUB, ERR_R_MALLOC_FAILURE);
        return 0;
    }

    BN_CTX_start(ctx);
    X = BN_CTX_get(ctx);
    Y = BN_CTX_get(ctx);
    pubkey = (key) ? EC_KEY_get0_public_key(key) : NULL;
    group = (key) ? EC_KEY_get0_group(key) : NULL;
    if (!pubkey || !group)
        goto err;

    if (!EC_POINT_get_affine_coordinates_GFp(group, pubkey, X, Y, ctx)) {
        GOSTerr(GOST_F_PRINT_GOST_EC_PUB, ERR_R_EC_LIB);
        goto err;
    }
    if (!BIO_indent(out, indent, 128))
        goto err;
    BIO_printf(out, "Public key:\n");
    if (!BIO_indent(out, indent + 3, 128))
        goto err;
    BIO_printf(out, "X:");
    BN_print(out, X);
    BIO_printf(out, "\n");
    if (!BIO_indent(out, indent + 3, 128))
        goto err;
    BIO_printf(out, "Y:");
    BN_print(out, Y);
    BIO_printf(out, "\n");
    ok = 1;
 err:
    BN_CTX_end(ctx);
    BN_CTX_free(ctx);

    return ok;
}
开发者ID:andbortnik,项目名称:engine,代码行数:47,代码来源:gost_ameth.c

示例9: do_dsa_print

static int do_dsa_print(BIO *bp, const DSA *x, int off, int ptype)
{
    unsigned char *m=NULL;
    int ret=0;
    size_t buf_len=0;
    const char *ktype = NULL;

    const BIGNUM *priv_key, *pub_key;

    if (ptype == 2)
        priv_key = x->priv_key;
    else
        priv_key = NULL;

    if (ptype > 0)
        pub_key = x->pub_key;
    else
        pub_key = NULL;

    if (ptype == 2)
        ktype = "Private-Key";
    else if (ptype == 1)
        ktype = "Public-Key";
    else
        ktype = "DSA-Parameters";

    update_buflen(x->p, &buf_len);
    update_buflen(x->q, &buf_len);
    update_buflen(x->g, &buf_len);
    update_buflen(priv_key, &buf_len);
    update_buflen(pub_key, &buf_len);

    m=(unsigned char *)OPENSSL_malloc(buf_len+10);
    if (m == NULL)
    {
        DSAerr(DSA_F_DO_DSA_PRINT,ERR_R_MALLOC_FAILURE);
        goto err;
    }

    if (priv_key)
    {
        if(!BIO_indent(bp,off,128))
            goto err;
        if (BIO_printf(bp,"%s: (%d bit)\n",ktype, BN_num_bits(x->p))
                <= 0) goto err;
    }

    if (!ASN1_bn_print(bp,"priv:",priv_key,m,off))
        goto err;
    if (!ASN1_bn_print(bp,"pub: ",pub_key,m,off))
        goto err;
    if (!ASN1_bn_print(bp,"P:   ",x->p,m,off)) goto err;
    if (!ASN1_bn_print(bp,"Q:   ",x->q,m,off)) goto err;
    if (!ASN1_bn_print(bp,"G:   ",x->g,m,off)) goto err;
    ret=1;
err:
    if (m != NULL) OPENSSL_free(m);
    return(ret);
}
开发者ID:Ashod,项目名称:openssl,代码行数:59,代码来源:dsa_ameth.c

示例10: KA_CTX_print_private

static int
KA_CTX_print_private(BIO *out, const KA_CTX *ctx, int indent)
{
    if (ctx) {
        if (!BIO_indent(out, indent, 80)
                || !BIO_printf(out, "Key Agreement Parameters:\n"))
            return 0;
        if (ctx->key)
            if (ctx->shared_secret) {
                /* If we have a shared secret, we also must have a private key
                 * which we can print. This is a bit clumsy but unfortunately
                 * OpenSSL doesn't offer a function to check whether or not an
                 * EVP_PKEY contains a private key. */
                if (!EVP_PKEY_print_private(out, ctx->key, indent+4, NULL))
                    return 0;
            } else {
                if (!EVP_PKEY_print_params(out, ctx->key, indent+4, NULL))
                    return 0;
            }
            else {
                if (!BIO_indent(out, indent+4, 80)
                        || !BIO_printf(out, "<ABSENT>\n"))
                    return 0;
            }
        if (!BIO_indent(out, indent, 80))
            return 0;
        if (ctx->cipher) {
            if (!BIO_printf(out, "Cipher: %s\n", EVP_CIPHER_name(ctx->cipher)))
                return 0;
        } else if (!BIO_printf(out, "Cipher: %s\n", "<ABSENT>"))
            return 0;
        if (!BIO_indent(out, indent, 80))
            return 0;
        if (ctx->md) {
            if (!BIO_printf(out, "Message Digest: %s\n", EVP_MD_name(ctx->md)))
                return 0;
        } else if (!BIO_printf(out, "Message Digest: %s\n", "<ABSENT>"))
                    return 0;
        if (!BIO_indent(out, indent, 80)
                || !BIO_printf(out, "Shared Secret:\n")
                || !BUF_MEM_print(out, ctx->shared_secret, indent+4)
                || !BIO_indent(out, indent, 80)
                || !BIO_printf(out, "K_enc:\n")
                || !BUF_MEM_print(out, ctx->k_enc, indent+4)
                || !BIO_indent(out, indent, 80)
                || !BIO_printf(out, "K_mac:\n")
                || !BUF_MEM_print(out, ctx->k_mac, indent+4))
            return 0;
    } else {
        if (!BIO_indent(out, indent, 80)
                || !BIO_printf(out, "<ABSENT>\n"))
            return 0;
    }
    return 1;
}
开发者ID:d0,项目名称:openpace,代码行数:55,代码来源:eac_print.c

示例11: ssl_print_random

static int ssl_print_random(BIO *bio, int indent,
				const unsigned char **pmsg, size_t *pmsglen)
	{
	unsigned int tm;
	const unsigned char *p = *pmsg;
	if (*pmsglen < 32)
		return 0;
	tm = (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3];
	p += 4;
	BIO_indent(bio, indent, 80);
	BIO_puts(bio, "Random:\n");
	BIO_indent(bio, indent + 2, 80);
	BIO_printf(bio, "gmt_unix_time=0x%08X\n", tm);
	ssl_print_hex(bio, indent + 2, "random_bytes", p, 28);
	*pmsg += 32;
	*pmsglen -= 32;
	return 1;
	}
开发者ID:bsnote,项目名称:openssl,代码行数:18,代码来源:t1_trce.c

示例12: do_dsa_print

static int do_dsa_print(BIO *bp, const DSA *x, int off, int ptype) {
  uint8_t *m = NULL;
  int ret = 0;
  size_t buf_len = 0;
  const char *ktype = NULL;

  const BIGNUM *priv_key, *pub_key;

  priv_key = NULL;
  if (ptype == 2) {
    priv_key = x->priv_key;
  }

  pub_key = NULL;
  if (ptype > 0) {
    pub_key = x->pub_key;
  }

  ktype = "DSA-Parameters";
  if (ptype == 2) {
    ktype = "Private-Key";
  } else if (ptype == 1) {
    ktype = "Public-Key";
  }

  update_buflen(x->p, &buf_len);
  update_buflen(x->q, &buf_len);
  update_buflen(x->g, &buf_len);
  update_buflen(priv_key, &buf_len);
  update_buflen(pub_key, &buf_len);

  m = (uint8_t *)OPENSSL_malloc(buf_len + 10);
  if (m == NULL) {
    OPENSSL_PUT_ERROR(EVP, ERR_R_MALLOC_FAILURE);
    goto err;
  }

  if (priv_key) {
    if (!BIO_indent(bp, off, 128) ||
        BIO_printf(bp, "%s: (%d bit)\n", ktype, BN_num_bits(x->p)) <= 0) {
      goto err;
    }
  }

  if (!ASN1_bn_print(bp, "priv:", priv_key, m, off) ||
      !ASN1_bn_print(bp, "pub: ", pub_key, m, off) ||
      !ASN1_bn_print(bp, "P:   ", x->p, m, off) ||
      !ASN1_bn_print(bp, "Q:   ", x->q, m, off) ||
      !ASN1_bn_print(bp, "G:   ", x->g, m, off)) {
    goto err;
  }
  ret = 1;

err:
  OPENSSL_free(m);
  return ret;
}
开发者ID:bheesham,项目名称:boringssl,代码行数:57,代码来源:p_dsa_asn1.c

示例13: ssl_print_hex

static void ssl_print_hex(BIO *bio, int indent, const char *name,
				const unsigned char *msg, size_t msglen)
	{
	size_t i;
	BIO_indent(bio, indent, 80);
	BIO_printf(bio, "%s (len=%d): ", name, (int)msglen);
	for (i = 0; i < msglen; i++)
		BIO_printf(bio, "%02X", msg[i]);
	BIO_puts(bio, "\n");
	}
开发者ID:bsnote,项目名称:openssl,代码行数:10,代码来源:t1_trce.c

示例14: PACE_SEC_print_private

int
PACE_SEC_print_private(BIO *out, const PACE_SEC *sec, int indent)
{
    const char *s;
    if (sec) {
        switch (sec->type) {
            case PACE_RAW:
                s = raw_str;
                break;
            case PACE_PIN:
                s = pin_str;
                break;
            case PACE_PUK:
                s = puk_str;
                break;
            case PACE_CAN:
                s = can_str;
                break;
            case PACE_MRZ:
                s = mrz_str;
                break;
            case PACE_SEC_UNDEF:
                /* fall through */
            default:
                s = undef_str;
                break;
        }
        if (!BIO_indent(out, indent, 80)
                || !BIO_printf(out, "%s\n", s)
                || !BIO_indent(out, indent, 80)
                || !BIO_printf(out, "Secret:\n")
                || !BUF_MEM_print(out, sec->mem, indent)
                || !BIO_indent(out, indent, 80)
                || !BIO_printf(out, "Encoded Secret:\n")
                || !BUF_MEM_print(out, sec->encoded, indent))
            return 0;
    } else {
        if (!BIO_indent(out, indent, 80)
                || !BIO_printf(out, "<ABSENT>\n"))
            return 0;
    }
    return 1;
}
开发者ID:d0,项目名称:openpace,代码行数:43,代码来源:eac_print.c

示例15: CA_CTX_print_private

static int
CA_CTX_print_private(BIO *out, const CA_CTX *ctx, int indent)
{
    if (ctx) {
        if (!BIO_indent(out, indent, 80)
                || !BIO_printf(out, "keyID: 0x%02X\n", ctx->id)
                || !BIO_indent(out, indent, 80)
                || !BIO_printf(out, "OID: %s\n", OBJ_nid2sn(ctx->protocol))
                || !BIO_indent(out, indent, 80)
                || !BIO_printf(out, "Version: %d\n", ctx->version)
                || !BIO_indent(out, indent, 80)
                || !BIO_printf(out, "PICC's Static Domain Parameters:\n")
                || !KA_CTX_print_private(out, ctx->ka_ctx, indent+4))
            return 0;
    } else {
        if (!BIO_indent(out, indent, 80)
                || !BIO_printf(out, "<ABSENT>\n"))
            return 0;
    }
    return 1;
}
开发者ID:d0,项目名称:openpace,代码行数:21,代码来源:eac_print.c


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