ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/rsa.c
(Generate patch)

Comparing ircd-hybrid/trunk/src/rsa.c (file contents):
Revision 4110 by michael, Tue Jul 1 15:56:12 2014 UTC vs.
Revision 4254 by michael, Fri Jul 18 19:07:27 2014 UTC

# Line 52 | Line 52 | report_crypto_errors(void)
52      ilog(LOG_TYPE_IRCD, "SSL error: %s", ERR_error_string(e, 0));
53   }
54  
55 < static void
55 > void
56   binary_to_hex(const unsigned char *bin, char *hex, unsigned int length)
57   {
58    static const char trans[] = "0123456789ABCDEF";
# Line 69 | Line 69 | binary_to_hex(const unsigned char *bin,
69   int
70   get_randomness(unsigned char *buf, int length)
71   {
72 <  /* Seed OpenSSL PRNG with EGD enthropy pool -kre */
73 <  if (ConfigFileEntry.use_egd && ConfigFileEntry.egdpool_path)
74 <    if (RAND_egd(ConfigFileEntry.egdpool_path) == -1)
75 <      return -1;
76 <
77 <  if (RAND_status())
78 <    return RAND_bytes(buf, length);
79 <  /* XXX - abort? */
80 <  return RAND_pseudo_bytes(buf, length);
72 >  return RAND_bytes(buf, length);
73   }
74  
75   int
# Line 90 | Line 82 | generate_challenge(char **r_challenge, c
82    if (!rsa)
83      return -1;
84  
85 <  get_randomness(secret, 32);
85 >  if (!get_randomness(secret, 32))
86 >  {
87 >    report_crypto_errors();
88 >    return -1;
89 >  }
90 >
91    *r_response = MyCalloc(65);
92    binary_to_hex(secret, *r_response, 32);
93  
# Line 99 | Line 96 | generate_challenge(char **r_challenge, c
96    ret = RSA_public_encrypt(32, secret, tmp, rsa, RSA_PKCS1_PADDING);
97  
98    *r_challenge = MyCalloc((length << 1) + 1);
99 <  binary_to_hex( tmp, *r_challenge, length);
103 <  (*r_challenge)[length << 1] = 0;
99 >  binary_to_hex(tmp, *r_challenge, length);
100    MyFree(tmp);
101  
102    if (ret < 0)

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)