Refactor rand

* Removed dependency from internal headers in rand.h. xmpp_rand
  interface can be public in the future;
* xmpp_rand functions accept xmpp_rand_t object instead of xmpp_ctx_t.
This commit is contained in:
Dmitry Podgorny
2016-04-29 14:18:43 +00:00
parent 063f4deb22
commit b5d9b33b6f
5 changed files with 68 additions and 43 deletions

View File

@@ -28,14 +28,14 @@
*/
static void crypto_uuid_gen(xmpp_ctx_t *ctx, char *uuid)
{
uint8_t buf[16];
unsigned char buf[16];
int i = 0; /* uuid iterator */
int j = 0; /* buf iterator */
static const char hex[] = {'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
xmpp_rand_bytes(ctx, buf, sizeof(buf));
xmpp_rand_bytes(ctx->rand, buf, sizeof(buf));
buf[8] &= 0x3f;
buf[8] |= 0x80;
buf[6] &= 0x0f;