RE : Random number seed in RSA

2004-08-10 Thread Marc Gaudichet
You can also use the RAND_status() function that implicitly calls RAND_poll(). 
RAND_poll() actually uses memory state, processes, handles, screen state... to 
initialize the PRNG. If it is not sufficiant (it usually is), you can read some 
entropy from a file using RAND_read() function.

Marc.


 -Message d'origine-
 De : lbfi [mailto:[EMAIL PROTECTED] 
 Envoyé : mardi 10 août 2004 12:59
 À : openssl-users
 Objet : Re:Random number seed in RSA
 
 
 You can use these functions:
 
 void RAND_seed(const void *buf, int num);
 
  void RAND_add(const void *buf, int num, double 
 entropy);
 
  int  RAND_status(void);
 
  int  RAND_event(UINT iMsg, WPARAM wParam, LPARAM 
 lParam);
  void RAND_screen(void);
 
 You need to seed PRNG before the function 
 RSA_generate_key(...). a good explanation you will find 
 in:
 http://www.openssl.org/docs/crypto/RAND_add.html
 
  Hi,
  I have a snippet that encrypts/decrypts using RSA.
   
  
  #include stdio.h
  
  #include openssl/rsa.h
  
  #include string.h
  
  // RSATest: Program illustrating Simple RSA
 Encryption/Decryption 
  
  int main()
  
  {
  
  char *plain=Sample text; //Sample text (plain text)
 to Encrypt/Decrypt
  
  char *ciphertext;
  
  char *plain1;
  
  int enclen,i,declen;
  
  printf(%s\n,plain);
  
  
  
  // Generate RSA key
  
  RSA *rsa1= RSA_generate_key(1024,65537,NULL,NULL);
  
  // RSA_size() will determine how much memory must be
 allocated for an RSA encrypted value
  
  ciphertext = (char *)malloc(RSA_size(rsa1));
  
  printf(RSA size %d,RSA_size(rsa1));
  
   
  
  I am using Cygwin. My question is thisWhere and
 How do I seed the random number generator?
  
  Thanks,
  
  Joe
  
   
  
  
  
  -
  Do you Yahoo!?
  New and Improved Yahoo! Mail - Send 10MB messages!
 
 Leandro Barros de Figueiredo
 Eng. Controle e Automação - UFMG
  
 __
 
 Acabe com aquelas janelinhas que pulam na sua tela.
 AntiPop-up UOL - É grátis!
 http://antipopup.uol.com.br/
 
 
 __
 OpenSSL Project http://www.openssl.org
 User Support Mailing List[EMAIL PROTECTED]
 Automated List Manager   [EMAIL PROTECTED]
 
__
OpenSSL Project http://www.openssl.org
User Support Mailing List[EMAIL PROTECTED]
Automated List Manager   [EMAIL PROTECTED]


RE: Random number seed in RSA

2004-08-10 Thread sakthi.subramaniam
Title: Message



HI.,
You can use /dev/random as a seed generator..I belive that cygwin
has the support for /dev/random device..
For that u can use RAND_load_file("/dev/random", no_of_bytes) for
programming the seed.
or
otherwise you can use the static character buffer (rnd_seed)as a seed and
use
RAND_seed(rnd_seed, sizeof rnd_seed); to program the seed. In the
second case you need to store the seed such a way hackers should not break the
seed..

Hope
this helps..
Sakthi
S G


  
  -Original Message-From:
  [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
  Behalf Of Joe smithSent: Tuesday, August 10, 2004 3:21
  AMTo: [EMAIL PROTECTED]Subject: Random number
  seed in RSA
  Hi,
  I have asnippet that encrypts/decrypts using RSA. 
  
  
  #include stdio.h
  #include openssl/rsa.h
  #include string.h
  // RSATest: Program illustrating Simple RSA Encryption/Decryption 
  int main()
  {
  char *plain="Sample text"; //Sample text (plain text) to
Encrypt/Decrypt
  char *ciphertext;
  char *plain1;
  int enclen,i,declen; 
  printf("%s\n",plain);
  
  // Generate RSA key
  RSA *rsa1= RSA_generate_key(1024,65537,NULL,NULL);
  // RSA_size() will determine how much memory must be allocated for an RSA
  encrypted value
  ciphertext = (char *)malloc(RSA_size(rsa1));
  printf("RSA size %d",RSA_size(rsa1));
  
  I am using Cygwin. My question is thisWhere and How do I seed the
  random number generator?
  Thanks,
  Joe
  
  
  
  Do you Yahoo!?New
  and Improved Yahoo! Mail - Send 10MB messages!




Confidentiality Notice

The information contained in this electronic message and any attachments to this message are intended
for the exclusive use of the addressee(s) and may contain confidential or privileged information. If
you are not the intended recipient, please notify the sender at Wipro or [EMAIL PROTECTED] immediately
and destroy all copies of this message and any attachments.