Re: Question about OffloadModExpo() Function

From: John Banes (jabanes_at_comcast.remove.net)
Date: 10/27/05

  • Next message: John Banes: "Re: CALG_SSL3_SHAMD5 support for ClientAuthentication"
    Date: Thu, 27 Oct 2005 14:19:58 -0700
    
    

    It seems to me that you're interpreting the length values as the DWORD count
    when in fact they are BYTE counts if I remember correctly. Perhaps this is
    the problem?

    It might be helpful if you were to create a private key whose structure you
    are familiar with and attempt to sign something with it. You can export the
    private key into a PRIVATEKEYBLOB and analyse its structure and compare that
    with the parameters that get passed to the modexp function.

    Signature operations always result in the same result (provided that PKCS1
    is used) because the padding is fixed. This makes things more deterministic
    and it should make it easier to spot any problems. You can switch to decrypt
    operations once signing is working okay.

    Regards,
    John

    "john" <phenerse@hotmail.com> wrote in message
    news:B39B20AE-27A4-4456-A80E-1E576F8DC518@microsoft.com...
    > 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:
    >
    >


  • Next message: John Banes: "Re: CALG_SSL3_SHAMD5 support for ClientAuthentication"

    Relevant Pages

    • RE: Cryptography Help Needed
      ... BOOL WINAPI CryptSignHash( ... // should I provide Private Key handle here???? ... DWORD dwKeySpec, ... >> Is there something wrong with the certificate, ...
      (microsoft.public.platformsdk.security)
    • Re: Question about OffloadModExpo() Function
      ... I test the function with Signature operations. ... "John Banes" wrote: ... > It seems to me that you're interpreting the length values as the DWORD count ... >> memcpy(base, pbBase, cbMod); ...
      (microsoft.public.platformsdk.security)
    • Re: Question about OffloadModExpo() Function
      ... I test the function with Signature operations. ... "John Banes" wrote: ... > It seems to me that you're interpreting the length values as the DWORD count ... >> memcpy(base, pbBase, cbMod); ...
      (microsoft.public.platformsdk.security)
    • Re: Question about OffloadModExpo() Function
      ... I test the function with Signature operations. ... "John Banes" wrote: ... > It seems to me that you're interpreting the length values as the DWORD count ... >> memcpy(base, pbBase, cbMod); ...
      (microsoft.public.platformsdk.security)
    • 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)