本文整理汇总了C++中OBJ_nid2ln函数的典型用法代码示例。如果您正苦于以下问题:C++ OBJ_nid2ln函数的具体用法?C++ OBJ_nid2ln怎么用?C++ OBJ_nid2ln使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了OBJ_nid2ln函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: NETSCAPE_SPKI_print
int NETSCAPE_SPKI_print(BIO *out, NETSCAPE_SPKI *spki)
{
EVP_PKEY *pkey;
ASN1_IA5STRING *chal;
int i, n;
char *s;
BIO_printf(out, "Netscape SPKI:\n");
i=OBJ_obj2nid(spki->spkac->pubkey->algor->algorithm);
BIO_printf(out," Public Key Algorithm: %s\n",
(i == NID_undef)?"UNKNOWN":OBJ_nid2ln(i));
pkey = X509_PUBKEY_get(spki->spkac->pubkey);
if(!pkey) BIO_printf(out, " Unable to load public key\n");
else {
#ifndef OPENSSL_NO_RSA
if (pkey->type == EVP_PKEY_RSA)
{
BIO_printf(out," RSA Public Key: (%d bit)\n",
BN_num_bits(pkey->pkey.rsa->n));
RSA_print(out,pkey->pkey.rsa,2);
}
else
#endif
#ifndef OPENSSL_NO_DSA
if (pkey->type == EVP_PKEY_DSA)
{
BIO_printf(out," DSA Public Key:\n");
DSA_print(out,pkey->pkey.dsa,2);
}
else
#endif
#ifndef OPENSSL_NO_EC
if (pkey->type == EVP_PKEY_EC)
{
BIO_printf(out, " EC Public Key:\n");
EC_KEY_print(out, pkey->pkey.ec,2);
}
else
#endif
BIO_printf(out," Unknown Public Key:\n");
EVP_PKEY_free(pkey);
}
chal = spki->spkac->challenge;
if(chal->length)
BIO_printf(out, " Challenge String: %s\n", chal->data);
i=OBJ_obj2nid(spki->sig_algor->algorithm);
BIO_printf(out," Signature Algorithm: %s",
(i == NID_undef)?"UNKNOWN":OBJ_nid2ln(i));
n=spki->signature->length;
s=(char *)spki->signature->data;
for (i=0; i<n; i++)
{
if ((i%18) == 0) BIO_write(out,"\n ",7);
BIO_printf(out,"%02x%s",(unsigned char)s[i],
((i+1) == n)?"":":");
}
BIO_write(out,"\n",1);
return 1;
}
示例2: EVP_add_digest
int EVP_add_digest(const EVP_MD *md)
{
int r;
const char *name;
OPENSSL_init();
name = OBJ_nid2sn(md->type);
r = OBJ_NAME_add(name, OBJ_NAME_TYPE_MD_METH, (const char *)md);
if (r == 0)
return (0);
check_defer(md->type);
r = OBJ_NAME_add(OBJ_nid2ln(md->type), OBJ_NAME_TYPE_MD_METH,
(const char *)md);
if (r == 0)
return (0);
if (md->pkey_type && md->type != md->pkey_type) {
r = OBJ_NAME_add(OBJ_nid2sn(md->pkey_type),
OBJ_NAME_TYPE_MD_METH | OBJ_NAME_ALIAS, name);
if (r == 0)
return (0);
check_defer(md->pkey_type);
r = OBJ_NAME_add(OBJ_nid2ln(md->pkey_type),
OBJ_NAME_TYPE_MD_METH | OBJ_NAME_ALIAS, name);
}
return (r);
}
示例3: check_nid
static int check_nid(const char *name, int expected_nid, int nid)
{
if (expected_nid == 0 || expected_nid == nid)
return 1;
TEST_error("%s type mismatch, %s vs %s\n",
name, OBJ_nid2ln(expected_nid),
nid == NID_undef ? "absent" : OBJ_nid2ln(nid));
return 0;
}
示例4: check_tmp_key
static int check_tmp_key(HANDSHAKE_RESULT *result, SSL_TEST_CTX *test_ctx)
{
if (test_ctx->expected_tmp_key_type == 0
|| test_ctx->expected_tmp_key_type == result->tmp_key_type)
return 1;
fprintf(stderr, "Tmp key type mismatch, %s vs %s\n",
OBJ_nid2ln(test_ctx->expected_tmp_key_type),
OBJ_nid2ln(result->tmp_key_type));
return 0;
}
示例5: dbheader
dbheaderList db_x509req::getHeaders()
{
dbheaderList h = db_x509super::getHeaders();
h << new dbheader(HD_req_signed, true, tr("Signed"),
tr("whether the request is already signed or not")) <<
new dbheader(HD_req_unstr_name, false, tr("Unstructured name"),
QString(OBJ_nid2ln(NID_pkcs9_unstructuredName))) <<
new dbheader(HD_req_chall_pass, false, tr("Challenge password"),
QString(OBJ_nid2ln(NID_pkcs9_challengePassword)));
return h;
}
示例6: dbheader
db_x509req::db_x509req(QString DBfile, MainWindow *mw)
:db_x509super(DBfile, mw)
{
allHeaders << new dbheader(HD_req_signed, true, tr("Signed"),
tr("whether the request is already signed or not")) <<
new dbheader(HD_req_unstr_name, false, tr("Unstructured name"),
QString(OBJ_nid2ln(NID_pkcs9_unstructuredName))) <<
new dbheader(HD_req_chall_pass, false, tr("Challenge password"),
QString(OBJ_nid2ln(NID_pkcs9_challengePassword)));
class_name = "requests";
pkitype << x509_req;
loadContainer();
}
示例7: 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;
}
示例8: 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;
}
示例9: main
int main(int argc, char **argv) {
ASN1_OBJECT *obj = NULL;
int tmp_size = 0;
int oid_len = 0;
if (argc < 2) {
usage(argv[0]);
return 0;
}
char *oid = NULL;
char *sn = NULL;
char *ln = NULL;
oid = (char *) malloc(STRSIZE + 1);
if (oid == NULL) {
printf("Error allocating %i bytes for oid string\n", STRSIZE + 1);
}
oid[STRSIZE] = '\0';
int nid = atoi(argv[1]);
printf("searching for nid shortname for %i\n", nid);
sn = (char *) OBJ_nid2sn(nid);
ln = (char *) OBJ_nid2ln(nid);
obj = OBJ_nid2obj(nid);
if (obj != NULL) {
oid_len = OBJ_obj2txt(oid, STRSIZE, obj, 1);
if (oid_len > 0) {
oid[oid_len] = '\0';
} else {
strncpy(oid, "Unkown", STRSIZE);
}
} else {
oid = strncpy(oid, "Unknown", STRSIZE);
}
printf("sb=\"%s\" ln=\"%s\" oid=\"%s\"\n", sn, ln, oid);
free(oid);
return 0;
}
示例10: test_tbl_standard
static int test_tbl_standard(void)
{
const ASN1_STRING_TABLE *tmp;
int last_nid = -1;
size_t i;
for (tmp = tbl_standard, i = 0; i < OSSL_NELEM(tbl_standard); i++, tmp++) {
if (tmp->nid < last_nid) {
last_nid = 0;
break;
}
last_nid = tmp->nid;
}
if (TEST_int_ne(last_nid, 0)) {
TEST_info("asn1 tbl_standard: Table order OK");
return 1;
}
TEST_info("asn1 tbl_standard: out of order");
for (tmp = tbl_standard, i = 0; i < OSSL_NELEM(tbl_standard); i++, tmp++)
TEST_note("asn1 tbl_standard: Index %zu, NID %d, Name=%s",
i, tmp->nid, OBJ_nid2ln(tmp->nid));
return 0;
}
示例11: IoObject_new
IoObject *IoCertificate_attributes(IoCertificate *self, IoObject *locals, IoMessage *m)
{
IoObject *map = IoObject_new(IoObject_state(self));
const EVP_PKEY *pkey = X509_extract_key(X509(self));
int i;
for(i = 0; i < EVP_PKEY_get_attr_count(pkey); i++)
{
IoList *list = IoList_new(IoObject_state(self));
X509_ATTRIBUTE *attr = EVP_PKEY_get_attr(pkey, i);
const char *key = (const char *)OBJ_nid2ln(OBJ_obj2nid(X509_ATTRIBUTE_get0_object(attr)));
int j;
for(j = 0; j < X509_ATTRIBUTE_count(attr); j++)
{
ASN1_TYPE *attrType = X509_ATTRIBUTE_get0_type(attr, j);
ASN1_OBJECT *attrData = X509_ATTRIBUTE_get0_data(attr, j, attrType->type, NULL);
//consider switching on attrType instead;
//really, that would be wiser, so that dates,
//numbers, etc can be happy
/*
switch(attrType->type) {
case V_ASN1_OCTET_STRING:
...
*/
int len = i2t_ASN1_OBJECT(NULL, 0, attrData);
char *value = calloc(len, sizeof(char));
i2t_ASN1_OBJECT(value, len, attrData);
IoList_rawAppend_(list, IoSeq_newWithCString_(IoObject_state(self), value));
}
IoObject_setSlot_to_(map, IOSYMBOL(key), list);
}
return map;
}
示例12: main
int main(int argc, char **argv)
{
X509 *cert;
FILE *inf;
int i, count;
X509_EXTENSION *ext;
X509V3_add_standard_extensions();
ERR_load_crypto_strings();
if(!argv[1]) {
fprintf(stderr, "Usage v3prin cert.pem\n");
exit(1);
}
if(!(inf = fopen(argv[1], "r"))) {
fprintf(stderr, "Can't open %s\n", argv[1]);
exit(1);
}
if(!(cert = PEM_read_X509(inf, NULL, NULL))) {
fprintf(stderr, "Can't read certificate %s\n", argv[1]);
ERR_print_errors_fp(stderr);
exit(1);
}
fclose(inf);
count = X509_get_ext_count(cert);
printf("%d extensions\n", count);
for(i = 0; i < count; i++) {
ext = X509_get_ext(cert, i);
printf("%s\n", OBJ_nid2ln(OBJ_obj2nid(ext->object)));
if(!X509V3_EXT_print_fp(stdout, ext, 0, 0)) ERR_print_errors_fp(stderr);
printf("\n");
}
return 0;
}
示例13: main
main()
{
ASN1_STRING_TABLE *tmp;
int i, last_nid = -1;
for (tmp = tbl_standard, i = 0;
i < sizeof(tbl_standard)/sizeof(ASN1_STRING_TABLE); i++, tmp++)
{
if (tmp->nid < last_nid)
{
last_nid = 0;
break;
}
last_nid = tmp->nid;
}
if (last_nid != 0)
{
printf("Table order OK\n");
exit(0);
}
for (tmp = tbl_standard, i = 0;
i < sizeof(tbl_standard)/sizeof(ASN1_STRING_TABLE); i++, tmp++)
printf("Index %d, NID %d, Name=%s\n", i, tmp->nid,
OBJ_nid2ln(tmp->nid));
}
示例14: test_pkey_meths
/* Test of EVP_PKEY_METHOD ordering */
static int test_pkey_meths(void)
{
size_t i;
int prev = -1;
int good = 1;
int pkey_id;
const EVP_PKEY_METHOD *pmeth;
for (i = 0; i < EVP_PKEY_meth_get_count(); i++) {
pmeth = EVP_PKEY_meth_get0(i);
EVP_PKEY_meth_get0_info(&pkey_id, NULL, pmeth);
if (pkey_id < prev)
good = 0;
prev = pkey_id;
}
if (!good) {
TEST_error("EVP_PKEY_METHOD table out of order");
for (i = 0; i < EVP_PKEY_meth_get_count(); i++) {
pmeth = EVP_PKEY_meth_get0(i);
EVP_PKEY_meth_get0_info(&pkey_id, NULL, pmeth);
TEST_note("%d : %s", pkey_id, OBJ_nid2ln(pkey_id));
}
}
return good;
}
示例15: d2i_X509_PKEY
X509_PKEY *
d2i_X509_PKEY(X509_PKEY **a, const unsigned char **pp, long length)
{
int i;
M_ASN1_D2I_vars(a, X509_PKEY *, X509_PKEY_new);
M_ASN1_D2I_Init();
M_ASN1_D2I_start_sequence();
M_ASN1_D2I_get_x(X509_ALGOR, ret->enc_algor, d2i_X509_ALGOR);
M_ASN1_D2I_get_x(ASN1_OCTET_STRING, ret->enc_pkey,
d2i_ASN1_OCTET_STRING);
ret->cipher.cipher = EVP_get_cipherbyname(
OBJ_nid2ln(OBJ_obj2nid(ret->enc_algor->algorithm)));
if (ret->cipher.cipher == NULL) {
c.error = ASN1_R_UNSUPPORTED_CIPHER;
c.line = __LINE__;
goto err;
}
if (ret->enc_algor->parameter->type == V_ASN1_OCTET_STRING) {
i = ret->enc_algor->parameter->value.octet_string->length;
if (i > EVP_MAX_IV_LENGTH) {
c.error = ASN1_R_IV_TOO_LARGE;
c.line = __LINE__;
goto err;
}
memcpy(ret->cipher.iv,
ret->enc_algor->parameter->value.octet_string->data, i);
} else
memset(ret->cipher.iv, 0, EVP_MAX_IV_LENGTH);
M_ASN1_D2I_Finish(a, X509_PKEY_free, ASN1_F_D2I_X509_PKEY);
}