Пример #1
0
int i2d_X509_NAME_ENTRY(X509_NAME_ENTRY *a, unsigned char **pp)
{
    M_ASN1_I2D_vars(a);

    M_ASN1_I2D_len(a->object,i2d_ASN1_OBJECT);
    M_ASN1_I2D_len(a->value,i2d_ASN1_PRINTABLE);

    M_ASN1_I2D_seq_total();

    M_ASN1_I2D_put(a->object,i2d_ASN1_OBJECT);
    M_ASN1_I2D_put(a->value,i2d_ASN1_PRINTABLE);

    M_ASN1_I2D_finish();
}
Пример #2
0
int i2d_X509_ALGOR(X509_ALGOR *a, unsigned char **pp)
	{
	M_ASN1_I2D_vars(a);

	M_ASN1_I2D_len(a->algorithm,i2d_ASN1_OBJECT);
	if (a->parameter != NULL)
		{ M_ASN1_I2D_len(a->parameter,i2d_ASN1_TYPE); }

	M_ASN1_I2D_seq_total();
	M_ASN1_I2D_put(a->algorithm,i2d_ASN1_OBJECT);
	if (a->parameter != NULL)
		{ M_ASN1_I2D_put(a->parameter,i2d_ASN1_TYPE); }

	M_ASN1_I2D_finish();
	}
Пример #3
0
int i2d_AC_ATTRIBUTE(AC_ATTRIBUTE *a, unsigned char **pp)
{
  M_ASN1_I2D_vars(a);
  M_ASN1_I2D_len(a->name,      i2d_ASN1_OCTET_STRING);
  M_ASN1_I2D_len(a->value,     i2d_ASN1_OCTET_STRING);
  M_ASN1_I2D_len(a->qualifier, i2d_ASN1_OCTET_STRING);

  M_ASN1_I2D_seq_total();

  M_ASN1_I2D_put(a->name,      i2d_ASN1_OCTET_STRING);
  M_ASN1_I2D_put(a->value,     i2d_ASN1_OCTET_STRING);
  M_ASN1_I2D_put(a->qualifier, i2d_ASN1_OCTET_STRING);

  M_ASN1_I2D_finish();
}
Пример #4
0
int i2d_AC_TARGET(AC_TARGET *a, unsigned char **pp)
{
  int v1=0, v2=0, v3=0;

  M_ASN1_I2D_vars(a);
  M_ASN1_I2D_len_EXP_opt(a->name, i2d_GENERAL_NAME, 0, v1);
  M_ASN1_I2D_len_EXP_opt(a->group, i2d_GENERAL_NAME, 1, v2);
  M_ASN1_I2D_len_EXP_opt(a->cert, i2d_AC_IS, 2, v3);
  M_ASN1_I2D_seq_total();

  M_ASN1_I2D_put_EXP_opt(a->name, i2d_GENERAL_NAME, 0, v1);
  M_ASN1_I2D_put_EXP_opt(a->group, i2d_GENERAL_NAME, 1, v2);
  M_ASN1_I2D_put_EXP_opt(a->cert, i2d_AC_IS, 2, v3);
  M_ASN1_I2D_finish();
}
Пример #5
0
int i2d_X509_KEY(X509 *a, unsigned char **pp)
	{
	M_ASN1_I2D_vars(a);

	M_ASN1_I2D_len(a->cert_info,	i2d_X509_CINF);
	M_ASN1_I2D_len(a->sig_alg,	i2d_X509_ALGOR);
	M_ASN1_I2D_len(a->signature,	i2d_ASN1_BIT_STRING);

	M_ASN1_I2D_seq_total();

	M_ASN1_I2D_put(a->cert_info,	i2d_X509_CINF);
	M_ASN1_I2D_put(a->sig_alg,	i2d_X509_ALGOR);
	M_ASN1_I2D_put(a->signature,	i2d_ASN1_BIT_STRING);

	M_ASN1_I2D_finish();
	}
