/* SPDX-License-Identifier: GPL-2.0 */12/*3* NIST SP800-90A DRBG derivation function4*5* Copyright (C) 2014, Stephan Mueller <[email protected]>6*/78#ifndef _INTERNAL_DRBG_H9#define _INTERNAL_DRBG_H1011/*12* Convert an integer into a byte representation of this integer.13* The byte representation is big-endian14*15* @val value to be converted16* @buf buffer holding the converted integer -- caller must ensure that17* buffer size is at least 32 bit18*/19static inline void drbg_cpu_to_be32(__u32 val, unsigned char *buf)20{21struct s {22__be32 conv;23};24struct s *conversion = (struct s *)buf;2526conversion->conv = cpu_to_be32(val);27}2829/*30* Concatenation Helper and string operation helper31*32* SP800-90A requires the concatenation of different data. To avoid copying33* buffers around or allocate additional memory, the following data structure34* is used to point to the original memory with its size. In addition, it35* is used to build a linked list. The linked list defines the concatenation36* of individual buffers. The order of memory block referenced in that37* linked list determines the order of concatenation.38*/39struct drbg_string {40const unsigned char *buf;41size_t len;42struct list_head list;43};4445static inline void drbg_string_fill(struct drbg_string *string,46const unsigned char *buf, size_t len)47{48string->buf = buf;49string->len = len;50INIT_LIST_HEAD(&string->list);51}5253#endif //_INTERNAL_DRBG_H545556