RE: Question about OffloadModExpo() Function

From: john (phenerse_at_hotmail.com)
Date: 10/26/05


Date: Wed, 26 Oct 2005 03:03:03 -0700

Hi Laszlo,

I'm sorry to disturb you again.Because I really have no idea about it.
So much time on this, but still little effect.

I'm sure my implementation is right. The problem is in the INTERFACE.
But I cannot know when and how MS CAPI calls OffloadModExpo.Maybe the
description of OffloadModExpo in MSDN is not right, at least not clear.

Would you please help me to have a look of my function?
It's quite short.

///////////////////////
_declspec (dllexport)
BOOL OffloadModExpo(
  BYTE *pbBase, // in
  BYTE *pbExpo, // in
  DWORD cbExpo, // in
  BYTE *pbMod, // in
  DWORD cbMod, // in
  BYTE *pbResult, // out
  void *pReserved, // reserved
  DWORD dwFlags // in
)
{
        DWORD dwModLen;
        DWORD dwExpoLen;

        DWORD *result;
        DWORD *base;
        DWORD *expo;
        DWORD *mod;
        
        dwModLen = ((cbMod - 1) >> 2) + 1;
        dwExpoLen = ((cbExpo - 1) >> 2) + 1;

        result = (DWORD *) malloc(dwModLen * sizeof(DWORD));
        base = (DWORD *) malloc(dwModLen * sizeof(DWORD));
        expo = (DWORD *) malloc(dwExpoLen * sizeof(DWORD));
        mod = (DWORD *) malloc(dwModLen * sizeof(DWORD));

        memset(result, 0, dwModLen * sizeof(DWORD));
        memset(base, 0, dwModLen * sizeof(DWORD));
        memset(expo, 0, dwExpoLen * sizeof(DWORD));
        memset(mod, 0, dwModLen * sizeof(DWORD));
                
        memcpy(base, pbBase, cbMod);
        memcpy(expo, pbExpo, cbExpo);
        memcpy(mod, pbMod, cbMod);

        NN_ModExp(result, base, expo, dwExpoLen, mod, dwModLen);
        memcpy(pbResult, result, cbMod);
        
        return TRUE;
}
///////////////

NN_ModExp() is from RSAREF
lib(http://www.mirrors.wiretapped.net/security/cryptography/libraries/math/rsaref/rsaref-2.0-1996.tar.gz)

It's 'big number' params are DWORD array, while MS is BYTE array.
So I do a convert here. NN_ModExp computes: result = base ^ expo % mod.

Thanks you very much.

-- 
John
"lelteto" wrote:


Relevant Pages

  • lineGetCallInfo CallerID
    ... with the LINECALLINFO i get the offset of a DWORD array of size x. ... HCALL *hCalls; ... LINECALLINFO *lpCallInfo; ...
    (microsoft.public.win32.programmer.tapi)
  • Re: Question about OffloadModExpo() Function
    ... It seems to me that you're interpreting the length values as the DWORD count ... It might be helpful if you were to create a private key whose structure you ... > memcpy(base, pbBase, cbMod); ... > It's 'big number' params are DWORD array, ...
    (microsoft.public.platformsdk.security)