Пример #6
0
int i2d_AC_SEQ(AC_SEQ *a, unsigned char **pp)
{
  M_ASN1_I2D_vars(a);
#ifdef TYPEDEF_I2D_OF
  M_ASN1_I2D_len_SEQUENCE(a->acs, (i2d_of_void*)i2d_AC);
#else
  M_ASN1_I2D_len_SEQUENCE(a->acs, i2d_AC);
#endif
  M_ASN1_I2D_seq_total();
#ifdef TYPEDEF_I2D_OF
  M_ASN1_I2D_put_SEQUENCE(a->acs, (i2d_of_void*)i2d_AC);
#else
  M_ASN1_I2D_put_SEQUENCE(a->acs, i2d_AC);
#endif
  M_ASN1_I2D_finish();
}
Пример #7
0
int i2d_NETSCAPE_CERT_SEQUENCE(NETSCAPE_CERT_SEQUENCE *a, unsigned char **pp)
{
	int v = 0;
	M_ASN1_I2D_vars(a);
	M_ASN1_I2D_len (a->type, i2d_ASN1_OBJECT);
	M_ASN1_I2D_len_EXP_SEQUENCE_opt_type(X509,a->certs,i2d_X509,0,
					     V_ASN1_SEQUENCE,v);

	M_ASN1_I2D_seq_total();

	M_ASN1_I2D_put (a->type, i2d_ASN1_OBJECT);
	M_ASN1_I2D_put_EXP_SEQUENCE_opt_type(X509,a->certs,i2d_X509,0,
					     V_ASN1_SEQUENCE,v);

	M_ASN1_I2D_finish();
}
int i2d_PBKDF2PARAM(PBKDF2PARAM *a, unsigned char **pp)
{
	M_ASN1_I2D_vars(a);
	M_ASN1_I2D_len (a->salt, i2d_ASN1_TYPE);
	M_ASN1_I2D_len (a->iter, i2d_ASN1_INTEGER);
	M_ASN1_I2D_len (a->keylength, i2d_ASN1_INTEGER);
	M_ASN1_I2D_len (a->prf, i2d_X509_ALGOR);

	M_ASN1_I2D_seq_total ();

	M_ASN1_I2D_put (a->salt, i2d_ASN1_TYPE);
	M_ASN1_I2D_put (a->iter, i2d_ASN1_INTEGER);
	M_ASN1_I2D_put (a->keylength, i2d_ASN1_INTEGER);
	M_ASN1_I2D_put (a->prf, i2d_X509_ALGOR);

	M_ASN1_I2D_finish();
}
Пример #9
0
static int i2d_NETSCAPE_PKEY(NETSCAPE_PKEY *a, unsigned char **pp)
	{
	M_ASN1_I2D_vars(a);


	M_ASN1_I2D_len(a->version,	i2d_ASN1_INTEGER);
	M_ASN1_I2D_len(a->algor,	i2d_X509_ALGOR);
	M_ASN1_I2D_len(a->private_key,	i2d_ASN1_OCTET_STRING);

	M_ASN1_I2D_seq_total();

	M_ASN1_I2D_put(a->version,	i2d_ASN1_INTEGER);
	M_ASN1_I2D_put(a->algor,	i2d_X509_ALGOR);
	M_ASN1_I2D_put(a->private_key,	i2d_ASN1_OCTET_STRING);

	M_ASN1_I2D_finish();
	}
Пример #10
0
int i2d_DLA3_QUERYURL(DLA3_QUERYURL *a, unsigned char **pp)
{
	M_ASN1_I2D_vars(a);

	r = M_ASN1_I2D_len (a->queryUrl, i2d_ASN1_OCTET_STRING);

#if 0
	M_ASN1_I2D_seq_total();
#endif

	if (pp)
	{
		p = *pp;
		M_ASN1_I2D_put (a->queryUrl, i2d_ASN1_OCTET_STRING);
		M_ASN1_I2D_finish();
	}
	else
		return(r);
}
Пример #11
0
int i2d_KCA_VERSION(KCA_VERSION *a, unsigned char **pp)
{
	M_ASN1_I2D_vars(a);

	r = M_ASN1_I2D_len (a->Version, i2d_ASN1_OCTET_STRING);

#if 0
	M_ASN1_I2D_seq_total();
#endif

	if (pp)
	{
		p = *pp;
		M_ASN1_I2D_put (a->Version, i2d_ASN1_OCTET_STRING);
		M_ASN1_I2D_finish();
	}
	else
		return(r);
}
Пример #12
0
/**
 * @ingroup proxypolicy
 *
 * Converts a PROXYPOLICY from its internal structure
 * to a DER encoded form
 *
 * @param a the PROXYPOLICY to convert
 * @param pp the buffer to put the DER encoding in
 *
 * @return the length of the DER encoding in bytes
 */
