#172 CryptoAPI needs new functions

closed-fixed
Danny Smith
2002-08-13
2002-08-12
Mark Schreiber
No

Mingw 1.1:

I see link errors when attempting to link an
application using CryptDuplicateHash() and
CryptDuplicateKey(). There are relatively new
functions, introduced only in Windows 98 and Windows
2000, and younger than most of the rest of CryptoAPI.
They are not declared in mingw 1.1's wincrypt.h.

bar.o: In function 'foo':
bar.c:749: undefined reference to `CryptDuplicateHash@16'
bar.o: In function `foo':
bar.c:779: undefined reference to `CryptDuplicateKey@16'

Discussion

  • Danny Smith
    Danny Smith
    2002-08-12

    • assigned_to: earnie --> dannysmith
     
  • Danny Smith
    Danny Smith
    2002-08-12

    Logged In: YES
    user_id=11494

    Thanks for the report. I'll add the declarations to
    wincrypt.h.

    However, the functions are exported from advapi32.dll
    so you need to -ladvapi32 (the stubs are already there).

    Danny

     
  • Mark Schreiber
    Mark Schreiber
    2002-08-13

    Logged In: YES
    user_id=353210

    Hmm. Odd. If -ladvapi32 is all that's needed, shouldn't
    this work?

    #include <windows.h>
    #include <wincrypt.h>

    int main (void)
    {
    CryptGetUserKey(0, 0, 0);
    CryptDuplicateKey(0, 0, 0, 0);
    return 1;
    }

    ---
    gcc test.c -Wall -ladvapi32
    ---

    test.c: In function `main':
    test.c:7: warning: implicit declaration of function
    `CryptDuplicateKey'
    C:\DOCUME~1\ADMINI~1\DOCUME~1\Temp\ccGabaaa.o(.text+0x25):test.c:
    undefined reference to `CryptDuplicateKey'

    There is no error regarding CryptGetUserKey() -- just
    CryptDuplicateKey().

     
  • Danny Smith
    Danny Smith
    2002-08-13

    • status: open --> closed-fixed
     
  • Danny Smith
    Danny Smith
    2002-08-13

    Logged In: YES
    user_id=11494

    No. An implicit decalaration is not good enough. These
    are __stdcall functions and you need to tell the
    compiler that, else you'll run into stack problems.
    The __stdcall decorations are there to protect against
    such a mismatch.

    As I indicated earlier I have added those two functions
    to wincrypt.h
    Danny