Exemplo n.º 1
0
STATUS
gcn_login( i4 type, i4 version, bool encrypt, char *key, char *ipb, char *opb )
{
    STATUS status = FAIL;

    switch( type )
    {
    case GCN_VLP_CLIENT :
	if ( ! encrypt )  
	    switch( version )
	    {
	    case GCN_VLP_V0 :	status = gcn_decrypt( key, ipb, opb );	break;
	    }
	break;

    case GCN_VLP_LOGIN  :
	if ( encrypt )
	    switch( version )
	    {
	    case GCN_VLP_V0 :	status = gcu_encode( key, ipb, opb );	break;
	    case GCN_VLP_V1 :	status = gcn_encode( key, 
					    (u_i1 *)IIGCn_static.login_mask, 
					    ipb, opb );			break;
	    }
	else
	    switch( version )
	    {
	    case GCN_VLP_V0 :	status = gcn_decrypt( key, ipb, opb );	break;
	    case GCN_VLP_V1 :	status = gcn_decode( key, 
					    (u_i1 *)IIGCn_static.login_mask, 
					    ipb, opb );			break;
	    }
	break;

    case GCN_VLP_COMSVR :
	if ( encrypt )  
	    switch( version )
	    {
	    case GCN_VLP_V0 :	status = gcu_encode( key, ipb, opb );	break;
	    case GCN_VLP_V1 :	status = gcn_encode( key, 
					    (u_i1 *)IIGCn_static.comsvr_mask, 
					    ipb, opb );			break;
	    }
	break;
    }

    return( status );
}
Exemplo n.º 2
0
STATUS gcn_recrypt( bool clustered, u_i1 *local_mask, char *gcn_val, 
    bool *v1DecryptErr, bool *writeOutput)
{
    i2 pc;
    char *pv[ 3 ];
    STATUS status = OK;
    char *p;
    char pwd[GC_L_PASSWORD];
    i2 j;
    bool printable;

    *v1DecryptErr = FALSE;

    pc = gcu_words( gcn_val, NULL, pv, ',', 3 );
    if (pc < 2 )  
        pv[1] = "";
    if (pc < 3 )  
        pv[2] = "";

    if (!STcasecmp(pv[2],"V0") || (pc < 3))
        status = gcn_decrypt( pv[0], pv[1], pwd );
    else
        status = gcn_decode( pv[0],(u_i1*)local_mask, pv[1], pwd );
    
    if (status != OK)
    {
        if (!STcasecmp(pv[2],"V1"))
            *v1DecryptErr = TRUE;
        goto end_routine;      
    }
    if (!STlength(pwd))
    {
        if (!STcasecmp(pv[2],"V1"))
            *v1DecryptErr = TRUE;
        status = FAIL;
        goto end_routine;
    }
    p = &pwd[0];
    printable = TRUE;
    for (j = 0; j < STlength(pwd); j++)
    {
        if (!CMprint(p))
        {
            printable = FALSE;
            break;
        }
        CMnext(p);
    }
    if (!printable)
    {
         if (!STcasecmp(pv[2],"V1"))
             *v1DecryptErr = TRUE;
         status = FAIL;
         goto end_routine;
    }

    if (clustered)
    {
        if (!STncasecmp("V1", pv[2], STlength(pv[2])))
            *writeOutput = TRUE;
        status = gcu_encode( pv[0], pwd, pv[1] );
        STpolycat( 5, pv[0], ",", pv[1], ",", "V0", gcn_val );
    }
    else
    {
        status = gcn_encode( pv[0],(u_i1*)local_mask, pwd, pv[1] );
        STpolycat( 5, pv[0], ",", pv[1], ",", "V1", gcn_val );
    }

end_routine:
     return status;
}