int i2d_PROXYPOLICY(
    PROXYPOLICY *                       a,
    unsigned char **                    pp)
{
    M_ASN1_I2D_vars(a);

    M_ASN1_I2D_len(a->policy_language, i2d_ASN1_OBJECT);

    if(a->policy)
    { 
        M_ASN1_I2D_len(a->policy, i2d_ASN1_OCTET_STRING);
    }
    
    M_ASN1_I2D_seq_total();
    M_ASN1_I2D_put(a->policy_language, i2d_ASN1_OBJECT);
    if(a->policy)
    { 
        M_ASN1_I2D_put(a->policy, i2d_ASN1_OCTET_STRING);
    }
    M_ASN1_I2D_finish();
}
Пример #13
0
int i2d_PKCS8_PRIV_KEY_INFO (PKCS8_PRIV_KEY_INFO *a, unsigned char **pp)
{

	M_ASN1_I2D_vars(a);

	M_ASN1_I2D_len (a->version, i2d_ASN1_INTEGER);
	M_ASN1_I2D_len (a->pkeyalg, i2d_X509_ALGOR);
	M_ASN1_I2D_len (a->pkey, i2d_ASN1_TYPE);
	M_ASN1_I2D_len_IMP_SET_opt_type (X509_ATTRIBUTE, a->attributes,
					 i2d_X509_ATTRIBUTE, 0);
	
	M_ASN1_I2D_seq_total ();

	M_ASN1_I2D_put (a->version, i2d_ASN1_INTEGER);
	M_ASN1_I2D_put (a->pkeyalg, i2d_X509_ALGOR);
	M_ASN1_I2D_put (a->pkey, i2d_ASN1_TYPE);
	M_ASN1_I2D_put_IMP_SET_opt_type (X509_ATTRIBUTE, a->attributes,
					 i2d_X509_ATTRIBUTE, 0);

	M_ASN1_I2D_finish();
}
int i2d_PKCS12_SAFEBAG(PKCS12_SAFEBAG *a, unsigned char **pp)
{
	int bagnid, v = 0;
	M_ASN1_I2D_vars(a);
	bagnid = OBJ_obj2nid (a->type);
	M_ASN1_I2D_len (a->type, i2d_ASN1_OBJECT);
	
	switch (bagnid) {

		case NID_keyBag:
			M_ASN1_I2D_len_EXP_opt (a->value.keybag,
						 i2d_PKCS8_PRIV_KEY_INFO, 0, v);
		break;

		case NID_pkcs8ShroudedKeyBag:
			M_ASN1_I2D_len_EXP_opt (a->value.shkeybag,
						 i2d_X509_SIG, 0, v);
		break;

		case NID_safeContentsBag:
			M_ASN1_I2D_len_EXP_SEQUENCE_opt_type (PKCS12_SAFEBAG,
			    a->value.safes, (i2d_func_t)i2d_PKCS12_SAFEBAG,
			    0, V_ASN1_SEQUENCE, v);
		break;

		case NID_certBag:
		case NID_crlBag:
		case NID_secretBag:
			M_ASN1_I2D_len_EXP_opt (a->value.bag,
						 i2d_PKCS12_BAGS, 0, v);
		break;

		default:
			M_ASN1_I2D_len_EXP_opt (a->value.other,
						 i2d_ASN1_TYPE, 0, v);
		break;
	}

	M_ASN1_I2D_len_SET_type (X509_ATTRIBUTE,a->attrib,
	    (i2d_func_t)i2d_X509_ATTRIBUTE);

	M_ASN1_I2D_seq_total ();
	
	M_ASN1_I2D_put (a->type, i2d_ASN1_OBJECT);

	switch (bagnid) {

		case NID_keyBag:
			M_ASN1_I2D_put_EXP_opt (a->value.keybag,
						 i2d_PKCS8_PRIV_KEY_INFO, 0, v);
		break;

		case NID_pkcs8ShroudedKeyBag:
			M_ASN1_I2D_put_EXP_opt (a->value.shkeybag,
						 i2d_X509_SIG, 0, v);
		break;

		case NID_safeContentsBag:
			M_ASN1_I2D_put_EXP_SEQUENCE_opt_type (PKCS12_SAFEBAG, 
			    a->value.safes, (i2d_func_t)i2d_PKCS12_SAFEBAG,
			    0, V_ASN1_SEQUENCE, v);
		break;

		case NID_certBag:
		case NID_crlBag:
		case NID_secretBag:
			M_ASN1_I2D_put_EXP_opt (a->value.bag,
						 i2d_PKCS12_BAGS, 0, v);
		break;

		default:
			M_ASN1_I2D_put_EXP_opt (a->value.other,
						 i2d_ASN1_TYPE, 0, v);
		break;
	}

	M_ASN1_I2D_put_SET_type (X509_ATTRIBUTE, a->attrib,
	    (i2d_func_t)i2d_X509_ATTRIBUTE);

	M_ASN1_I2D_finish();
}