/* $Id$ */
/** @file
* IPRT - ASN.1, Dynamic Type, Decoding.
*/
/*
* Copyright (C) 2006-2014 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
RTDECL(int) RTAsn1DynType_DecodeAsn1(PRTASN1CURSOR pCursor, uint32_t fFlags, PRTASN1DYNTYPE pDynType, const char *pszErrorTag)
{
if (RT_SUCCESS(rc))
{
{
{
case ASN1_TAG_BOOLEAN:
break;
case ASN1_TAG_INTEGER:
break;
//case ASN1_TAG_ENUMERATED:
// pDynType->enmType = RTASN1TYPE_ENUMERATED;
// break;
//case ASN1_TAG_REAL:
// pDynType->enmType = RTASN1TYPE_REAL;
// break;
case ASN1_TAG_BIT_STRING:
break;
case ASN1_TAG_OCTET_STRING:
break;
case ASN1_TAG_NULL:
break;
case ASN1_TAG_SEQUENCE:
return RTAsn1CursorSetInfo(pCursor, VERR_ASN1_DYNTYPE_BAD_TAG, "ASN.1 SEQUENCE shall be constructed.");
case ASN1_TAG_SET:
case ASN1_TAG_OID:
break;
//case ASN1_TAG_RELATIVE_OID:
// pDynType->enmType = RTASN1TYPE_RELATIVE_OBJID;
// break;
case ASN1_TAG_UTC_TIME:
break;
case ASN1_TAG_UTF8_STRING:
case ASN1_TAG_NUMERIC_STRING:
case ASN1_TAG_T61_STRING:
case ASN1_TAG_VIDEOTEX_STRING:
case ASN1_TAG_IA5_STRING:
case ASN1_TAG_GRAPHIC_STRING:
case ASN1_TAG_VISIBLE_STRING:
case ASN1_TAG_GENERAL_STRING:
case ASN1_TAG_BMP_STRING:
break;
//case ASN1_TAG_CHARACTER_STRING:
// pDynType->enmType = RTASN1TYPE_CHARACTER_STRING;
// break;
default:
"Primitive tag %u (%#x) not implemented.",
}
}
{
case ASN1_TAG_BOOLEAN:
return RTAsn1CursorSetInfo(pCursor, VERR_ASN1_DYNTYPE_BAD_TAG, "ASN.1 BOOLEAN shall be primitive.");
case ASN1_TAG_INTEGER:
return RTAsn1CursorSetInfo(pCursor, VERR_ASN1_DYNTYPE_BAD_TAG, "ASN.1 BOOLEAN shall be primitive.");
case ASN1_TAG_ENUMERATED:
return RTAsn1CursorSetInfo(pCursor, VERR_ASN1_DYNTYPE_BAD_TAG, "ASN.1 ENUMERATED shall be primitive.");
case ASN1_TAG_REAL:
case ASN1_TAG_BIT_STRING:
break;
case ASN1_TAG_OCTET_STRING:
break;
case ASN1_TAG_NULL:
case ASN1_TAG_SEQUENCE:
#if 0
return VINF_SUCCESS;
#else
#endif
break;
case ASN1_TAG_SET:
#if 0
return VINF_SUCCESS;
#else
#endif
break;
case ASN1_TAG_OID:
return RTAsn1CursorSetInfo(pCursor, VERR_ASN1_DYNTYPE_BAD_TAG, "ASN.1 OBJECT ID shall be primitive.");
case ASN1_TAG_RELATIVE_OID:
return RTAsn1CursorSetInfo(pCursor, VERR_ASN1_DYNTYPE_BAD_TAG, "ASN.1 RELATIVE OID shall be primitive.");
case ASN1_TAG_UTF8_STRING:
case ASN1_TAG_NUMERIC_STRING:
case ASN1_TAG_T61_STRING:
case ASN1_TAG_VIDEOTEX_STRING:
case ASN1_TAG_IA5_STRING:
case ASN1_TAG_GRAPHIC_STRING:
case ASN1_TAG_VISIBLE_STRING:
case ASN1_TAG_GENERAL_STRING:
case ASN1_TAG_BMP_STRING:
break;
//case ASN1_TAG_CHARACTER_STRING:
// pDynType->enmType = RTASN1TYPE_CHARACTER_STRING;
// break;
default:
"Constructed tag %u (%#x) not implemented.",
}
else
{
return VINF_SUCCESS;
}
/*
* Restore the cursor and redo with specific type.
*/
{
case RTASN1TYPE_INTEGER:
break;
case RTASN1TYPE_BOOLEAN:
break;
case RTASN1TYPE_OBJID:
break;
case RTASN1TYPE_BIT_STRING:
break;
case RTASN1TYPE_OCTET_STRING:
break;
case RTASN1TYPE_NULL:
break;
case RTASN1TYPE_TIME:
break;
case RTASN1TYPE_STRING:
break;
case RTASN1TYPE_CORE:
break;
default:
}
if (RT_SUCCESS(rc))
return rc;
}
return rc;
}