本文整理汇总了C++中i2d函数的典型用法代码示例。如果您正苦于以下问题:C++ i2d函数的具体用法?C++ i2d怎么用?C++ i2d使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了i2d函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: ASN1err
ASN1_STRING *ASN1_pack_string(void *obj, i2d_of_void *i2d, ASN1_STRING **oct)
{
unsigned char *p;
ASN1_STRING *octmp;
if (!oct || !*oct) {
if (!(octmp = ASN1_STRING_new ())) {
ASN1err(ASN1_F_ASN1_PACK_STRING,ERR_R_MALLOC_FAILURE);
return NULL;
}
if (oct) *oct = octmp;
} else octmp = *oct;
if (!(octmp->length = i2d(obj, NULL))) {
ASN1err(ASN1_F_ASN1_PACK_STRING,ASN1_R_ENCODE_ERROR);
goto err;
}
if (!(p = OPENSSL_malloc (octmp->length))) {
ASN1err(ASN1_F_ASN1_PACK_STRING,ERR_R_MALLOC_FAILURE);
goto err;
}
octmp->data = p;
i2d (obj, &p);
return octmp;
err:
if (!oct || !*oct)
{
ASN1_STRING_free(octmp);
if (oct)
*oct = NULL;
}
return NULL;
}
开发者ID:UNIVERSAL-IT-SYSTEMS,项目名称:shim,代码行数:33,代码来源:asn_pack.c
示例2: return
void *ASN1_dup (i2d_of_void * i2d, d2i_of_void * d2i, void *x)
{
unsigned char *b, *p;
const unsigned char *p2;
int i;
char *ret;
if (x == NULL)
return (NULL);
i = i2d (x, NULL);
b = OPENSSL_malloc (i + 10);
if (b == NULL)
{
ASN1err (ASN1_F_ASN1_DUP, ERR_R_MALLOC_FAILURE);
return (NULL);
}
p = b;
i = i2d (x, &p);
p2 = b;
ret = d2i (NULL, &p2, i);
OPENSSL_free (b);
return (ret);
}
开发者ID:274914765,项目名称:C,代码行数:27,代码来源:a_dup.c
示例3: ASN1_digest
int ASN1_digest(i2d_of_void *i2d, const EVP_MD *type, char *data,
unsigned char *md, unsigned int *len)
{
int inl;
unsigned char *str, *p;
inl = i2d(data, NULL);
if (inl <= 0) {
ASN1err(ASN1_F_ASN1_DIGEST, ERR_R_INTERNAL_ERROR);
return 0;
}
if ((str = OPENSSL_malloc(inl)) == NULL) {
ASN1err(ASN1_F_ASN1_DIGEST, ERR_R_MALLOC_FAILURE);
return 0;
}
p = str;
i2d(data, &p);
if (!EVP_Digest(str, inl, md, len, type, NULL)) {
OPENSSL_free(str);
return 0;
}
OPENSSL_free(str);
return 1;
}
开发者ID:Ana06,项目名称:openssl,代码行数:25,代码来源:a_digest.c
示例4: multiply
// Full multiplication.
// For every digit d in 'a' b is multiplied by d.
// Final result is obtained by addition of all results of multiplications with proper offset.
digit* multiply(const digit* a, const digit* b)
{
digit* result = 0;
int offset = 0;
while(a)
{
if(a->n != i2d(0))
{
digit* row = copy(b);
multiply_by_digit(row, d2i(a->n));
for(int i = 0; i < offset; ++i)
{
digit* new_row = new digit;
new_row->next = row;
new_row->n = i2d(0);
row = new_row;
}
addto(row, result);
deletebigint(row);
}
++offset;
a = a->next;
}
// needed when a or b is 0
rm_leading_0s(result);
return result;
}
开发者ID:foo,项目名称:ii,代码行数:30,代码来源:bigint.cpp
示例5: ASN1_i2d_bio
int ASN1_i2d_bio(i2d_of_void *i2d, BIO *out, void *x)
{
char *b;
unsigned char *p;
int i, j = 0, n, ret = 1;
n = i2d(x, NULL);
if (n <= 0)
return 0;
b = (char *)OPENSSL_malloc(n);
if (b == NULL) {
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
return (0);
}
p = (unsigned char *)b;
i2d(x, &p);
for (;;) {
i = BIO_write(out, &(b[j]), n);
if (i == n)
break;
if (i <= 0) {
ret = 0;
break;
}
j += i;
n -= i;
}
OPENSSL_free(b);
return (ret);
}
开发者ID:0x64616E69656C,项目名称:boringssl,代码行数:33,代码来源:a_i2d_fp.c
示例6: ASN1_i2d_bio
int ASN1_i2d_bio(i2d_of_void *i2d, BIO *out, uint8_t *x)
{
char *b;
uint8_t *p;
int i, j = 0, n, ret = 1;
n = i2d(x, NULL);
b = malloc(n);
if (b == NULL) {
ASN1err(ASN1_F_ASN1_I2D_BIO, ERR_R_MALLOC_FAILURE);
return (0);
}
p = (uint8_t *)b;
i2d(x, &p);
for (;;) {
i = BIO_write(out, &(b[j]), n);
if (i == n)
break;
if (i <= 0) {
ret = 0;
break;
}
j += i;
n -= i;
}
free(b);
return (ret);
}
开发者ID:vigortls,项目名称:vigortls,代码行数:30,代码来源:a_i2d_fp.c
示例7: ASN1_i2d_bio
int ASN1_i2d_bio(i2d_of_void *i2d, BIO *out, unsigned char *x)
{
char *b;
unsigned char *p;
int i, j = 0, n, ret = 1;
n = i2d(x, NULL);
if (n <= 0)
return 0;
b = OPENSSL_malloc(n);
if (b == NULL) {
ASN1err(ASN1_F_ASN1_I2D_BIO, ERR_R_MALLOC_FAILURE);
return 0;
}
p = (unsigned char *)b;
i2d(x, &p);
for (;;) {
i = BIO_write(out, &(b[j]), n);
if (i == n)
break;
if (i <= 0) {
ret = 0;
break;
}
j += i;
n -= i;
}
OPENSSL_free(b);
return ret;
}
开发者ID:RTEMS,项目名称:rtems-libbsd,代码行数:33,代码来源:a_i2d_fp.c
示例8: ASN1_verify
int ASN1_verify(i2d_of_void *i2d, X509_ALGOR *a, ASN1_BIT_STRING *signature,
char *data, EVP_PKEY *pkey)
{
EVP_MD_CTX *ctx = EVP_MD_CTX_new();
const EVP_MD *type;
unsigned char *p, *buf_in = NULL;
int ret = -1, i, inl;
if (ctx == NULL) {
ASN1err(ASN1_F_ASN1_VERIFY, ERR_R_MALLOC_FAILURE);
goto err;
}
i = OBJ_obj2nid(a->algorithm);
type = EVP_get_digestbyname(OBJ_nid2sn(i));
if (type == NULL) {
ASN1err(ASN1_F_ASN1_VERIFY, ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM);
goto err;
}
if (signature->type == V_ASN1_BIT_STRING && signature->flags & 0x7) {
ASN1err(ASN1_F_ASN1_VERIFY, ASN1_R_INVALID_BIT_STRING_BITS_LEFT);
goto err;
}
inl = i2d(data, NULL);
if (inl <= 0) {
ASN1err(ASN1_F_ASN1_VERIFY, ERR_R_INTERNAL_ERROR);
goto err;
}
buf_in = OPENSSL_malloc((unsigned int)inl);
if (buf_in == NULL) {
ASN1err(ASN1_F_ASN1_VERIFY, ERR_R_MALLOC_FAILURE);
goto err;
}
p = buf_in;
i2d(data, &p);
ret = EVP_VerifyInit_ex(ctx, type, NULL)
&& EVP_VerifyUpdate(ctx, (unsigned char *)buf_in, inl);
OPENSSL_clear_free(buf_in, (unsigned int)inl);
if (!ret) {
ASN1err(ASN1_F_ASN1_VERIFY, ERR_R_EVP_LIB);
goto err;
}
ret = -1;
if (EVP_VerifyFinal(ctx, (unsigned char *)signature->data,
(unsigned int)signature->length, pkey) <= 0) {
ASN1err(ASN1_F_ASN1_VERIFY, ERR_R_EVP_LIB);
ret = 0;
goto err;
}
ret = 1;
err:
EVP_MD_CTX_free(ctx);
return ret;
}
开发者ID:Ana06,项目名称:openssl,代码行数:59,代码来源:a_verify.c
示例9: ASN1_verify
int ASN1_verify(i2d_of_void *i2d, X509_ALGOR *a, ASN1_BIT_STRING *signature,
char *data, EVP_PKEY *pkey)
{
EVP_MD_CTX ctx;
const EVP_MD *type;
unsigned char *p, *buf_in = NULL;
int ret = -1, i, inl;
EVP_MD_CTX_init(&ctx);
i = OBJ_obj2nid(a->algorithm);
type = EVP_get_digestbyname(OBJ_nid2sn(i));
if (type == NULL) {
ASN1err(ASN1_F_ASN1_VERIFY, ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM);
goto err;
}
if (signature->type == V_ASN1_BIT_STRING && signature->flags & 0x7) {
ASN1err(ASN1_F_ASN1_VERIFY, ASN1_R_INVALID_BIT_STRING_BITS_LEFT);
goto err;
}
inl = i2d(data, NULL);
buf_in = OPENSSL_malloc((unsigned int)inl);
if (buf_in == NULL) {
ASN1err(ASN1_F_ASN1_VERIFY, ERR_R_MALLOC_FAILURE);
goto err;
}
p = buf_in;
i2d(data, &p);
ret = EVP_VerifyInit_ex(&ctx, type, NULL)
&& EVP_VerifyUpdate(&ctx, (unsigned char *)buf_in, inl);
OPENSSL_cleanse(buf_in, (unsigned int)inl);
OPENSSL_free(buf_in);
if (!ret) {
ASN1err(ASN1_F_ASN1_VERIFY, ERR_R_EVP_LIB);
goto err;
}
ret = -1;
if (EVP_VerifyFinal(&ctx, (unsigned char *)signature->data,
(unsigned int)signature->length, pkey) <= 0) {
ASN1err(ASN1_F_ASN1_VERIFY, ERR_R_EVP_LIB);
ret = 0;
goto err;
}
/*
* we don't need to zero the 'ctx' because we just checked public
* information
*/
/* memset(&ctx,0,sizeof(ctx)); */
ret = 1;
err:
EVP_MD_CTX_cleanup(&ctx);
return (ret);
}
开发者ID:Adallom,项目名称:openssl,代码行数:58,代码来源:a_verify.c
示例10: i2d_bytearray
QByteArray i2d_bytearray(int(*i2d)(const void*, unsigned char **),
const void *data)
{
QByteArray ba;
ba.resize(i2d(data, NULL));
unsigned char *p = (unsigned char*)ba.data();
i2d(data, &p);
openssl_error();
return ba;
}
开发者ID:jbfavre,项目名称:xca,代码行数:11,代码来源:func.cpp
示例11: rm_leading_0s
// Auxilary function for subtractfrom
void rm_leading_0s(digit*& big)
{
digit* last_non_0 = 0;
digit* big_iter = big;
while(big_iter)
{
if(big_iter->n != i2d(0))
last_non_0 = big_iter;
big_iter = big_iter->next;
}
if(last_non_0 == 0)
{
// no digits other then 0
big = 0;
}
else
{
if(last_non_0->next)
{
deletebigint(last_non_0->next);
}
last_non_0->next = 0;
}
}
开发者ID:foo,项目名称:ii,代码行数:26,代码来源:bigint.cpp
示例12: compare
bool pki_base::compare(pki_base *refcrl)
{
bool ret;
ret = (i2d() == refcrl->i2d());
pki_openssl_error();
return ret;
}
开发者ID:jbfavre,项目名称:xca,代码行数:7,代码来源:pki_base.cpp
示例13: i2d_vec
/* ======================================================================== */
void i2d_vec(double *d_vec,int *i_vec, int n)
{
int i;
for(i=0;i<n;i++){
*(d_vec+i)= i2d(*(i_vec+i));
}
}
开发者ID:haolong886,项目名称:arpa,代码行数:8,代码来源:DSP_gen_twiddle.c
示例14: ASN1_digest
int ASN1_digest(i2d_of_void *i2d, const EVP_MD *type, char *data,
unsigned char *md, unsigned int *len)
{
int i, ret;
unsigned char *str, *p;
i = i2d(data, NULL);
if ((str = (unsigned char *)OPENSSL_malloc(i)) == NULL) {
OPENSSL_PUT_ERROR(X509, ERR_R_MALLOC_FAILURE);
return (0);
}
p = str;
i2d(data, &p);
ret = EVP_Digest(str, i, md, len, type, NULL);
OPENSSL_free(str);
return ret;
}
开发者ID:0x64616E69656C,项目名称:boringssl,代码行数:18,代码来源:a_digest.c
示例15: multiply_by_digit
// Auxilary function for multiply.
// Performs one step of full multiplication.
void multiply_by_digit(digit* a, int x)
{
digit* original_a = a;
while(a)
{
a->n = i2d(d2i(a->n) * x);
a = a->next;
}
fix_over_9(original_a);
}
开发者ID:foo,项目名称:ii,代码行数:12,代码来源:bigint.cpp
示例16: ASN1_digest
int ASN1_digest(i2d_of_void *i2d, const EVP_MD *type, char *data,
unsigned char *md, unsigned int *len)
{
int i;
unsigned char *str,*p;
i=i2d(data,NULL);
if ((str=(unsigned char *)OPENSSL_malloc(i)) == NULL)
{
ASN1err(ASN1_F_ASN1_DIGEST,ERR_R_MALLOC_FAILURE);
return(0);
}
p=str;
i2d(data,&p);
EVP_Digest(str, i, md, len, type, NULL);
OPENSSL_free(str);
return(1);
}
开发者ID:CoryXie,项目名称:BarrelfishOS,代码行数:19,代码来源:a_digest.c
示例17: ASN1err
char *ASN1_dup(int (*i2d)(), char *(*d2i)(), char *x)
{
unsigned char *b,*p;
long i;
char *ret;
if (x == NULL) return(NULL);
i=(long)i2d(x,NULL);
b=(unsigned char *)OPENSSL_malloc((unsigned int)i+10);
if (b == NULL)
{ ASN1err(ASN1_F_ASN1_DUP,ERR_R_MALLOC_FAILURE); return(NULL); }
p= b;
i=i2d(x,&p);
p= b;
ret=d2i(NULL,&p,i);
OPENSSL_free(b);
return(ret);
}
开发者ID:FelipeFernandes1988,项目名称:Alice-1121-Modem,代码行数:19,代码来源:a_dup.c
示例18: i2d
QByteArray pki_evp::toData()
{
QByteArray ba;
ba += db::intToData(key->type);
ba += db::intToData(ownPass);
ba += i2d();
ba += encKey;
return ba;
}
开发者ID:J-Javan,项目名称:xca,代码行数:10,代码来源:pki_evp.cpp
示例19: i2d
QByteArray pki_x509req::toData()
{
QByteArray ba;
ba += i2d();
if (spki) {
ba += i2d_spki();
}
pki_openssl_error();
return ba;
}
开发者ID:jbfavre,项目名称:xca,代码行数:11,代码来源:pki_x509req.cpp
示例20: fix_over_9
// Moves carry foreward.
// This function is more general then fix_under_0 because
// fix_over_9 is used in addition as well as in multiplication,
// where temporarily excessive values can range up to 9*9 = 81
// with carry = 8
void fix_over_9(digit* big)
{
while(big)
{
if(d2i(big->n) > 9)
{
int carry = d2i(big->n) / 10;
big->n = i2d(d2i(big->n) % 10);
assert(carry > 0);
if(big->next)
big->next->n = i2d(d2i(big->next->n) + carry);
else
{
big->next = new digit;
big->next->next = 0;
big->next->n = i2d(carry);
}
}
big = big->next;
}
}
开发者ID:foo,项目名称:ii,代码行数:29,代码来源:bigint.cpp
注:本文中的i2d函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论