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

C++ EC_KEY_set_conv_form函数代码示例

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

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



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

示例1: EC_KEY_set_conv_form

		void elliptic_curve_key::set_compressed(bool compressed)
		{
			if (compressed)
				EC_KEY_set_conv_form(key_, POINT_CONVERSION_COMPRESSED);
			else
				EC_KEY_set_conv_form(key_, POINT_CONVERSION_UNCOMPRESSED);
		}
开发者ID:ballisticwhisper,项目名称:decentralised,代码行数:7,代码来源:elliptic_curve_key.cpp


示例2: main

int main(int argc, const char **argv)
{
	EC_KEY *pub;
	char workbuf[BUFSIZE];
	const unsigned char *workbuf_p;
	size_t len, i;

	if (argv[1] == NULL)
	{
		fprintf(stderr, "usage: %s [base64key]\n", argv[0]);
		return EXIT_FAILURE;
	}

	memset(workbuf, '\0', sizeof workbuf);

	pub = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);
	EC_KEY_set_conv_form(pub, POINT_CONVERSION_COMPRESSED);

	len = base64_decode(argv[1], workbuf, BUFSIZE);
	workbuf_p = (unsigned char *) workbuf;

	o2i_ECPublicKey(&pub, &workbuf_p, len);
	if (!EC_KEY_check_key(pub))
	{
		fprintf(stderr, "Key data provided on commandline is inconsistent.\n");
		return EXIT_FAILURE;
	}

	printf("Public key (reassembled):\n");
	EC_KEY_print_fp(stdout, pub, 4);

	return EXIT_SUCCESS;
}
开发者ID:Desuneko,项目名称:atheme,代码行数:33,代码来源:main.c


示例3: ec_key_new_from_group

/*
 * Creates a new EC_KEY on the EC group obj. arg can be an EC::Group or a String
 * representing an OID.
 */
static EC_KEY *
ec_key_new_from_group(VALUE arg)
{
    EC_KEY *ec;

    if (rb_obj_is_kind_of(arg, cEC_GROUP)) {
	EC_GROUP *group;

	SafeRequire_EC_GROUP(arg, group);

	if (!(ec = EC_KEY_new()))
	    ossl_raise(eECError, NULL);

	if (!EC_KEY_set_group(ec, group)) {
	    EC_KEY_free(ec);
	    ossl_raise(eECError, NULL);
	}
    } else {
	int nid = OBJ_sn2nid(StringValueCStr(arg));

	if (nid == NID_undef)
	    ossl_raise(eECError, "invalid curve name");

	if (!(ec = EC_KEY_new_by_curve_name(nid)))
	    ossl_raise(eECError, NULL);

	EC_KEY_set_asn1_flag(ec, OPENSSL_EC_NAMED_CURVE);
	EC_KEY_set_conv_form(ec, POINT_CONVERSION_UNCOMPRESSED);
    }

    return ec;
}
开发者ID:coderhs,项目名称:jruby,代码行数:36,代码来源:ossl_pkey_ec.c


示例4: key_set_privkey

bool key_set_privkey(struct key *k, const void *privkey, size_t len) {
  BIGNUM *res;
  BIGNUM bn;
  int s;

  /*
   * Cf bitcoin/src/base58.h
   *    bitcoin/src/key.h
   *
   * If len == 33 and privkey[32] == 1, then:
   *   "the public key corresponding to this private key is (to be)
   *   compressed."
   */
  ASSERT(len == 32 || len == 33);

  BN_init(&bn);
  res = BN_bin2bn(privkey, 32, &bn);
  ASSERT(res);

  s = key_regenerate(k, &bn);
  ASSERT(s);
  ASSERT(EC_KEY_check_key(k->key));

  EC_KEY_set_conv_form(k->key, POINT_CONVERSION_COMPRESSED);

  ASSERT(k->pub_key == NULL);
  ASSERT(k->pub_len == 0);
  key_get_pubkey_int(k, &k->pub_key, &k->pub_len);

  BN_clear_free(&bn);
  ASSERT(EC_KEY_check_key(k->key));

  return 1;
}
开发者ID:jma127,项目名称:bitc-rpc,代码行数:34,代码来源:key.c


