All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
blob 63d1fe4b30c8c65e5d908cf1e8e2df139fea544b 1323 bytes (raw)
name: include/linux/prandom.h 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
 
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * include/linux/prandom.h
 *
 * Include file for the fast pseudo-random 32-bit
 * generation.
 */
#ifndef _LINUX_PRANDOM_H
#define _LINUX_PRANDOM_H

#include <linux/types.h>
#include <linux/once.h>
#include <linux/percpu.h>
#include <linux/random.h>

struct rnd_state {
	__u32 s1, s2, s3, s4;
};

/* WARNING: this API MUST NOT be used for cryptographic purposes! */
u32 prandom_u32_state(struct rnd_state *state);
/* WARNING: this API MUST NOT be used for cryptographic purposes! */
void prandom_bytes_state(struct rnd_state *state, void *buf, size_t nbytes);
void prandom_seed_full_state(struct rnd_state __percpu *pcpu_state);

#define prandom_init_once(pcpu_state)			\
	DO_ONCE(prandom_seed_full_state, (pcpu_state))

/*
 * Handle minimum values for seeds
 */
static inline u32 __seed(u32 x, u32 m)
{
	return (x < m) ? x + m : x;
}

/**
 * prandom_seed_state - set seed for prandom_u32_state().
 * @state: pointer to state structure to receive the seed.
 * @seed: arbitrary 64-bit value to use as a seed.
 */
static inline void prandom_seed_state(struct rnd_state *state, u64 seed)
{
	u32 i = ((seed >> 32) ^ (seed << 10) ^ seed) & 0xffffffffUL;

	state->s1 = __seed(i,   2U);
	state->s2 = __seed(i,   8U);
	state->s3 = __seed(i,  16U);
	state->s4 = __seed(i, 128U);
}

#endif

debug log:

solving 63d1fe4b30c8 ...
found 63d1fe4b30c8 in https://yhbt.net/lore/all/20250214081840.47229-2-theil.markus@gmail.com/
found ff7dcc3fa105 in https://yhbt.net/lore/pub/scm/linux/kernel/git/pkl/squashfs-lzma.git/
preparing index
index prepared:
100644 ff7dcc3fa1057ae4b9a871ff4938345ad8d360d3	include/linux/prandom.h

applying [1/1] https://yhbt.net/lore/all/20250214081840.47229-2-theil.markus@gmail.com/
diff --git a/include/linux/prandom.h b/include/linux/prandom.h
index ff7dcc3fa105..63d1fe4b30c8 100644

Checking patch include/linux/prandom.h...
Applied patch include/linux/prandom.h cleanly.

index at:
100644 63d1fe4b30c8c65e5d908cf1e8e2df139fea544b	include/linux/prandom.h

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.