asn1-ut-string-decode.cpp revision 13493ab7596e827b8d0caab2c89e635dd65f78f9
/* $Id$ */
/** @file
* IPRT - ASN.1, XXX STRING Types, 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) RTAsn1String_DecodeAsn1(PRTASN1CURSOR pCursor, uint32_t fFlags, PRTASN1STRING pThis, const char *pszErrorTag)
{
if (RT_SUCCESS(rc))
{
/*
* Do tag matching.
*/
{
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:
rc = VINF_SUCCESS;
break;
default:
"%s: Not a string object: fClass=%#x / uTag=%#x",
}
if (RT_SUCCESS(rc))
{
/*
*/
{
/*
* Primitive strings are simple.
*/
/* UTF-8 conversion is done lazily, upon request. */
return VINF_SUCCESS;
}
{
/*
* Constructed strings are not yet fully implemented.
*/
"%s: DER encoding does not allow constructed strings (cb=%#x uTag=%#x fClass=%#x)",
{
rc = VINF_SUCCESS;
else
"%s: Constructed strings only allowed for >1000 byte in CER encoding: cb=%#x uTag=%#x fClass=%#x",
}
/** @todo implement constructed strings. */
if (RT_SUCCESS(rc))
"%s: Support for constructed strings is not implemented", pszErrorTag);
}
else
"%s: Not a valid string object: fClass=%#x / uTag=%#x",
}
}
return rc;
}
/**
* Common worker for the specific string type getters.
*
* @returns IPRT status code
* @param pCursor The cursor.
* @param fFlags The RTASN1CURSOR_GET_F_XXX flags.
* @param uTag The string tag.
* @param pThis The output object.
* @param pszErrorTag The error tag.
* @param pszWhat The string type name.
*/
static int rtAsn1XxxString_DecodeAsn1(PRTASN1CURSOR pCursor, uint32_t fFlags, uint8_t uTag, PRTASN1STRING pThis,
const char *pszErrorTag, const char *pszWhat)
{
if (RT_SUCCESS(rc))
{
if (RT_SUCCESS(rc))
{
{
/* UTF-8 conversion is done lazily, upon request. */
return VINF_SUCCESS;
}
}
}
return rc;
}
/*
* Generate code for the tag specific decoders.
*/
{ \
}
#include "asn1-ut-string-template2.h"
/*
* Generate code for the associated collection types.
*/
#define RTASN1TMPL_TEMPLATE_FILE "../common/asn1/asn1-ut-string-template.h"
#include <iprt/asn1-generator-internal-header.h>
#include <iprt/asn1-generator-asn1-decoder.h>