165686Smarkm/*- 2284959Smarkm * Copyright (c) 2000-2015 Mark R V Murray 365686Smarkm * All rights reserved. 465686Smarkm * 565686Smarkm * Redistribution and use in source and binary forms, with or without 665686Smarkm * modification, are permitted provided that the following conditions 765686Smarkm * are met: 865686Smarkm * 1. Redistributions of source code must retain the above copyright 965686Smarkm * notice, this list of conditions and the following disclaimer 1065686Smarkm * in this position and unchanged. 1165686Smarkm * 2. Redistributions in binary form must reproduce the above copyright 1265686Smarkm * notice, this list of conditions and the following disclaimer in the 1365686Smarkm * documentation and/or other materials provided with the distribution. 1465686Smarkm * 1565686Smarkm * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 1665686Smarkm * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 1765686Smarkm * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 1865686Smarkm * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 1965686Smarkm * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 2065686Smarkm * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2165686Smarkm * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2265686Smarkm * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2365686Smarkm * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 2465686Smarkm * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2565686Smarkm * 2665686Smarkm * $FreeBSD$ 2765686Smarkm */ 2865686Smarkm 29256377Smarkm#ifndef SYS_DEV_RANDOM_HASH_H_INCLUDED 30284959Smarkm#define SYS_DEV_RANDOM_HASH_H_INCLUDED 31256377Smarkm 32285422Smarkm/* Keys are formed from cipher blocks */ 33284959Smarkm#define RANDOM_KEYSIZE 32 /* (in bytes) == 256 bits */ 34284959Smarkm#define RANDOM_KEYSIZE_WORDS (RANDOM_KEYSIZE/sizeof(uint32_t)) 35284959Smarkm#define RANDOM_BLOCKSIZE 16 /* (in bytes) == 128 bits */ 36284959Smarkm#define RANDOM_BLOCKSIZE_WORDS (RANDOM_BLOCKSIZE/sizeof(uint32_t)) 37284959Smarkm#define RANDOM_KEYS_PER_BLOCK (RANDOM_KEYSIZE/RANDOM_BLOCKSIZE) 38285422Smarkm 39285422Smarkm/* The size of the zero block portion used to form H_d(m) */ 40284959Smarkm#define RANDOM_ZERO_BLOCKSIZE 64 /* (in bytes) == 512 zero bits */ 4165686Smarkm 42285422Smarkmstruct randomdev_hash { 43100082Smarkm SHA256_CTX sha; 4465686Smarkm}; 4565686Smarkm 46285422Smarkmstruct randomdev_key { 4774072Smarkm keyInstance key; /* Key schedule */ 4874072Smarkm cipherInstance cipher; /* Rijndael internal */ 4965686Smarkm}; 5065686Smarkm 51255362Smarkmvoid randomdev_hash_init(struct randomdev_hash *); 52274340Sdesvoid randomdev_hash_iterate(struct randomdev_hash *, const void *, size_t); 53255362Smarkmvoid randomdev_hash_finish(struct randomdev_hash *, void *); 54274340Sdesvoid randomdev_encrypt_init(struct randomdev_key *, const void *); 55274340Sdesvoid randomdev_encrypt(struct randomdev_key *context, const void *, void *, u_int); 56256377Smarkm 57284959Smarkm#endif /* SYS_DEV_RANDOM_HASH_H_INCLUDED */ 58