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


C++ i2o_ECPublicKey函数代码示例

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


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

示例1: eckey_pub_encode

static int eckey_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey)
	{
	EC_KEY *ec_key = pkey->pkey.ec;
	void *pval = NULL;
	int ptype;
	unsigned char *penc = NULL, *p;
	int penclen;

	if (!eckey_param2type(&ptype, &pval, ec_key))
		{
		ECerr(EC_F_ECKEY_PUB_ENCODE, ERR_R_EC_LIB);
		return 0;
		}
	penclen = i2o_ECPublicKey(ec_key, NULL);
	if (penclen <= 0)
		goto err;
	penc = OPENSSL_malloc(penclen);
	if (!penc)
		goto err;
	p = penc;
	penclen = i2o_ECPublicKey(ec_key, &p);
	if (penclen <= 0)
		goto err;
	if (X509_PUBKEY_set0_param(pk, OBJ_nid2obj(EVP_PKEY_EC),
				ptype, pval, penc, penclen))
		return 1;
	err:
	if (ptype == V_ASN1_OBJECT)
		ASN1_OBJECT_free(pval);
	else
		ASN1_STRING_free(pval);
	if (penc)
		OPENSSL_free(penc);
	return 0;
	}
开发者ID:RyunosukeOno,项目名称:rayjack,代码行数:35,代码来源:ec_ameth.c

示例2: opensslecdsa_todns

static isc_result_t
opensslecdsa_todns(const dst_key_t *key, isc_buffer_t *data) {
	isc_result_t ret;
	EVP_PKEY *pkey;
	EC_KEY *eckey = NULL;
	isc_region_t r;
	int len;
	unsigned char *cp;
	unsigned char buf[DNS_KEY_ECDSA384SIZE + 1];

	REQUIRE(key->keydata.pkey != NULL);

	pkey = key->keydata.pkey;
	eckey = EVP_PKEY_get1_EC_KEY(pkey);
	if (eckey == NULL)
		return (dst__openssl_toresult(ISC_R_FAILURE));
	len = i2o_ECPublicKey(eckey, NULL);
	/* skip form */
	len--;

	isc_buffer_availableregion(data, &r);
	if (r.length < (unsigned int) len)
		DST_RET (ISC_R_NOSPACE);
	cp = buf;
	if (!i2o_ECPublicKey(eckey, &cp))
		DST_RET (dst__openssl_toresult(ISC_R_FAILURE));
	memmove(r.base, buf + 1, len);
	isc_buffer_add(data, len);
	ret = ISC_R_SUCCESS;

 err:
	if (eckey != NULL)
		EC_KEY_free(eckey);
	return (ret);
}
开发者ID:SvenDowideit,项目名称:clearlinux,代码行数:35,代码来源:opensslecdsa_link.c

示例3: i2o_ECPublicKey

CPubKey CKey::GetPubKey() const
{
    int nSize = i2o_ECPublicKey(pkey, NULL);
    if (!nSize)
        throw key_error("CKey::GetPubKey() : i2o_ECPublicKey failed");
    std::vector<unsigned char> vchPubKey(nSize, 0);
    unsigned char* pbegin = &vchPubKey[0];
    if (i2o_ECPublicKey(pkey, &pbegin) != nSize)
        throw key_error("CKey::GetPubKey() : i2o_ECPublicKey returned unexpected size");
    return CPubKey(vchPubKey);
}
开发者ID:uscoin,项目名称:uscoin,代码行数:11,代码来源:key.cpp

示例4: EC_KEY_set_conv_form

void CECKey::GetPubKey(CPubKey &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);
    unsigned char c[65];
    unsigned char *pbegin = c;
    int nSize2 = i2o_ECPublicKey(pkey, &pbegin);
    assert(nSize == nSize2);
    pubkey.Set(&c[0], &c[nSize]);
}
开发者ID:okcashpro,项目名称:okcash,代码行数:11,代码来源:eckey.cpp

示例5: 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

示例6: i2o_ECPublicKey

		data_chunk elliptic_curve_key::public_key() const
		{
			// same as get_private_key
			int length = i2o_ECPublicKey(key_, NULL);
			if (!length)
				return data_chunk();
			data_chunk pubkey(length, 0);
			uint8_t* pubkey_begin = pubkey.data();
			if (i2o_ECPublicKey(key_, &pubkey_begin) != length)
				return data_chunk();
			return pubkey;
		}
开发者ID:ballisticwhisper,项目名称:decentralised,代码行数:12,代码来源:elliptic_curve_key.cpp

示例7: bp_pubkey_get

bool bp_pubkey_get(struct bp_key *key, void **pubkey, size_t *pk_len)
{
	if (!EC_KEY_check_key(key->k))
		return false;

	size_t sz = i2o_ECPublicKey(key->k, 0);
	unsigned char *orig_mem, *mem = malloc(sz);
	orig_mem = mem;
	i2o_ECPublicKey(key->k, &mem);

	*pubkey = orig_mem;
	*pk_len = sz;

	return true;
}
开发者ID:colindean,项目名称:picocoin,代码行数:15,代码来源: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: 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

