Re: Hash input and output

2008-04-12 Thread Badra
Hi Marek,

I do the following:

static char *login=login;
static char *password=password;
static char *label=label;

const unsigned char *buf=NULL;
strcat(buf, login); strcat(buf, password); strcat(buf, label);

unsigned char *m1[20];
unsigned char *m2[20];

SHA1(buf, strlen(buf), m1); // The output is:
3d79ad220830e96dabd6ae6f9973306df1800906

//the output of the above SHA1 will be used as an input for the SHA1
below, after concatenating it with label

strcat(m1, label);
SHA1(m1, str len(m1), m2);

I don't know why the output of the second SHA1 is not the same when I
run the program several times. But I think the problem is in the m1
storing, but I don't know how to resolve that.

Thanks,
Best regards,

On Fri, Apr 11, 2008 at 12:46 PM,  [EMAIL PROTECTED] wrote:
 Hello,

 [EMAIL PROTECTED] wrote on 04/11/2008 03:51:18 AM:


  Dear all,
 
  I need to call the hash function two times, in which the output of the
  first call is used as an input for the second (result = hash[hash(A
  +B) + C]
 
  The first call is ok, but when I concatenate its output to the C, I
  don't get the expected output.
 
  Did I miss something?
 Expression above looks good, but there is too little information
 of real implementation to say something reasonable.

 Best regards,
 --
 Marek Marcola [EMAIL PROTECTED]

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




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


Hi

2008-04-12 Thread Rodfraga
Hello, I’m from México, we have a .NET Client application, and a Server Java
Application  for Webservices,

We want to implement the SSL protocol, by using the OpenSSL, so

I’m the .NET Developer but honestly I don’t have an idea how to start or
what must I do to implement this libraries using Visual Studio 2005.

I installed Win32 OpenSSL http://www.slproweb.com/products/Win32OpenSSL.html

But now, I don’t know what’s next.

 

Thanks, 

Best regards,

Rod

 



Hi

2008-04-12 Thread Rodfraga
Hello, I’m from México, we have a .NET Client application, and a Server Java
Application  for Webservices,

We want to implement the SSL protocol, by using the OpenSSL, so

I’m the .NET Developer but honestly I don’t have an idea how to start or
what must I do to implement this libraries using Visual Studio 2005.

I installed Win32 OpenSSL http://www.slproweb.com/products/Win32OpenSSL.html

But now, I don’t know what’s next.

 

Thanks, 

Best regards,

Rod

 



Re: Hash input and output

2008-04-12 Thread Marek . Marcola
Hello,

[EMAIL PROTECTED] wrote on 04/11/2008 03:56:45 PM:

 Hi Marek,
 
 I do the following:
 
 static char *login=login;
 static char *password=password;
 static char *label=label;
 
 const unsigned char *buf=NULL;
 strcat(buf, login); strcat(buf, password); strcat(buf, label);
You should allocate space for buf before strcat().
 
 unsigned char *m1[20];
 unsigned char *m2[20];
 
 SHA1(buf, strlen(buf), m1); // The output is:
 3d79ad220830e96dabd6ae6f9973306df1800906
 
 //the output of the above SHA1 will be used as an input for the SHA1
 below, after concatenating it with label
 
 strcat(m1, label);
m1 has binary data, not string.
This data may have embeded 0x00 (look at your output above) and strcat
can not copy data in good place (to bytes before end instead of end of 
md1).
Use memcpy, does not relay of strlen() on such data too.

 SHA1(m1, str len(m1), m2);
 
 I don't know why the output of the second SHA1 is not the same when I
 run the program several times. But I think the problem is in the m1
 storing, but I don't know how to resolve that.

Best regards,
--
Marek Marcola [EMAIL PROTECTED]


Re: Hi

2008-04-12 Thread Jurko Gospodnetić

 Hi Rodfraga.

Hello, I’m from México, we have a .NET Client application, and a Server 
Java Application  for Webservices,


We want to implement the SSL protocol, by using the OpenSSL, so

I’m the .NET Developer but honestly I don’t have an idea how to start or 
what must I do to implement this libraries using Visual Studio 2005.


I installed Win32 OpenSSL http://www.slproweb.com/products/Win32OpenSSL.html

But now, I don’t know what’s next.


  If you really do not want to use the SSL support provided by the .NET 
framework (never used it so do not know its good or bad sides, but I 
know it is there...) you should first set up a simple unmanaged C/C++ 
application that sets up an SSL connection to your server application... 
Use that to get to know OpenSSL and only then add code for using OpenSSL 
from .NET code by doing what is needed to cross the managed/unmanaged 
code boundary...


  Hope this helps...

  Best regards,
Jurko Gospodnetić

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


How to implement compression as a CMS package in 0.9.7e version

2008-04-12 Thread shankar ks
Hi ,

Can Any one knows how to implement compression (zlib ) as a CMS Enveolpe
data in SSL version 0.9.7e( we have resitricted to this version only).



-- 
--Best Regards
Shankar


Can PEM_read_RSAPublicKey() load public key from private key ?

2008-04-12 Thread Th�nh Trung Nguy#7877;n
Hi !

I used PEM_write_RSAPrivateKey() to write private key to a pem file.
Then I used PEM_read_RSAPublicKey() to read public key from that file, but it 
returned an error.
The ERR_error_string() only return message like :
error:0906D06C:lib(9):func(109):reason(108)
So can any one tell me can i use PEM_read_RSAPublicKey() to load public key 
from a private key ?
And are the any way to get human understandable error message ?

Thanks !


trungnt
 __
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Re: Can PEM_read_RSAPublicKey() load public key from private key ?

2008-04-12 Thread shankar ks
Hi Trung,
 The error which u got was you can not read the public key as in the
certificate it is not finding the lines as BEGIN RSA CERTIFICATE
so here i am giving you the code , use it directly , it will work fine as i
refined it many times ... and one more thing is error string funtion will
give you the reason also , so it is human readible message only...



pubk = RSA_new();
if(pubk == NULL)
printf(error to create new RSA structure \n);

fp = fopen (recevercert, r);
if (fp == NULL){
pri ntf(err );
exit (1);
}
x509 = PEM_read_X509(fp, NULL, NULL, NULL);
fclose (fp);


if (x509 == NULL) {
printf(error reading the certificate \n);
ERR_print_errors_fp (stderr);
exit (1);
}

pub=X509_get_pubkey(x509);
if (pub == NULL) {
printf(error reading the public key \n);
ERR_print_errors_fp (stderr);
exit (1);
}

pubk = EVP_PKEY_get1_RSA(pub);


On 4/13/08, Thành Trung Nguy#7877;n [EMAIL PROTECTED] wrote:

 Hi !

 I used PEM_write_RSAPrivateKey() to write private key to a pem file.
 Then I used PEM_read_RSAPublicKey() to read public key from that file, but
 it returned an error.
 The ERR_error_string() only return message like :
 error:0906D06C:lib(9):func(109):reason(108)
 So can any one tell me can i use PEM_read_RSAPublicKey() to load public
 key from a private key ?
 And are the any way to get human understandable error message ?

 Thanks !


 trungnt

 __
 Do You Yahoo!?
 Tired of spam? Yahoo! Mail has the best spam protection around
 http://mail.yahoo.com




-- 
--Best Regards
Shankar


Re: Can PEM_read_RSAPublicKey() load public key from private key ?

2008-04-12 Thread Th�nh Trung Nguy#7877;n
Thank you for fast response !

But it's ok if I use PEM_read_RSAPublicKey() to load public key from file save 
by using PEM_write_RSAPublicKey().
And even publickey extract by openssl command doesn't have any line as BEGIN 
RSA CERTIFICATE. It just has line as BEGIN RSA PUBLIC KEY.

I've tried your code, but it can't read public key save by openssl.

So can PEM_read_RSAPublicKey() or PEM_read_RSA_PUBKEY() can load public key 
from a private key ? In my program, I use PEM_write_RSAPublicKey() to store 
public key and use PEM_read_RSAPublicKey() to load it. I just want to know if 
user can use my program to read public key from a private key.

p/s :
I used openssl to extract publickey like this ( I don't know if there is 
another way) :
openssl rsa -in privatekey.pem -out publickey.pem -pubout


shankar ks [EMAIL PROTECTED] wrote: Hi Trung,
  The error which u got was you can not read the public key as in the 
certificate it is not finding the lines as BEGIN RSA CERTIFICATE
 so here i am giving you the code , use it directly , it will work fine as i 
refined it many times ... and one more thing is error string funtion will give 
you the reason also , so it is human readible message only...
   
  
 pubk = RSA_new();
if(pubk == NULL)
printf(error to create new RSA structure \n);
 fp = fopen (recevercert, r);
if (fp == NULL){
pri ntf(err );
exit (1);
}
x509 = PEM_read_X509(fp, NULL, NULL, NULL);
fclose (fp);
  
if (x509 == NULL) {
printf(error reading the certificate \n);
ERR_print_errors_fp (stderr);
exit (1);
}
 pub=X509_get_pubkey(x509);
if (pub == NULL) {
printf(error reading the public key \n);
ERR_print_errors_fp (stderr);
exit (1);
}
 pubk = EVP_PKEY_get1_RSA(pub);




 On 4/13/08, Th�nh Trung Nguy#7877;n [EMAIL PROTECTED] wrote: Hi !

I used PEM_write_RSAPrivateKey() to write private key to a pem file.
Then I used PEM_read_RSAPublicKey() to read public key from that file, but it 
returned an error.
 The ERR_error_string() only return message like :
error:0906D06C:lib(9):func(109):reason(108)
So can any one tell me can i use PEM_read_RSAPublicKey() to load public key 
from a private key ?
And are the any way to get human understandable error message ?
 
Thanks !


trungnt  __
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
 



-- 
--Best Regards
Shankar  


trungnt
 __
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Re: Can PEM_read_RSAPublicKey() load public key from private key ?

2008-04-12 Thread shankar ks
Hi Trung,

One thing I will conform you is  we can not get public key from a private
key . I do not remember where i studied , but it is true.
So do not try to get a public key from private key.
And I have mistakenly typed as BEGIN RSA CERTIFICATE , as you told it is
BEGIN RSA PUBLIC KEY only.

So PEM_read_RSAPublicKey() or PEM_read_RSA_PUBKEY() can be used to load
public key from a private key

The main concept (and also the general concept )in my program ( or any other
programs )is we have to load public key from the certificate only .
In the certificte if the public key does not have header like  BEGIN RSA
PUBLIC KEY , then these functions wont work . so I have used other procedure
to get the RSA public key ..

if you still have doubts , mail me ...

--- Shankar




On 4/13/08, Thành Trung Nguy#7877;n [EMAIL PROTECTED] wrote:

 Thank you for fast response !

 But it's ok if I use PEM_read_RSAPublicKey() to load public key from file
 save by using PEM_write_RSAPublicKey().
 And even publickey extract by openssl command doesn't have any line as
 BEGIN RSA CERTIFICATE. It just has line as BEGIN RSA PUBLIC KEY.

 I've tried your code, but it can't read public key save by openssl.

 So can PEM_read_RSAPublicKey() or PEM_read_RSA_PUBKEY() can load public
 key from a private key ? In my program, I use PEM_write_RSAPublicKey() to
 store public key and use PEM_read_RSAPublicKey() to load it. I just want to
 know if user can use my program to read public key from a private key.

 p/s :
 I used openssl to extract publickey like this ( I don't know if there
 is another way) :
 openssl rsa -in privatekey.pem -out publickey.pem -pubout


 *shankar ks [EMAIL PROTECTED]* wrote:

 Hi Trung,
  The error which u got was you can not read the public key as in the
 certificate it is not finding the lines as BEGIN RSA CERTIFICATE
 so here i am giving you the code , use it directly , it will work fine as
 i refined it many times ... and one more thing is error string funtion will
 give you the reason also , so it is human readible message only...


 pubk = RSA_new();
 if(pubk == NULL)
 printf(error to create new RSA structure \n);
 fp = fopen (recevercert, r);
 if (fp == NULL){
 pri ntf(err );
 exit (1);
 }
 x509 = PEM_read_X509(fp, NULL, NULL, NULL);
 fclose (fp);

 if (x509 == NULL) {
 printf(error reading the certificate \n);
 ERR_print_errors_fp (stderr);
 exit (1);
 }
 pub=X509_get_pubkey(x509);
 if (pub == NULL) {
 printf(error reading the public key \n);
 ERR_print_errors_fp (stderr);
 exit (1);
 }
 pubk = EVP_PKEY_get1_RSA(pub);




 On 4/13/08, Th�nh Trung Nguy#7877;n [EMAIL PROTECTED] wrote:
 
  Hi !
 
  I used PEM_write_RSAPrivateKey() to write private key to a pem file.
  Then I used PEM_read_RSAPublicKey() to read public key from that file,
  but it returned an error.
  The ERR_error_string() only return message like :
  error:0906D06C:lib(9):func(109):reason(108)
  So can any one tell me can i use PEM_read_RSAPublicKey() to load public
  key from a private key ?
  And are the any way to get human understandable error message ?
 
  Thanks !
 
 
  trungnt __
  Do You Yahoo!?
  Tired of spam? Yahoo! Mail has the best spam protection around
  http://mail.yahoo.com
 



 --
 --Best Regards
 Shankar




 trungnt

 __
 Do You Yahoo!?
 Tired of spam? Yahoo! Mail has the best spam protection around
 http://mail.yahoo.com




-- 
--Best Regards
Shankar