Solved

MS CryptoAPI

Posted on 2000-03-27
6
579 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
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…

744 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now