Bonjour,
j'utilise evC++ pour developper sur pocket PC.
Je dois signer un message avec une clé privée.

Voici un bout de mon code
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
 
// signature.cpp : Defines the entry point for the application.
//
 
#include "stdafx.h"
#include "afx.h"
#include <stdio.h>
#include <windows.h>
#include <Wincrypt.h>
// Link with the Crypt32.lib file.
#pragma comment (lib, "Crypt32.lib")
#define MY_TYPE  (PKCS_7_ASN_ENCODING | X509_ASN_ENCODING)
 
 
#define SIGNER_NAME  L"SM"
 
//-------------------------------------------------------------------
//    Define the name of the store where the needed certificate
//    can be found. 
 
#define CERT_STORE_NAME  L"CTM"
 
 
...
 
 
//-------------------------------------------------------------------
// Initialize the signature structure.
 
SigParams.cbSize = sizeof(CRYPT_SIGN_MESSAGE_PARA);
SigParams.dwMsgEncodingType = MY_TYPE;
SigParams.pSigningCert = pSignerCert;
SigParams.HashAlgorithm.pszObjId = szOID_RSA_MD5;
SigParams.HashAlgorithm.Parameters.cbData = NULL;
SigParams.cMsgCert = 1;
SigParams.rgpMsgCert = &pSignerCert;
SigParams.cAuthAttr = 0;
SigParams.dwInnerContentType = 0;
SigParams.cMsgCrl = 0;
SigParams.cUnauthAttr = 0;
SigParams.dwFlags = 0;
SigParams.pvHashAuxInfo = NULL;
SigParams.rgAuthAttr = NULL;
 
//-------------------------------------------------------------------
// With two calls to CryptSignMessage, sign the message.
// First, get the size of the output signed BLOB.
 
if(CryptSignMessage(
    &SigParams,            // Signature parameters
    FALSE,                 // Not detached
    1,                     // Number of messages
    MessageArray,          // Messages to be signed
    MessageSizeArray,      // Size of messages
    NULL,                  // Buffer for signed message
    &cbSignedMessageBlob)) // Size of buffer
{
    printf("The size of the BLOB is %d.\n",cbSignedMessageBlob);
}
else
{
    MyHandleError("Getting signed BLOB size failed");
}
 
//-------------------------------------------------------------------
// Allocate memory for the signed BLOB.
 
if(!(pbSignedMessageBlob = 
   (BYTE*)malloc(cbSignedMessageBlob)))
{
    MyHandleError("Memory allocation error while signing.");
}
 
//-------------------------------------------------------------------
// Get the SignedMessageBlob.
 
if(CryptSignMessage(
      &SigParams,            // Signature parameters
      FALSE,                 // Not detached
      1,                     // Number of messages
      MessageArray,          // Messages to be signed
      MessageSizeArray,      // Size of messages
      pbSignedMessageBlob,   // Buffer for signed message
      &cbSignedMessageBlob)) // Size of buffer
{
    printf("The message was signed successfully. \n");
}
else
{
    MyHandleError("Error getting signed BLOB");
}
 
...
J'ai trouver le code sur le msdn mais j'ai des fonctions qui ne sont pas reconnu
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
error LNK2019: unresolved external symbol __imp__CryptVerifyMessageSignature referenced in function _WinMain
error LNK2019: unresolved external symbol __imp__CryptSignMessage referenced in function _WinMain
Quelqu'un sait il comment faire soit pour pouvoir utiliser ces methodes soit pour faire cela d'une autre maniere?
Merci beaucoup pour votre aide.
Je suis vraiment bloque, pour faire cette signature par une cle privée sur pocket PC,
please help.