Lines Matching defs:ctx
84 idgen32_permute(struct idgen32_ctx *ctx, u_int32_t in)
94 wr ^= (idgen32_g(ctx->id32_key, r, wl) ^ r);
96 wl ^= (idgen32_g(ctx->id32_key, r, wr) ^ r) & 0x7fff;
99 wr ^= (idgen32_g(ctx->id32_key, r, wl) ^ r);
105 idgen32_rekey(struct idgen32_ctx *ctx)
107 ctx->id32_counter = 0;
108 ctx->id32_hibit ^= 0x80000000;
109 ctx->id32_offset = arc4random();
110 arc4random_buf(ctx->id32_key, sizeof(ctx->id32_key));
111 ctx->id32_rekey_time = getuptime() + IDGEN32_REKEY_TIME;
115 idgen32_init(struct idgen32_ctx *ctx)
117 bzero(ctx, sizeof(*ctx));
118 ctx->id32_hibit = arc4random() & 0x80000000;
119 idgen32_rekey(ctx);
123 idgen32(struct idgen32_ctx *ctx)
129 if (ctx->id32_counter > IDGEN32_REKEY_LIMIT ||
130 ctx->id32_rekey_time < getuptime())
131 idgen32_rekey(ctx);
132 ret = ctx->id32_hibit | idgen32_permute(ctx,
133 (ctx->id32_offset + ctx->id32_counter++) & 0x7fffffff);