/********************************************************************** caller: owner of this object All the ASN1 object can share the same function here, you don't need to rewrite it, but you have to free the memory cause it's new created. prototype: PUCHAR AnscAsn1GetEncodedData ( ANSC_HANDLE hThisObject, PULONG pLength ); description: This function encoded the object to the created binary data argument: ANSC_HANDLE hThisObject This handle is actually the pointer of this object itself. PULONG pLength The buffer of new created binary length return: The new created and encoded binary data **********************************************************************/ PUCHAR AnscAsn1GetEncodedData ( ANSC_HANDLE hThisObject, PULONG pLength ) { PANSC_ASN1_OBJECT pThisObject = (PANSC_ASN1_OBJECT)hThisObject; PUCHAR pNewBuffer, pBack; LONG length; if( pThisObject == NULL) { return NULL; } length = pThisObject->GetSizeOfEncoded(pThisObject); if( length <= 0) { return NULL; } pNewBuffer = (PUCHAR)AnscAllocateMemory(length + 16); if( pNewBuffer == NULL) { return NULL; } pBack = pNewBuffer; if( ANSC_STATUS_SUCCESS != pThisObject->EncodingData(pThisObject, (PVOID*)&pBack)) { AnscFreeMemory(pNewBuffer); return NULL; } if( pLength) { *pLength = length; } return pNewBuffer; }