/*
* Copyright (c) 1996, David Mazieres <dm@uun.org>
* Copyright (c) 2008, Damien Miller <djm@openbsd.org>
* Copyright (c) 2013, Markus Friedl <markus@openbsd.org>
* Copyright (c) 2015 Joyent, Inc.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/*
* arc4random(3C), derived from the OpenBSD version.
*
* To ensure that a parent process and any potential children see a different
* state, we mmap the entire arc4_state_t structure and mark that page as
* MC_INHERIT_ZERO. That ensures that the data is zeroed, and really the bit we
* care about, arc4_init is set to B_FALSE, which will cause the child to
* reinitialize it when they first use the interface.
*/
#include <synch.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/sysmacros.h>
#include <chacha.h>
#include "thr_uberdata.h"
typedef struct arc4_state {
} arc4_state_t;
static void
{
if (n < ARC4_KEYSZ + ARC4_IVSZ)
abort();
}
static void
{
/* Fill in the keystream buffer */
/* mix in optional user provided data */
size_t i, m;
for (i = 0; i < m; i++)
}
/* immediately reinit for backtracking resistence */
}
static void
{
abort();
} else {
}
/* Invalidate the data buffer */
}
arc4->arc4_count = 0;
} else {
}
}
static void
{
void *a;
if (pgsz == -1)
abort();
if (a == MAP_FAILED)
abort();
abort();
arc4 = a;
}
arc4_stir(n);
while (n > 0) {
explicit_bzero(keystream, m);
buf += m;
n -= m;
}
arc4_rekey(NULL, 0);
}
}
arc4random(void)
{
return (out);
}
void
{
}