示例5: key_alloc

struct key *key_generate_new(void) {
  struct key *k;
  int s;

  k = key_alloc();

  s = EC_KEY_generate_key(k->key);
  if (s == 0) {
    Log(LGPFX " EC_KEY_generate_key failed.\n");
    goto exit;
  }
  s = EC_KEY_check_key(k->key);
  if (s == 0) {
    Log(LGPFX " EC_KEY_check_key failed.\n");
    goto exit;
  }

  EC_KEY_set_conv_form(k->key, POINT_CONVERSION_COMPRESSED);

  ASSERT(k->pub_key == NULL);
  ASSERT(k->pub_len == 0);
  key_get_pubkey_int(k, &k->pub_key, &k->pub_len);

  return k;
exit:
  key_free(k);
  return NULL;
}
开发者ID:jma127,项目名称:bitc-rpc,代码行数:28,代码来源:key.c


示例6: FC_THROW_EXCEPTION

    public_key::public_key( const compact_signature& c, const fc::sha256& digest, bool check_canonical )
    {
        int nV = c.data[0];
        if (nV<27 || nV>=35)
            FC_THROW_EXCEPTION( exception, "unable to reconstruct public key from signature" );

        ECDSA_SIG *sig = ECDSA_SIG_new();
        BN_bin2bn(&c.data[1],32,sig->r);
        BN_bin2bn(&c.data[33],32,sig->s);

        if( check_canonical )
        {
            FC_ASSERT( is_canonical( c ), "signature is not canonical" );
        }

        my->_key = EC_KEY_new_by_curve_name(NID_secp256k1);

        if (nV >= 31)
        {
            EC_KEY_set_conv_form( my->_key, POINT_CONVERSION_COMPRESSED );
            nV -= 4;
//            fprintf( stderr, "compressed\n" );
        }

        if (detail::public_key_impl::ECDSA_SIG_recover_key_GFp(my->_key, sig, (unsigned char*)&digest, sizeof(digest), nV - 27, 0) == 1)
        {
            ECDSA_SIG_free(sig);
            return;
        }
        ECDSA_SIG_free(sig);
        FC_THROW_EXCEPTION( exception, "unable to reconstruct public key from signature" );
    }
开发者ID:techsharesteam,项目名称:techshares,代码行数:32,代码来源:elliptic_impl_pub.cpp


示例7: bp_key_secret_set

bool bp_key_secret_set(struct bp_key *key, const void *privkey_, size_t pk_len)
{
	bp_key_free(key);

	if (!privkey_ || pk_len != 32)
		return false;

	const unsigned char *privkey = privkey_;
	BIGNUM *bn = BN_bin2bn(privkey, 32, BN_new());
	if (!bn)
		return false;

	key->k = EC_KEY_new_by_curve_name(NID_secp256k1);
	if (!key->k)
		goto err_out;
	
	if (!EC_KEY_regenerate_key(key->k, bn))
		goto err_out;
	if (!EC_KEY_check_key(key->k))
		return false;

	EC_KEY_set_conv_form(key->k, POINT_CONVERSION_COMPRESSED);

	BN_clear_free(bn);
	return true;

err_out:
	bp_key_free(key);
	BN_clear_free(bn);
	return false;
}
开发者ID:colindean,项目名称:picocoin,代码行数:31,代码来源:key.c


示例8: EC_KEY_set_conv_form

 public_key_point_data public_key::serialize_ecc_point()const
 {
   public_key_point_data dat;
   if( !my->_key ) return dat;
   EC_KEY_set_conv_form( my->_key, POINT_CONVERSION_UNCOMPRESSED );
   char* front = &dat.data[0];
   i2o_ECPublicKey( my->_key, (unsigned char**)&front ); // FIXME: questionable memory handling
   return dat;
 }
