Re: Problem to compile static void *KDF1_SHA1

2006-12-22 Thread shakal
yeah, I've tried before and It hasn't worked. And now, I did it again
using g++ command instead gcc and it worked.
Thank you!
Shakal
 [EMAIL PROTECTED] wrote:
 Hi all,

 I've created a method to generate ECDH Key, based on ecdhtest.c,
 available
 at /openssl/test directory.
 But I'm facing some trouble to compile it.
 I've inserted the following code in the begining of the file, acording
 ecdhtest.c,
 static const int KDF1_SHA1_len = 20;
 static void *KDF1_SHA1(const void *in, size_t inlen, void *out, size_t
 *outlen)
 {
 #ifndef OPENSSL_NO_SHA
 if (*outlen  SHA_DIGEST_LENGTH)
  return NULL;
 else
  *outlen = SHA_DIGEST_LENGTH;
 return SHA1(in, inlen, out);
 #else
 return NULL;
 #endif
 }
 in order to use the ECDH method:
 out=ECDH_compute_key(buf,len,EC_KEY_get0_public_key(public_key),ec_key,KDF1_SHA1);
 When I compile it, the following messages appear.
 aodv/aodv.cc: In function ‘void* KDF1_SHA1(const void*, size_t,
 void*,
 size_t*)’:
 aodv/aodv.cc:52: error: invalid conversion from ‘const void*’ to
 ‘const
 unsigned char*’
 aodv/aodv.cc:52: error:   initializing argument 1 of ‘unsigned char*
 SHA1(const unsigned char*, size_t, unsigned char*)’
 aodv/aodv.cc:52: error: invalid conversion from ‘void*’ to
 ‘unsigned char*’
 aodv/aodv.cc:52: error:   initializing argument 3 of ‘unsigned char*
 SHA1(const unsigned char*, size_t, unsigned char*)

 I've already looked for the SHA1 constructor, and I don't know what is
 going wrong.

 Has anybody already faced this problem?
 if not, could you give me some tips in order to solve this problem?

 it looks like your compiler doesn't like the implicit conversion
 from const void * to const unsigned char * ... Did you try to
 use a cast ?

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



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


Problem to compile static void *KDF1_SHA1

2006-12-21 Thread shakal
Hi all,

I've created a method to generate ECDH Key, based on ecdhtest.c, available
at /openssl/test directory.
But I'm facing some trouble to compile it.
I've inserted the following code in the begining of the file, acording
ecdhtest.c,
static const int KDF1_SHA1_len = 20;
static void *KDF1_SHA1(const void *in, size_t inlen, void *out, size_t
*outlen)
{
#ifndef OPENSSL_NO_SHA
 if (*outlen  SHA_DIGEST_LENGTH)
  return NULL;
 else
  *outlen = SHA_DIGEST_LENGTH;
 return SHA1(in, inlen, out);
#else
 return NULL;
#endif
}
in order to use the ECDH method:
out=ECDH_compute_key(buf,len,EC_KEY_get0_public_key(public_key),ec_key,KDF1_SHA1);
When I compile it, the following messages appear.
aodv/aodv.cc: In function ‘void* KDF1_SHA1(const void*, size_t, void*,
size_t*)’:
aodv/aodv.cc:52: error: invalid conversion from ‘const void*’ to ‘const
unsigned char*’
aodv/aodv.cc:52: error:   initializing argument 1 of ‘unsigned char*
SHA1(const unsigned char*, size_t, unsigned char*)’
aodv/aodv.cc:52: error: invalid conversion from ‘void*’ to ‘unsigned char*’
aodv/aodv.cc:52: error:   initializing argument 3 of ‘unsigned char*
SHA1(const unsigned char*, size_t, unsigned char*)

I've already looked for the SHA1 constructor, and I don't know what is
going wrong.

Has anybody already faced this problem?
if not, could you give me some tips in order to solve this problem?

Thanks.
Alexandre Gava Menezes
NPD/UFSC

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


how to use the shared key through ECDH_compute_key method

