Ejemplo n.º 1
0
/**
 * @ingroup proxypolicy
 *
 * Converts the PROXYPOLICY from its DER encoded form
 * to an internal PROXYPOLICY structure
 *
 * @param a the PROXYPOLICY struct to set
 * @param pp the DER encoding to get the PROXYPOLICY from
 * @param length the length of the DER encoding
 * 
 * @return the resulting PROXYPOLICY in its internal structure
 * form - this variable has been allocated using _new routines, 
 * so it needs to be freed once its no longer used
 */
PROXYPOLICY * d2i_PROXYPOLICY(
    PROXYPOLICY **                      a,
    unsigned char **                    pp,
    long                                length)
{
    M_ASN1_D2I_vars(a, PROXYPOLICY *, PROXYPOLICY_new);
    
    M_ASN1_D2I_Init();
    M_ASN1_D2I_start_sequence();
    M_ASN1_D2I_get(ret->policy_language, d2i_ASN1_OBJECT);

    /* need to try getting the policy using
     *     a) a call expecting no tags
     *     b) a call expecting tags
     * one of which should succeed
     */
    
    M_ASN1_D2I_get_opt(ret->policy,
                       d2i_ASN1_OCTET_STRING,
                       V_ASN1_OCTET_STRING);
    
    M_ASN1_D2I_get_IMP_opt(ret->policy,
                           d2i_ASN1_OCTET_STRING,
                           0,
                           V_ASN1_OCTET_STRING);

    M_ASN1_D2I_Finish(a, 
                      PROXYPOLICY_free, 
                      ASN1_F_D2I_PROXYPOLICY);
}
Ejemplo n.º 2
0
RSA *d2i_RSAPublicKey(RSA **a, unsigned char **pp, long length)
	{
	int i=ASN1_R_PARSING;
	ASN1_INTEGER *bs=NULL;
	M_ASN1_D2I_vars(a,RSA *,RSA_new);

	M_ASN1_D2I_Init();
	M_ASN1_D2I_start_sequence();
	M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
	if ((ret->n=BN_bin2bn(bs->data,bs->length,ret->n)) == NULL) goto err_bn;
	M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
	if ((ret->e=BN_bin2bn(bs->data,bs->length,ret->e)) == NULL) goto err_bn;

	M_ASN1_INTEGER_free(bs);
	bs=NULL;

	M_ASN1_D2I_Finish_2(a);

err_bn:
	i=ERR_R_BN_LIB;
err:
	ASN1err(ASN1_F_D2I_RSAPUBLICKEY,i);
	if ((ret != NULL) && ((a == NULL) || (*a != ret))) RSA_free(ret);
	if (bs != NULL) M_ASN1_INTEGER_free(bs);
	return(NULL);
	}
Ejemplo n.º 3
0
RSA *d2i_RSA_NET(RSA **a, unsigned char **pp, long length, int (*cb)(), int sgckey)
	{
	RSA *ret=NULL;
	ASN1_OCTET_STRING *os=NULL;
	ASN1_CTX c;

	c.pp=pp;
	c.error=ASN1_R_DECODING_ERROR;

	M_ASN1_D2I_Init();
	M_ASN1_D2I_start_sequence();
	M_ASN1_D2I_get(os,d2i_ASN1_OCTET_STRING);
	if ((os->length != 11) || (strncmp("private-key",
		(char *)os->data,os->length) != 0))
		{
		ASN1err(ASN1_F_D2I_NETSCAPE_RSA,ASN1_R_PRIVATE_KEY_HEADER_MISSING);
		M_ASN1_BIT_STRING_free(os);
		goto err;
		}
	M_ASN1_BIT_STRING_free(os);
	c.q=c.p;
	if ((ret=d2i_RSA_NET_2(a,&c.p,c.slen,cb, sgckey)) == NULL) goto err;
	/* Note: some versions of IIS key files use length values that are
	 * too small for the surrounding SEQUENCEs. This following line
	 * effectively disable length checking.
	 */
	c.slen = 0;

	M_ASN1_D2I_Finish(a,RSA_free,ASN1_F_D2I_NETSCAPE_RSA);
	}
