コード例 #1
0
ANSC_HANDLE
AnscAsn1CertificateRequestCreateChildObject
    (
        ANSC_HANDLE                 hThisObject,
        ULONG                       index
    )
{
    PANSC_ASN1_OBJECT               pThisObject      = NULL;
    PANSC_ASN1_SEQUENCE             pParent          = (PANSC_ASN1_SEQUENCE)hThisObject;

    switch( index )
    {

        case 0:

            pThisObject = AnscAsn1CreateCertificationRequestInfo(NULL);

            if( pThisObject != NULL)
            {
                pThisObject->AddAttribute(pThisObject, pParent->CreateChildAttr(pParent,index), FALSE);
                pThisObject->SetName(pThisObject, pParent->GetChildName(pParent,index));
            }

            break;

        case 1:

            pThisObject = AnscAsn1CreateSignatureAlgorithmIdentifier(NULL);

            if( pThisObject != NULL)
            {
                pThisObject->AddAttribute(pThisObject, pParent->CreateChildAttr(pParent,index), FALSE);
                pThisObject->SetName(pThisObject, pParent->GetChildName(pParent,index));
            }

            break;

        case 2:

            pThisObject = AnscAsn1CreateBitString(NULL);

            if( pThisObject != NULL)
            {
                pThisObject->AddAttribute(pThisObject, pParent->CreateChildAttr(pParent,index), FALSE);
                pThisObject->SetName(pThisObject, pParent->GetChildName(pParent,index));
            }

            break;

    }

    return pThisObject;

}
コード例 #2
0
/**********************************************************************

    caller:     owner of the object

    prototype:

        ANSC_HANDLE
        AnscAsn1Clone
            (
                ANSC_HANDLE                 hThisObject
            );

    description:

        This function clones a same ASN.1 object.

    argument:   ANSC_HANDLE                 hContainerContext
                This handle is actually the pointer of this object
                itself.

    return:     The cloned container object.

**********************************************************************/
ANSC_HANDLE
AnscAsn1Clone
    (
        ANSC_HANDLE                 hThisObject
    )
{
    PANSC_ASN1_OBJECT               pMyObject    = (PANSC_ASN1_OBJECT)hThisObject;
    PANSC_ASN1_OBJECT               pNewObject   = NULL;

    pNewObject = 
        pMyObject->Create
            (
                pMyObject->hContainerContext
            );

    if( pNewObject == NULL)
    {
        AnscTrace("Failed to clone at AnscAsn1SetOfClone()\n");

        return NULL;
    }

    /*
     *  Copy all the attributes;
     */
    /* AttrListCopyAllAttributes( &pNewObject->sAttrList, &pMyObject->sAttrList);*/
    pNewObject->SetName(pNewObject, pMyObject->Name);

    if( !pMyObject->CopyTo(pMyObject, pNewObject))
    {
        pNewObject->AsnFree(pNewObject);

        return NULL;
    }

    return pNewObject;
}
コード例 #3
0
ANSC_HANDLE
AnscAsn1CertificationRequestInfoCreateChildObject
    (
        ANSC_HANDLE                 hThisObject,
        ULONG                       index
    )
{
    PANSC_ASN1_OBJECT               pThisObject      = NULL;
    PANSC_ASN1_SEQUENCE             pParent          = (PANSC_ASN1_SEQUENCE)hThisObject;

    switch( index )
    {

        case 0:

            pThisObject = AnscAsn1CreateInteger(NULL);

            if( pThisObject != NULL)
            {
                pThisObject->AddAttribute(pThisObject, pParent->CreateChildAttr(pParent,index), FALSE);
                pThisObject->SetName(pThisObject, pParent->GetChildName(pParent,index));
                pThisObject->bCanBeOptional = TRUE;
                pThisObject->bOptional = TRUE;
            }

            break;

        case 1:

            pThisObject = AnscAsn1CreateName(NULL);

            if( pThisObject != NULL)
            {
                pThisObject->AddAttribute(pThisObject, pParent->CreateChildAttr(pParent,index), FALSE);
                pThisObject->SetName(pThisObject, pParent->GetChildName(pParent,index));
            }

            break;

        case 2:

            pThisObject = AnscAsn1CreateSubjectPublicKeyInfo(NULL);

            if( pThisObject != NULL)
            {
                pThisObject->AddAttribute(pThisObject, pParent->CreateChildAttr(pParent,index), FALSE);
                pThisObject->SetName(pThisObject, pParent->GetChildName(pParent,index));
            }

            break;

        case 3:

            pThisObject = AnscAsn1CreateAttributes(NULL);

            if( pThisObject != NULL)
            {
                pThisObject->AddAttribute(pThisObject, pParent->CreateChildAttr(pParent,index), FALSE);
                pThisObject->SetName(pThisObject, pParent->GetChildName(pParent,index));
                pThisObject->bCanBeOptional = TRUE;
                pThisObject->bOptional = TRUE;
            }

            break;

    }

    return pThisObject;

}