示例10: key_get_pubkey_int

static bool key_get_pubkey_int(struct key *k, uint8 **pub, size_t *len) {
  uint8 *data;

  ASSERT(pub);
  *pub = NULL;
  *len = 0;

  if (!EC_KEY_check_key(k->key)) {
    NOT_TESTED();
    return 0;
  }

  *len = i2o_ECPublicKey(k->key, 0);
  ASSERT(*len <= 65);
  data = safe_malloc(*len);
  *pub = data;
  i2o_ECPublicKey(k->key, &data);

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

示例11: get_PublicKey

STDMETHODIMP CBECC::get_PublicKey(VARIANT *pVal)
{
	if (m_pECC == NULL)
		return E_NOTIMPL;

	if (!EC_KEY_check_key((EC_KEY*)m_pECC))
		return E_NOTIMPL;

	int nSize;

	if((nSize = i2o_ECPublicKey((EC_KEY*)m_pECC, NULL)) < 0)
		return E_NOTIMPL;

	CBVarPtr varPtr;
	varPtr.Create(nSize);

	if (!i2o_ECPublicKey((EC_KEY*)m_pECC, (unsigned char **)&varPtr.m_pData))
		return E_INVALIDARG;

	return varPtr.GetVariant(pVal);
}
开发者ID:2Quico,项目名称:netbox,代码行数:21,代码来源:BECC.cpp

示例12: eckey_pub_encode

static int eckey_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey) {
  EC_KEY *ec_key = pkey->pkey.ec;
  void *pval = NULL;
  int ptype;
  uint8_t *penc = NULL, *p;
  int penclen;

  if (!eckey_param2type(&ptype, &pval, ec_key)) {
    OPENSSL_PUT_ERROR(EVP, ERR_R_EC_LIB);
    return 0;
  }
  penclen = i2o_ECPublicKey(ec_key, NULL);
  if (penclen <= 0) {
    goto err;
  }
  penc = OPENSSL_malloc(penclen);
  if (!penc) {
    goto err;
  }
  p = penc;
  penclen = i2o_ECPublicKey(ec_key, &p);
  if (penclen <= 0) {
    goto err;
  }
  if (X509_PUBKEY_set0_param(pk, OBJ_nid2obj(EVP_PKEY_EC), ptype, pval, penc,
                             penclen)) {
    return 1;
  }

err:
  if (ptype == V_ASN1_OBJECT) {
    ASN1_OBJECT_free(pval);
  } else {
    ASN1_STRING_free(pval);
  }
  if (penc) {
    OPENSSL_free(penc);
  }
  return 0;
}
开发者ID:bheesham,项目名称:boringssl,代码行数:40,代码来源:p_ec_asn1.c

示例13: i2d_PublicKey

int i2d_PublicKey(EVP_PKEY *key, uint8_t **outp) {
  switch (key->type) {
    case EVP_PKEY_RSA:
      return i2d_RSAPublicKey(key->pkey.rsa, outp);
    case EVP_PKEY_DSA:
      return i2d_DSAPublicKey(key->pkey.dsa, outp);
    case EVP_PKEY_EC:
      return i2o_ECPublicKey(key->pkey.ec, outp);
    default:
      OPENSSL_PUT_ERROR(EVP, EVP_R_UNSUPPORTED_PUBLIC_KEY_TYPE);
      return -1;
  }
}
开发者ID:AadityaDev,项目名称:AadityaDev.github.io,代码行数:13,代码来源:evp_asn1.c

示例14: serialize_ec_point

void serialize_ec_point (ec_point const& point, std::uint8_t* ptr)
{
    ec_key key = ec_key_new_secp256k1_compressed();

    if (EC_KEY_set_public_key((EC_KEY*) key.get(), point.get()) <= 0)
    {
        throw std::runtime_error ("EC_KEY_set_public_key() failed");
    }

    int const size = i2o_ECPublicKey ((EC_KEY*) key.get(), &ptr);

    assert (size <= 33);
    (void) size;
}
开发者ID:xdv,项目名称:divvyd,代码行数:14,代码来源:openssl.cpp

示例15: ucrypto_ec_get_public_key_nif

ERL_NIF_TERM ucrypto_ec_get_public_key_nif(ErlNifEnv *env, int argc, const ERL_NIF_TERM argv[])
{
    int length;
    struct ec_key_handle *handle = NULL;
    ErlNifBinary public_key;

    if (! enif_get_resource(env, argv[0], ec_key_resource, (void **)&handle))
        return enif_make_badarg(env);

    if (! handle->key)
        return enif_make_tuple2(env, ATOM_ERROR, ATOM_UNINITIALIZED_KEY);

    length = i2o_ECPublicKey(handle->key, NULL);

    if (! length)
        return ATOM_ERROR;

    enif_alloc_binary(length, &public_key);

    if (i2o_ECPublicKey(handle->key, &public_key.data) != length)
        return ATOM_ERROR;

    return enif_make_binary(env, &public_key);
}
开发者ID:ahf,项目名称:erlang-ucrypto,代码行数:24,代码来源:ucrypto_ec.c


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