1.\" $OpenBSD: idgen32.9,v 1.3 2013/06/04 19:27:07 schwarze Exp $ 2.\" 3.\" Copyright (c) 2008 Damien Miller <djm@mindrot.org> 4.\" All rights reserved. 5.\" 6.\" Permission to use, copy, modify, and distribute this software for any 7.\" purpose with or without fee is hereby granted, provided that the above 8.\" copyright notice and this permission notice appear in all copies. 9.\" 10.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17.\" 18.Dd $Mdocdate: June 4 2013 $ 19.Dt IDGEN32 9 20.Os 21.Sh NAME 22.Nm idgen32 23.Nd non-repeating ID generation 24.Sh SYNOPSIS 25.In crypto/idgen.h 26.Ft void 27.Fn idgen32_init "struct idgen32_ctx *ctx" 28.Ft uint32_t 29.Fn idgen32 "struct idgen32_ctx *ctx" 30.Sh DESCRIPTION 31The 32.Fn idgen32 33functions provide a facility to generate a stream of 32-bit numbers 34that are strongly unpredictable and have a repetition cycle close to 352^32. 36Such numbers are useful as protocol identifiers where there are negative 37consequences to reusing an ID within a short time period, as may happen 38if they are simply assigned at random. 39.Pp 40The 41.Fn idgen32_init 42function prepares a context structure for use. 43.Pp 44The 45.Fn idgen32 46function returns a new ID in host byte order. 47Note that this function will never return 0 as it often has a special 48meaning in network protocols. 49.Sh SEE ALSO 50.Xr arc4random 9 51.Sh HISTORY 52The 53.Nm 54functions were added in 55.Ox 4.4 . 56