开发者ID:techsharesteam,项目名称:techshares,代码行数:9,代码来源:elliptic_impl_pub.cpp


示例9: EC_KEY_set_conv_form

void CECKey::GetPrivKey(CPrivKey &privkey, bool fCompressed) {
    EC_KEY_set_conv_form(pkey, fCompressed ? POINT_CONVERSION_COMPRESSED : POINT_CONVERSION_UNCOMPRESSED);
    int nSize = i2d_ECPrivateKey(pkey, NULL);
    assert(nSize);
    privkey.resize(nSize);
    unsigned char* pbegin = &privkey[0];
    int nSize2 = i2d_ECPrivateKey(pkey, &pbegin);
    assert(nSize == nSize2);
}
开发者ID:okcashpro,项目名称:okcash,代码行数:9,代码来源:eckey.cpp


示例10: bp_pubkey_set

bool bp_pubkey_set(struct bp_key *key, const void *pubkey_, size_t pk_len)
{
	const unsigned char *pubkey = pubkey_;
	if (!o2i_ECPublicKey(&key->k, &pubkey, pk_len))
		return false;
	if (pk_len == 33)
		EC_KEY_set_conv_form(key->k, POINT_CONVERSION_COMPRESSED);
	return true;
}
开发者ID:colindean,项目名称:picocoin,代码行数:9,代码来源:key.c


示例11: ec_key_new_secp256k1_compressed

static ec_key ec_key_new_secp256k1_compressed()
{
    EC_KEY* key = EC_KEY_new_by_curve_name (NID_secp256k1);

    if (key == nullptr)  throw std::runtime_error ("EC_KEY_new_by_curve_name() failed");

    EC_KEY_set_conv_form (key, POINT_CONVERSION_COMPRESSED);

    return ec_key((ec_key::pointer_t) key);
}
开发者ID:xdv,项目名称:divvyd,代码行数:10,代码来源:openssl.cpp


示例12: EC_KEY_set_conv_form

void CECKey::GetPubKey(std::vector<unsigned char> &pubkey, bool fCompressed) {
    EC_KEY_set_conv_form(pkey, fCompressed ? POINT_CONVERSION_COMPRESSED : POINT_CONVERSION_UNCOMPRESSED);
    int nSize = i2o_ECPublicKey(pkey, NULL);
    assert(nSize);
    assert(nSize <= 65);
    pubkey.clear();
    pubkey.resize(nSize);
    unsigned char *pbegin(begin_ptr(pubkey));
    int nSize2 = i2o_ECPublicKey(pkey, &pbegin);
    assert(nSize == nSize2);
}
开发者ID:zebbra2014,项目名称:bitcredit,代码行数:11,代码来源:ecwrapper.cpp


示例13: bp_privkey_set

bool bp_privkey_set(struct bp_key *key, const void *privkey_, size_t pk_len)
{
	const unsigned char *privkey = privkey_;
	if (!d2i_ECPrivateKey(&key->k, &privkey, pk_len))
		return false;
	if (!EC_KEY_check_key(key->k))
		return false;

	EC_KEY_set_conv_form(key->k, POINT_CONVERSION_COMPRESSED);

	return true;
}
开发者ID:colindean,项目名称:picocoin,代码行数:12,代码来源:key.c


示例14: mech_start

static int mech_start(sasl_session_t *p, char **out, size_t *out_len)
{
	ecdsa_session_t *s = mowgli_alloc(sizeof(ecdsa_session_t));
	p->mechdata = s;

	s->pubkey = EC_KEY_new_by_curve_name(CURVE_IDENTIFIER);
	s->step = ECDSA_ST_ACCNAME;

	EC_KEY_set_conv_form(s->pubkey, POINT_CONVERSION_COMPRESSED);

	return ASASL_MORE;
}
开发者ID:Acidburn0zzz,项目名称:atheme,代码行数:12,代码来源:ecdsa-nist256p-challenge.c


示例15: bp_key_generate

