Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/random/hash.h
Show All 20 Lines | |||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||
* | * | ||||
* $FreeBSD$ | * $FreeBSD$ | ||||
*/ | */ | ||||
#ifndef SYS_DEV_RANDOM_HASH_H_INCLUDED | #ifndef SYS_DEV_RANDOM_HASH_H_INCLUDED | ||||
#define SYS_DEV_RANDOM_HASH_H_INCLUDED | #define SYS_DEV_RANDOM_HASH_H_INCLUDED | ||||
emaste: this is not standard include guard style (but it's already so) | |||||
/* Keys are formed from cipher blocks */ | |||||
#define RANDOM_KEYSIZE 32 /* (in bytes) == 256 bits */ | #define RANDOM_KEYSIZE 32 /* (in bytes) == 256 bits */ | ||||
#define RANDOM_KEYSIZE_WORDS (RANDOM_KEYSIZE/sizeof(uint32_t)) | #define RANDOM_KEYSIZE_WORDS (RANDOM_KEYSIZE/sizeof(uint32_t)) | ||||
#define RANDOM_BLOCKSIZE 16 /* (in bytes) == 128 bits */ | #define RANDOM_BLOCKSIZE 16 /* (in bytes) == 128 bits */ | ||||
#define RANDOM_BLOCKSIZE_WORDS (RANDOM_BLOCKSIZE/sizeof(uint32_t)) | #define RANDOM_BLOCKSIZE_WORDS (RANDOM_BLOCKSIZE/sizeof(uint32_t)) | ||||
#define RANDOM_KEYS_PER_BLOCK (RANDOM_KEYSIZE/RANDOM_BLOCKSIZE) | #define RANDOM_KEYS_PER_BLOCK (RANDOM_KEYSIZE/RANDOM_BLOCKSIZE) | ||||
Done Inline ActionsPossible lack of a <tab> after #define and before the constant name? rwatson: Possible lack of a <tab> after #define and before the constant name? | |||||
/* The size of the zero block portion used to form H_d(m) */ | |||||
#define RANDOM_ZERO_BLOCKSIZE 64 /* (in bytes) == 512 zero bits */ | #define RANDOM_ZERO_BLOCKSIZE 64 /* (in bytes) == 512 zero bits */ | ||||
struct randomdev_hash { /* Big! Make static! */ | struct randomdev_hash { | ||||
SHA256_CTX sha; | SHA256_CTX sha; | ||||
}; | }; | ||||
struct randomdev_key { /* Big! Make static! */ | struct randomdev_key { | ||||
keyInstance key; /* Key schedule */ | keyInstance key; /* Key schedule */ | ||||
cipherInstance cipher; /* Rijndael internal */ | cipherInstance cipher; /* Rijndael internal */ | ||||
}; | }; | ||||
void randomdev_hash_init(struct randomdev_hash *); | void randomdev_hash_init(struct randomdev_hash *); | ||||
void randomdev_hash_iterate(struct randomdev_hash *, const void *, size_t); | void randomdev_hash_iterate(struct randomdev_hash *, const void *, size_t); | ||||
void randomdev_hash_finish(struct randomdev_hash *, void *); | void randomdev_hash_finish(struct randomdev_hash *, void *); | ||||
void randomdev_encrypt_init(struct randomdev_key *, const void *); | void randomdev_encrypt_init(struct randomdev_key *, const void *); | ||||
void randomdev_encrypt(struct randomdev_key *context, const void *, void *, u_int); | void randomdev_encrypt(struct randomdev_key *context, const void *, void *, u_int); | ||||
Done Inline ActionsNot in this patch, but .. does it seem odd to you that the other functions above are randomdev_hash_*() in the random/hash.h header, but these are reandomdev_encrypt() functions? :-) rwatson: Not in this patch, but .. does it seem odd to you that the other functions above are… | |||||
Done Inline ActionsThere is room for renaming here; the encryption routines are not really being used for anything other than output (hash) generation, so I'm not overly concerned by this. markm: There is room for renaming here; the encryption routines are not really being used for anything… | |||||
#endif /* SYS_DEV_RANDOM_HASH_H_INCLUDED */ | #endif /* SYS_DEV_RANDOM_HASH_H_INCLUDED */ |
this is not standard include guard style (but it's already so)