2006-12-15 Thread shakal
Hi all,
I'm a new user trying to use the EC_DH benefits on key sharing.
But I'm having some problems to understand how it works...
First, in(ecdhtest.c),
aout=ECDH_compute_key(abuf,alen,EC_KEY_get0_public_key(b),a,KDF1_SHA1);
it generates the following key in both sides Alice and Bob
key Alice = B51C8F5AFDEC7ACA11EAD5EA184732839C7B7502
key Bob   = B51C8F5AFDEC7ACA11EAD5EA184732839C7B7502
Now, I'd be very please if someone could explain me how this generated key
should be used.
With which algoritm does it work?
I'm sorry about these basic questions, but I've really tried to find any
similar solution on the Web.
Thank you,
Alexandre Gava Menezes
NPD/UFSC


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


ECDSA: using the same EC_KEY to sign and verify...

2006-12-15 Thread shakal
Hi all,
here I come again.
I'm testing the ECDSAtest.c approach to make my own test and I saw one
thing that I don't really know if it's right.
I'm sorry about taking your time, but I'm really trying to learn EC!

01 int main() {
02   const char message[] = abc;
03   unsigned char digest[20];
04   unsigned int  dgst_len = 0;
05   EVP_MD_CTX md_ctx;
06   EC_KEY*key = NULL;
07   ECDSA_SIG *signature = NULL;
08   BIGNUM*r = NULL, *s = NULL;
09   int nid = NID_X9_62_prime192v1;
10   EVP_MD_CTX_init(md_ctx);
11   printf(Creating the DIGEST: );
12   EVP_DigestInit(md_ctx, EVP_ecdsa());
13   EVP_DigestUpdate(md_ctx, (const void*)message, 3);
14   EVP_DigestFinal(md_ctx, digest, dgst_len);
15 intret;
16   if ((key = EC_KEY_new_by_curve_name(nid)) == NULL)
17 printf(\nError:  EC_KEY_new_by_curve_name(nid));
18   if (!EC_KEY_generate_key(key))
19 printf(\nError: EC_KEY_generate_key(key));
20   signature = ECDSA_do_sign(digest, 20, key);
21   ret = ECDSA_do_verify(digest, 20, signature, key);
22   if (ret == -1){
23 printf(Error: ECDSA_do_verify\n);
24   }else if (ret == 0){
25 printf(Incorrect Signature\n);
26   }else{   /* ret == 1 */
27 printf(The Signature is CORRECT\n);
28   }
29   return 0;
30 }

On both lines 20 and 21, it is being passed key as parameter to sign and
verify.
But, if Alice signs (with its private key) a message and send to Bob, as
Bob has only Alice's public key, is quite hard to use the same 'key' to
verify that was used to sign.
Because its seems that Bob can obtain Alice private key from EC_KEY's key.
It would sound better if:
20 signature = ECDSA_do_sign(digest, 20,EC_KEY_get0_private_key(key));
and
21 ret = ECDSA_do_verify(digest, 20, EC_KEY_get0_public_key(key);
I know that these functions were expect to receive a EC_KEY parameter
instead either BIGNUM or EC_POINT.
I would be pleased if someone could explain me if there is another way to
do  this or even if this approach is correct and the problem is with me
(probably).
Thanks.
Alexandre Gava Menezes
NPD/UFSC


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


Re: how to use the shared key through ECDH_compute_key method

2006-12-15 Thread shakal
Nils, thanks.
That's what I though, but I've looked rc5 up in the /crypto/rc5/rc5*.{h,c}
files, and I don't know how to suply this key, 'cause it generates its key
by its own, i.e, through RC5_32_set_key method.
Is there another way to use this shared key(or one part of it) from EC_DH,
in the rc5 symmetric algorithm?
Again, sorry about these primary questions. But I'll be really grateful if
you or someone else could explain me. And maybe it can help other people.
Thank you!
Alexandre Gava Menezes
NPD/UFSC
 [EMAIL PROTECTED] wrote:
 Hi all,
 I'm a new user trying to use the EC_DH benefits on key sharing.
 But I'm having some problems to understand how it works...
 First, in(ecdhtest.c),
 aout=ECDH_compute_key(abuf,alen,EC_KEY_get0_public_key(b),a,KDF1_SHA1);
 it generates the following key in both sides Alice and Bob
 key Alice = B51C8F5AFDEC7ACA11EAD5EA184732839C7B7502
 key Bob   = B51C8F5AFDEC7ACA11EAD5EA184732839C7B7502
 Now, I'd be very please if someone could explain me how this generated
 key
 should be used.

 if you generate a shared secret key with a key agreement scheme
 you should know what you want to do with it ... normally such
 keys / secrets are used for session keys for symmetric crypto
 algorithms.

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



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