Exemple #1
0
void *inap_decode(Invoke_t *invoke, asn_TYPE_descriptor_t **type) {
	long opcode;
	int rv;
	void *arg = 0;

	if (!invoke || !invoke->parameter || !type)
		goto nothing;

	if (invoke->opCode.present != OPERATION_PR_localValue)
		goto nothing;

	if (asn_INTEGER2long(&invoke->opCode.choice.localValue, &opcode))
		goto nothing;

	if (opcode >= ARRAY_SIZE(opcode_type_map))
		goto nothing;

	*type = opcode_type_map[opcode];
	if (!*type)
		goto nothing;

	rv = ANY_to_type(invoke->parameter, *type, &arg);

	if (!rv)
		return arg;

	if (arg)
		(*type)->free_struct(*type, arg, 0);

nothing:
	*type = NULL;
	return NULL;
}
Exemple #2
0
// pobranie z ContenInfo struktury SignedData.
// Jest wykonywana kopia !, gdyz struktura SignedData jest dekodowana
long ContentInfo_get_SignedData(
	ContentInfo_t *content,
	SignedData_t **sigData)
{
	long OID_id_signedData[] = {OID_CMS_ID_SIGNED_DATA_LONG};
	long *oid = NULL;
	long oid_cnt;

	if (( content == NULL ) || ( sigData == NULL ))
		return ERR_WRONG_ARGUMENT;
	oid_cnt = OID_to_ulong_alloc2(&(content->contentType), &oid);
	if ( oid_cnt < 0 )
		return oid_cnt;
	if ( OID_cmp2(OID_id_signedData, sizeof(OID_id_signedData),
		oid, sizeof(*oid)*oid_cnt) )
	{
		free(oid);
		return ERR_OPERATION_FAILED; // not id-signed-data
	}
	free(oid);
	if ( ANY_to_type(&(content->content), &asn_DEF_SignedData, (void **)sigData) )
		return ERR_OPERATION_FAILED; // nieudana konwersja
	return 0;
}