mirror of
https://github.com/openbsd/src.git
synced 2024-12-22 16:42:56 -08:00
Defining the interface in terms of char * means most callers are
required to cast their pointers, which is ugly and possibly error prone. accidentally casting an int to a pointer, for example, instead of the address of the int. implicit void * casting is safer. This updates the kernel hash interfaces to use void *. Similar changes are possible for userland. I think it's safe, but there may be some peculiar source compatbility issues there, so let's just do the kernel first. ok dlg millert
This commit is contained in:
parent
842fba9566
commit
de2d0d0b4c
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: md5.c,v 1.2 2011/01/11 15:42:05 deraadt Exp $ */
|
||||
/* $OpenBSD: md5.c,v 1.3 2014/11/16 17:39:09 tedu Exp $ */
|
||||
|
||||
/*
|
||||
* This code implements the MD5 message-digest algorithm.
|
||||
@ -62,8 +62,9 @@ MD5Init(MD5_CTX *ctx)
|
||||
* of bytes.
|
||||
*/
|
||||
void
|
||||
MD5Update(MD5_CTX *ctx, const unsigned char *input, size_t len)
|
||||
MD5Update(MD5_CTX *ctx, const void *inputptr, size_t len)
|
||||
{
|
||||
const uint8_t *input = inputptr;
|
||||
size_t have, need;
|
||||
|
||||
/* Check how many bytes we already have and how many more we need. */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: md5.h,v 1.2 2012/12/05 23:20:15 deraadt Exp $ */
|
||||
/* $OpenBSD: md5.h,v 1.3 2014/11/16 17:39:09 tedu Exp $ */
|
||||
|
||||
/*
|
||||
* This code implements the MD5 message-digest algorithm.
|
||||
@ -26,7 +26,7 @@ typedef struct MD5Context {
|
||||
|
||||
__BEGIN_DECLS
|
||||
void MD5Init(MD5_CTX *);
|
||||
void MD5Update(MD5_CTX *, const u_int8_t *, size_t)
|
||||
void MD5Update(MD5_CTX *, const void *, size_t)
|
||||
__attribute__((__bounded__(__string__,2,3)));
|
||||
void MD5Final(u_int8_t [MD5_DIGEST_LENGTH], MD5_CTX *)
|
||||
__attribute__((__bounded__(__minbytes__,1,MD5_DIGEST_LENGTH)));
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: sha1.c,v 1.9 2011/01/11 15:50:40 deraadt Exp $ */
|
||||
/* $OpenBSD: sha1.c,v 1.10 2014/11/16 17:39:09 tedu Exp $ */
|
||||
|
||||
/*
|
||||
* SHA-1 in C
|
||||
@ -121,8 +121,9 @@ SHA1Init(SHA1_CTX *context)
|
||||
/* Run your data through this. */
|
||||
|
||||
void
|
||||
SHA1Update(SHA1_CTX *context, const unsigned char *data, unsigned int len)
|
||||
SHA1Update(SHA1_CTX *context, const void *dataptr, unsigned int len)
|
||||
{
|
||||
const uint8_t *data = dataptr;
|
||||
unsigned int i;
|
||||
unsigned int j;
|
||||
|
||||
@ -153,9 +154,9 @@ SHA1Final(unsigned char digest[SHA1_DIGEST_LENGTH], SHA1_CTX *context)
|
||||
finalcount[i] = (unsigned char)((context->count >>
|
||||
((7 - (i & 7)) * 8)) & 255); /* Endian independent */
|
||||
}
|
||||
SHA1Update(context, (unsigned char *)"\200", 1);
|
||||
SHA1Update(context, "\200", 1);
|
||||
while ((context->count & 504) != 448) {
|
||||
SHA1Update(context, (unsigned char *)"\0", 1);
|
||||
SHA1Update(context, "\0", 1);
|
||||
}
|
||||
SHA1Update(context, finalcount, 8); /* Should cause a SHA1Transform() */
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: sha1.h,v 1.5 2007/09/10 22:19:42 henric Exp $ */
|
||||
/* $OpenBSD: sha1.h,v 1.6 2014/11/16 17:39:09 tedu Exp $ */
|
||||
|
||||
/*
|
||||
* SHA-1 in C
|
||||
@ -20,7 +20,7 @@ typedef struct {
|
||||
|
||||
void SHA1Init(SHA1_CTX * context);
|
||||
void SHA1Transform(u_int32_t state[5], const unsigned char buffer[SHA1_BLOCK_LENGTH]);
|
||||
void SHA1Update(SHA1_CTX *context, const unsigned char *data, unsigned int len);
|
||||
void SHA1Update(SHA1_CTX *context, const void *data, unsigned int len);
|
||||
void SHA1Final(unsigned char digest[SHA1_DIGEST_LENGTH], SHA1_CTX *context);
|
||||
|
||||
#endif /* _SHA1_H_ */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: sha2.c,v 1.8 2011/01/11 15:42:05 deraadt Exp $ */
|
||||
/* $OpenBSD: sha2.c,v 1.9 2014/11/16 17:39:09 tedu Exp $ */
|
||||
|
||||
/*
|
||||
* FILE: sha2.c
|
||||
@ -444,8 +444,9 @@ SHA256Transform(SHA2_CTX *context, const u_int8_t *data)
|
||||
#endif /* SHA2_UNROLL_TRANSFORM */
|
||||
|
||||
void
|
||||
SHA256Update(SHA2_CTX *context, const u_int8_t *data, size_t len)
|
||||
SHA256Update(SHA2_CTX *context, const void *dataptr, size_t len)
|
||||
{
|
||||
const uint8_t *data = dataptr;
|
||||
size_t freespace, usedspace;
|
||||
|
||||
/* Calling with no data is valid (we do nothing) */
|
||||
@ -730,8 +731,9 @@ SHA512Transform(SHA2_CTX *context, const u_int8_t *data)
|
||||
#endif /* SHA2_UNROLL_TRANSFORM */
|
||||
|
||||
void
|
||||
SHA512Update(SHA2_CTX *context, const u_int8_t *data, size_t len)
|
||||
SHA512Update(SHA2_CTX *context, const void *dataptr, size_t len)
|
||||
{
|
||||
const uint8_t *data = dataptr;
|
||||
size_t freespace, usedspace;
|
||||
|
||||
/* Calling with no data is valid (we do nothing) */
|
||||
@ -861,9 +863,9 @@ SHA384Init(SHA2_CTX *context)
|
||||
}
|
||||
|
||||
void
|
||||
SHA384Update(SHA2_CTX *context, const u_int8_t *data, size_t len)
|
||||
SHA384Update(SHA2_CTX *context, const void *data, size_t len)
|
||||
{
|
||||
SHA512Update((SHA2_CTX *)context, data, len);
|
||||
SHA512Update(context, data, len);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: sha2.h,v 1.4 2012/12/05 23:20:15 deraadt Exp $ */
|
||||
/* $OpenBSD: sha2.h,v 1.5 2014/11/16 17:39:09 tedu Exp $ */
|
||||
|
||||
/*
|
||||
* FILE: sha2.h
|
||||
@ -62,19 +62,19 @@ typedef struct _SHA2_CTX {
|
||||
|
||||
__BEGIN_DECLS
|
||||
void SHA256Init(SHA2_CTX *);
|
||||
void SHA256Update(SHA2_CTX *, const u_int8_t *, size_t)
|
||||
void SHA256Update(SHA2_CTX *, const void *, size_t)
|
||||
__attribute__((__bounded__(__string__,2,3)));
|
||||
void SHA256Final(u_int8_t[SHA256_DIGEST_LENGTH], SHA2_CTX *)
|
||||
__attribute__((__bounded__(__minbytes__,1,SHA256_DIGEST_LENGTH)));
|
||||
|
||||
void SHA384Init(SHA2_CTX *);
|
||||
void SHA384Update(SHA2_CTX *, const u_int8_t *, size_t)
|
||||
void SHA384Update(SHA2_CTX *, const void *, size_t)
|
||||
__attribute__((__bounded__(__string__,2,3)));
|
||||
void SHA384Final(u_int8_t[SHA384_DIGEST_LENGTH], SHA2_CTX *)
|
||||
__attribute__((__bounded__(__minbytes__,1,SHA384_DIGEST_LENGTH)));
|
||||
|
||||
void SHA512Init(SHA2_CTX *);
|
||||
void SHA512Update(SHA2_CTX *, const u_int8_t *, size_t)
|
||||
void SHA512Update(SHA2_CTX *, const void *, size_t)
|
||||
__attribute__((__bounded__(__string__,2,3)));
|
||||
void SHA512Final(u_int8_t[SHA512_DIGEST_LENGTH], SHA2_CTX *)
|
||||
__attribute__((__bounded__(__minbytes__,1,SHA512_DIGEST_LENGTH)));
|
||||
|
Loading…
Reference in New Issue
Block a user