bool bp_key_generate(struct bp_key *key)
{
	if (!key->k)
		return false;

	if (!EC_KEY_generate_key(key->k))
		return false;
	if (!EC_KEY_check_key(key->k))
		return false;

	EC_KEY_set_conv_form(key->k, POINT_CONVERSION_COMPRESSED);

	return true;
}
开发者ID:colindean,项目名称:picocoin,代码行数:14,代码来源:key.c


示例16: EC_KEY_dup

ec_key::ec_key (const ec_key& that)
{
    if (that.ptr == nullptr)
    {
        ptr = nullptr;
        return;
    }

    ptr = (pointer_t) EC_KEY_dup (get_EC_KEY (that));

    if (ptr == nullptr)
    {
        throw std::runtime_error ("ec_key::ec_key() : EC_KEY_dup failed");
    }

    EC_KEY_set_conv_form (get_EC_KEY (*this), POINT_CONVERSION_COMPRESSED);
}
开发者ID:Joke-Dk,项目名称:rippled,代码行数:17,代码来源:ec_key.cpp


示例17: main

int
main(int argc, const char **argv)
{
	if (! libathemecore_early_init())
		return EXIT_FAILURE;

	BIO *out;
	EC_KEY *prv;
	unsigned char *workbuf, *workbuf_p;
	char encbuf[BUFSIZE];
	size_t len;

	memset(encbuf, '\0', sizeof encbuf);

	prv = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);

	EC_KEY_set_conv_form(prv, POINT_CONVERSION_COMPRESSED);
	EC_KEY_generate_key(prv);

	len = i2o_ECPublicKey(prv, NULL);
	workbuf = mowgli_alloc(len);
	workbuf_p = workbuf;
	i2o_ECPublicKey(prv, &workbuf_p);
	workbuf_p = workbuf;

	if (base64_encode(workbuf_p, len, encbuf, sizeof encbuf) == (size_t) -1)
	{
		fprintf(stderr, "Failed to encode public key!\n");
		return EXIT_FAILURE;
	}

	printf("Keypair:\n");
	EC_KEY_print_fp(stdout, prv, 4);

	printf("Private key:\n");
	out = BIO_new_fp(stdout, 0);
	PEM_write_bio_ECPrivateKey(out, prv, NULL, NULL, 0, NULL, NULL);

	printf("Public key (atheme format):\n");
	printf("%s\n", encbuf);

	return EXIT_SUCCESS;
}
开发者ID:aszrul,项目名称:atheme,代码行数:43,代码来源:main.c


示例18: EC_KEY_new_by_curve_name

EC_KEY *helper_gateway_key(const tal_t *ctx)
{
	const unsigned char *p = gateway_key;
	EC_KEY *priv = EC_KEY_new_by_curve_name(NID_secp256k1);
	EC_KEY **ptr;

	if (!d2i_ECPrivateKey(&priv, &p, sizeof(gateway_key)))
		abort();

	if (!EC_KEY_check_key(priv))
		abort();

	/* We *always* used compressed form keys. */
	EC_KEY_set_conv_form(priv, POINT_CONVERSION_COMPRESSED);

	/* To get tal to clean it up... */
	ptr = tal(ctx, EC_KEY *);
	*ptr = priv;
	tal_add_destructor(ptr, free_gateway_key);

	return priv;
}
开发者ID:kanghaiyang,项目名称:pettycoin,代码行数:22,代码来源:helper_gateway_key.c


示例19: EC_KEY_set_conv_form

void CKey::SetCompressedPubKey()
{
    EC_KEY_set_conv_form(pkey, POINT_CONVERSION_COMPRESSED);
    fCompressedPubKey = true;
}
开发者ID:uscoin,项目名称:uscoin,代码行数:5,代码来源:key.cpp


示例20: EC_KEY_set_conv_form

void CKey::SetUnCompressedPubKey()
{
    EC_KEY_set_conv_form(pkey, POINT_CONVERSION_UNCOMPRESSED);
    fCompressedPubKey = false;
}
开发者ID:IngenierosWeb,项目名称:pokecoin,代码行数:5,代码来源:key.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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