asn1-ut-octetstring-decode.cpp revision 375c27aef516595a50459787463506d474668e8c
2N/A/* $Id$ */
2N/A/** @file
2N/A * IPRT - ASN.1, OCTET STRING Type, Decoding.
2N/A */
2N/A
2N/A/*
2N/A * Copyright (C) 2006-2014 Oracle Corporation
2N/A *
2N/A * This file is part of VirtualBox Open Source Edition (OSE), as
2N/A * available from http://www.virtualbox.org. This file is free software;
2N/A * you can redistribute it and/or modify it under the terms of the GNU
2N/A * General Public License (GPL) as published by the Free Software
2N/A * Foundation, in version 2 as it comes in the "COPYING" file of the
2N/A * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
2N/A * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
2N/A *
2N/A * The contents of this file may alternatively be used under the terms
2N/A * of the Common Development and Distribution License Version 1.0
2N/A * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
2N/A * VirtualBox OSE distribution, in which case the provisions of the
2N/A * CDDL are applicable instead of those of the GPL.
2N/A *
2N/A * You may elect to license modified versions of this file under the
2N/A * terms and conditions of either the GPL or the CDDL or both.
2N/A */
2N/A
2N/A/*******************************************************************************
2N/A* Header Files *
2N/A*******************************************************************************/
2N/A#include "internal/iprt.h"
2N/A#include <iprt/asn1.h>
2N/A
2N/A#include <iprt/err.h>
2N/A#include <iprt/string.h>
2N/A
2N/A#include <iprt/formats/asn1.h>
2N/A
2N/A
2N/ARTDECL(int) RTAsn1OctetString_DecodeAsn1(PRTASN1CURSOR pCursor, uint32_t fFlags, PRTASN1OCTETSTRING pThis,
2N/A const char *pszErrorTag)
2N/A{
2N/A pThis->pEncapsulated = NULL;
2N/A RTAsn1CursorInitAllocation(pCursor, &pThis->EncapsulatedAllocation);
2N/A
2N/A int rc = RTAsn1CursorReadHdr(pCursor, &pThis->Asn1Core, pszErrorTag);
2N/A if (RT_SUCCESS(rc))
2N/A {
2N/A rc = RTAsn1CursorMatchTagClassFlagsString(pCursor, &pThis->Asn1Core, ASN1_TAG_OCTET_STRING,
2N/A ASN1_TAGCLASS_UNIVERSAL | ASN1_TAGFLAG_PRIMITIVE,
2N/A fFlags, pszErrorTag, "OCTET STRING");
2N/A if (RT_SUCCESS(rc))
2N/A {
2N/A if ( !(pThis->Asn1Core.fClass & ASN1_TAGFLAG_CONSTRUCTED)
2N/A || (fFlags & RTASN1CURSOR_GET_F_IMPLICIT) ) /* PKCS #7 ContentInfo tweak. */
2N/A {
2N/A RTAsn1CursorSkip(pCursor, pThis->Asn1Core.cb);
2N/A pThis->Asn1Core.pOps = &g_RTAsn1OctetString_Vtable;
2N/A pThis->Asn1Core.fFlags |= RTASN1CORE_F_PRIMITE_TAG_STRUCT;
2N/A return VINF_SUCCESS;
2N/A }
2N/A rc = RTAsn1CursorSetInfo(pCursor, VERR_ASN1_CONSTRUCTED_STRING_NOT_IMPL,
2N/A "%s: Constructed OCTET STRING not implemented.", pszErrorTag);
2N/A }
2N/A else
2N/A rc = RTAsn1CursorSetInfo(pCursor, rc, "%s: Not OCTET STRING: fClass=%#x / uTag=%#x",
2N/A pszErrorTag, pThis->Asn1Core.fClass, pThis->Asn1Core.uTag);
2N/A }
2N/A RT_ZERO(*pThis);
2N/A return rc;
2N/A}
2N/A
2N/A
2N/A/*
2N/A * Generate code for the associated collection types.
*/
#define RTASN1TMPL_TEMPLATE_FILE "../common/asn1/asn1-ut-octetstring-template.h"
#include <iprt/asn1-generator-internal-header.h>
#include <iprt/asn1-generator-asn1-decoder.h>