[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now


MS CryptoAPI

Posted on 2000-03-27
Medium Priority
Last Modified: 2011-04-14
can someone please deminstrate how to use the function "CryptSignMessage" in visual basic. An example in C can be found at http://msdn.microsoft.com/library/psdk/crypto/usingcrypto_7rvp.htm

Question by:majestic
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 2662663
Here is a sample I got from a friend.  Only clue as to the author is "black dog"  *shrug*

Enjoy!  :)



Expert Comment

ID: 2662664
oops!  I suppose the filename would help:


Author Comment

ID: 2662759
it seems to be a clearly written program but it does not use the CryptSignMessage function that i'm looking for.  Thanks any way.
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 28

Accepted Solution

AzraSound earned 200 total points
ID: 2662969
i cannot find documentation on it in VB either.  You may consider using several functions to achieve the effect of the CryptSignMessage function however from the functions listed here:

Expert Comment

ID: 2663023
See Also
  Windows NT/2000: Requires Windows NT 4.0 SP3 or later (or Windows NT 4.0 with Internet Explorer 3.02 or later).
  Windows 95/98: Requires Windows 98 (or Windows 95 with Internet Explorer 3.02 or later).
  Header: Declared in wincrypt.h.
  Import Library: Use crypt32.lib.
  Platform SDK: Cryptography
The CryptSignMessage function creates a hash of the specified content, signs the hash, and then encodes both the original message content and the signed hash.

BOOL WINAPI CryptSignMessage(
  BOOL fDetachedSignature,            // in
  DWORD cToBeSigned,                  // in
  const BYTE *rgpbToBeSigned[ ],      // in
  DWORD rgcbToBeSigned[ ],            // in
  BYTE *pbSignedBlob,                 // out
  DWORD *pcbSignedBlob                // in/out
Pointer to CRYPT_SIGN_MESSAGE_PARA structure containing the signature parameters.
TRUE if this is to be a detached signature. Otherwise it is set to FALSE. If this parameter is set to TRUE, only the signed hash is encoded in pbSignedBlob. Otherwise, both rgpbToBeSigned and the signed hash are encoded.
Count of the number of array elements in rgpbToBeSigned and rgcbToBeSigned. This parameter must be set to one unless fDetachedSignature is set to TRUE.
Array of pointers to buffers that contain the contents to be signed.
Array of sizes, in bytes, of the content buffers pointed to in rgpbToBeSigned.
Pointer to a buffer to receive the encoded signed hash, if fDetachedSignature is TRUE, or to both the encoded content and signed hash if fDetachedSignature is FALSE.
This parameter can be NULL to set the size of this information for memory allocation purposes. See Retrieving Data of Unknown Length.

Pointer to a DWORD specifying the size, in bytes, of the pbSignedBlob buffer. When the function returns, this variable contains the size, in bytes, of the signed and encoded message.
Note  When processing the data returned, applications must use the actual size of the data returned. The actual size can be slightly smaller than the size of the buffer specified on input. (On input, buffer sizes are usually specified large enough to ensure that the largest possible output data will fit in the buffer.) On output, the variable pointed to by this parameter is updated to reflect the actual size of the data copied to the buffer.

Return Values
If the function succeeds, the return value is nonzero (TRUE).

If the function fails, the return value is zero (FALSE). For extended error information, call GetLastError.

Note  Errors from the called functions CryptCreateHash, CryptHashData, and CryptSignHash might be propagated to this function.

This function has the following error codes.

Error code Description
ERROR_MORE_DATA  If the buffer specified by the pbSignedBlob parameter is not large enough to hold the returned data, the function sets the ERROR_MORE_DATA code, and stores the required buffer size, in bytes, into the variable pointed to by pcbSignedBlob.
E_INVALIDARG  Invalid message encoding type. Currently only PKCS_7_ASN_ENCODING is supported. Invalid cbSize in *pSignPara.
KEY_PROPERTY  The pSigningCert in *pSignPara does not have a CERT_KEY_PROV_INFO_PROP_ID or CERT_KEY_CONTEXT_PROP_ID property.
OSS_ERROR  Message ASN.1 encoding error. Note, to get the OSS error subtract CRYPT_E_OSS_ERROR from the returned error and see Asn1code.h for details on the error.

See Example C Program: Using CryptSignMessage.

  Windows NT/2000: Requires Windows NT 4.0 SP3 or later (or Windows NT 4.0 with Internet Explorer 3.02 or later).
  Windows 95/98: Requires Windows 98 (or Windows 95 with Internet Explorer 3.02 or later).
  Header: Declared in wincrypt.h.
  Import Library: Use crypt32.lib.

See Also

Built on Wednesday, May 12, 1999

Author Comment

ID: 2671733
I found the answer to my question on another link on this site.




Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question