Re: CryptEncrypt fails on pocket pc (c#)

From: Pieter Philippaerts (Pieter_at_nospam.mentalis.org)
Date: 10/26/03


Date: Sun, 26 Oct 2003 01:57:17 +0200


"Anatoly" <wiretransfers@yahoo.com> wrote in message
> I am testing out some encryption on pocket pc with C#.net, (see below
code)
> it executes through Generating the key, but fails when trying to actually
> encrypt data with it.

Your definition of CryptEncrypt is wrong. Try this:

[DllImport(CryptDll)]
public static extern bool CryptEncrypt(IntPtr hKey, IntPtr hHash, int Final,
uint dwFlags, byte[] pbData, ref uint pdwDataLen, uint dwBufLen);

There's a difference between 'bool' and 'BOOL' in C. Like in C#, bool is a
1-byte variable and BOOL is a 4-byte variable. The CryptEncrypt uses the
4-byte type and you declared it as a 1-byte type. This corrupts the
parameters on the stack, and hence the error.

Regards,
Pieter Philippaerts
Managed SSL/TLS: http://www.mentalis.org/go.php?sl



Relevant Pages

  • Re: CryptEncrypt fails on pocketpc
    ... > I am testing out some encryption on pocket pc with C#.net, ... Your definition of CryptEncrypt is wrong. ... uint dwFlags, bytepbData, ref uint pdwDataLen, uint dwBufLen); ... There's a difference between 'bool' and 'BOOL' in C. ...
    (microsoft.public.platformsdk.security)
  • Re: Wie programmiert man den Systray?
    ... CSystemTray::CSystemTray(HINSTANCE hInst, HWND hWnd, UINT uCallbackMessage, ... BOOL CSystemTray::RemoveIcon ... // variables in TimerFuncvia a reinterpret_cast in the static CALLBACK ...
    (microsoft.public.de.vc)
  • Thread base class
    ... tasks of thread creation so that all the derived class has to do ... static UINT StaticEntryPoint(LPVOID lParam) ... BOOL IsThreadRunning() ...
    (microsoft.public.vc.mfc)
  • _fcloseall () conflicts with DirectMusic 8.1
    ... MusicManager::SetBGMusic (LPCTSTR *ppFile, UINT nFile, UINT uVol, UINT ... uChangeTime, BOOL bFade) ... MusicManager::CreateSegmentFromFile (Music **ppMusic, LPCTSTR szFile, BOOL ... DXUtil_ConvertGenericStringToWide (wszFile, szFile); ...
    (microsoft.public.win32.programmer.directx.audio)
  • Re: CryptUIDlgViewCertificate: hows the signature?
    ... Gabriele ... > public static extern bool CryptUIDlgViewCertificate( ... > public uint dwFlags; ... > public IntPtr rgszPurposes; ...
    (microsoft.public.platformsdk.security)