Building.Open.Source.Network.Security.Tools.Components.And.Techniques [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Building.Open.Source.Network.Security.Tools.Components.And.Techniques [Electronic resources] - نسخه متنی

Mike D. Schiffman

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید







Random Number Generation

Libdnet also offers the application programmer a rich set of functions to manipulate pseudo-random numbers. This functionality is useful in many network applications, including packet generation and security testing.



rand_t *rand_open (void);


rand_open() obtains a random number handle for fast cryptographic and strong pseudo-random number generation. The initial seed for the generator is derived from the system random data source device (if one exists; /dev/arandom or /dev/urandom under Unix variants) or from the current time and random stack contents. Upon success, the function returns a valid blob_t handle pointer; upon failure (malloc()), the function returns NULL.



int rand_get (rand_t *r, void *buf, size_t len);


rand_get() writes len random bytes from r into buf. The function does not fail and returns 0.



int rand_set (rand_t *r, const void *seed, size_t len);


rand_set() reinitializes r with the seed seed of len bytes. This function is useful when you desire a random sequence, but it needs to be repeatable (in other words, for network protocol stress testing). The function does not fail and returns 0.



int rand_add (rand_t *r, const void *buf, size_t len);


rand_add() writes len bytes of entropy data from buf into r. The function does not fail and returns 0.



uint8_t rand_uint8(rand_t *r);


rand_uint8() returns an unsigned 8-bit pseudo-random value.



uint16_t rand_uint16(rand_t *r);


rand_uint16() returns an unsigned 16-bit pseudo-random value.



uint32_t rand_uint32(rand_t *r);


rand_uint32() returns an unsigned 32-bit pseudo-random value.



int rand_shuffle(rand_t *r, void *base, size_t nmemb, size_t size);


rand_shuffle() pseudo-randomly shuffles an array of elements nmemb of size bytes, starting at base and using r. Note that this function performs an implicit malloc(). Upon success, the function returns 0; upon failure, the function returns -1.



rand_t *rand_close (rand_t *r);


rand_close() frees the memory associated with r. The function returns NULL.

/ 135