Changeset 14440
- Timestamp:
- Jan 7, 2015, 1:13:19 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/crypto-utils-cyassl.c
r14436 r14440 20 20 #include "crypto-utils.h" 21 21 #include "log.h" 22 #include "platform.h" 22 23 #include "utils.h" 23 24 … … 90 91 } 91 92 93 static tr_lock * 94 get_rng_lock (void) 95 { 96 static tr_lock * lock = NULL; 97 98 if (lock == NULL) 99 lock = tr_lockNew (); 100 101 return lock; 102 } 103 92 104 /*** 93 105 **** … … 232 244 struct tr_dh_ctx * handle = raw_handle; 233 245 word32 my_private_key_length, my_public_key_length; 246 tr_lock * rng_lock = get_rng_lock (); 234 247 235 248 assert (handle != NULL); … … 238 251 if (handle->private_key == NULL) 239 252 handle->private_key = tr_malloc (handle->key_length); 253 254 tr_lockLock (rng_lock); 240 255 241 256 if (!check_result (DhGenerateKeyPair (&handle->dh, get_rng (), 242 257 handle->private_key, &my_private_key_length, 243 258 public_key, &my_public_key_length))) 244 return false; 259 { 260 tr_lockUnlock (rng_lock); 261 return false; 262 } 263 264 tr_lockUnlock (rng_lock); 245 265 246 266 tr_dh_align_key (public_key, my_public_key_length, handle->key_length); … … 292 312 size_t length) 293 313 { 314 bool ret; 315 tr_lock * rng_lock = get_rng_lock (); 316 294 317 assert (buffer != NULL); 295 318 296 return check_result (RNG_GenerateBlock (get_rng (), buffer, length)); 297 } 319 tr_lockLock (rng_lock); 320 ret = check_result (RNG_GenerateBlock (get_rng (), buffer, length)); 321 tr_lockUnlock (rng_lock); 322 323 return ret; 324 }
Note: See TracChangeset
for help on using the changeset viewer.