// SPDX-License-Identifier: GPL-2.0-only /* * s390 TRNG device driver * * Driver for the TRNG (true random number generation) command * available via CPACF extension MSA 7 on the s390 arch.
* Copyright IBM Corp. 2017 * Author(s): Harald Freudenberger <freude@de.ibm.com>
*/
staticint trng_hwrng_read(struct hwrng *rng, void *data, size_t max, bool wait)
{
size_t len = max <= PAGE_SIZE ? max : PAGE_SIZE;
_trng_hwrng_read((u8 *) data, len);
DEBUG_DBG("trng_hwrng_read()=%zu\n", len);
return len;
}
/* * hwrng register struct * The trng is supposed to have 100% entropy, and thus we register with a very * high quality value. If we ever have a better driver in the future, we should * change this value again when we merge this driver.
*/ staticstruct hwrng trng_hwrng_dev = {
.name = "s390-trng",
.data_read = trng_hwrng_data_read,
.read = trng_hwrng_read,
};
/* check if subfunction CPACF_PRNO_TRNG is available */ if (!cpacf_query_func(CPACF_PRNO, CPACF_PRNO_TRNG)) {
DEBUG_INFO("trng_init CPACF_PRNO_TRNG not available\n");
ret = -ENODEV; goto out_dbg;
}
ret = misc_register(&trng_dev); if (ret) {
DEBUG_WARN("trng_init misc_register() failed rc=%d\n", ret); goto out_dbg;
}
ret = hwrng_register(&trng_hwrng_dev); if (ret) {
DEBUG_WARN("trng_init hwrng_register() failed rc=%d\n", ret); goto out_misc;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.