Example #1
0
int pea::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: move_p(); break;
        default: ;
        }
        _id -= 1;
    }
    return _id;
}
Example #2
0
static void RSATest(void)
{   
	char modulus_str[] = "ce812d6f1979ed7839b895d4b4b034319a630213b4b4528a0100f6ef961ffd050c775e9e9ebc9ca09d422c948d63698acf3f7c3615eb2cceac2c46bdfc8016c1988803ebdd5177ade1195c5caa6630ab2c8708e9cd430aedba92b26ba52e18e4e1b6c4f429dfa53c20c7b756f9622beb40c00e481e1dcdf0afa5e83ca7e4e443";	
	char signature_str[] = "c70bf6a79679af36ca72b7f6a9ce3b7a669860e22dffbcd6fe3075fab07e0ba6eb68f620653ba17144c431d9fa527f40ba5c83cf6b4154ae4ff9e604a2b74d8f4fb2f57a9a190ce3916e6176dbfb045485ad05109cc6ae7423900e12ccdc6dbd76e6e094e94543609c0427527ca7fa5fe5928f86053e05c419cd52cea7573596";
	char digest_str[]    = "026946989674B77821CE9EBCB0F66445ACC6A154";
    BI *signature, *pub_exp, *modulous, *res;
    
    printk("signature: %s\n", signature_str);
    printk("original checksum: %s\n", digest_str);
    
    // Note: public exponent is always 65537
	signature = InPutFromStr(signature_str, HEX);
	pub_exp   = move_p(65537);
	modulous  = InPutFromStr(modulus_str, HEX);
    res       = init_BI();	
	
	rsa_verify(signature, pub_exp, modulous, res);
	
	printk("recovered checksum:");
	dump_bi(res);	
		
	free_BI(signature);
	free_BI(pub_exp);
	free_BI(modulous);
	free_BI(res);
	
	/*
	BI* signature = move_p(65537);
	BI* pub_exp   = move_p(3);	
	BI* res       = NULL;
	printk("--------------start mod--------------\n");
	res =  Mod(signature, pub_exp);
	printk("--------------stop mode--------------\n");	
	free_BI(signature);
	free_BI(pub_exp);
	free_BI(res);		 
	*/
}
Example #3
0
int rsa_dev_do_rsa_verify(RSA_VERIFY* rsa)
{   
    BI* signature = NULL;    
    BI* pub_exp = NULL;
    BI* mod  = NULL;
    BI* dgst = init_BI();
    int ret  = -EFAULT;        
    
    if (!rsa)   
    {        
        printk("[MCP][RSA] WARNING, do rsa verify failed, invalid argument\n");        
        goto end_proc;
    }    
    
    if (rsa->dgst==NULL)
    {
        printk("[MCP][RSA] WARNING, do rsa verify failed, dgst should not be zero\n");
        return -EFAULT;    
    }
    
    if (rsa->signature)        
    {
        signature = init_BI();
        
        if (copy_from_user(signature, (RSA_VERIFY __user *) rsa->signature, sizeof(BI)))
        {            
            printk("[MCP][RSA] WARNING, do rsa verify failed, copy signature failed\n");
            goto end_proc;
        }            
    }    
    else    
    {
        printk("[MCP][RSA] WARNING, do rsa verify failed, signature should not be null\n");
        goto end_proc;
    }            
        
    if (rsa->pub_exp)                
    {
        pub_exp = init_BI();
        
        if (copy_from_user(pub_exp, (BI __user *) rsa->pub_exp, sizeof(BI)))
        {
            printk("[MCP][RSA] WARNING, do rsa verify failed, copy signature failed\n");
            goto end_proc;  
        }                                  
    }        
    else            
    {        
        pub_exp = move_p(65537);            // default public exp        
    }        
    
    if (rsa->mod)                
    {
        mod = init_BI();
        
        if (copy_from_user(mod, (BI __user *) rsa->mod, sizeof(BI)))
        {
            printk("[MCP][RSA] WARNING, do rsa verify failed, copy signature failed\n");
            goto end_proc;  
        }        
    }        
    else            
    {        
        mod = InPutFromStr(DEF_RSA_MOD, DEF_RSA_MOD_FMT);
    }     


    ret = rsa_verify(signature, pub_exp, mod, dgst);
                
    if (copy_to_user((BI __user *) rsa->dgst, dgst, sizeof(BI)))
    {
        printk("[MCP][RSA] WARNING, do rsa verify failed, copy dgst to user failed\n");        
        ret = -EFAULT;
    }             

end_proc:
    
    if (signature)  free_BI(signature); 
    if (pub_exp)    free_BI(pub_exp); 
    if (mod)        free_BI(mod);         
    if (dgst)       free_BI(dgst);         

    return ret;            
}