Re: Question about OffloadModExpo() Function
From: John Banes (jabanes_at_comcast.remove.net)
Date: 10/27/05
- Previous message: Alun Jones: "Re: CertSetContextProperty/CERT_KEY_PROV_INFO_PROP_ID"
- In reply to: john: "RE: Question about OffloadModExpo() Function"
- Next in thread: john: "Re: Question about OffloadModExpo() Function"
- Reply: john: "Re: Question about OffloadModExpo() Function"
- Reply: john: "Re: Question about OffloadModExpo() Function"
- Reply: john: "Re: Question about OffloadModExpo() Function"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
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:
>
>
- Previous message: Alun Jones: "Re: CertSetContextProperty/CERT_KEY_PROV_INFO_PROP_ID"
- In reply to: john: "RE: Question about OffloadModExpo() Function"
- Next in thread: john: "Re: Question about OffloadModExpo() Function"
- Reply: john: "Re: Question about OffloadModExpo() Function"
- Reply: john: "Re: Question about OffloadModExpo() Function"
- Reply: john: "Re: Question about OffloadModExpo() Function"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|