Christian Schmitz wrote:
> Tim Jones <[EMAIL PROTECTED]> wrote:
>
>   
>> Thanks Christian.  Since 'r' is going to be modified by the algorithm,
>> shouldn't the entry be "ByRef r As MemoryBlock"?
>>     
>
> do you modify the reference or the content?
> Byref is to modify the reference.
> e.g. to assign a new memoryblock to it in the function.
>   

Ah, since I'm modifying the content, I shouldn't use ByRef in the 
definition.  But, will I need to use ByRef in the call from RB as I do 
if calling a shared library declare?

>  Also, am I using the 
> correct identifier for this type of function (accept 3 memoryblocks, 
> modify the contents of the 3rd) when I use "REALNoImplementation"?
>   
>
> looks correct.
>
>   
>> The change above works and my ModularExp() method nows autocompletes in
>> the IDE editor - however, the helper text does not show up in the IDE's
>> status bar.
>>     
>
> You will get used to it.
>   

Oh, another of *THOSE* quirky things ...

>  
>   
>>  
>> I get a hard crash.
>>     
>
> your C function is not declared to take REALmemoryblocks.
>   

Ah, so my current function call code looks like:

  void ModularExp(unsigned short *base,
                               unsigned short *power,
                               unsigned short *result)

and the actual module's code expects pointers to 3 arrays of 64 unsigned 
shorts.  When I look up the type definition for REALmemoryBlock, I can't 
find a typedef, so I should assume that, in this case, a REALmemoryBlock 
is just a struct?  What should be changed from normal C code to enable 
the memoryblock manipulation?

Here's the entire function in C.  The arrays "one[]" and "exp[]" are 
predefined arrays of 64 unsigned shorts. And the variable BIGNUM_SHORTS 
is 64.

void ModularExp(unsigned short *base, unsigned short *power, unsigned 
short *result) {
    unsigned short z, sqr[BIGNUM_SHORTS], exp[BIGNUM_SHORTS];
    int i;
   
    for(i=0; i<BIGNUM_SHORTS; i++) {
        result[i] = one[i];
        exp[i]    = power[i];
    }
   
    modular_product(base, one, sqr);
   
    for(;;) {
        if (exp[0] & 1)
            montgomery_reduction(sqr, result, result);
       
        z = 0;
        for(i=0; i<BIGNUM_SHORTS-1; i++) {
            exp[i] = (exp[i] >> 1) | ((exp[i+1] & 1) << 15);
            z |= exp[i];
        }
       
        exp[BIGNUM_SHORTS-1] >>= 1;
        z |= exp[BIGNUM_SHORTS-1];
       
        if (z == 0)
            break;
       
        montgomery_reduction(sqr, sqr, sqr);
    }
   
    modular_product(result, rp, result);
}

Am I just going to modify the calling parameters and then deal with the 
arrays internally as I do in the normal C program, or are the required 
changes going to move into my other functions as well?

Thanks,

Tim

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to