| // SPDX-License-Identifier: GPL-2.0+ |
| * The 'rng' command prints bytes from the hardware random number generator. |
| * Copyright (c) 2019, Heinrich Schuchardt <xypron.glpk@gmx.de> |
| static int do_rng(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) |
| int ret = CMD_RET_SUCCESS; |
| if (uclass_get_device(UCLASS_RNG, 0, &dev) || !dev) { |
| printf("No RNG device\n"); |
| n = hextoul(argv[1], NULL); |
| printf("Out of memory\n"); |
| if (dm_rng_read(dev, buf, n)) { |
| printf("Reading RNG failed\n"); |
| print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, buf, n); |
| #ifdef CONFIG_SYS_LONGHELP |
| static char rng_help_text[] = |
| " - print n random bytes\n"; |
| "print bytes from the hardware random number generator", |