本文整理汇总了C++中i2o_ECPublicKey函数的典型用法代码示例。如果您正苦于以下问题:C++ i2o_ECPublicKey函数的具体用法?C++ i2o_ECPublicKey怎么用?C++ i2o_ECPublicKey使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了i2o_ECPublicKey函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: main
int main(int argc, char **argv)
{
unsigned char ecprot[128];
unsigned char pbuf[1024];
EC_KEY *pkey;
EC_POINT *ptnew, *ptmpk, *ptz;
BIGNUM z;
unsigned char *pend = (unsigned char *) pbuf, *px;
unsigned char hash1[32], hashz[32];
int n, zlen;
if(argc < 3) {
printf("Usage: %s <mpk> <seq>\n", argv[0]);
exit(1);
}
OpenSSL_add_all_algorithms();
strcpy(pbuf, argv[2]);
strcat(pbuf, ":0:");
zlen = strlen(pbuf);
px = pbuf + zlen;
for(n=0; n < 64; n++)
px[n] = hex(argv[1][n*2])*16 + hex(argv[1][n*2+1]);
SHA256(pbuf, zlen+64, hash1);
SHA256(hash1, sizeof(hash1), hashz);
BN_init(&z);
BN_bin2bn(hashz, 32, &z);
pkey = EC_KEY_new_by_curve_name(NID_secp256k1);
ptmpk = EC_POINT_new(EC_KEY_get0_group(pkey));
pbuf[zlen-1] = 0x04;
EC_POINT_oct2point(EC_KEY_get0_group(pkey), ptmpk, pbuf+zlen-1, 65, NULL);
ptz = EC_POINT_new(EC_KEY_get0_group(pkey));
EC_POINT_mul(EC_KEY_get0_group(pkey), ptz, NULL, EC_GROUP_get0_generator(EC_KEY_get0_group(pkey)), &z, NULL);
ptnew = EC_POINT_new(EC_KEY_get0_group(pkey));
EC_POINT_add(EC_KEY_get0_group(pkey), ptnew, ptmpk, ptz, NULL);
EC_KEY_set_public_key(pkey, ptnew);
i2o_ECPublicKey(pkey, &pend);
b58encode_address(EC_KEY_get0_public_key(pkey), EC_KEY_get0_group(pkey), 0, ecprot);
printf("%s\n", ecprot);
}
开发者ID:9cat,项目名称:misc,代码行数:43,代码来源:mpkgen.c
示例17: i2d_PublicKey
int i2d_PublicKey(EVP_PKEY *a, unsigned char **pp)
{
switch (a->type) {
#ifndef OPENSSL_NO_RSA
case EVP_PKEY_RSA:
return (i2d_RSAPublicKey(a->pkey.rsa, pp));
#endif
#ifndef OPENSSL_NO_DSA
case EVP_PKEY_DSA:
return (i2d_DSAPublicKey(a->pkey.dsa, pp));
#endif
#ifndef OPENSSL_NO_EC
case EVP_PKEY_EC:
return (i2o_ECPublicKey(a->pkey.ec, pp));
#endif
default:
ASN1err(ASN1_F_I2D_PUBLICKEY, ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE);
return (-1);
}
}
开发者ID:03050903,项目名称:godot,代码行数:20,代码来源:i2d_pu.c
示例18: i2d_PublicKey
int i2d_PublicKey(const EVP_PKEY *a, unsigned char **pp)
{
switch (EVP_PKEY_id(a)) {
#ifndef OPENSSL_NO_RSA
case EVP_PKEY_RSA:
return i2d_RSAPublicKey(EVP_PKEY_get0_RSA(a), pp);
#endif
#ifndef OPENSSL_NO_DSA
case EVP_PKEY_DSA:
return i2d_DSAPublicKey(EVP_PKEY_get0_DSA(a), pp);
#endif
#ifndef OPENSSL_NO_EC
case EVP_PKEY_EC:
return i2o_ECPublicKey(EVP_PKEY_get0_EC_KEY(a), pp);
#endif
default:
ASN1err(ASN1_F_I2D_PUBLICKEY, ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE);
return -1;
}
}
开发者ID:Ana06,项目名称:openssl,代码行数:20,代码来源:i2d_pu.c
示例19: Bitcoin_MakePublicKeyFromPrivateKey
BitcoinResult Bitcoin_MakePublicKeyFromPrivateKey(
struct BitcoinPublicKey *public_key,
const struct BitcoinPrivateKey *private_key
)
{
BN_CTX *ctx = NULL;
EC_KEY *key = NULL;
EC_POINT *ec_public = NULL;
unsigned char *public_key_ptr = public_key->data;
BIGNUM *private_key_bn;
const EC_GROUP *group = NULL;
int size, size2;
unsigned compression = private_key->public_key_compression;
size_t expected_public_key_size = 0;
enum BitcoinPublicKeyCompression public_key_compression;
switch (compression) {
case BITCOIN_PUBLIC_KEY_COMPRESSED :
case BITCOIN_PUBLIC_KEY_UNCOMPRESSED :
break;
default :
applog(APPLOG_ERROR, __func__,
"public key compression is not specified, please set using"
" --public-key-compression compressed/uncompressed"
);
EC_KEY_free(key);
return BITCOIN_ERROR_PRIVATE_KEY_INVALID_FORMAT;
break;
}
key = EC_KEY_new_by_curve_name_NID_secp256k1();
if (!key) {
applog(APPLOG_ERROR, __func__,
"EC_KEY_new_by_curve_name failed: %s",
ERR_error_string(ERR_get_error(), NULL)
);
return BITCOIN_ERROR_LIBRARY_FAILURE;
}
group = EC_KEY_get0_group(key);
if (!group) {
applog(APPLOG_ERROR, __func__,
"EC_KEY_get0_group failed: %s",
ERR_error_string(ERR_get_error(), NULL)
);
EC_KEY_free(key);
return BITCOIN_ERROR_LIBRARY_FAILURE;
}
private_key_bn = BN_new();
BN_bin2bn(private_key->data, BITCOIN_PRIVATE_KEY_SIZE, private_key_bn);
ec_public = EC_POINT_new(group);
ctx = BN_CTX_new();
if (!ctx) {
applog(APPLOG_ERROR, __func__,
"BN_CTX_new failed: %s",
ERR_error_string(ERR_get_error(), NULL)
);
EC_KEY_free(key);
return BITCOIN_ERROR_LIBRARY_FAILURE;
}
if (!EC_POINT_mul(group, ec_public, private_key_bn, NULL, NULL, ctx)) {
applog(APPLOG_ERROR, __func__,
"EC_POINT_mul failed: %s",
ERR_error_string(ERR_get_error(), NULL)
);
EC_KEY_free(key);
return BITCOIN_ERROR_LIBRARY_FAILURE;
}
EC_KEY_set_private_key(key, private_key_bn);
EC_KEY_set_public_key(key, ec_public);
if (compression == BITCOIN_PUBLIC_KEY_COMPRESSED) {
EC_KEY_set_conv_form(key, POINT_CONVERSION_COMPRESSED);
expected_public_key_size = BITCOIN_PUBLIC_KEY_COMPRESSED_SIZE;
public_key_compression = BITCOIN_PUBLIC_KEY_COMPRESSED;
} else {
EC_KEY_set_conv_form(key, POINT_CONVERSION_UNCOMPRESSED);
expected_public_key_size = BITCOIN_PUBLIC_KEY_UNCOMPRESSED_SIZE;
public_key_compression = BITCOIN_PUBLIC_KEY_UNCOMPRESSED;
}
size = i2o_ECPublicKey(key, NULL);
if (size != expected_public_key_size) {
fprintf(stderr, "%s: invalid public key size (%u), should be %u\n",
__func__,
(unsigned)size,
(unsigned)expected_public_key_size
);
BN_free(private_key_bn);
EC_KEY_free(key);
return BITCOIN_ERROR_PUBLIC_KEY_INVALID_FORMAT;
}
size2 = i2o_ECPublicKey(key, &public_key_ptr);
if (size2 != expected_public_key_size) {
//.........这里部分代码省略.........
开发者ID:matja,项目名称:bitcoin-tool,代码行数:101,代码来源:keys.c
示例20: vg_output_match_console
void
vg_output_match_console(vg_context_t *vcp, EC_KEY *pkey, const char *pattern)
{
unsigned char key_buf[512], *pend;
char addr_buf[64], addr2_buf[64];
char privkey_buf[VG_PROTKEY_MAX_B58];
const char *keytype = "Privkey";
int len;
int isscript = (vcp->vc_format == VCF_SCRIPT);
EC_POINT *ppnt;
int free_ppnt = 0;
if (vcp->vc_pubkey_base) {
ppnt = EC_POINT_new(EC_KEY_get0_group(pkey));
EC_POINT_copy(ppnt, EC_KEY_get0_public_key(pkey));
EC_POINT_add(EC_KEY_get0_group(pkey),
ppnt,
ppnt,
vcp->vc_pubkey_base,
NULL);
free_ppnt = 1;
keytype = "PrivkeyPart";
} else {
ppnt = (EC_POINT *) EC_KEY_get0_public_key(pkey);
}
assert(EC_KEY_check_key(pkey));
vg_encode_address(ppnt,
EC_KEY_get0_group(pkey),
vcp->vc_pubkeytype, addr_buf);
if (isscript)
vg_encode_script_address(ppnt,
EC_KEY_get0_group(pkey),
vcp->vc_addrtype, addr2_buf);
if (vcp->vc_key_protect_pass) {
len = vg_protect_encode_privkey(privkey_buf,
pkey, vcp->vc_privtype,
VG_PROTKEY_DEFAULT,
vcp->vc_key_protect_pass);
if (len) {
keytype = "Protkey";
} else {
fprintf(stderr,
"ERROR: could not password-protect key\n");
vcp->vc_key_protect_pass = NULL;
}
}
if (!vcp->vc_key_protect_pass) {
vg_encode_privkey(pkey, vcp->vc_privtype, privkey_buf);
}
if (!vcp->vc_result_file || (vcp->vc_verbose > 0)) {
printf("\r%79s\r\nPattern: %s\n", "", pattern);
}
if (vcp->vc_verbose > 0) {
if (vcp->vc_verbose > 1) {
pend = key_buf;
len = i2o_ECPublicKey(pkey, &pend);
printf("Pubkey (hex): ");
dumphex(key_buf, len);
printf("Privkey (hex): ");
dumpbn(EC_KEY_get0_private_key(pkey));
pend = key_buf;
len = i2d_ECPrivateKey(pkey, &pend);
printf("Privkey (ASN1): ");
dumphex(key_buf, len);
}
}
if (!vcp->vc_result_file || (vcp->vc_verbose > 0)) {
if (isscript)
printf("P2SHAddress: %s\n", addr2_buf);
printf("Address: %s\n"
"%s: %s\n",
addr_buf, keytype, privkey_buf);
}
if (vcp->vc_result_file) {
FILE *fp = fopen(vcp->vc_result_file, "a");
if (!fp) {
fprintf(stderr,
"ERROR: could not open result file: %s\n",
strerror(errno));
} else {
fprintf(fp,
"Pattern: %s\n"
, pattern);
if (isscript)
fprintf(fp, "P2SHAddress: %s\n", addr2_buf);
fprintf(fp,
"Address: %s\n"
"%s: %s\n",
addr_buf, keytype, privkey_buf);
fclose(fp);
}
}
if (free_ppnt)
//.........这里部分代码省略.........
开发者ID:bifubao,项目名称:vanitygen,代码行数:101,代码来源:pattern.c
注:本文中的i2o_ECPublicKey函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论