Ejemplo n.º 4
0
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);
}
Ejemplo n.º 5
0
AC_SEQ *d2i_AC_SEQ(AC_SEQ **a, VOMS_MAYBECONST unsigned char **pp, long length)
{
  M_ASN1_D2I_vars(a, AC_SEQ *, AC_SEQ_new);

  M_ASN1_D2I_Init();
  M_ASN1_D2I_start_sequence();
  M_ASN1_D2I_get_seq(ret->acs, d2i_AC, AC_free);
  M_ASN1_D2I_Finish(a, AC_SEQ_free, ASN1_F_D2I_AC_SEQ);
}
Ejemplo n.º 6
0
AC_CERTS *d2i_AC_CERTS(AC_CERTS **a, VOMS_MAYBECONST unsigned char **pp, long length)
{
  M_ASN1_D2I_vars(a, AC_CERTS *, AC_CERTS_new);

  M_ASN1_D2I_Init();
  M_ASN1_D2I_start_sequence();
  M_ASN1_D2I_get_seq(ret->stackcert, d2i_X509, X509_free);
  M_ASN1_D2I_Finish(a, AC_CERTS_free, ASN1_F_D2I_AC_CERTS);
}
Ejemplo n.º 7
0
AC_TARGETS *d2i_AC_TARGETS(AC_TARGETS **a, VOMS_MAYBECONST unsigned char **pp, long length)
{
  M_ASN1_D2I_vars(a, AC_TARGETS *, AC_TARGETS_new);

  M_ASN1_D2I_Init();
  M_ASN1_D2I_start_sequence();
  M_ASN1_D2I_get_seq(ret->targets, d2i_AC_TARGET, AC_TARGET_free);
  M_ASN1_D2I_Finish(a, AC_TARGETS_free, ASN1_F_D2I_AC_TARGETS);
}
PBE2PARAM *d2i_PBE2PARAM(PBE2PARAM **a, unsigned char **pp, long length)
{
	M_ASN1_D2I_vars(a,PBE2PARAM *,PBE2PARAM_new);
	M_ASN1_D2I_Init();
	M_ASN1_D2I_start_sequence();
	M_ASN1_D2I_get (ret->keyfunc, d2i_X509_ALGOR);
	M_ASN1_D2I_get (ret->encryption, d2i_X509_ALGOR);
	M_ASN1_D2I_Finish(a, PBE2PARAM_free, ASN1_F_D2I_PBE2PARAM);
}
Ejemplo n.º 9
0
AC_FULL_ATTRIBUTES *d2i_AC_FULL_ATTRIBUTES(AC_FULL_ATTRIBUTES **a, VOMS_MAYBECONST unsigned char **pp, long length)
{
  M_ASN1_D2I_vars(a, AC_FULL_ATTRIBUTES *, AC_FULL_ATTRIBUTES_new);

  M_ASN1_D2I_Init();
  M_ASN1_D2I_start_sequence();
  M_ASN1_D2I_get_seq(ret->providers, d2i_AC_ATT_HOLDER, AC_ATT_HOLDER_free);
  M_ASN1_D2I_Finish(a, AC_FULL_ATTRIBUTES_free, ASN1_F_D2I_AC_FULL_ATTRIBUTES);
}
Ejemplo n.º 10
0
AC_ATT_HOLDER *d2i_AC_ATT_HOLDER(AC_ATT_HOLDER **a, VOMS_MAYBECONST unsigned char **pp, long length)
{
  M_ASN1_D2I_vars(a, AC_ATT_HOLDER *, AC_ATT_HOLDER_new);

  M_ASN1_D2I_Init();
  M_ASN1_D2I_start_sequence();
  M_ASN1_D2I_get(ret->grantor, d2i_GENERAL_NAMES);
  M_ASN1_D2I_get_seq(ret->attributes, d2i_AC_ATTRIBUTE, AC_ATTRIBUTE_free);
  M_ASN1_D2I_Finish(a, AC_ATT_HOLDER_free, ASN1_F_D2I_AC_ATT_HOLDER);
}
Ejemplo n.º 11
0
X509_SIG *d2i_X509_SIG(X509_SIG **a, unsigned char **pp, long length)
{
    M_ASN1_D2I_vars(a,X509_SIG *,X509_SIG_new);

    M_ASN1_D2I_Init();
    M_ASN1_D2I_start_sequence();
    M_ASN1_D2I_get(ret->algor,d2i_X509_ALGOR);
    M_ASN1_D2I_get(ret->digest,d2i_ASN1_OCTET_STRING);
    M_ASN1_D2I_Finish(a,X509_SIG_free,ASN1_F_D2I_X509_SIG);
}
Ejemplo n.º 12
0
X509 *d2i_X509_KEY(X509 **a, unsigned char **pp, long length)
	{
	M_ASN1_D2I_vars(a,X509 *,X509_new);

	M_ASN1_D2I_Init();
	M_ASN1_D2I_start_sequence();
	M_ASN1_D2I_get(ret->cert_info,d2i_X509_CINF);
	M_ASN1_D2I_get(ret->sig_alg,d2i_X509_ALGOR);
	M_ASN1_D2I_get(ret->signature,d2i_ASN1_BIT_STRING);
	M_ASN1_D2I_Finish(a,X509_free,ASN1_F_D2I_X509);
	}
