1.\" $OpenBSD: idgen32.9,v 1.4 2015/11/23 17:53:57 jmc 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: November 23 2015 $ 19.Dt IDGEN32 9 20.Os 21.Sh NAME 22.Nm idgen32 , 23.Nm idgen32_init 24.Nd non-repeating ID generation 25.Sh SYNOPSIS 26.In crypto/idgen.h 27.Ft void 28.Fn idgen32_init "struct idgen32_ctx *ctx" 29.Ft uint32_t 30.Fn idgen32 "struct idgen32_ctx *ctx" 31.Sh DESCRIPTION 32The 33.Fn idgen32 34functions provide a facility to generate a stream of 32-bit numbers 35that are strongly unpredictable and have a repetition cycle close to 362^32. 37Such numbers are useful as protocol identifiers where there are negative 38consequences to reusing an ID within a short time period, as may happen 39if they are simply assigned at random. 40.Pp 41The 42.Fn idgen32_init 43function prepares a context structure for use. 44.Pp 45The 46.Fn idgen32 47function returns a new ID in host byte order. 48Note that this function will never return 0 as it often has a special 49meaning in network protocols. 50.Sh SEE ALSO 51.Xr arc4random 9 52.Sh HISTORY 53The 54.Nm 55functions were added in 56.Ox 4.4 . 57