Urgent: VC++ Component with OPenSSL

2002-07-30 Thread Chuo HUANG(CMS)

Hello! 
Did you use OpenSSL in a VC++ Component before?
I am developing an ATL component with VC++ in windows 2000 environment but
encountered the problem . I am not sure if I can use OpenSSL function in a
component. For example:

pkey = PEM_read_PrivateKey(fp12, NULL,NULL, NULL);??

Pls give me some help.

Zoe

Details::
Hello!
I am developing an ATL component with VC++ in windows 2000 environment.
Actually, I'd like to use this component in a web server.
When Client wants to connect to the Server, Client downloads this
component---OutCtl from Server.
The task of the component OutCtl is:
1. Read private key of the client ( in a special place  of client machine:
key.pem)
2. Do the digital signature   

I set one property of the component as Signature.
Then I'd like to pass this property to Client side by VBScript or JavaScript. 
I will use that property later.
 The function using OpenSSL in my component mainly as the following:
#include openssl/rsa.h
#include openssl/evp.h
#include openssl/objects.h
#include openssl/x509.h
#include openssl/err.h
#include openssl/pem.h
#include openssl/ssl.h
#include string.h

void COutCtl: : DoSignature( )
{
  int err;
  int sig_len;
  unsigned char sig_buf [4096];
static char keyfile[]  = D:\key.pem;
  static char data[] = I owe you...;
   EVP_MD_CTX md_ctx;
  EVP_PKEY *  pkey;
  FILE *fp12;

  /* Just load the crypto library error strings,
   * SSL_load_error_strings() loads the crypto AND the SSL ones */
  /* SSL_load_error_strings();*/
  ERR_load_crypto_strings();
  
   OpenSSL_add_all_algorithms();
   
  /* Read private key */
  
  fp12 = fopen (keyfile, r+);
  if (fp12 == NULL) { 
  printf (Can't read private key.\n);
  exit (1);

  }
pkey = PEM_read_PrivateKey(fp12, NULL,NULL, NULL);
fclose (fp12);
 
if (pkey == NULL) { 
ERR_print_errors_fp (stderr);
exit (1);
  }
  
  /* Do the signature */
  
  EVP_SignInit   (md_ctx, EVP_sha1());
  EVP_SignUpdate (md_ctx, data, strlen(data));
  sig_len = sizeof(sig_buf);
  err = EVP_SignFinal (md_ctx, sig_buf, sig_len, pkey);

  if (err != 1) {
ERR_print_errors_fp(stderr);
exit (1);
  }
// m_bstrSignature will be passed to the property Signature
m_bstrSignature= (CComBSTR) sig_buf;


  EVP_PKEY_free (pkey);

}


STDMETHODIMP COutCtl::get_Signature (BSTR *pval)
{

*pval= m_bstrSignature;
return S_OK;

} 

Then in a test page OutCtl.html:

html
head
titleATL 3.0 test pages for object OutCtl/title
/head
body
OBJECT ID =OutCtl  CLASSID=CLSID: 48933cd2_etc..
script Language =VBScript
document.write (Hello!!   OutCtl.Signature)
/script 

/body/html

The component OutCtl passed when building Dll .
When I test another property (a string for testing purpose), The test page
OutCtl.html works. But It loaded extremely slowly when I added the funtion void
COutCtl: : DoSignature( ) in my component. There is no error appeared. Only IE
stopped there when open OutCtl.html. I tried to debug step by step. At last I
found the problem appeared when the first statement needing OpenSSL being used:
key = PEM_read_PrivateKey(fp12, NULL,NULL, NULL);

Actually, I have used the same function of void COutCtl: : DoSignature( )  in a
VC++ Application ( not a ATL Component), And the whole application is OK. I can
print out the Signature. 
But Can't I work with Open SSL in a Component? By the way, I have found all the
.h files of OpenSSL in my External Dependencies , such as evp.h, sha.h,
pem.h...Etc. I have set Debug Multithreaded DLL in project setting.

Is there anyone using OPenSSL in a component before? 
I do appreciate if you can give me any information about my problem.

Thank you!

Zoe

__
OpenSSL Project http://www.openssl.org
User Support Mailing List[EMAIL PROTECTED]
Automated List Manager   [EMAIL PROTECTED]



OpenSSL and Web pages

2002-07-30 Thread Chuo HUANG(CMS)

Hello! 

I have programmed succefully a piece of VC++ with OpenSSL. The program is to
read the private key in a client's machine and do the signature. I'd like to
set cookies using this Signature to Client's machine later. 

What makes me confused is how to combine my VC++ program with web page, for
example: a php file or a cold fusion file?  I tried to make a .dll file using
most of my successful win32 application I talked before.And I set a property of
that DLL as Signature. The Dll was built succefully but the IE stopped when I
using this DLL in a html file.  It stopped in the statement using the first
OPenSSL: pkey = PEM_read_PrivateKey(fp12, NULL,NULL, NULL);

Do you have any idea about how can I combine my VC++ program with web page?
Many thanks,

Zoe

__
OpenSSL Project http://www.openssl.org
User Support Mailing List[EMAIL PROTECTED]
Automated List Manager   [EMAIL PROTECTED]



nmake problem on win2000

2002-04-25 Thread Chuo HUANG(CMS)

Hello!I encountered a problem (might be a silly one you think) when I install
0.9.6c. 
 My system is windows 2000, ActivePerl-5.6.1.631-MSWin32-x86.msi, and MSVC++ 6. 
 Please see below. 
C:\cd D:\openssl-engine-0.9.6c
D:\openssl-engine-0.9.6cperl Configure VC-WIN32 
D:\openssl-engine-0.9.6cms\do-nasm
(I installed nasm. )
D:\openssl-engine-0.9.6cnmake -f ms\ntdll.mak
It compiled for a long time then displayed:


rypto\engine\hw_aep.c
hw_aep.c
.\crypto\engine\hw_aep.c(61): fatal error C1083: Cannot open include file:
'unistd.h': No such file or directory
NMAKE: fatal error  U1077: 'cl': return code '0x2'
stop

Then I searched in my computer and found there is a unistd.h under
C:\Perl\Site\Tk\pTk\compat\.

Could you help me to find what wrong is?
Many thanks to you.
Special thanks to the owner of [EMAIL PROTECTED] 

Zoe


__
OpenSSL Project http://www.openssl.org
User Support Mailing List[EMAIL PROTECTED]
Automated List Manager   [EMAIL PROTECTED]



Help---Install problem

2002-04-23 Thread Chuo HUANG(CMS)

Hello!

I encountered a problem (might be a silly one you think) when I install 0.9.6c. 
 My system is windows 2000, ActivePerl-5.6.1.631-MSWin32-x86, and MSVC++ 6. 
 Please see below. 

C:\cd C:\openssl-engine-0.9.6c
 C:\openssl-engine-0.9.6cperl Configure VC-WIN32 

'perl' is not recongnized as an internal or external command, operable program
or batch file.

It seems that I did not install Perl. However, I have downloaded activeperl.
THen I unzip the ActivePer-5.6.1.631-MSWin32-x86 into a folder  which I named
'Perlinstall'.  I found a folder 'ActivePerl' and a MS-DOS Batch file
'installer' under it. So I ran installer  by default and C:\Perl appeared
later. Then I tried C:\Perl\bin Perl eg\example.pl
It returned : Hello from ActivePerl!  Seems everything OK. But...
What need I to do??

Thank you very much for any suggestion. I need to use OpenSSL urgently.

Zoe
 

__
OpenSSL Project http://www.openssl.org
User Support Mailing List[EMAIL PROTECTED]
Automated List Manager   [EMAIL PROTECTED]