Ejemplo n.º 13
0
AC_TARGET *d2i_AC_TARGET(AC_TARGET **a, VOMS_MAYBECONST unsigned char **pp, long length)
{
  M_ASN1_D2I_vars(a, AC_TARGET *, AC_TARGET_new);

  M_ASN1_D2I_Init();
  M_ASN1_D2I_start_sequence();
  M_ASN1_D2I_get_EXP_opt(ret->name, d2i_GENERAL_NAME, 0);
  M_ASN1_D2I_get_EXP_opt(ret->group, d2i_GENERAL_NAME, 1);
  M_ASN1_D2I_get_EXP_opt(ret->cert, d2i_AC_IS, 2);
  M_ASN1_D2I_Finish(a, AC_TARGET_free, ASN1_F_D2I_AC_TARGET);
}
Ejemplo n.º 14
0
PKCS12_MAC_DATA *d2i_PKCS12_MAC_DATA(PKCS12_MAC_DATA **a, unsigned char **pp,
	     long length)
{
	M_ASN1_D2I_vars(a,PKCS12_MAC_DATA *,PKCS12_MAC_DATA_new);
	M_ASN1_D2I_Init();
	M_ASN1_D2I_start_sequence();
	M_ASN1_D2I_get(ret->dinfo, d2i_X509_SIG);
	M_ASN1_D2I_get(ret->salt, d2i_ASN1_OCTET_STRING);
	M_ASN1_D2I_get_opt(ret->iter, d2i_ASN1_INTEGER, V_ASN1_INTEGER);
	M_ASN1_D2I_Finish(a, PKCS12_MAC_DATA_free, ASN1_F_D2I_PKCS12_MAC_DATA);
}
Ejemplo n.º 15
0
ASN1_HEADER *d2i_ASN1_HEADER(ASN1_HEADER **a, const unsigned char **pp,
       long length)
  {
  M_ASN1_D2I_vars(a,ASN1_HEADER *,ASN1_HEADER_new);

  M_ASN1_D2I_Init();
        M_ASN1_D2I_start_sequence();
        M_ASN1_D2I_get_x(ASN1_OCTET_STRING,ret->header,d2i_ASN1_OCTET_STRING);
  if (ret->meth != NULL)
    {
    M_ASN1_D2I_get_x(void,ret->data,ret->meth->d2i);
    }
Ejemplo n.º 16
0
PKCS7_ENCRYPT *d2i_PKCS7_ENCRYPT(PKCS7_ENCRYPT **a, unsigned char **pp,
                                 long length)
{
    M_ASN1_D2I_vars(a,PKCS7_ENCRYPT *,PKCS7_ENCRYPT_new);

    M_ASN1_D2I_Init();
    M_ASN1_D2I_start_sequence();
    M_ASN1_D2I_get(ret->version,d2i_ASN1_INTEGER);
    M_ASN1_D2I_get(ret->enc_data,d2i_PKCS7_ENC_CONTENT);

    M_ASN1_D2I_Finish(a,PKCS7_ENCRYPT_free,ASN1_F_D2I_PKCS7_ENCRYPT);
}
Ejemplo n.º 17
0
static NETSCAPE_PKEY *d2i_NETSCAPE_PKEY(NETSCAPE_PKEY **a, unsigned char **pp,
	     long length)
	{
	M_ASN1_D2I_vars(a,NETSCAPE_PKEY *,NETSCAPE_PKEY_new);

	M_ASN1_D2I_Init();
	M_ASN1_D2I_start_sequence();
	M_ASN1_D2I_get(ret->version,d2i_ASN1_INTEGER);
	M_ASN1_D2I_get(ret->algor,d2i_X509_ALGOR);
	M_ASN1_D2I_get(ret->private_key,d2i_ASN1_OCTET_STRING);
	M_ASN1_D2I_Finish(a,NETSCAPE_PKEY_free,ASN1_F_D2I_NETSCAPE_PKEY);
	}
Ejemplo n.º 18
0
AC_ATTRIBUTE *d2i_AC_ATTRIBUTE(AC_ATTRIBUTE **a, VOMS_MAYBECONST unsigned char **pp, long length)
{
  M_ASN1_D2I_vars(a, AC_ATTRIBUTE *, AC_ATTRIBUTE_new);

  M_ASN1_D2I_Init();
  M_ASN1_D2I_start_sequence();
  M_ASN1_D2I_get(ret->name,      d2i_ASN1_OCTET_STRING);
  M_ASN1_D2I_get(ret->value,     d2i_ASN1_OCTET_STRING);
  M_ASN1_D2I_get(ret->qualifier, d2i_ASN1_OCTET_STRING);

  M_ASN1_D2I_Finish(a, AC_ATTRIBUTE_free, AC_F_D2I_AC_ATTRIBUTE);
}
Ejemplo n.º 19
0
X509_NAME_ENTRY *d2i_X509_NAME_ENTRY(X509_NAME_ENTRY **a, unsigned char **pp,
                                     long length)
{
    M_ASN1_D2I_vars(a,X509_NAME_ENTRY *,X509_NAME_ENTRY_new);

    M_ASN1_D2I_Init();
    M_ASN1_D2I_start_sequence();
    M_ASN1_D2I_get(ret->object,d2i_ASN1_OBJECT);
    M_ASN1_D2I_get(ret->value,d2i_ASN1_PRINTABLE);
    ret->set=0;
    M_ASN1_D2I_Finish(a,X509_NAME_ENTRY_free,ASN1_F_D2I_X509_NAME_ENTRY);
}
PBKDF2PARAM *d2i_PBKDF2PARAM(PBKDF2PARAM **a, unsigned char **pp,
	     long length)
{
	M_ASN1_D2I_vars(a,PBKDF2PARAM *,PBKDF2PARAM_new);
	M_ASN1_D2I_Init();
	M_ASN1_D2I_start_sequence();
	M_ASN1_D2I_get (ret->salt, d2i_ASN1_TYPE);
	M_ASN1_D2I_get (ret->iter, d2i_ASN1_INTEGER);
	M_ASN1_D2I_get_opt (ret->keylength, d2i_ASN1_INTEGER, V_ASN1_INTEGER);
	M_ASN1_D2I_get_opt (ret->prf, d2i_X509_ALGOR, V_ASN1_SEQUENCE);
	M_ASN1_D2I_Finish(a, PBKDF2PARAM_free, ASN1_F_D2I_PBKDF2PARAM);
}
Ejemplo n.º 21
0
pkcs7_issuer_and_subject *
d2i_pkcs7_issuer_and_subject(pkcs7_issuer_and_subject **a,
		unsigned char **pp, long length) {

	M_ASN1_D2I_vars(a, pkcs7_issuer_and_subject *,
		pkcs7_issuer_and_subject_new);
	M_ASN1_D2I_Init();
	M_ASN1_D2I_start_sequence();
	M_ASN1_D2I_get(ret->issuer,d2i_X509_NAME);
	M_ASN1_D2I_get(ret->subject,d2i_X509_NAME);
	M_ASN1_D2I_Finish(a,pkcs7_issuer_and_subject_free, 99);
}
Ejemplo n.º 22
0
NETSCAPE_CERT_SEQUENCE *d2i_NETSCAPE_CERT_SEQUENCE(NETSCAPE_CERT_SEQUENCE **a,
	     unsigned char **pp, long length)
{
	M_ASN1_D2I_vars(a,NETSCAPE_CERT_SEQUENCE *,
					NETSCAPE_CERT_SEQUENCE_new);
	M_ASN1_D2I_Init();
	M_ASN1_D2I_start_sequence();
	M_ASN1_D2I_get (ret->type, d2i_ASN1_OBJECT);
	M_ASN1_D2I_get_EXP_set_opt_type(X509,ret->certs,d2i_X509,X509_free,0,
					V_ASN1_SEQUENCE);
	M_ASN1_D2I_Finish(a, NETSCAPE_CERT_SEQUENCE_free,
			  ASN1_F_D2I_NETSCAPE_CERT_SEQUENCE);
}
Ejemplo n.º 23
0
PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO(PKCS8_PRIV_KEY_INFO **a,
	     unsigned char **pp, long length)
{
	M_ASN1_D2I_vars(a,PKCS8_PRIV_KEY_INFO *,PKCS8_PRIV_KEY_INFO_new);
	M_ASN1_D2I_Init();
	M_ASN1_D2I_start_sequence();
	M_ASN1_D2I_get (ret->version, d2i_ASN1_INTEGER);
	M_ASN1_D2I_get (ret->pkeyalg, d2i_X509_ALGOR);
	M_ASN1_D2I_get (ret->pkey, d2i_ASN1_TYPE);
	M_ASN1_D2I_get_IMP_set_opt_type(X509_ATTRIBUTE, ret->attributes,
					d2i_X509_ATTRIBUTE,
					X509_ATTRIBUTE_free, 0);
	M_ASN1_D2I_Finish(a, PKCS8_PRIV_KEY_INFO_free, ASN1_F_D2I_PKCS8_PRIV_KEY_INFO);
}
GENERAL_NAME *d2i_GENERAL_NAME(GENERAL_NAME **a, unsigned char **pp,
								 long length)
{
	unsigned char _tmp;
	M_ASN1_D2I_vars(a,GENERAL_NAME *,GENERAL_NAME_new);
	M_ASN1_D2I_Init();
	c.slen = length;

	_tmp = M_ASN1_next;
	ret->type = _tmp & ~V_ASN1_CONSTRUCTED;

	switch(ret->type) {
		/* Just put these in a "blob" for now */
		case GEN_X400:
		case GEN_EDIPARTY:
		M_ASN1_D2I_get_imp(ret->d.other, d2i_ASN1_TYPE,V_ASN1_SEQUENCE);
		break;

		case GEN_OTHERNAME:
		M_ASN1_D2I_get_imp(ret->d.otherName, d2i_OTHERNAME,V_ASN1_SEQUENCE);
		break;

		case GEN_EMAIL:
		case GEN_DNS:
		case GEN_URI:
		M_ASN1_D2I_get_imp(ret->d.ia5, d2i_ASN1_IA5STRING,
							V_ASN1_IA5STRING);
		break;

		case GEN_DIRNAME:
		M_ASN1_D2I_get_EXP_opt(ret->d.dirn, d2i_X509_NAME, 4);
		break;

		case GEN_IPADD:
		M_ASN1_D2I_get_imp(ret->d.ip, d2i_ASN1_OCTET_STRING,
							V_ASN1_OCTET_STRING);
		break;
	
		case GEN_RID:
		M_ASN1_D2I_get_imp(ret->d.rid, d2i_ASN1_OBJECT,V_ASN1_OBJECT);
		break;

		default:
		c.error = ASN1_R_BAD_TAG;
		goto err;
	}

	c.slen = 0;
	M_ASN1_D2I_Finish(a, GENERAL_NAME_free, ASN1_F_D2I_GENERAL_NAME);
}
Ejemplo n.º 25
0
X509_PUBKEY *d2i_X509_PUBKEY(X509_PUBKEY **a, unsigned char **pp,
	     long length)
	{
	M_ASN1_D2I_vars(a,X509_PUBKEY *,X509_PUBKEY_new);

	M_ASN1_D2I_Init();
	M_ASN1_D2I_start_sequence();
	M_ASN1_D2I_get(ret->algor,d2i_X509_ALGOR);
	M_ASN1_D2I_get(ret->public_key,d2i_ASN1_BIT_STRING);
	if (ret->pkey != NULL)
		{
		EVP_PKEY_free(ret->pkey);
		ret->pkey=NULL;
		}
	M_ASN1_D2I_Finish(a,X509_PUBKEY_free,ASN1_F_D2I_X509_PUBKEY);
	}
Ejemplo n.º 26
0
X509_ALGOR *d2i_X509_ALGOR(X509_ALGOR **a, unsigned char **pp, long length)
	{
	M_ASN1_D2I_vars(a,X509_ALGOR *,X509_ALGOR_new);

	M_ASN1_D2I_Init();
	M_ASN1_D2I_start_sequence();
	M_ASN1_D2I_get(ret->algorithm,d2i_ASN1_OBJECT);
	if (!M_ASN1_D2I_end_sequence())
		{ M_ASN1_D2I_get(ret->parameter,d2i_ASN1_TYPE); }
	else
		{
		ASN1_TYPE_free(ret->parameter);
		ret->parameter=NULL;
		}
	M_ASN1_D2I_Finish(a,X509_ALGOR_free,ASN1_F_D2I_X509_ALGOR);
	}
PKCS12_SAFEBAG *d2i_PKCS12_SAFEBAG(PKCS12_SAFEBAG **a, unsigned char **pp,
	     long length)
{
	int bagnid;
	M_ASN1_D2I_vars(a,PKCS12_SAFEBAG *,PKCS12_SAFEBAG_new);
	M_ASN1_D2I_Init();
	M_ASN1_D2I_start_sequence();
	M_ASN1_D2I_get (ret->type, d2i_ASN1_OBJECT);
	bagnid = OBJ_obj2nid (ret->type);

	switch (bagnid) {

		case NID_keyBag:
			M_ASN1_D2I_get_EXP_opt (ret->value.keybag,
						 d2i_PKCS8_PRIV_KEY_INFO, 0);
		break;

		case NID_pkcs8ShroudedKeyBag:
			M_ASN1_D2I_get_EXP_opt (ret->value.shkeybag,
						 	d2i_X509_SIG, 0);
		break;

		case NID_safeContentsBag:
			M_ASN1_D2I_get_EXP_set_opt_type
			  (PKCS12_SAFEBAG, ret->value.safes,
			   d2i_PKCS12_SAFEBAG, PKCS12_SAFEBAG_free, 0,
			   V_ASN1_SEQUENCE);
		break;

		case NID_certBag:
		case NID_crlBag:
		case NID_secretBag:
			M_ASN1_D2I_get_EXP_opt (ret->value.bag,
							 d2i_PKCS12_BAGS, 0);
		break;

		default:
			M_ASN1_D2I_get_EXP_opt (ret->value.other,
							 d2i_ASN1_TYPE, 0);
		break;
	}
	M_ASN1_D2I_get_set_opt_type(X509_ATTRIBUTE,ret->attrib,
				    d2i_X509_ATTRIBUTE,X509_ATTRIBUTE_free);
	M_ASN1_D2I_Finish(a, PKCS12_SAFEBAG_free, ASN1_F_D2I_PKCS12_SAFEBAG);
}
Ejemplo n.º 28
0
RSA *d2i_RSAPrivateKey(RSA **a, unsigned char **pp, long length)
	{
	int i=ASN1_R_PARSING;
	ASN1_INTEGER *bs=NULL;
	M_ASN1_D2I_vars(a,RSA *,RSA_new);

	M_ASN1_D2I_Init();
	M_ASN1_D2I_start_sequence();
	M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
	if (bs->length == 0)
		ret->version=0;
	else	ret->version=bs->data[0];
	M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
	if ((ret->n=BN_bin2bn(bs->data,bs->length,ret->n)) == NULL) goto err_bn;
	M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
	if ((ret->e=BN_bin2bn(bs->data,bs->length,ret->e)) == NULL) goto err_bn;
	M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
	if ((ret->d=BN_bin2bn(bs->data,bs->length,ret->d)) == NULL) goto err_bn;
	M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
	if ((ret->p=BN_bin2bn(bs->data,bs->length,ret->p)) == NULL) goto err_bn;
	M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
	if ((ret->q=BN_bin2bn(bs->data,bs->length,ret->q)) == NULL) goto err_bn;
	M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
	if ((ret->dmp1=BN_bin2bn(bs->data,bs->length,ret->dmp1)) == NULL)
		goto err_bn;
	M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
	if ((ret->dmq1=BN_bin2bn(bs->data,bs->length,ret->dmq1)) == NULL)
		goto err_bn;
	M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
	if ((ret->iqmp=BN_bin2bn(bs->data,bs->length,ret->iqmp)) == NULL)
		goto err_bn;

	M_ASN1_INTEGER_free(bs);

	M_ASN1_D2I_Finish_2(a);
err_bn:
	i=ERR_R_BN_LIB;
err:
	ASN1err(ASN1_F_D2I_RSAPRIVATEKEY,i);
	if ((ret != NULL) && ((a == NULL) || (*a != ret))) RSA_free(ret);
	if (bs != NULL) M_ASN1_INTEGER_free(bs);

	return(NULL);
	}
Ejemplo n.º 29
0
ASN1_HEADER *d2i_ASN1_HEADER(ASN1_HEADER **a, unsigned char **pp,
	     long length)
	{
	M_ASN1_D2I_vars(a,ASN1_HEADER *,ASN1_HEADER_new);

	M_ASN1_D2I_Init();
        M_ASN1_D2I_start_sequence();
        M_ASN1_D2I_get(ret->header,d2i_ASN1_OCTET_STRING);
	if (ret->meth != NULL)
		{
		M_ASN1_D2I_get(ret->data,ret->meth->d2i);
		}
	else
		{
		if (a != NULL) (*a)=ret;
		return(ret);
		}
        M_ASN1_D2I_Finish(a,ASN1_HEADER_free,ASN1_F_D2I_ASN1_HEADER);
	}
Ejemplo n.º 30
0
DLA3_QUERYURL *d2i_DLA3_QUERYURL(DLA3_QUERYURL **a,
	     unsigned char **pp, long length)
{
	M_ASN1_D2I_vars(a,DLA3_QUERYURL *,DLA3_QUERYURL_new);
	M_ASN1_D2I_Init();
	M_ASN1_D2I_start_sequence();
	M_ASN1_D2I_get (ret->queryUrl, d2i_ASN1_OCTET_STRING);
#if 0
	M_ASN1_D2I_Finish(a, DLA3_QUERYURL_free, ASN1_F_D2I_DLA3_QUERYURL);
#else
	if (!asn1_Finish(&c))
		goto err;
	*pp = c.p;
	if (a != NULL)
		(*a)=ret;
	return(ret);
err:
	if ((ret != NULL) && ((a == NULL) || (*a != ret)))
		DLA3_QUERYURL_free(ret);
	return(NULL);
#endif
}