randomdev.c (13774e82285e8d5eb3afeff63760725f747f8581) | randomdev.c (f3d2512db6ec23985b10fbcbe0b3bd34ea2574df) |
---|---|
1/*- 2 * Copyright (c) 2017 Oliver Pinter 3 * Copyright (c) 2000-2015 Mark R V Murray 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 48 unchanged lines hidden (view full) --- 57#include <dev/random/randomdev.h> 58#include <dev/random/random_harvestq.h> 59 60#define RANDOM_UNIT 0 61 62#if defined(RANDOM_LOADABLE) 63#define READ_RANDOM_UIO _read_random_uio 64#define READ_RANDOM _read_random | 1/*- 2 * Copyright (c) 2017 Oliver Pinter 3 * Copyright (c) 2000-2015 Mark R V Murray 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 48 unchanged lines hidden (view full) --- 57#include <dev/random/randomdev.h> 58#include <dev/random/random_harvestq.h> 59 60#define RANDOM_UNIT 0 61 62#if defined(RANDOM_LOADABLE) 63#define READ_RANDOM_UIO _read_random_uio 64#define READ_RANDOM _read_random |
65#define IS_RANDOM_SEEDED _is_random_seeded |
|
65static int READ_RANDOM_UIO(struct uio *, bool); 66static void READ_RANDOM(void *, u_int); | 66static int READ_RANDOM_UIO(struct uio *, bool); 67static void READ_RANDOM(void *, u_int); |
68static bool IS_RANDOM_SEEDED(void); |
|
67#else 68#define READ_RANDOM_UIO read_random_uio 69#define READ_RANDOM read_random | 69#else 70#define READ_RANDOM_UIO read_random_uio 71#define READ_RANDOM read_random |
72#define IS_RANDOM_SEEDED is_random_seeded |
|
70#endif 71 72static d_read_t randomdev_read; 73static d_write_t randomdev_write; 74static d_poll_t randomdev_poll; 75static d_ioctl_t randomdev_ioctl; 76 77static struct cdevsw random_cdevsw = { --- 10 unchanged lines hidden (view full) --- 88 89static void 90random_alg_context_ra_init_alg(void *data) 91{ 92 93 p_random_alg_context = &random_alg_context; 94 p_random_alg_context->ra_init_alg(data); 95#if defined(RANDOM_LOADABLE) | 73#endif 74 75static d_read_t randomdev_read; 76static d_write_t randomdev_write; 77static d_poll_t randomdev_poll; 78static d_ioctl_t randomdev_ioctl; 79 80static struct cdevsw random_cdevsw = { --- 10 unchanged lines hidden (view full) --- 91 92static void 93random_alg_context_ra_init_alg(void *data) 94{ 95 96 p_random_alg_context = &random_alg_context; 97 p_random_alg_context->ra_init_alg(data); 98#if defined(RANDOM_LOADABLE) |
96 random_infra_init(READ_RANDOM_UIO, READ_RANDOM); | 99 random_infra_init(READ_RANDOM_UIO, READ_RANDOM, IS_RANDOM_SEEDED); |
97#endif 98} 99 100static void 101random_alg_context_ra_deinit_alg(void *data) 102{ 103 104#if defined(RANDOM_LOADABLE) --- 161 unchanged lines hidden (view full) --- 266 sizeof(remainder_buf)); 267 memcpy((char *)random_buf + read_directly_len, remainder_buf, 268 len - read_directly_len); 269 270 explicit_bzero(remainder_buf, sizeof(remainder_buf)); 271 } 272} 273 | 100#endif 101} 102 103static void 104random_alg_context_ra_deinit_alg(void *data) 105{ 106 107#if defined(RANDOM_LOADABLE) --- 161 unchanged lines hidden (view full) --- 269 sizeof(remainder_buf)); 270 memcpy((char *)random_buf + read_directly_len, remainder_buf, 271 len - read_directly_len); 272 273 explicit_bzero(remainder_buf, sizeof(remainder_buf)); 274 } 275} 276 |
277bool 278IS_RANDOM_SEEDED(void) 279{ 280 return (p_random_alg_context->ra_seeded()); 281} 282 |
|
274static __inline void 275randomdev_accumulate(uint8_t *buf, u_int count) 276{ 277 static u_int destination = 0; 278 static struct harvest_event event; 279 static struct randomdev_hash hash; 280 static uint32_t entropy_data[RANDOM_KEYSIZE_WORDS]; 281 uint32_t timestamp; --- 183 unchanged lines hidden --- | 283static __inline void 284randomdev_accumulate(uint8_t *buf, u_int count) 285{ 286 static u_int destination = 0; 287 static struct harvest_event event; 288 static struct randomdev_hash hash; 289 static uint32_t entropy_data[RANDOM_KEYSIZE_WORDS]; 290 uint32_t timestamp; --- 183 unchanged lines hidden --- |