|
Hi,
I have a code that generates hash from data stream using following calls:
CryptAcquireContext(&hDummyProv, NULL, NULL, PROV_RSA_FULL, 0)
CryptCreateHash()
CryptHashData()
CryptGetHashParam()
CryptDestroyHash()
I am trying to use the hash blob to generate signed message using following calls:
CertEnumCertificatesInStore
CertGetCertificateContextProperty ()
CryptAcquireContext(
&hProv,
pProvInfoData->pwszContainerName,
pProvInfoData->pwszProvName,
PROV_RSA_FULL,
0)
CryptCreateHash() – get new hash handle this time from CSP
CryptSetHashParam() – update hash handle with message digest prepared earlier
CryptMsgOpenToEncode(
MY_ENCODING_TYPE,
CMSG_DETACHED_FLAG | CMSG_AUTHENTICATED_ATTRIBUTES_FLAG,
CMSG_SIGNED,
&SignedEncodedInfo,
0,
NULL)
Everything works fine until I retrieve the szOID_RSA_messageDigest property to compare with previously generated hash. I get a different value than I set.
Comment: I must use a call to CryptMsgOpenToEncode to generate encrypted message signed by A CSP.
What am I doing wrong?
Thanks for helping me,
Lilach
|
|
|
|
|
Hi Lilach,
Unfortunately you have not provided enough information to conclusively identify the cause of your problem. The only thing that comes to mind is that I dont see your mention of calling CryptMsgUpdate.
With the limited information provided the only thing I can think of is to point you towards an MSDN sample which closely matches your requirements:
Example C Program: Encoding an Enveloped, Signed Message[^]
Best Wishes,
-David Delaune
|
|
|
|
|
Hi David,
I added a call to CryptMsgUpdate() as you suggested. The problem is that when I decode the resulted message, the content contains different message digest. In fact, I think it is the digest of an empty message.
Here is the message digest I got:
DA 39 A3 EE 5E 6B 4B 0D 32 55 BF EF 95 60 18 90 AF D8 07 09
Here is the relevant code:
CMSG_SIGNED_ENCODE_INFO signedEncodedInfo;
HCRYPTPROV hHash = NULL;
// ... here singedEncodedInfo is initiated
// create a hash object.
if (!CryptCreateHash(d_hCryptProv, CALG_SHA1, 0, 0, &hHash))
{
throw( GetLastError());
}
// set hash data to hash handle
// pHashBytes is a pointer to bytes array containing
// hashed data
if (!CryptSetHashParam(hHash, HP_HASHVAL, pHashBytes, 0))
{
throw(GetLastError());
}
// initiate encoded message
d_hMsg = CryptMsgOpenToEncode(MY_ENCODING_TYPE,
CMSG_DETACHED_FLAG | MSG_AUTHENTICATED_ATTRIBUTES_FLAG,
MSG_SIGNED,
&SignedEncodedInfo,
0,
NULL);
if (!CryptMsgUpdate( d_hMsg, NULL, 0, TRUE ))
{
throw(GetLastError());
}
Do you have an idea what is wrong?
Thanks,
Lilach
|
|
|
|
|
What do you mean when you say decode? Are you trying to decode a SHA1 hash back into the original message? SHA1 is a one way hash, it cannot be decoded back into the original message!
Best Wishes,
-David Delaune
|
|
|
|
|
I'm using CSSplitter class to split some controls in a dialog. CSSplitters take two * CWnd arguments for the up and down control window. (or left and right).
It's very easy to do that. But now, I'd like to add some controls in one pane, because only two controls are split for now. The goal is to make a bar with buttons between the controls that would move as the splitter is moved.
A picture would be more eloquent : http://img11.imageshack.us/img11/4145/sanstitre1fgg.jpg (http://img11.imageshack.us/img11/4145/sanstitre1fgg.jpg)
That's what i'd like to do in the best case. (Image from bearshare)
We can drag the splitter and the bar moves as the bottom list is resized.
Have you got any idea on how to do that ?
Any simple solutions ?
Or do you know some other splitter class than CSSplitter that would be able to do it in a dialog ?
I tried Zsplitter on this site, but it doesn't work with visual studio 2008... And is somewhat complex to install. (not to use)
I've been stuck for 2 days trying to solve that ridiculous but very annoying and frustrating problem. For hours I tried tutorials, different classes. But none worked well, because most classes are made for sdi/mdi, most don't allow more than one control per pane, can't be resized... (As my dialog is a CResizingDialog to resize controls automatically, sometimes it works, sometimes i get numerous errors...)
Thanks in advance,
One idea was to make a separate panel that includes controls and attach it when creating the splitter. But it doesn't work too, and i wouldn't be able to access objects any more.
modified on Wednesday, July 15, 2009 1:07 PM
|
|
|
|
|
Is it possible to mount a file (from C/C++) to a folder in Microsoft Windows? Like some virtual CD drive applications mount *.iso (and other formats) files to a virtual drive, but to folder instead of a drive.
If it is, please point me in the right direction (some article for example). I've spent countless hours google'ing for it but found nothing.
Thanks in advance.
|
|
|
|
|
What kind of file do you want to mount? It only makes sense if the file is a container of some sort that has a folder structure inside (ISO, ZIP).
|
|
|
|
|
Yes, I'm working on a project, a part of which is creation of a file format that contains just plain data of files, stored sequentaly, so that such file can be mounted as a directory. 'Container' in other words. ISO, ZIP etc are good examples.
|
|
|
|
|
Assuming you're using an NTFS filesystem, I think reparse points[^] sound like they could fit the bill?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Well, this looks like a solution, but a bit complicated (only for me? ) Anyway, many thanks for the reply.
|
|
|
|
|
gospel567 wrote: Well, this looks like a solution, but a bit complicated
Stuart gave you some excellent advice. Have a look at the Microsoft MSDN sample code:
Creating a Mounted Folder[^]
Hopefully viewing code samples will shed some light on this mysterious function and reduce the percieved complexity level.
Best Wishes,
-David Delaune
|
|
|
|
|
You could use CreateHardLink[^] to create a link to a file in another folder.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Sounds to me like you want to create a Shell Extenstion.
It's not easy. You need to implement a wide variety of interfaces.
Look up Shell Extensions, and you'll see that it does what you want.
|
|
|
|
|
Hello,
I am developing a small application that reads remote machine's username by reading "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon" key. Even when I logoff remote machine, I still get the same username. I want to ask are my following assumptions correct:
1) This registry key stores the last logged on username.
2) Its value changes when another user logs into the system.
|
|
|
|
|
hackcrackvirus wrote: I want to ask are my following assumptions correct:
1) This registry key stores the last logged on username.
The DefaultUserName value stores the name of the last user to log on to a computer.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Hi,
I am working on a C++ project, in this I have to change the access of a temporary drive to read only or readwrite. I have code to find the temporary drive but the problem is to change the access properties (Read only, Read Write, Locked etc something like this).
If anyone have any idea to solve this please reply me.
Thanks in advance
|
|
|
|
|
ACLs[^]? Disks are objects, you can set ACLs on them, I believe.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
basically i need to change access of the usb device driver to read only
i want to know which api i need to use to make the usb device drive read only
i am using vc++ and visual studio 2005
i didn't understand how the ACL will help here
|
|
|
|
|
If you need to do something with the device driver, then you probably need an appropriate IOCTL[^]
Or maybe this article[^] is of relevance?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
that article explains the procedure for changing access through registry keys. it will fails if we have more than one usb device plugged in to the machine.
i want to use win32 api to change the access of usb device driver through vc++ application.
can you please explain me how can modify the acl of the volume stack of the usb device to make it read only
or is there any setupDi... function which makes a usb driver to read only
|
|
|
|
|
What you want is not achieved by adjusting the USB driver.
Stuart is right. You need to learn how to use ACL's if you want to control access to the files and folders on the USB drive.
|
|
|
|
|
Nekkantidivya wrote: i didn't understand how the ACL will help here
Since you are wanting to control access to the device, an Access Control List/Entry will help.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Iam trying to hook to a window.This window has tab controle in it.In one the page ,ocx is placed.This ocx opens word document using automation.
I want to hook to this word document.Iam getting parent window,then enumerating all child windows till I get the word document.Then, hook to it.Now i want to get cursor position in it.Not able to get proper cursor position.
Please help to get cursor position in child window.
Also Not able to set word document window as foreground window.
|
|
|
|
|
You can get the current cursor position in screen coordinates using GetCursorPos[^].
You can then convert that to window relative coordinates using ScreenToClient[^].
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Hello,
I want to create a static library using .net 2008 Framework 3.5 and export a function.
In order to call this function from a vc6 enviroment what project type I should use on the .net Enviroment and how should I call this function from vc6 application?
I would appreciate if you could send me a short code of both sides(.net,vc6) Smile
Thanks in advance...
|
|
|
|