Solved

MS CryptoAPI

Posted on 2000-03-27
6
589 Views
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


0
Comment
Question by:majestic
[X]
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
6 Comments
 
LVL 3

Expert Comment

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

Enjoy!  :)

Paul

http://www.syix.com/wpsjr1/index.html
0
 
LVL 3

Expert Comment

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

http://www.syix.com/wpsjr1/crypt.zip
0
 

Author Comment

by:majestic
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.
0
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
LVL 28

Accepted Solution

by:
AzraSound earned 100 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:
http://members.xoom.com/_XMCM/allapi/api/grpCrypto.htm
0
 
LVL 6

Expert Comment

by:VBGuru
ID: 2663023
See Also
CryptSignAndEncryptMessage
Requirements
  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
 
CryptSignMessage
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(
  PCRYPT_SIGN_MESSAGE_PARA pSignPara, // in
  BOOL fDetachedSignature,            // in
  DWORD cToBeSigned,                  // in
  const BYTE *rgpbToBeSigned[ ],      // in
  DWORD rgcbToBeSigned[ ],            // in
  BYTE *pbSignedBlob,                 // out
  DWORD *pcbSignedBlob                // in/out
Parameters
pSignPara
Pointer to CRYPT_SIGN_MESSAGE_PARA structure containing the signature parameters.
fDetachedSignature
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.
cToBeSigned
Count of the number of array elements in rgpbToBeSigned and rgcbToBeSigned. This parameter must be set to one unless fDetachedSignature is set to TRUE.
rgpbToBeSigned
Array of pointers to buffers that contain the contents to be signed.
rgcbToBeSigned
Array of sizes, in bytes, of the content buffers pointed to in rgpbToBeSigned.
pbSignedBlob
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.

pcbSignedBlob
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.
CRYPT_E_NO_
KEY_PROPERTY  The pSigningCert in *pSignPara does not have a CERT_KEY_PROV_INFO_PROP_ID or CERT_KEY_CONTEXT_PROP_ID property.
CRYPT_E_
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.


Examples
See Example C Program: Using CryptSignMessage.

Requirements
  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
CryptSignAndEncryptMessage

Built on Wednesday, May 12, 1999
0
 

Author Comment

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

thanks

http://kpdteam.hypermart.net/download/crypto.zip

0

Featured Post

Independent Software Vendors: 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!

Question has a verified solution.

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

Suggested Solutions

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

726 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