Re: windows programming cryptography(problem in implementing a Sma
- From: lelteto <lelteto@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 27 Jan 2009 20:10:01 -0800
Normally your smart card should have on-board key pair generation, so that's
what you should use. (I am not familiar with the smart card API, but you
should use it to call the card's key gen.) This is especially important as
you indicated you want to use the card for SIGNING - in which case the
private key should NEVER be outside of the card => generated on-card and sign
on-card.
Laszlo Elteto
SafeNet, Inc.
"creative22" wrote:
Hello and Thanks of your help!.
I want to implement “CPGenKey” function in CSP code,
I made a dialog(MFC based) with a button named “CPGenKey” that if a user
pushes it, in it’s related MFC function, “CPGenKey” function of
csp.c(csp.dll)to be called.
It is as below:
CPGenKey(&hCryptProv,AT_SIGNATURE, RSA1024BIT_KEY,&hKey);
I want to use RSA algorithm code to generate keys for signing!
And I should use “Crypto++” library codes for this purpose,the Crypto++ code
can be seen and downloaded at links below:
1)
http://www.koders.com/cpp/fid87D28AE3955B03B9F2EDA3A57C085E3FA0658191.aspx?s=cryptopp.cpp
2)
http://sourceforge.net/project/showfiles.php?group_id=6152
First,I should include it’s header file in CSP code as below:
#include "cryptopp.h"
Then I should use necessary functions in it, about generate key!
Now my question?
1-Which codes of Crypto++.c,I should use to generate RSA signature key pair
and how should I apply them? (I want to use RSA 1024-bit)
2-What variable would be assigned to “*phKey” or what would replace “NULL”
in this cammand:
*phKey = (HCRYPTKEY)NULL;
I know my questions are rudiment, but I have not any experience in
implementing these functions!
Please help me with sample code or any help,I have not much time!!!
Thank you in Advance.
"Kalle Olavi Niemitalo" wrote:
creative22 <creative22@xxxxxxxxxxxxxxxxxxxxxxxxx> writes:
The functions listed above, should call WinSCard.dll functions for
interacting with Smart Card!
Now, I don't know how to implemet CPAcquirecontext function in CSP in order
to acquire a context handle to a cryptographic service provider (CSP)!
CSP Architectural Overview (Windows)
http://msdn.microsoft.com/en-us/library/aa381482(VS.85).aspx
says the handles are opaque, and the application does not use
the same handles as your CSP.
So, I guess your CSP can define some struct
YOUR_SMART_CARD_CSP_CONTEXT that contains the SCARDHANDLE and
whatever else you need. Then, your CPAcquireContext function can
allocate a piece of memory with e.g. HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY, sizeof(struct YOUR_SMART_CARD_CSP_CONTEXT)),
save any required information to that, cast the address of the
memory to HCRYPTPROV, and save it to *phProv.
CryptAcquireContext in Windows would then construct another
HCRYPTPROV and remember that it refers to your CSP and to the
HCRYPTPROV that your CPAcquireContext provided. I don't see how
else the documentation could be interpreted. Especially the word
"opaque" indicates to me that CryptoAPI merely saves the
HCRYPTPROV values provided by the CSP and later hands them back,
and never tries to use e.g. DuplicateHandle on them or peek at
any memory they might point to.
- References:
- windows programming cryptography(problem in implementing a Smart C
- From: creative22
- Re: windows programming cryptography(problem in implementing a Smart C
- From: Kalle Olavi Niemitalo
- Re: windows programming cryptography(problem in implementing a Sma
- From: creative22
- windows programming cryptography(problem in implementing a Smart C
- Prev by Date: How to read the registry key from IE addon in vista?
- Next by Date: Re: CryptAcquireContext with CRYPT_NEWKEYSET return Access Denied
- Previous by thread: Re: windows programming cryptography(problem in implementing a Sma
- Next by thread: CryptAcquireContext with CRYPT_NEWKEYSET return Access Denied
- Index(es):