Latest update
This commit is contained in:
+2
-2
@@ -13,7 +13,7 @@
|
||||
|
||||
#ifndef NO_OLD_ASN1
|
||||
|
||||
void *ASN1_dup(i2d_of_void *i2d, d2i_of_void *d2i, void *x)
|
||||
void *ASN1_dup(i2d_of_void *i2d, d2i_of_void *d2i, const void *x)
|
||||
{
|
||||
unsigned char *b, *p;
|
||||
const unsigned char *p2;
|
||||
@@ -46,7 +46,7 @@ void *ASN1_dup(i2d_of_void *i2d, d2i_of_void *d2i, void *x)
|
||||
* decode.
|
||||
*/
|
||||
|
||||
void *ASN1_item_dup(const ASN1_ITEM *it, void *x)
|
||||
void *ASN1_item_dup(const ASN1_ITEM *it, const void *x)
|
||||
{
|
||||
unsigned char *b = NULL;
|
||||
const unsigned char *p;
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#ifndef NO_OLD_ASN1
|
||||
|
||||
# ifndef OPENSSL_NO_STDIO
|
||||
int ASN1_i2d_fp(i2d_of_void *i2d, FILE *out, void *x)
|
||||
int ASN1_i2d_fp(i2d_of_void *i2d, FILE *out, const void *x)
|
||||
{
|
||||
BIO *b;
|
||||
int ret;
|
||||
@@ -31,7 +31,7 @@ int ASN1_i2d_fp(i2d_of_void *i2d, FILE *out, void *x)
|
||||
}
|
||||
# endif
|
||||
|
||||
int ASN1_i2d_bio(i2d_of_void *i2d, BIO *out, unsigned char *x)
|
||||
int ASN1_i2d_bio(i2d_of_void *i2d, BIO *out, const void *x)
|
||||
{
|
||||
char *b;
|
||||
unsigned char *p;
|
||||
@@ -68,7 +68,7 @@ int ASN1_i2d_bio(i2d_of_void *i2d, BIO *out, unsigned char *x)
|
||||
#endif
|
||||
|
||||
#ifndef OPENSSL_NO_STDIO
|
||||
int ASN1_item_i2d_fp(const ASN1_ITEM *it, FILE *out, void *x)
|
||||
int ASN1_item_i2d_fp(const ASN1_ITEM *it, FILE *out, const void *x)
|
||||
{
|
||||
BIO *b;
|
||||
int ret;
|
||||
@@ -84,7 +84,7 @@ int ASN1_item_i2d_fp(const ASN1_ITEM *it, FILE *out, void *x)
|
||||
}
|
||||
#endif
|
||||
|
||||
int ASN1_item_i2d_bio(const ASN1_ITEM *it, BIO *out, void *x)
|
||||
int ASN1_item_i2d_bio(const ASN1_ITEM *it, BIO *out, const void *x)
|
||||
{
|
||||
unsigned char *b = NULL;
|
||||
int i, j = 0, n, ret = 1;
|
||||
|
||||
@@ -9,6 +9,9 @@
|
||||
|
||||
/* Internal ASN1 structures and functions: not for application use */
|
||||
|
||||
typedef const ASN1_VALUE const_ASN1_VALUE;
|
||||
SKM_DEFINE_STACK_OF(const_ASN1_VALUE, const ASN1_VALUE, ASN1_VALUE)
|
||||
|
||||
int asn1_time_to_tm(struct tm *tm, const ASN1_TIME *d);
|
||||
int asn1_utctime_to_tm(struct tm *tm, const ASN1_UTCTIME *d);
|
||||
int asn1_generalizedtime_to_tm(struct tm *tm, const ASN1_GENERALIZEDTIME *d);
|
||||
@@ -46,19 +49,22 @@ DEFINE_STACK_OF(MIME_HEADER)
|
||||
void asn1_string_embed_free(ASN1_STRING *a, int embed);
|
||||
|
||||
int asn1_get_choice_selector(ASN1_VALUE **pval, const ASN1_ITEM *it);
|
||||
int asn1_get_choice_selector_const(const ASN1_VALUE **pval, const ASN1_ITEM *it);
|
||||
int asn1_set_choice_selector(ASN1_VALUE **pval, int value,
|
||||
const ASN1_ITEM *it);
|
||||
|
||||
ASN1_VALUE **asn1_get_field_ptr(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt);
|
||||
const ASN1_VALUE **asn1_get_const_field_ptr(const ASN1_VALUE **pval,
|
||||
const ASN1_TEMPLATE *tt);
|
||||
|
||||
const ASN1_TEMPLATE *asn1_do_adb(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt,
|
||||
const ASN1_TEMPLATE *asn1_do_adb(const ASN1_VALUE *val, const ASN1_TEMPLATE *tt,
|
||||
int nullerr);
|
||||
|
||||
int asn1_do_lock(ASN1_VALUE **pval, int op, const ASN1_ITEM *it);
|
||||
|
||||
void asn1_enc_init(ASN1_VALUE **pval, const ASN1_ITEM *it);
|
||||
void asn1_enc_free(ASN1_VALUE **pval, const ASN1_ITEM *it);
|
||||
int asn1_enc_restore(int *len, unsigned char **out, ASN1_VALUE **pval,
|
||||
int asn1_enc_restore(int *len, unsigned char **out, const ASN1_VALUE **pval,
|
||||
const ASN1_ITEM *it);
|
||||
int asn1_enc_save(ASN1_VALUE **pval, const unsigned char *in, int inlen,
|
||||
const ASN1_ITEM *it);
|
||||
|
||||
@@ -64,6 +64,7 @@ static void mime_hdr_free(MIME_HEADER *hdr);
|
||||
|
||||
/* Output an ASN1 structure in BER format streaming if necessary */
|
||||
|
||||
/* unfortunately cannot constify this due to CMS_stream() and PKCS7_stream() */
|
||||
int i2d_ASN1_bio_stream(BIO *out, ASN1_VALUE *val, BIO *in, int flags,
|
||||
const ASN1_ITEM *it)
|
||||
{
|
||||
@@ -311,6 +312,7 @@ int SMIME_write_ASN1(BIO *bio, ASN1_VALUE *val, BIO *data, int flags,
|
||||
|
||||
/* Handle output of ASN1 data */
|
||||
|
||||
/* cannot constify val because of CMS_dataFinal() */
|
||||
static int asn1_output_data(BIO *out, BIO *data, ASN1_VALUE *val, int flags,
|
||||
const ASN1_ITEM *it)
|
||||
{
|
||||
|
||||
@@ -49,6 +49,7 @@ static int ndef_suffix(BIO *b, unsigned char **pbuf, int *plen, void *parg);
|
||||
static int ndef_suffix_free(BIO *b, unsigned char **pbuf, int *plen,
|
||||
void *parg);
|
||||
|
||||
/* unfortunately cannot constify this due to CMS_stream() and PKCS7_stream() */
|
||||
BIO *BIO_new_NDEF(BIO *out, ASN1_VALUE *val, const ASN1_ITEM *it)
|
||||
{
|
||||
NDEF_SUPPORT *ndef_aux = NULL;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "internal/asn1_int.h"
|
||||
#include "internal/evp_int.h"
|
||||
|
||||
int i2d_PrivateKey(EVP_PKEY *a, unsigned char **pp)
|
||||
int i2d_PrivateKey(const EVP_PKEY *a, unsigned char **pp)
|
||||
{
|
||||
if (a->ameth && a->ameth->old_priv_encode) {
|
||||
return a->ameth->old_priv_encode(a, pp);
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include <openssl/dsa.h>
|
||||
#include <openssl/ec.h>
|
||||
|
||||
int i2d_PublicKey(EVP_PKEY *a, unsigned char **pp)
|
||||
int i2d_PublicKey(const EVP_PKEY *a, unsigned char **pp)
|
||||
{
|
||||
switch (EVP_PKEY_id(a)) {
|
||||
#ifndef OPENSSL_NO_RSA
|
||||
|
||||
@@ -43,9 +43,9 @@ ASN1_BROKEN_SEQUENCE(NETSCAPE_ENCRYPTED_PKEY) = {
|
||||
ASN1_SIMPLE(NETSCAPE_ENCRYPTED_PKEY, enckey, X509_SIG)
|
||||
} static_ASN1_BROKEN_SEQUENCE_END(NETSCAPE_ENCRYPTED_PKEY)
|
||||
|
||||
DECLARE_ASN1_FUNCTIONS_const(NETSCAPE_ENCRYPTED_PKEY)
|
||||
DECLARE_ASN1_ENCODE_FUNCTIONS_const(NETSCAPE_ENCRYPTED_PKEY,NETSCAPE_ENCRYPTED_PKEY)
|
||||
IMPLEMENT_ASN1_FUNCTIONS_const(NETSCAPE_ENCRYPTED_PKEY)
|
||||
DECLARE_ASN1_FUNCTIONS(NETSCAPE_ENCRYPTED_PKEY)
|
||||
DECLARE_ASN1_ENCODE_FUNCTIONS_name(NETSCAPE_ENCRYPTED_PKEY, NETSCAPE_ENCRYPTED_PKEY)
|
||||
IMPLEMENT_ASN1_FUNCTIONS(NETSCAPE_ENCRYPTED_PKEY)
|
||||
|
||||
ASN1_SEQUENCE(NETSCAPE_PKEY) = {
|
||||
ASN1_EMBED(NETSCAPE_PKEY, version, INT32),
|
||||
@@ -53,9 +53,9 @@ ASN1_SEQUENCE(NETSCAPE_PKEY) = {
|
||||
ASN1_SIMPLE(NETSCAPE_PKEY, private_key, ASN1_OCTET_STRING)
|
||||
} static_ASN1_SEQUENCE_END(NETSCAPE_PKEY)
|
||||
|
||||
DECLARE_ASN1_FUNCTIONS_const(NETSCAPE_PKEY)
|
||||
DECLARE_ASN1_ENCODE_FUNCTIONS_const(NETSCAPE_PKEY,NETSCAPE_PKEY)
|
||||
IMPLEMENT_ASN1_FUNCTIONS_const(NETSCAPE_PKEY)
|
||||
DECLARE_ASN1_FUNCTIONS(NETSCAPE_PKEY)
|
||||
DECLARE_ASN1_ENCODE_FUNCTIONS_name(NETSCAPE_PKEY, NETSCAPE_PKEY)
|
||||
IMPLEMENT_ASN1_FUNCTIONS(NETSCAPE_PKEY)
|
||||
|
||||
# endif /* OPENSSL_NO_RC4 */
|
||||
|
||||
|
||||
@@ -316,7 +316,7 @@ static int asn1_item_embed_d2i(ASN1_VALUE **pval, const unsigned char **in,
|
||||
if (tt->flags & ASN1_TFLG_ADB_MASK) {
|
||||
const ASN1_TEMPLATE *seqtt;
|
||||
ASN1_VALUE **pseqval;
|
||||
seqtt = asn1_do_adb(pval, tt, 0);
|
||||
seqtt = asn1_do_adb(*pval, tt, 0);
|
||||
if (seqtt == NULL)
|
||||
continue;
|
||||
pseqval = asn1_get_field_ptr(pval, seqtt);
|
||||
@@ -328,7 +328,7 @@ static int asn1_item_embed_d2i(ASN1_VALUE **pval, const unsigned char **in,
|
||||
for (i = 0, tt = it->templates; i < it->tcount; i++, tt++) {
|
||||
const ASN1_TEMPLATE *seqtt;
|
||||
ASN1_VALUE **pseqval;
|
||||
seqtt = asn1_do_adb(pval, tt, 1);
|
||||
seqtt = asn1_do_adb(*pval, tt, 1);
|
||||
if (seqtt == NULL)
|
||||
goto err;
|
||||
pseqval = asn1_get_field_ptr(pval, seqtt);
|
||||
@@ -394,7 +394,7 @@ static int asn1_item_embed_d2i(ASN1_VALUE **pval, const unsigned char **in,
|
||||
*/
|
||||
for (; i < it->tcount; tt++, i++) {
|
||||
const ASN1_TEMPLATE *seqtt;
|
||||
seqtt = asn1_do_adb(pval, tt, 1);
|
||||
seqtt = asn1_do_adb(*pval, tt, 1);
|
||||
if (seqtt == NULL)
|
||||
goto err;
|
||||
if (seqtt->flags & ASN1_TFLG_OPTIONAL) {
|
||||
|
||||
+47
-43
@@ -16,16 +16,17 @@
|
||||
#include "internal/asn1_int.h"
|
||||
#include "asn1_locl.h"
|
||||
|
||||
static int asn1_i2d_ex_primitive(ASN1_VALUE **pval, unsigned char **out,
|
||||
static int asn1_i2d_ex_primitive(const ASN1_VALUE **pval, unsigned char **out,
|
||||
const ASN1_ITEM *it, int tag, int aclass);
|
||||
static int asn1_set_seq_out(STACK_OF(ASN1_VALUE) *sk, unsigned char **out,
|
||||
static int asn1_set_seq_out(STACK_OF(const_ASN1_VALUE) *sk,
|
||||
unsigned char **out,
|
||||
int skcontlen, const ASN1_ITEM *item,
|
||||
int do_sort, int iclass);
|
||||
static int asn1_template_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
|
||||
static int asn1_template_ex_i2d(const ASN1_VALUE **pval, unsigned char **out,
|
||||
const ASN1_TEMPLATE *tt, int tag, int aclass);
|
||||
static int asn1_item_flags_i2d(ASN1_VALUE *val, unsigned char **out,
|
||||
static int asn1_item_flags_i2d(const ASN1_VALUE *val, unsigned char **out,
|
||||
const ASN1_ITEM *it, int flags);
|
||||
static int asn1_ex_i2c(ASN1_VALUE **pval, unsigned char *cout, int *putype,
|
||||
static int asn1_ex_i2c(const ASN1_VALUE **pval, unsigned char *cout, int *putype,
|
||||
const ASN1_ITEM *it);
|
||||
|
||||
/*
|
||||
@@ -33,13 +34,13 @@ static int asn1_ex_i2c(ASN1_VALUE **pval, unsigned char *cout, int *putype,
|
||||
* indefinite length constructed encoding, where appropriate
|
||||
*/
|
||||
|
||||
int ASN1_item_ndef_i2d(ASN1_VALUE *val, unsigned char **out,
|
||||
int ASN1_item_ndef_i2d(const ASN1_VALUE *val, unsigned char **out,
|
||||
const ASN1_ITEM *it)
|
||||
{
|
||||
return asn1_item_flags_i2d(val, out, it, ASN1_TFLG_NDEF);
|
||||
}
|
||||
|
||||
int ASN1_item_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it)
|
||||
int ASN1_item_i2d(const ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it)
|
||||
{
|
||||
return asn1_item_flags_i2d(val, out, it, 0);
|
||||
}
|
||||
@@ -51,7 +52,7 @@ int ASN1_item_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it)
|
||||
* allocated and populated with the encoding.
|
||||
*/
|
||||
|
||||
static int asn1_item_flags_i2d(ASN1_VALUE *val, unsigned char **out,
|
||||
static int asn1_item_flags_i2d(const ASN1_VALUE *val, unsigned char **out,
|
||||
const ASN1_ITEM *it, int flags)
|
||||
{
|
||||
if (out && !*out) {
|
||||
@@ -79,20 +80,22 @@ static int asn1_item_flags_i2d(ASN1_VALUE *val, unsigned char **out,
|
||||
* performs the normal item handling: it can be used in external types.
|
||||
*/
|
||||
|
||||
int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
|
||||
int ASN1_item_ex_i2d(const ASN1_VALUE **pval, unsigned char **out,
|
||||
const ASN1_ITEM *it, int tag, int aclass)
|
||||
{
|
||||
const ASN1_TEMPLATE *tt = NULL;
|
||||
int i, seqcontlen, seqlen, ndef = 1;
|
||||
const ASN1_EXTERN_FUNCS *ef;
|
||||
const ASN1_AUX *aux = it->funcs;
|
||||
ASN1_aux_cb *asn1_cb = 0;
|
||||
ASN1_aux_const_cb *asn1_cb = NULL;
|
||||
|
||||
if ((it->itype != ASN1_ITYPE_PRIMITIVE) && !*pval)
|
||||
return 0;
|
||||
|
||||
if (aux && aux->asn1_cb)
|
||||
asn1_cb = aux->asn1_cb;
|
||||
if (aux != NULL) {
|
||||
asn1_cb = ((aux->flags & ASN1_AFLG_CONST_CB) != 0) ? aux->asn1_const_cb
|
||||
: (ASN1_aux_const_cb *)aux->asn1_cb; /* backward compatibility */
|
||||
}
|
||||
|
||||
switch (it->itype) {
|
||||
|
||||
@@ -108,12 +111,12 @@ int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
|
||||
case ASN1_ITYPE_CHOICE:
|
||||
if (asn1_cb && !asn1_cb(ASN1_OP_I2D_PRE, pval, it, NULL))
|
||||
return 0;
|
||||
i = asn1_get_choice_selector(pval, it);
|
||||
i = asn1_get_choice_selector_const(pval, it);
|
||||
if ((i >= 0) && (i < it->tcount)) {
|
||||
ASN1_VALUE **pchval;
|
||||
const ASN1_VALUE **pchval;
|
||||
const ASN1_TEMPLATE *chtt;
|
||||
chtt = it->templates + i;
|
||||
pchval = asn1_get_field_ptr(pval, chtt);
|
||||
pchval = asn1_get_const_field_ptr(pval, chtt);
|
||||
return asn1_template_ex_i2d(pchval, out, chtt, -1, aclass);
|
||||
}
|
||||
/* Fixme: error condition if selector out of range */
|
||||
@@ -154,12 +157,12 @@ int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
|
||||
/* First work out sequence content length */
|
||||
for (i = 0, tt = it->templates; i < it->tcount; tt++, i++) {
|
||||
const ASN1_TEMPLATE *seqtt;
|
||||
ASN1_VALUE **pseqval;
|
||||
const ASN1_VALUE **pseqval;
|
||||
int tmplen;
|
||||
seqtt = asn1_do_adb(pval, tt, 1);
|
||||
seqtt = asn1_do_adb(*pval, tt, 1);
|
||||
if (!seqtt)
|
||||
return 0;
|
||||
pseqval = asn1_get_field_ptr(pval, seqtt);
|
||||
pseqval = asn1_get_const_field_ptr(pval, seqtt);
|
||||
tmplen = asn1_template_ex_i2d(pseqval, NULL, seqtt, -1, aclass);
|
||||
if (tmplen == -1 || (tmplen > INT_MAX - seqcontlen))
|
||||
return -1;
|
||||
@@ -173,11 +176,11 @@ int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
|
||||
ASN1_put_object(out, ndef, seqcontlen, tag, aclass);
|
||||
for (i = 0, tt = it->templates; i < it->tcount; tt++, i++) {
|
||||
const ASN1_TEMPLATE *seqtt;
|
||||
ASN1_VALUE **pseqval;
|
||||
seqtt = asn1_do_adb(pval, tt, 1);
|
||||
const ASN1_VALUE **pseqval;
|
||||
seqtt = asn1_do_adb(*pval, tt, 1);
|
||||
if (!seqtt)
|
||||
return 0;
|
||||
pseqval = asn1_get_field_ptr(pval, seqtt);
|
||||
pseqval = asn1_get_const_field_ptr(pval, seqtt);
|
||||
/* FIXME: check for errors in enhanced version */
|
||||
asn1_template_ex_i2d(pseqval, out, seqtt, -1, aclass);
|
||||
}
|
||||
@@ -194,11 +197,11 @@ int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int asn1_template_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
|
||||
static int asn1_template_ex_i2d(const ASN1_VALUE **pval, unsigned char **out,
|
||||
const ASN1_TEMPLATE *tt, int tag, int iclass)
|
||||
{
|
||||
int i, ret, flags, ttag, tclass, ndef;
|
||||
ASN1_VALUE *tval;
|
||||
const ASN1_VALUE *tval;
|
||||
flags = tt->flags;
|
||||
|
||||
/*
|
||||
@@ -250,10 +253,10 @@ static int asn1_template_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
|
||||
|
||||
if (flags & ASN1_TFLG_SK_MASK) {
|
||||
/* SET OF, SEQUENCE OF */
|
||||
STACK_OF(ASN1_VALUE) *sk = (STACK_OF(ASN1_VALUE) *)*pval;
|
||||
STACK_OF(const_ASN1_VALUE) *sk = (STACK_OF(const_ASN1_VALUE) *)*pval;
|
||||
int isset, sktag, skaclass;
|
||||
int skcontlen, sklen;
|
||||
ASN1_VALUE *skitem;
|
||||
const ASN1_VALUE *skitem;
|
||||
|
||||
if (!*pval)
|
||||
return 0;
|
||||
@@ -283,9 +286,9 @@ static int asn1_template_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
|
||||
|
||||
/* Determine total length of items */
|
||||
skcontlen = 0;
|
||||
for (i = 0; i < sk_ASN1_VALUE_num(sk); i++) {
|
||||
for (i = 0; i < sk_const_ASN1_VALUE_num(sk); i++) {
|
||||
int tmplen;
|
||||
skitem = sk_ASN1_VALUE_value(sk, i);
|
||||
skitem = sk_const_ASN1_VALUE_value(sk, i);
|
||||
tmplen = ASN1_item_ex_i2d(&skitem, NULL, ASN1_ITEM_ptr(tt->item),
|
||||
-1, iclass);
|
||||
if (tmplen == -1 || (skcontlen > INT_MAX - tmplen))
|
||||
@@ -351,7 +354,7 @@ static int asn1_template_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
|
||||
typedef struct {
|
||||
unsigned char *data;
|
||||
int length;
|
||||
ASN1_VALUE *field;
|
||||
const ASN1_VALUE *field;
|
||||
} DER_ENC;
|
||||
|
||||
static int der_cmp(const void *a, const void *b)
|
||||
@@ -367,20 +370,21 @@ static int der_cmp(const void *a, const void *b)
|
||||
|
||||
/* Output the content octets of SET OF or SEQUENCE OF */
|
||||
|
||||
static int asn1_set_seq_out(STACK_OF(ASN1_VALUE) *sk, unsigned char **out,
|
||||
static int asn1_set_seq_out(STACK_OF(const_ASN1_VALUE) *sk,
|
||||
unsigned char **out,
|
||||
int skcontlen, const ASN1_ITEM *item,
|
||||
int do_sort, int iclass)
|
||||
{
|
||||
int i;
|
||||
ASN1_VALUE *skitem;
|
||||
const ASN1_VALUE *skitem;
|
||||
unsigned char *tmpdat = NULL, *p = NULL;
|
||||
DER_ENC *derlst = NULL, *tder;
|
||||
if (do_sort) {
|
||||
/* Don't need to sort less than 2 items */
|
||||
if (sk_ASN1_VALUE_num(sk) < 2)
|
||||
if (sk_const_ASN1_VALUE_num(sk) < 2)
|
||||
do_sort = 0;
|
||||
else {
|
||||
derlst = OPENSSL_malloc(sk_ASN1_VALUE_num(sk)
|
||||
derlst = OPENSSL_malloc(sk_const_ASN1_VALUE_num(sk)
|
||||
* sizeof(*derlst));
|
||||
if (derlst == NULL)
|
||||
return 0;
|
||||
@@ -393,8 +397,8 @@ static int asn1_set_seq_out(STACK_OF(ASN1_VALUE) *sk, unsigned char **out,
|
||||
}
|
||||
/* If not sorting just output each item */
|
||||
if (!do_sort) {
|
||||
for (i = 0; i < sk_ASN1_VALUE_num(sk); i++) {
|
||||
skitem = sk_ASN1_VALUE_value(sk, i);
|
||||
for (i = 0; i < sk_const_ASN1_VALUE_num(sk); i++) {
|
||||
skitem = sk_const_ASN1_VALUE_value(sk, i);
|
||||
ASN1_item_ex_i2d(&skitem, out, item, -1, iclass);
|
||||
}
|
||||
return 1;
|
||||
@@ -402,33 +406,33 @@ static int asn1_set_seq_out(STACK_OF(ASN1_VALUE) *sk, unsigned char **out,
|
||||
p = tmpdat;
|
||||
|
||||
/* Doing sort: build up a list of each member's DER encoding */
|
||||
for (i = 0, tder = derlst; i < sk_ASN1_VALUE_num(sk); i++, tder++) {
|
||||
skitem = sk_ASN1_VALUE_value(sk, i);
|
||||
for (i = 0, tder = derlst; i < sk_const_ASN1_VALUE_num(sk); i++, tder++) {
|
||||
skitem = sk_const_ASN1_VALUE_value(sk, i);
|
||||
tder->data = p;
|
||||
tder->length = ASN1_item_ex_i2d(&skitem, &p, item, -1, iclass);
|
||||
tder->field = skitem;
|
||||
}
|
||||
|
||||
/* Now sort them */
|
||||
qsort(derlst, sk_ASN1_VALUE_num(sk), sizeof(*derlst), der_cmp);
|
||||
qsort(derlst, sk_const_ASN1_VALUE_num(sk), sizeof(*derlst), der_cmp);
|
||||
/* Output sorted DER encoding */
|
||||
p = *out;
|
||||
for (i = 0, tder = derlst; i < sk_ASN1_VALUE_num(sk); i++, tder++) {
|
||||
for (i = 0, tder = derlst; i < sk_const_ASN1_VALUE_num(sk); i++, tder++) {
|
||||
memcpy(p, tder->data, tder->length);
|
||||
p += tder->length;
|
||||
}
|
||||
*out = p;
|
||||
/* If do_sort is 2 then reorder the STACK */
|
||||
if (do_sort == 2) {
|
||||
for (i = 0, tder = derlst; i < sk_ASN1_VALUE_num(sk); i++, tder++)
|
||||
(void)sk_ASN1_VALUE_set(sk, i, tder->field);
|
||||
for (i = 0, tder = derlst; i < sk_const_ASN1_VALUE_num(sk); i++, tder++)
|
||||
(void)sk_const_ASN1_VALUE_set(sk, i, tder->field);
|
||||
}
|
||||
OPENSSL_free(derlst);
|
||||
OPENSSL_free(tmpdat);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int asn1_i2d_ex_primitive(ASN1_VALUE **pval, unsigned char **out,
|
||||
static int asn1_i2d_ex_primitive(const ASN1_VALUE **pval, unsigned char **out,
|
||||
const ASN1_ITEM *it, int tag, int aclass)
|
||||
{
|
||||
int len;
|
||||
@@ -488,7 +492,7 @@ static int asn1_i2d_ex_primitive(ASN1_VALUE **pval, unsigned char **out,
|
||||
|
||||
/* Produce content octets from a structure */
|
||||
|
||||
static int asn1_ex_i2c(ASN1_VALUE **pval, unsigned char *cout, int *putype,
|
||||
static int asn1_ex_i2c(const ASN1_VALUE **pval, unsigned char *cout, int *putype,
|
||||
const ASN1_ITEM *it)
|
||||
{
|
||||
ASN1_BOOLEAN *tbool = NULL;
|
||||
@@ -521,7 +525,7 @@ static int asn1_ex_i2c(ASN1_VALUE **pval, unsigned char *cout, int *putype,
|
||||
typ = (ASN1_TYPE *)*pval;
|
||||
utype = typ->type;
|
||||
*putype = utype;
|
||||
pval = &typ->value.asn1_value;
|
||||
pval = (const ASN1_VALUE **)&typ->value.asn1_value; /* actually is const */
|
||||
} else
|
||||
utype = *putype;
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ void asn1_item_embed_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed)
|
||||
ASN1_VALUE **pseqval;
|
||||
|
||||
tt--;
|
||||
seqtt = asn1_do_adb(pval, tt, 0);
|
||||
seqtt = asn1_do_adb(*pval, tt, 0);
|
||||
if (!seqtt)
|
||||
continue;
|
||||
pseqval = asn1_get_field_ptr(pval, seqtt);
|
||||
|
||||
+26
-26
@@ -101,15 +101,15 @@ void ASN1_PCTX_set_str_flags(ASN1_PCTX *p, unsigned long flags)
|
||||
|
||||
/* Main print routines */
|
||||
|
||||
static int asn1_item_print_ctx(BIO *out, ASN1_VALUE **fld, int indent,
|
||||
static int asn1_item_print_ctx(BIO *out, const ASN1_VALUE **fld, int indent,
|
||||
const ASN1_ITEM *it,
|
||||
const char *fname, const char *sname,
|
||||
int nohdr, const ASN1_PCTX *pctx);
|
||||
|
||||
static int asn1_template_print_ctx(BIO *out, ASN1_VALUE **fld, int indent,
|
||||
static int asn1_template_print_ctx(BIO *out, const ASN1_VALUE **fld, int indent,
|
||||
const ASN1_TEMPLATE *tt, const ASN1_PCTX *pctx);
|
||||
|
||||
static int asn1_primitive_print(BIO *out, ASN1_VALUE **fld,
|
||||
static int asn1_primitive_print(BIO *out, const ASN1_VALUE **fld,
|
||||
const ASN1_ITEM *it, int indent,
|
||||
const char *fname, const char *sname,
|
||||
const ASN1_PCTX *pctx);
|
||||
@@ -118,7 +118,7 @@ static int asn1_print_fsname(BIO *out, int indent,
|
||||
const char *fname, const char *sname,
|
||||
const ASN1_PCTX *pctx);
|
||||
|
||||
int ASN1_item_print(BIO *out, ASN1_VALUE *ifld, int indent,
|
||||
int ASN1_item_print(BIO *out, const ASN1_VALUE *ifld, int indent,
|
||||
const ASN1_ITEM *it, const ASN1_PCTX *pctx)
|
||||
{
|
||||
const char *sname;
|
||||
@@ -131,25 +131,25 @@ int ASN1_item_print(BIO *out, ASN1_VALUE *ifld, int indent,
|
||||
return asn1_item_print_ctx(out, &ifld, indent, it, NULL, sname, 0, pctx);
|
||||
}
|
||||
|
||||
static int asn1_item_print_ctx(BIO *out, ASN1_VALUE **fld, int indent,
|
||||
static int asn1_item_print_ctx(BIO *out, const ASN1_VALUE **fld, int indent,
|
||||
const ASN1_ITEM *it,
|
||||
const char *fname, const char *sname,
|
||||
int nohdr, const ASN1_PCTX *pctx)
|
||||
{
|
||||
const ASN1_TEMPLATE *tt;
|
||||
const ASN1_EXTERN_FUNCS *ef;
|
||||
ASN1_VALUE **tmpfld;
|
||||
const ASN1_VALUE **tmpfld;
|
||||
const ASN1_AUX *aux = it->funcs;
|
||||
ASN1_aux_cb *asn1_cb;
|
||||
ASN1_aux_const_cb *asn1_cb = NULL;
|
||||
ASN1_PRINT_ARG parg;
|
||||
int i;
|
||||
if (aux && aux->asn1_cb) {
|
||||
if (aux != NULL) {
|
||||
parg.out = out;
|
||||
parg.indent = indent;
|
||||
parg.pctx = pctx;
|
||||
asn1_cb = aux->asn1_cb;
|
||||
} else
|
||||
asn1_cb = 0;
|
||||
asn1_cb = ((aux->flags & ASN1_AFLG_CONST_CB) != 0) ? aux->asn1_const_cb
|
||||
: (ASN1_aux_const_cb *)aux->asn1_cb; /* backward compatibility */
|
||||
}
|
||||
|
||||
if (((it->itype != ASN1_ITYPE_PRIMITIVE)
|
||||
|| (it->utype != V_ASN1_BOOLEAN)) && *fld == NULL) {
|
||||
@@ -195,7 +195,7 @@ static int asn1_item_print_ctx(BIO *out, ASN1_VALUE **fld, int indent,
|
||||
|
||||
case ASN1_ITYPE_CHOICE:
|
||||
/* CHOICE type, get selector */
|
||||
i = asn1_get_choice_selector(fld, it);
|
||||
i = asn1_get_choice_selector_const(fld, it);
|
||||
/* This should never happen... */
|
||||
if ((i < 0) || (i >= it->tcount)) {
|
||||
if (BIO_printf(out, "ERROR: selector [%d] invalid\n", i) <= 0)
|
||||
@@ -203,7 +203,7 @@ static int asn1_item_print_ctx(BIO *out, ASN1_VALUE **fld, int indent,
|
||||
return 1;
|
||||
}
|
||||
tt = it->templates + i;
|
||||
tmpfld = asn1_get_field_ptr(fld, tt);
|
||||
tmpfld = asn1_get_const_field_ptr(fld, tt);
|
||||
if (!asn1_template_print_ctx(out, tmpfld, indent, tt, pctx))
|
||||
return 0;
|
||||
break;
|
||||
@@ -233,10 +233,10 @@ static int asn1_item_print_ctx(BIO *out, ASN1_VALUE **fld, int indent,
|
||||
/* Print each field entry */
|
||||
for (i = 0, tt = it->templates; i < it->tcount; i++, tt++) {
|
||||
const ASN1_TEMPLATE *seqtt;
|
||||
seqtt = asn1_do_adb(fld, tt, 1);
|
||||
seqtt = asn1_do_adb(*fld, tt, 1);
|
||||
if (!seqtt)
|
||||
return 0;
|
||||
tmpfld = asn1_get_field_ptr(fld, seqtt);
|
||||
tmpfld = asn1_get_const_field_ptr(fld, seqtt);
|
||||
if (!asn1_template_print_ctx(out, tmpfld,
|
||||
indent + 2, seqtt, pctx))
|
||||
return 0;
|
||||
@@ -261,12 +261,12 @@ static int asn1_item_print_ctx(BIO *out, ASN1_VALUE **fld, int indent,
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int asn1_template_print_ctx(BIO *out, ASN1_VALUE **fld, int indent,
|
||||
static int asn1_template_print_ctx(BIO *out, const ASN1_VALUE **fld, int indent,
|
||||
const ASN1_TEMPLATE *tt, const ASN1_PCTX *pctx)
|
||||
{
|
||||
int i, flags;
|
||||
const char *sname, *fname;
|
||||
ASN1_VALUE *tfld;
|
||||
const ASN1_VALUE *tfld;
|
||||
flags = tt->flags;
|
||||
if (pctx->flags & ASN1_PCTX_FLAGS_SHOW_FIELD_STRUCT_NAME)
|
||||
sname = ASN1_ITEM_ptr(tt->item)->sname;
|
||||
@@ -282,14 +282,14 @@ static int asn1_template_print_ctx(BIO *out, ASN1_VALUE **fld, int indent,
|
||||
* a pointer to a field.
|
||||
*/
|
||||
if (flags & ASN1_TFLG_EMBED) {
|
||||
tfld = (ASN1_VALUE *)fld;
|
||||
tfld = (const ASN1_VALUE *)fld;
|
||||
fld = &tfld;
|
||||
}
|
||||
|
||||
if (flags & ASN1_TFLG_SK_MASK) {
|
||||
char *tname;
|
||||
ASN1_VALUE *skitem;
|
||||
STACK_OF(ASN1_VALUE) *stack;
|
||||
const ASN1_VALUE *skitem;
|
||||
STACK_OF(const_ASN1_VALUE) *stack;
|
||||
|
||||
/* SET OF, SEQUENCE OF */
|
||||
if (fname) {
|
||||
@@ -304,12 +304,12 @@ static int asn1_template_print_ctx(BIO *out, ASN1_VALUE **fld, int indent,
|
||||
} else if (BIO_printf(out, "%*s%s:\n", indent, "", fname) <= 0)
|
||||
return 0;
|
||||
}
|
||||
stack = (STACK_OF(ASN1_VALUE) *)*fld;
|
||||
for (i = 0; i < sk_ASN1_VALUE_num(stack); i++) {
|
||||
stack = (STACK_OF(const_ASN1_VALUE) *)*fld;
|
||||
for (i = 0; i < sk_const_ASN1_VALUE_num(stack); i++) {
|
||||
if ((i > 0) && (BIO_puts(out, "\n") <= 0))
|
||||
return 0;
|
||||
|
||||
skitem = sk_ASN1_VALUE_value(stack, i);
|
||||
skitem = sk_const_ASN1_VALUE_value(stack, i);
|
||||
if (!asn1_item_print_ctx(out, &skitem, indent + 2,
|
||||
ASN1_ITEM_ptr(tt->item), NULL, NULL, 1,
|
||||
pctx))
|
||||
@@ -430,7 +430,7 @@ static int asn1_print_obstring(BIO *out, const ASN1_STRING *str, int indent)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int asn1_primitive_print(BIO *out, ASN1_VALUE **fld,
|
||||
static int asn1_primitive_print(BIO *out, const ASN1_VALUE **fld,
|
||||
const ASN1_ITEM *it, int indent,
|
||||
const char *fname, const char *sname,
|
||||
const ASN1_PCTX *pctx)
|
||||
@@ -456,9 +456,9 @@ static int asn1_primitive_print(BIO *out, ASN1_VALUE **fld,
|
||||
str = (ASN1_STRING *)*fld;
|
||||
}
|
||||
if (utype == V_ASN1_ANY) {
|
||||
ASN1_TYPE *atype = (ASN1_TYPE *)*fld;
|
||||
const ASN1_TYPE *atype = (const ASN1_TYPE *)*fld;
|
||||
utype = atype->type;
|
||||
fld = &atype->value.asn1_value;
|
||||
fld = (const ASN1_VALUE **)&atype->value.asn1_value; /* actually is const */
|
||||
str = (ASN1_STRING *)*fld;
|
||||
if (pctx->flags & ASN1_PCTX_FLAGS_NO_ANY_TYPE)
|
||||
pname = NULL;
|
||||
|
||||
@@ -80,5 +80,5 @@ ASN1_ITEM_TEMPLATE(ASN1_SET_ANY) =
|
||||
ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SET_OF, 0, ASN1_SET_ANY, ASN1_ANY)
|
||||
ASN1_ITEM_TEMPLATE_END(ASN1_SET_ANY)
|
||||
|
||||
IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(ASN1_SEQUENCE_ANY, ASN1_SEQUENCE_ANY, ASN1_SEQUENCE_ANY)
|
||||
IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(ASN1_SEQUENCE_ANY, ASN1_SET_ANY, ASN1_SET_ANY)
|
||||
IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(ASN1_SEQUENCE_ANY, ASN1_SEQUENCE_ANY, ASN1_SEQUENCE_ANY)
|
||||
IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(ASN1_SEQUENCE_ANY, ASN1_SET_ANY, ASN1_SET_ANY)
|
||||
+57
-25
@@ -29,6 +29,14 @@
|
||||
int asn1_get_choice_selector(ASN1_VALUE **pval, const ASN1_ITEM *it)
|
||||
{
|
||||
int *sel = offset2ptr(*pval, it->utype);
|
||||
|
||||
return *sel;
|
||||
}
|
||||
|
||||
int asn1_get_choice_selector_const(const ASN1_VALUE **pval, const ASN1_ITEM *it)
|
||||
{
|
||||
int *sel = offset2ptr(*pval, it->utype);
|
||||
|
||||
return *sel;
|
||||
}
|
||||
|
||||
@@ -40,6 +48,7 @@ int asn1_set_choice_selector(ASN1_VALUE **pval, int value,
|
||||
const ASN1_ITEM *it)
|
||||
{
|
||||
int *sel, ret;
|
||||
|
||||
sel = offset2ptr(*pval, it->utype);
|
||||
ret = *sel;
|
||||
*sel = value;
|
||||
@@ -66,7 +75,7 @@ int asn1_do_lock(ASN1_VALUE **pval, int op, const ASN1_ITEM *it)
|
||||
&& (it->itype != ASN1_ITYPE_NDEF_SEQUENCE))
|
||||
return 0;
|
||||
aux = it->funcs;
|
||||
if (!aux || !(aux->flags & ASN1_AFLG_REFCOUNT))
|
||||
if (aux == NULL || (aux->flags & ASN1_AFLG_REFCOUNT) == 0)
|
||||
return 0;
|
||||
lck = offset2ptr(*pval, aux->ref_offset);
|
||||
lock = offset2ptr(*pval, aux->ref_lock);
|
||||
@@ -104,19 +113,33 @@ int asn1_do_lock(ASN1_VALUE **pval, int op, const ASN1_ITEM *it)
|
||||
static ASN1_ENCODING *asn1_get_enc_ptr(ASN1_VALUE **pval, const ASN1_ITEM *it)
|
||||
{
|
||||
const ASN1_AUX *aux;
|
||||
if (!pval || !*pval)
|
||||
|
||||
if (pval == NULL || *pval == NULL)
|
||||
return NULL;
|
||||
aux = it->funcs;
|
||||
if (!aux || !(aux->flags & ASN1_AFLG_ENCODING))
|
||||
if (aux == NULL || (aux->flags & ASN1_AFLG_ENCODING) == 0)
|
||||
return NULL;
|
||||
return offset2ptr(*pval, aux->enc_offset);
|
||||
}
|
||||
|
||||
static const ASN1_ENCODING *asn1_get_const_enc_ptr(const ASN1_VALUE **pval,
|
||||
const ASN1_ITEM *it)
|
||||
{
|
||||
const ASN1_AUX *aux;
|
||||
|
||||
if (pval == NULL || *pval == NULL)
|
||||
return NULL;
|
||||
aux = it->funcs;
|
||||
if (aux == NULL || (aux->flags & ASN1_AFLG_ENCODING) == 0)
|
||||
return NULL;
|
||||
return offset2ptr(*pval, aux->enc_offset);
|
||||
}
|
||||
|
||||
void asn1_enc_init(ASN1_VALUE **pval, const ASN1_ITEM *it)
|
||||
{
|
||||
ASN1_ENCODING *enc;
|
||||
enc = asn1_get_enc_ptr(pval, it);
|
||||
if (enc) {
|
||||
ASN1_ENCODING *enc = asn1_get_enc_ptr(pval, it);
|
||||
|
||||
if (enc != NULL) {
|
||||
enc->enc = NULL;
|
||||
enc->len = 0;
|
||||
enc->modified = 1;
|
||||
@@ -125,9 +148,9 @@ void asn1_enc_init(ASN1_VALUE **pval, const ASN1_ITEM *it)
|
||||
|
||||
void asn1_enc_free(ASN1_VALUE **pval, const ASN1_ITEM *it)
|
||||
{
|
||||
ASN1_ENCODING *enc;
|
||||
enc = asn1_get_enc_ptr(pval, it);
|
||||
if (enc) {
|
||||
ASN1_ENCODING *enc = asn1_get_enc_ptr(pval, it);
|
||||
|
||||
if (enc != NULL) {
|
||||
OPENSSL_free(enc->enc);
|
||||
enc->enc = NULL;
|
||||
enc->len = 0;
|
||||
@@ -138,9 +161,9 @@ void asn1_enc_free(ASN1_VALUE **pval, const ASN1_ITEM *it)
|
||||
int asn1_enc_save(ASN1_VALUE **pval, const unsigned char *in, int inlen,
|
||||
const ASN1_ITEM *it)
|
||||
{
|
||||
ASN1_ENCODING *enc;
|
||||
enc = asn1_get_enc_ptr(pval, it);
|
||||
if (!enc)
|
||||
ASN1_ENCODING *enc = asn1_get_enc_ptr(pval, it);
|
||||
|
||||
if (enc == NULL)
|
||||
return 1;
|
||||
|
||||
OPENSSL_free(enc->enc);
|
||||
@@ -155,18 +178,18 @@ int asn1_enc_save(ASN1_VALUE **pval, const unsigned char *in, int inlen,
|
||||
return 1;
|
||||
}
|
||||
|
||||
int asn1_enc_restore(int *len, unsigned char **out, ASN1_VALUE **pval,
|
||||
int asn1_enc_restore(int *len, unsigned char **out, const ASN1_VALUE **pval,
|
||||
const ASN1_ITEM *it)
|
||||
{
|
||||
ASN1_ENCODING *enc;
|
||||
enc = asn1_get_enc_ptr(pval, it);
|
||||
if (!enc || enc->modified)
|
||||
const ASN1_ENCODING *enc = asn1_get_const_enc_ptr(pval, it);
|
||||
|
||||
if (enc == NULL || enc->modified)
|
||||
return 0;
|
||||
if (out) {
|
||||
memcpy(*out, enc->enc, enc->len);
|
||||
*out += enc->len;
|
||||
}
|
||||
if (len)
|
||||
if (len != NULL)
|
||||
*len = enc->len;
|
||||
return 1;
|
||||
}
|
||||
@@ -174,8 +197,8 @@ int asn1_enc_restore(int *len, unsigned char **out, ASN1_VALUE **pval,
|
||||
/* Given an ASN1_TEMPLATE get a pointer to a field */
|
||||
ASN1_VALUE **asn1_get_field_ptr(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt)
|
||||
{
|
||||
ASN1_VALUE **pvaltmp;
|
||||
pvaltmp = offset2ptr(*pval, tt->offset);
|
||||
ASN1_VALUE **pvaltmp = offset2ptr(*pval, tt->offset);
|
||||
|
||||
/*
|
||||
* NOTE for BOOLEAN types the field is just a plain int so we can't
|
||||
* return int **, so settle for (int *).
|
||||
@@ -183,31 +206,40 @@ ASN1_VALUE **asn1_get_field_ptr(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt)
|
||||
return pvaltmp;
|
||||
}
|
||||
|
||||
/* Given an ASN1_TEMPLATE get a const pointer to a field */
|
||||
const ASN1_VALUE **asn1_get_const_field_ptr(const ASN1_VALUE **pval,
|
||||
const ASN1_TEMPLATE *tt)
|
||||
{
|
||||
return offset2ptr(*pval, tt->offset);
|
||||
}
|
||||
|
||||
/*
|
||||
* Handle ANY DEFINED BY template, find the selector, look up the relevant
|
||||
* ASN1_TEMPLATE in the table and return it.
|
||||
*/
|
||||
|
||||
const ASN1_TEMPLATE *asn1_do_adb(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt,
|
||||
const ASN1_TEMPLATE *asn1_do_adb(const ASN1_VALUE *val,
|
||||
const ASN1_TEMPLATE *tt,
|
||||
int nullerr)
|
||||
{
|
||||
const ASN1_ADB *adb;
|
||||
const ASN1_ADB_TABLE *atbl;
|
||||
long selector;
|
||||
ASN1_VALUE **sfld;
|
||||
const ASN1_VALUE **sfld;
|
||||
int i;
|
||||
if (!(tt->flags & ASN1_TFLG_ADB_MASK))
|
||||
|
||||
if ((tt->flags & ASN1_TFLG_ADB_MASK) == 0)
|
||||
return tt;
|
||||
|
||||
/* Else ANY DEFINED BY ... get the table */
|
||||
adb = ASN1_ADB_ptr(tt->item);
|
||||
|
||||
/* Get the selector field */
|
||||
sfld = offset2ptr(*pval, adb->offset);
|
||||
sfld = offset2ptr(val, adb->offset);
|
||||
|
||||
/* Check if NULL */
|
||||
if (*sfld == NULL) {
|
||||
if (!adb->null_tt)
|
||||
if (adb->null_tt == NULL)
|
||||
goto err;
|
||||
return adb->null_tt;
|
||||
}
|
||||
@@ -216,7 +248,7 @@ const ASN1_TEMPLATE *asn1_do_adb(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt,
|
||||
* Convert type to a long: NB: don't check for NID_undef here because it
|
||||
* might be a legitimate value in the table
|
||||
*/
|
||||
if (tt->flags & ASN1_TFLG_ADB_OID)
|
||||
if ((tt->flags & ASN1_TFLG_ADB_OID) != 0)
|
||||
selector = OBJ_obj2nid((ASN1_OBJECT *)*sfld);
|
||||
else
|
||||
selector = ASN1_INTEGER_get((ASN1_INTEGER *)*sfld);
|
||||
|
||||
@@ -25,13 +25,13 @@ static int bn_new(ASN1_VALUE **pval, const ASN1_ITEM *it);
|
||||
static int bn_secure_new(ASN1_VALUE **pval, const ASN1_ITEM *it);
|
||||
static void bn_free(ASN1_VALUE **pval, const ASN1_ITEM *it);
|
||||
|
||||
static int bn_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype,
|
||||
static int bn_i2c(const ASN1_VALUE **pval, unsigned char *cont, int *putype,
|
||||
const ASN1_ITEM *it);
|
||||
static int bn_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len,
|
||||
int utype, char *free_cont, const ASN1_ITEM *it);
|
||||
static int bn_secure_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len,
|
||||
int utype, char *free_cont, const ASN1_ITEM *it);
|
||||
static int bn_print(BIO *out, ASN1_VALUE **pval, const ASN1_ITEM *it,
|
||||
static int bn_print(BIO *out, const ASN1_VALUE **pval, const ASN1_ITEM *it,
|
||||
int indent, const ASN1_PCTX *pctx);
|
||||
|
||||
static ASN1_PRIMITIVE_FUNCS bignum_pf = {
|
||||
@@ -91,7 +91,7 @@ static void bn_free(ASN1_VALUE **pval, const ASN1_ITEM *it)
|
||||
*pval = NULL;
|
||||
}
|
||||
|
||||
static int bn_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype,
|
||||
static int bn_i2c(const ASN1_VALUE **pval, unsigned char *cont, int *putype,
|
||||
const ASN1_ITEM *it)
|
||||
{
|
||||
BIGNUM *bn;
|
||||
@@ -135,7 +135,7 @@ static int bn_secure_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len,
|
||||
return bn_c2i(pval, cont, len, utype, free_cont, it);
|
||||
}
|
||||
|
||||
static int bn_print(BIO *out, ASN1_VALUE **pval, const ASN1_ITEM *it,
|
||||
static int bn_print(BIO *out, const ASN1_VALUE **pval, const ASN1_ITEM *it,
|
||||
int indent, const ASN1_PCTX *pctx)
|
||||
{
|
||||
if (!BN_print(out, *(BIGNUM **)pval))
|
||||
|
||||
@@ -46,8 +46,8 @@ static void uint64_clear(ASN1_VALUE **pval, const ASN1_ITEM *it)
|
||||
**(uint64_t **)pval = 0;
|
||||
}
|
||||
|
||||
static int uint64_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype,
|
||||
const ASN1_ITEM *it)
|
||||
static int uint64_i2c(const ASN1_VALUE **pval, unsigned char *cont, int *putype,
|
||||
const ASN1_ITEM *it)
|
||||
{
|
||||
uint64_t utmp;
|
||||
int neg = 0;
|
||||
@@ -71,7 +71,7 @@ static int uint64_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype,
|
||||
}
|
||||
|
||||
static int uint64_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len,
|
||||
int utype, char *free_cont, const ASN1_ITEM *it)
|
||||
int utype, char *free_cont, const ASN1_ITEM *it)
|
||||
{
|
||||
uint64_t utmp = 0;
|
||||
char *cp;
|
||||
@@ -111,7 +111,7 @@ static int uint64_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len,
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int uint64_print(BIO *out, ASN1_VALUE **pval, const ASN1_ITEM *it,
|
||||
static int uint64_print(BIO *out, const ASN1_VALUE **pval, const ASN1_ITEM *it,
|
||||
int indent, const ASN1_PCTX *pctx)
|
||||
{
|
||||
if ((it->size & INTxx_FLAG_SIGNED) == INTxx_FLAG_SIGNED)
|
||||
@@ -141,8 +141,8 @@ static void uint32_clear(ASN1_VALUE **pval, const ASN1_ITEM *it)
|
||||
**(uint32_t **)pval = 0;
|
||||
}
|
||||
|
||||
static int uint32_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype,
|
||||
const ASN1_ITEM *it)
|
||||
static int uint32_i2c(const ASN1_VALUE **pval, unsigned char *cont, int *putype,
|
||||
const ASN1_ITEM *it)
|
||||
{
|
||||
uint32_t utmp;
|
||||
int neg = 0;
|
||||
@@ -173,7 +173,7 @@ static int uint32_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype,
|
||||
#define ABS_INT32_MIN ((uint32_t)INT32_MAX + 1)
|
||||
|
||||
static int uint32_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len,
|
||||
int utype, char *free_cont, const ASN1_ITEM *it)
|
||||
int utype, char *free_cont, const ASN1_ITEM *it)
|
||||
{
|
||||
uint64_t utmp = 0;
|
||||
uint32_t utmp2 = 0;
|
||||
@@ -220,7 +220,7 @@ static int uint32_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len,
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int uint32_print(BIO *out, ASN1_VALUE **pval, const ASN1_ITEM *it,
|
||||
static int uint32_print(BIO *out, const ASN1_VALUE **pval, const ASN1_ITEM *it,
|
||||
int indent, const ASN1_PCTX *pctx)
|
||||
{
|
||||
if ((it->size & INTxx_FLAG_SIGNED) == INTxx_FLAG_SIGNED)
|
||||
|
||||
@@ -25,11 +25,11 @@ NON_EMPTY_TRANSLATION_UNIT
|
||||
static int long_new(ASN1_VALUE **pval, const ASN1_ITEM *it);
|
||||
static void long_free(ASN1_VALUE **pval, const ASN1_ITEM *it);
|
||||
|
||||
static int long_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype,
|
||||
static int long_i2c(const ASN1_VALUE **pval, unsigned char *cont, int *putype,
|
||||
const ASN1_ITEM *it);
|
||||
static int long_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len,
|
||||
int utype, char *free_cont, const ASN1_ITEM *it);
|
||||
static int long_print(BIO *out, ASN1_VALUE **pval, const ASN1_ITEM *it,
|
||||
static int long_print(BIO *out, const ASN1_VALUE **pval, const ASN1_ITEM *it,
|
||||
int indent, const ASN1_PCTX *pctx);
|
||||
|
||||
static ASN1_PRIMITIVE_FUNCS long_pf = {
|
||||
@@ -86,7 +86,7 @@ static int num_bits_ulong(unsigned long value)
|
||||
return (int)ret;
|
||||
}
|
||||
|
||||
static int long_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype,
|
||||
static int long_i2c(const ASN1_VALUE **pval, unsigned char *cont, int *putype,
|
||||
const ASN1_ITEM *it)
|
||||
{
|
||||
long ltmp;
|
||||
@@ -190,7 +190,7 @@ static int long_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len,
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int long_print(BIO *out, ASN1_VALUE **pval, const ASN1_ITEM *it,
|
||||
static int long_print(BIO *out, const ASN1_VALUE **pval, const ASN1_ITEM *it,
|
||||
int indent, const ASN1_PCTX *pctx)
|
||||
{
|
||||
long l;
|
||||
|
||||
Reference in New Issue
Block a user