Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src Improve portability and clarity by using uint8_t for the byt...



details:   https://anonhg.NetBSD.org/src/rev/56bb0a7a7ae3
branches:  trunk
changeset: 748842:56bb0a7a7ae3
user:      joerg <joerg%NetBSD.org@localhost>
date:      Fri Nov 06 20:31:18 2009 +0000

description:
Improve portability and clarity by using uint8_t for the byte data
and expanding u_int to not depend on the !POSIX types.

diffstat:

 lib/libc/hash/sha1/sha1.3 |  16 ++++++++--------
 sys/sys/sha1.h            |  12 ++++++------
 2 files changed, 14 insertions(+), 14 deletions(-)

diffs (91 lines):

diff -r 69b76d78de2d -r 56bb0a7a7ae3 lib/libc/hash/sha1/sha1.3
--- a/lib/libc/hash/sha1/sha1.3 Fri Nov 06 20:31:17 2009 +0000
+++ b/lib/libc/hash/sha1/sha1.3 Fri Nov 06 20:31:18 2009 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: sha1.3,v 1.4 2009/10/22 01:38:18 snj Exp $
+.\"    $NetBSD: sha1.3,v 1.5 2009/11/06 20:31:18 joerg Exp $
 .\"    $OpenBSD: sha1.3,v 1.9 1998/03/07 22:18:12 millert Exp $
 .\"
 .\" Copyright (c) 1997, 2004 Todd C. Miller <Todd.Miller%courtesan.com@localhost>
@@ -35,17 +35,17 @@
 .Ft void
 .Fn SHA1Init "SHA1_CTX *context"
 .Ft void
-.Fn SHA1Update "SHA1_CTX *context" "const u_char *data" "u_int len"
+.Fn SHA1Update "SHA1_CTX *context" "const uint8_t *data" "u_int len"
 .Ft void
-.Fn SHA1Final "u_char digest[20]" "SHA1_CTX *context"
+.Fn SHA1Final "uint8_t digest[20]" "SHA1_CTX *context"
 .Ft void
-.Fn SHA1Transform "uint32_t state[5]" "u_char buffer[64]"
+.Fn SHA1Transform "uint32_t state[5]" "uint8_t buffer[64]"
 .Ft "char *"
 .Fn SHA1End "SHA1_CTX *context" "char *buf"
 .Ft "char *"
 .Fn SHA1File "char *filename" "char *buf"
 .Ft "char *"
-.Fn SHA1Data "u_char *data" "size_t len" "char *buf"
+.Fn SHA1Data "uint8_t *data" "size_t len" "char *buf"
 .Sh DESCRIPTION
 The SHA1 functions implement the NIST Secure Hash Algorithm (SHA-1),
 FIPS PUB 180-1.
@@ -145,14 +145,14 @@
 the string "abc" which is ``0xa9993e36476816aba3e25717850c26c9cd0d89d''.
 .Bd -literal -offset indent
 SHA1_CTX sha;
-u_char results[20];
+uint8_t results[20];
 char *buf;
 int n;
 
 buf = "abc";
 n = strlen(buf);
 SHA1Init(\*[Am]sha);
-SHA1Update(\*[Am]sha, (u_char *)buf, n);
+SHA1Update(\*[Am]sha, (uint8_t *)buf, n);
 SHA1Final(results, \*[Am]sha);
 
 /* Print the digest as one long hex value */
@@ -165,7 +165,7 @@
 Alternately, the helper functions could be used in the following way:
 .Bd -literal -offset indent
 SHA1_CTX sha;
-u_char output[41];
+uint8_t output[41];
 char *buf = "abc";
 
 printf("0x%s", SHA1Data(buf, strlen(buf), output));
diff -r 69b76d78de2d -r 56bb0a7a7ae3 sys/sys/sha1.h
--- a/sys/sys/sha1.h    Fri Nov 06 20:31:17 2009 +0000
+++ b/sys/sys/sha1.h    Fri Nov 06 20:31:18 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sha1.h,v 1.13 2005/12/26 18:41:36 perry Exp $  */
+/*     $NetBSD: sha1.h,v 1.14 2009/11/06 20:31:19 joerg Exp $  */
 
 /*
  * SHA-1 in C
@@ -18,19 +18,19 @@
 typedef struct {
        uint32_t state[5];
        uint32_t count[2];
-       u_char buffer[64];
+       uint8_t buffer[64];
 } SHA1_CTX;
 
 __BEGIN_DECLS
-void   SHA1Transform(uint32_t[5], const u_char[64]);
+void   SHA1Transform(uint32_t[5], const uint8_t[64]);
 void   SHA1Init(SHA1_CTX *);
-void   SHA1Update(SHA1_CTX *, const u_char *, u_int);
-void   SHA1Final(u_char[SHA1_DIGEST_LENGTH], SHA1_CTX *);
+void   SHA1Update(SHA1_CTX *, const uint8_t *, unsigned int);
+void   SHA1Final(uint8_t[SHA1_DIGEST_LENGTH], SHA1_CTX *);
 #ifndef _KERNEL
 char   *SHA1End(SHA1_CTX *, char *);
 char   *SHA1FileChunk(const char *, char *, off_t, off_t);
 char   *SHA1File(const char *, char *);
-char   *SHA1Data(const u_char *, size_t, char *);
+char   *SHA1Data(const uint8_t *, size_t, char *);
 #endif /* _KERNEL */
 __END_DECLS
 



Home | Main Index | Thread Index | Old Index