Commit 18ebbe24a789c26e93e7b81050a48261f73152cc

Guillem Jover 2012-05-29T05:44:54

Use stdint types instead of BSD u_int ones

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
diff --git a/include/md4.h b/include/md4.h
index c0eaac5..57f77bc 100644
--- a/include/md4.h
+++ b/include/md4.h
@@ -16,28 +16,30 @@
 #ifndef _MD4_H_
 #define _MD4_H_
 
+#include <stdint.h>
+
 #define	MD4_BLOCK_LENGTH		64
 #define	MD4_DIGEST_LENGTH		16
 #define	MD4_DIGEST_STRING_LENGTH	(MD4_DIGEST_LENGTH * 2 + 1)
 
 typedef struct MD4Context {
-	u_int32_t state[4];			/* state */
-	u_int64_t count;			/* number of bits, mod 2^64 */
-	u_int8_t buffer[MD4_BLOCK_LENGTH];	/* input buffer */
+	uint32_t state[4];			/* state */
+	uint64_t count;				/* number of bits, mod 2^64 */
+	uint8_t buffer[MD4_BLOCK_LENGTH];	/* input buffer */
 } MD4_CTX;
 
 #include <sys/cdefs.h>
 
 __BEGIN_DECLS
 void	 MD4Init(MD4_CTX *);
-void	 MD4Update(MD4_CTX *, const u_int8_t *, size_t);
+void	 MD4Update(MD4_CTX *, const uint8_t *, size_t);
 void	 MD4Pad(MD4_CTX *);
-void	 MD4Final(u_int8_t [MD4_DIGEST_LENGTH], MD4_CTX *);
-void	 MD4Transform(u_int32_t [4], const u_int8_t [MD4_BLOCK_LENGTH]);
+void	 MD4Final(uint8_t [MD4_DIGEST_LENGTH], MD4_CTX *);
+void	 MD4Transform(uint32_t [4], const uint8_t [MD4_BLOCK_LENGTH]);
 char	*MD4End(MD4_CTX *, char *);
 char	*MD4File(const char *, char *);
 char	*MD4FileChunk(const char *, char *, off_t, off_t);
-char	*MD4Data(const u_int8_t *, size_t, char *);
+char	*MD4Data(const uint8_t *, size_t, char *);
 __END_DECLS
 
 #endif /* _MD4_H_ */
diff --git a/include/md5.h b/include/md5.h
index 6e04815..e6f151e 100644
--- a/include/md5.h
+++ b/include/md5.h
@@ -15,28 +15,30 @@
 #ifndef _MD5_H_
 #define _MD5_H_
 
+#include <stdint.h>
+
 #define	MD5_BLOCK_LENGTH		64
 #define	MD5_DIGEST_LENGTH		16
 #define	MD5_DIGEST_STRING_LENGTH	(MD5_DIGEST_LENGTH * 2 + 1)
 
 typedef struct MD5Context {
-	u_int32_t state[4];			/* state */
-	u_int64_t count;			/* number of bits, mod 2^64 */
-	u_int8_t buffer[MD5_BLOCK_LENGTH];	/* input buffer */
+	uint32_t state[4];			/* state */
+	uint64_t count;				/* number of bits, mod 2^64 */
+	uint8_t buffer[MD5_BLOCK_LENGTH];	/* input buffer */
 } MD5_CTX;
 
 #include <sys/cdefs.h>
 
 __BEGIN_DECLS
 void	 MD5Init(MD5_CTX *);
-void	 MD5Update(MD5_CTX *, const u_int8_t *, size_t);
+void	 MD5Update(MD5_CTX *, const uint8_t *, size_t);
 void	 MD5Pad(MD5_CTX *);
-void	 MD5Final(u_int8_t [MD5_DIGEST_LENGTH], MD5_CTX *);
-void	 MD5Transform(u_int32_t [4], const u_int8_t [MD5_BLOCK_LENGTH]);
+void	 MD5Final(uint8_t [MD5_DIGEST_LENGTH], MD5_CTX *);
+void	 MD5Transform(uint32_t [4], const uint8_t [MD5_BLOCK_LENGTH]);
 char	*MD5End(MD5_CTX *, char *);
 char	*MD5File(const char *, char *);
 char	*MD5FileChunk(const char *, char *, off_t, off_t);
-char	*MD5Data(const u_int8_t *, size_t, char *);
+char	*MD5Data(const uint8_t *, size_t, char *);
 __END_DECLS
 
 #endif /* _MD5_H_ */
diff --git a/include/rmd160.h b/include/rmd160.h
index d7829ed..3cda0b9 100644
--- a/include/rmd160.h
+++ b/include/rmd160.h
@@ -25,29 +25,31 @@
 #ifndef  _RMD160_H
 #define  _RMD160_H
 
+#include <stdint.h>
+
 #define	RMD160_BLOCK_LENGTH		64
 #define	RMD160_DIGEST_LENGTH		20
 #define	RMD160_DIGEST_STRING_LENGTH	(RMD160_DIGEST_LENGTH * 2 + 1)
 
 /* RMD160 context. */
 typedef struct RMD160Context {
-	u_int32_t state[5];			/* state */
-	u_int64_t count;			/* number of bits, mod 2^64 */
-	u_int8_t buffer[RMD160_BLOCK_LENGTH];	/* input buffer */
+	uint32_t state[5];			/* state */
+	uint64_t count;				/* number of bits, mod 2^64 */
+	uint8_t buffer[RMD160_BLOCK_LENGTH];	/* input buffer */
 } RMD160_CTX;
 
 #include <sys/cdefs.h>
 
 __BEGIN_DECLS
 void	 RMD160Init(RMD160_CTX *);
-void	 RMD160Transform(u_int32_t [5], const u_int8_t [RMD160_BLOCK_LENGTH]);
-void	 RMD160Update(RMD160_CTX *, const u_int8_t *, size_t);
+void	 RMD160Transform(uint32_t [5], const uint8_t [RMD160_BLOCK_LENGTH]);
+void	 RMD160Update(RMD160_CTX *, const uint8_t *, size_t);
 void	 RMD160Pad(RMD160_CTX *);
-void	 RMD160Final(u_int8_t [RMD160_DIGEST_LENGTH], RMD160_CTX *);
+void	 RMD160Final(uint8_t [RMD160_DIGEST_LENGTH], RMD160_CTX *);
 char	*RMD160End(RMD160_CTX *, char *);
 char	*RMD160File(const char *, char *);
 char	*RMD160FileChunk(const char *, char *, off_t, off_t);
-char	*RMD160Data(const u_int8_t *, size_t, char *);
+char	*RMD160Data(const uint8_t *, size_t, char *);
 __END_DECLS
 
 #endif  /* _RMD160_H */
diff --git a/include/sha1.h b/include/sha1.h
index dafaf65..c56cc1b 100644
--- a/include/sha1.h
+++ b/include/sha1.h
@@ -9,14 +9,16 @@
 #ifndef _SHA1_H
 #define _SHA1_H
 
+#include <stdint.h>
+
 #define	SHA1_BLOCK_LENGTH		64
 #define	SHA1_DIGEST_LENGTH		20
 #define	SHA1_DIGEST_STRING_LENGTH	(SHA1_DIGEST_LENGTH * 2 + 1)
 
 typedef struct {
-    u_int32_t state[5];
-    u_int64_t count;
-    u_int8_t buffer[SHA1_BLOCK_LENGTH];
+    uint32_t state[5];
+    uint64_t count;
+    uint8_t buffer[SHA1_BLOCK_LENGTH];
 } SHA1_CTX;
 
 #include <sys/cdefs.h>
@@ -24,13 +26,13 @@ typedef struct {
 __BEGIN_DECLS
 void SHA1Init(SHA1_CTX *);
 void SHA1Pad(SHA1_CTX *);
-void SHA1Transform(u_int32_t [5], const u_int8_t [SHA1_BLOCK_LENGTH]);
-void SHA1Update(SHA1_CTX *, const u_int8_t *, size_t);
-void SHA1Final(u_int8_t [SHA1_DIGEST_LENGTH], SHA1_CTX *);
+void SHA1Transform(uint32_t [5], const uint8_t [SHA1_BLOCK_LENGTH]);
+void SHA1Update(SHA1_CTX *, const uint8_t *, size_t);
+void SHA1Final(uint8_t [SHA1_DIGEST_LENGTH], SHA1_CTX *);
 char *SHA1End(SHA1_CTX *, char *);
 char *SHA1File(const char *, char *);
 char *SHA1FileChunk(const char *, char *, off_t, off_t);
-char *SHA1Data(const u_int8_t *, size_t, char *);
+char *SHA1Data(const uint8_t *, size_t, char *);
 __END_DECLS
 
 #define HTONDIGEST(x) do {                                              \
diff --git a/include/sha2.h b/include/sha2.h
index f08ef79..631e6ae 100644
--- a/include/sha2.h
+++ b/include/sha2.h
@@ -37,6 +37,7 @@
 #ifndef _SHA2_H
 #define _SHA2_H
 
+#include <stdint.h>
 
 /*** SHA-256/384/512 Various Length Definitions ***********************/
 #define SHA256_BLOCK_LENGTH		64
@@ -53,45 +54,45 @@
 /*** SHA-256/384/512 Context Structure *******************************/
 typedef struct _SHA2_CTX {
 	union {
-		u_int32_t	st32[8];
-		u_int64_t	st64[8];
+		uint32_t	st32[8];
+		uint64_t	st64[8];
 	} state;
-	u_int64_t	bitcount[2];
-	u_int8_t	buffer[SHA512_BLOCK_LENGTH];
+	uint64_t	bitcount[2];
+	uint8_t		buffer[SHA512_BLOCK_LENGTH];
 } SHA2_CTX;
 
 #include <sys/cdefs.h>
 
 __BEGIN_DECLS
 void SHA256Init(SHA2_CTX *);
-void SHA256Transform(u_int32_t state[8], const u_int8_t [SHA256_BLOCK_LENGTH]);
-void SHA256Update(SHA2_CTX *, const u_int8_t *, size_t);
+void SHA256Transform(uint32_t state[8], const uint8_t [SHA256_BLOCK_LENGTH]);
+void SHA256Update(SHA2_CTX *, const uint8_t *, size_t);
 void SHA256Pad(SHA2_CTX *);
-void SHA256Final(u_int8_t [SHA256_DIGEST_LENGTH], SHA2_CTX *);
+void SHA256Final(uint8_t [SHA256_DIGEST_LENGTH], SHA2_CTX *);
 char *SHA256End(SHA2_CTX *, char *);
 char *SHA256File(const char *, char *);
 char *SHA256FileChunk(const char *, char *, off_t, off_t);
-char *SHA256Data(const u_int8_t *, size_t, char *);
+char *SHA256Data(const uint8_t *, size_t, char *);
 
 void SHA384Init(SHA2_CTX *);
-void SHA384Transform(u_int64_t state[8], const u_int8_t [SHA384_BLOCK_LENGTH]);
-void SHA384Update(SHA2_CTX *, const u_int8_t *, size_t);
+void SHA384Transform(uint64_t state[8], const uint8_t [SHA384_BLOCK_LENGTH]);
+void SHA384Update(SHA2_CTX *, const uint8_t *, size_t);
 void SHA384Pad(SHA2_CTX *);
-void SHA384Final(u_int8_t [SHA384_DIGEST_LENGTH], SHA2_CTX *);
+void SHA384Final(uint8_t [SHA384_DIGEST_LENGTH], SHA2_CTX *);
 char *SHA384End(SHA2_CTX *, char *);
 char *SHA384File(const char *, char *);
 char *SHA384FileChunk(const char *, char *, off_t, off_t);
-char *SHA384Data(const u_int8_t *, size_t, char *);
+char *SHA384Data(const uint8_t *, size_t, char *);
 
 void SHA512Init(SHA2_CTX *);
-void SHA512Transform(u_int64_t state[8], const u_int8_t [SHA512_BLOCK_LENGTH]);
-void SHA512Update(SHA2_CTX *, const u_int8_t *, size_t);
+void SHA512Transform(uint64_t state[8], const uint8_t [SHA512_BLOCK_LENGTH]);
+void SHA512Update(SHA2_CTX *, const uint8_t *, size_t);
 void SHA512Pad(SHA2_CTX *);
-void SHA512Final(u_int8_t [SHA512_DIGEST_LENGTH], SHA2_CTX *);
+void SHA512Final(uint8_t [SHA512_DIGEST_LENGTH], SHA2_CTX *);
 char *SHA512End(SHA2_CTX *, char *);
 char *SHA512File(const char *, char *);
 char *SHA512FileChunk(const char *, char *, off_t, off_t);
-char *SHA512Data(const u_int8_t *, size_t, char *);
+char *SHA512Data(const uint8_t *, size_t, char *);
 __END_DECLS
 
 #endif /* _SHA2_H */
diff --git a/man/mdX.3 b/man/mdX.3
index f411d8c..b27f5f3 100644
--- a/man/mdX.3
+++ b/man/mdX.3
@@ -32,13 +32,13 @@ message digest
 .Ft void
 .Fn MDXInit "MDX_CTX *context"
 .Ft void
-.Fn MDXUpdate "MDX_CTX *context" "const u_int8_t *data" "size_t len"
+.Fn MDXUpdate "MDX_CTX *context" "const uint8_t *data" "size_t len"
 .Ft void
 .Fn MDXPad "MDX_CTX *context"
 .Ft void
-.Fn MDXFinal "u_int8_t digest[MDX_DIGEST_LENGTH]" "MDX_CTX *context"
+.Fn MDXFinal "uint8_t digest[MDX_DIGEST_LENGTH]" "MDX_CTX *context"
 .Ft void
-.Fn MDXTransform "u_int32_t state[4]" "u_int8_t block[MDX_BLOCK_LENGTH]"
+.Fn MDXTransform "uint32_t state[4]" "uint8_t block[MDX_BLOCK_LENGTH]"
 .Ft "char *"
 .Fn MDXEnd "MDX_CTX *context" "char *buf"
 .Ft "char *"
@@ -46,7 +46,7 @@ message digest
 .Ft "char *"
 .Fn MDXFileChunk "const char *filename" "char *buf" "off_t offset" "off_t length"
 .Ft "char *"
-.Fn MDXData "const u_int8_t *data" "size_t len" "char *buf"
+.Fn MDXData "const uint8_t *data" "size_t len" "char *buf"
 .Sh DESCRIPTION
 The MDX functions calculate a 128-bit cryptographic checksum (digest)
 for any number of input bytes.
diff --git a/man/rmd160.3 b/man/rmd160.3
index f619c98..c22b46e 100644
--- a/man/rmd160.3
+++ b/man/rmd160.3
@@ -39,13 +39,13 @@
 .Ft void
 .Fn RMD160Init "RMD160_CTX *context"
 .Ft void
-.Fn RMD160Update "RMD160_CTX *context" "const u_int8_t *data" "u_int32_t nbytes"
+.Fn RMD160Update "RMD160_CTX *context" "const uint8_t *data" "uint32_t nbytes"
 .Ft void
 .Fn RMD160Pad "RMD160_CTX *context"
 .Ft void
-.Fn RMD160Final "u_int8_t digest[RMD160_DIGEST_LENGTH]" "RMD160_CTX *context"
+.Fn RMD160Final "uint8_t digest[RMD160_DIGEST_LENGTH]" "RMD160_CTX *context"
 .Ft void
-.Fn RMD160Transform "u_int32_t state[5]" "const u_int8_t block[RMD160_BLOCK_LENGTH]"
+.Fn RMD160Transform "uint32_t state[5]" "const uint8_t block[RMD160_BLOCK_LENGTH]"
 .Ft "char *"
 .Fn RMD160End "RMD160_CTX *context" "char *buf"
 .Ft "char *"
@@ -53,7 +53,7 @@
 .Ft "char *"
 .Fn RMD160FileChunk "const char *filename" "char *buf" "off_t offset" "off_t length"
 .Ft "char *"
-.Fn RMD160Data "const u_int8_t *data" "size_t len" "char *buf"
+.Fn RMD160Data "const uint8_t *data" "size_t len" "char *buf"
 .Sh DESCRIPTION
 The RMD160 functions implement the 160-bit RIPE message digest hash algorithm
 (RMD-160).
@@ -174,14 +174,14 @@ The follow code fragment will calculate the digest for
 the string "abc" which is ``0x8eb208f7e05d987a9b044a8e98c6b087f15a0bfc''.
 .Bd -literal -offset indent
 RMD160_CTX rmd;
-u_int8_t results[RMD160_DIGEST_LENGTH];
+uint8_t results[RMD160_DIGEST_LENGTH];
 char *buf;
 int n;
 
 buf = "abc";
 n = strlen(buf);
 RMD160Init(&rmd);
-RMD160Update(&rmd, (u_int8_t *)buf, n);
+RMD160Update(&rmd, (uint8_t *)buf, n);
 RMD160Final(results, &rmd);
 
 /* Print the digest as one long hex value */
@@ -194,7 +194,7 @@ putchar('\en');
 Alternately, the helper functions could be used in the following way:
 .Bd -literal -offset indent
 RMD160_CTX rmd;
-u_int8_t output[RMD160_DIGEST_STRING_LENGTH];
+uint8_t output[RMD160_DIGEST_STRING_LENGTH];
 char *buf = "abc";
 
 printf("0x%s\en", RMD160Data(buf, strlen(buf), output));
diff --git a/man/sha1.3 b/man/sha1.3
index 2250c41..088d949 100644
--- a/man/sha1.3
+++ b/man/sha1.3
@@ -39,13 +39,13 @@
 .Ft void
 .Fn SHA1Init "SHA1_CTX *context"
 .Ft void
-.Fn SHA1Update "SHA1_CTX *context" "const u_int8_t *data" "size_t len"
+.Fn SHA1Update "SHA1_CTX *context" "const uint8_t *data" "size_t len"
 .Ft void
 .Fn SHA1Pad "SHA1_CTX *context"
 .Ft void
-.Fn SHA1Final "u_int8_t digest[SHA1_DIGEST_LENGTH]" "SHA1_CTX *context"
+.Fn SHA1Final "uint8_t digest[SHA1_DIGEST_LENGTH]" "SHA1_CTX *context"
 .Ft void
-.Fn SHA1Transform "u_int32_t state[5]" "const u_int8_t buffer[SHA1_BLOCK_LENGTH]"
+.Fn SHA1Transform "uint32_t state[5]" "const uint8_t buffer[SHA1_BLOCK_LENGTH]"
 .Ft "char *"
 .Fn SHA1End "SHA1_CTX *context" "char *buf"
 .Ft "char *"
@@ -53,7 +53,7 @@
 .Ft "char *"
 .Fn SHA1FileChunk "const char *filename" "char *buf" "off_t offset" "off_t length"
 .Ft "char *"
-.Fn SHA1Data "const u_int8_t *data" "size_t len" "char *buf"
+.Fn SHA1Data "const 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.
@@ -171,14 +171,14 @@ The follow code fragment will calculate the digest for
 the string "abc" which is ``0xa9993e364706816aba3e25717850c26c9cd0d89d''.
 .Bd -literal -offset indent
 SHA1_CTX sha;
-u_int8_t results[SHA1_DIGEST_LENGTH];
+uint8_t results[SHA1_DIGEST_LENGTH];
 char *buf;
 int n;
 
 buf = "abc";
 n = strlen(buf);
 SHA1Init(&sha);
-SHA1Update(&sha, (u_int8_t *)buf, n);
+SHA1Update(&sha, (uint8_t *)buf, n);
 SHA1Final(results, &sha);
 
 /* Print the digest as one long hex value */
@@ -190,7 +190,7 @@ putchar('\en');
 .Pp
 Alternately, the helper functions could be used in the following way:
 .Bd -literal -offset indent
-u_int8_t output[SHA1_DIGEST_STRING_LENGTH];
+uint8_t output[SHA1_DIGEST_STRING_LENGTH];
 char *buf = "abc";
 
 printf("0x%s\en", SHA1Data(buf, strlen(buf), output));
diff --git a/man/sha2.3 b/man/sha2.3
index 39e36b6..dd977a1 100644
--- a/man/sha2.3
+++ b/man/sha2.3
@@ -42,13 +42,13 @@
 .Ft void
 .Fn SHA256Init "SHA2_CTX *context"
 .Ft void
-.Fn SHA256Update "SHA2_CTX *context" "const u_int8_t *data" "size_t len"
+.Fn SHA256Update "SHA2_CTX *context" "const uint8_t *data" "size_t len"
 .Ft void
 .Fn SHA256Pad "SHA2_CTX *context"
 .Ft void
-.Fn SHA256Final "u_int8_t digest[SHA256_DIGEST_LENGTH]" "SHA2_CTX *context"
+.Fn SHA256Final "uint8_t digest[SHA256_DIGEST_LENGTH]" "SHA2_CTX *context"
 .Ft void
-.Fn SHA256Transform "u_int32_t state[8]" "const u_int8_t buffer[SHA256_BLOCK_LENGTH]"
+.Fn SHA256Transform "uint32_t state[8]" "const uint8_t buffer[SHA256_BLOCK_LENGTH]"
 .Ft "char *"
 .Fn SHA256End "SHA2_CTX *context" "char *buf"
 .Ft "char *"
@@ -56,17 +56,17 @@
 .Ft "char *"
 .Fn SHA256FileChunk "const char *filename" "char *buf" "off_t offset" "off_t length"
 .Ft "char *"
-.Fn SHA256Data "u_int8_t *data" "size_t len" "char *buf"
+.Fn SHA256Data "uint8_t *data" "size_t len" "char *buf"
 .Ft void
 .Fn SHA384Init "SHA2_CTX *context"
 .Ft void
-.Fn SHA384Update "SHA2_CTX *context" "const u_int8_t *data" "size_t len"
+.Fn SHA384Update "SHA2_CTX *context" "const uint8_t *data" "size_t len"
 .Ft void
 .Fn SHA384Pad "SHA2_CTX *context"
 .Ft void
-.Fn SHA384Final "u_int8_t digest[SHA384_DIGEST_LENGTH]" "SHA2_CTX *context"
+.Fn SHA384Final "uint8_t digest[SHA384_DIGEST_LENGTH]" "SHA2_CTX *context"
 .Ft void
-.Fn SHA384Transform "u_int64_t state[8]" "const u_int8_t buffer[SHA384_BLOCK_LENGTH]"
+.Fn SHA384Transform "uint64_t state[8]" "const uint8_t buffer[SHA384_BLOCK_LENGTH]"
 .Ft "char *"
 .Fn SHA384End "SHA2_CTX *context" "char *buf"
 .Ft "char *"
@@ -74,17 +74,17 @@
 .Ft "char *"
 .Fn SHA384FileChunk "char *filename" "char *buf" "off_t offset" "off_t length"
 .Ft "char *"
-.Fn SHA384Data "u_int8_t *data" "size_t len" "char *buf"
+.Fn SHA384Data "uint8_t *data" "size_t len" "char *buf"
 .Ft void
 .Fn SHA512Init "SHA2_CTX *context"
 .Ft void
-.Fn SHA512Update "SHA2_CTX *context" "const u_int8_t *data" "size_t len"
+.Fn SHA512Update "SHA2_CTX *context" "const uint8_t *data" "size_t len"
 .Ft void
 .Fn SHA512Pad "SHA2_CTX *context"
 .Ft void
-.Fn SHA512Final "u_int8_t digest[SHA512_DIGEST_LENGTH]" "SHA2_CTX *context"
+.Fn SHA512Final "uint8_t digest[SHA512_DIGEST_LENGTH]" "SHA2_CTX *context"
 .Ft void
-.Fn SHA512Transform "u_int64_t state[8]" "const u_int8_t buffer[SHA512_BLOCK_LENGTH]"
+.Fn SHA512Transform "uint64_t state[8]" "const uint8_t buffer[SHA512_BLOCK_LENGTH]"
 .Ft "char *"
 .Fn SHA512End "SHA2_CTX *context" "char *buf"
 .Ft "char *"
@@ -92,7 +92,7 @@
 .Ft "char *"
 .Fn SHA512FileChunk "char *filename" "char *buf" "off_t offset" "off_t length"
 .Ft "char *"
-.Fn SHA512Data "u_int8_t *data" "size_t len" "char *buf"
+.Fn SHA512Data "uint8_t *data" "size_t len" "char *buf"
 .Sh DESCRIPTION
 The SHA2 functions implement the NIST Secure Hash Standard,
 FIPS PUB 180-2.
@@ -226,14 +226,14 @@ which is
 .Dq 0xba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad .
 .Bd -literal -offset indent
 SHA2_CTX ctx;
-u_int8_t results[SHA256_DIGEST_LENGTH];
+uint8_t results[SHA256_DIGEST_LENGTH];
 char *buf;
 int n;
 
 buf = "abc";
 n = strlen(buf);
 SHA256Init(&ctx);
-SHA256Update(&ctx, (u_int8_t *)buf, n);
+SHA256Update(&ctx, (uint8_t *)buf, n);
 SHA256Final(results, &ctx);
 
 /* Print the digest as one long hex value */
@@ -245,7 +245,7 @@ putchar('\en');
 .Pp
 Alternately, the helper functions could be used in the following way:
 .Bd -literal -offset indent
-u_int8_t output[SHA256_DIGEST_STRING_LENGTH];
+uint8_t output[SHA256_DIGEST_STRING_LENGTH];
 char *buf = "abc";
 
 printf("0x%s\en", SHA256Data(buf, strlen(buf), output));
diff --git a/src/helper.c b/src/helper.c
index 27d053b..5b16ec1 100644
--- a/src/helper.c
+++ b/src/helper.c
@@ -26,7 +26,7 @@ char *
 HASHEnd(HASH_CTX *ctx, char *buf)
 {
 	int i;
-	u_int8_t digest[HASH_DIGEST_LENGTH];
+	uint8_t digest[HASH_DIGEST_LENGTH];
 	static const char hex[] = "0123456789abcdef";
 
 	if (buf == NULL && (buf = malloc(HASH_DIGEST_STRING_LENGTH)) == NULL)
@@ -46,7 +46,7 @@ char *
 HASHFileChunk(const char *filename, char *buf, off_t off, off_t len)
 {
 	struct stat sb;
-	u_char buffer[BUFSIZ];
+	uint8_t buffer[BUFSIZ];
 	HASH_CTX ctx;
 	int fd, save_errno;
 	ssize_t nr;
@@ -86,7 +86,7 @@ HASHFile(const char *filename, char *buf)
 }
 
 char *
-HASHData(const u_char *data, size_t len, char *buf)
+HASHData(const uint8_t *data, size_t len, char *buf)
 {
 	HASH_CTX ctx;
 
diff --git a/src/md4.c b/src/md4.c
index 88f8b3b..cf32b29 100644
--- a/src/md4.c
+++ b/src/md4.c
@@ -38,7 +38,7 @@
 	(cp)[1] = (value) >> 8;						\
 	(cp)[0] = (value); } while (0)
 
-static u_int8_t PADDING[MD4_BLOCK_LENGTH] = {
+static uint8_t PADDING[MD4_BLOCK_LENGTH] = {
 	0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
@@ -72,7 +72,7 @@ MD4Update(MD4_CTX *ctx, const unsigned char *input, size_t len)
 	need = MD4_BLOCK_LENGTH - have;
 
 	/* Update bitcount */
-	ctx->count += (u_int64_t)len << 3;
+	ctx->count += (uint64_t)len << 3;
 
 	if (len >= need) {
 		if (have != 0) {
@@ -103,7 +103,7 @@ MD4Update(MD4_CTX *ctx, const unsigned char *input, size_t len)
 void
 MD4Pad(MD4_CTX *ctx)
 {
-	u_int8_t count[8];
+	uint8_t count[8];
 	size_t padlen;
 
 	/* Convert count to 8 bytes in little endian order. */
@@ -152,19 +152,19 @@ MD4Final(unsigned char digest[MD4_DIGEST_LENGTH], MD4_CTX *ctx)
  * the data and converts bytes into longwords for this routine.
  */
 void
-MD4Transform(u_int32_t state[4], const u_int8_t block[MD4_BLOCK_LENGTH])
+MD4Transform(uint32_t state[4], const uint8_t block[MD4_BLOCK_LENGTH])
 {
-	u_int32_t a, b, c, d, in[MD4_BLOCK_LENGTH / 4];
+	uint32_t a, b, c, d, in[MD4_BLOCK_LENGTH / 4];
 
 #if BYTE_ORDER == LITTLE_ENDIAN
 	memcpy(in, block, sizeof(in));
 #else
 	for (a = 0; a < MD4_BLOCK_LENGTH / 4; a++) {
-		in[a] = (u_int32_t)(
-		    (u_int32_t)(block[a * 4 + 0]) |
-		    (u_int32_t)(block[a * 4 + 1]) <<  8 |
-		    (u_int32_t)(block[a * 4 + 2]) << 16 |
-		    (u_int32_t)(block[a * 4 + 3]) << 24);
+		in[a] = (uint32_t)(
+		    (uint32_t)(block[a * 4 + 0]) |
+		    (uint32_t)(block[a * 4 + 1]) <<  8 |
+		    (uint32_t)(block[a * 4 + 2]) << 16 |
+		    (uint32_t)(block[a * 4 + 3]) << 24);
 	}
 #endif
 
diff --git a/src/md5.c b/src/md5.c
index ceea701..0fc118a 100644
--- a/src/md5.c
+++ b/src/md5.c
@@ -37,7 +37,7 @@
 	(cp)[1] = (value) >> 8;						\
 	(cp)[0] = (value); } while (0)
 
-static u_int8_t PADDING[MD5_BLOCK_LENGTH] = {
+static uint8_t PADDING[MD5_BLOCK_LENGTH] = {
 	0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
@@ -71,7 +71,7 @@ MD5Update(MD5_CTX *ctx, const unsigned char *input, size_t len)
 	need = MD5_BLOCK_LENGTH - have;
 
 	/* Update bitcount */
-	ctx->count += (u_int64_t)len << 3;
+	ctx->count += (uint64_t)len << 3;
 
 	if (len >= need) {
 		if (have != 0) {
@@ -102,7 +102,7 @@ MD5Update(MD5_CTX *ctx, const unsigned char *input, size_t len)
 void
 MD5Pad(MD5_CTX *ctx)
 {
-	u_int8_t count[8];
+	uint8_t count[8];
 	size_t padlen;
 
 	/* Convert count to 8 bytes in little endian order. */
@@ -152,19 +152,19 @@ MD5Final(unsigned char digest[MD5_DIGEST_LENGTH], MD5_CTX *ctx)
  * the data and converts bytes into longwords for this routine.
  */
 void
-MD5Transform(u_int32_t state[4], const u_int8_t block[MD5_BLOCK_LENGTH])
+MD5Transform(uint32_t state[4], const uint8_t block[MD5_BLOCK_LENGTH])
 {
-	u_int32_t a, b, c, d, in[MD5_BLOCK_LENGTH / 4];
+	uint32_t a, b, c, d, in[MD5_BLOCK_LENGTH / 4];
 
 #if BYTE_ORDER == LITTLE_ENDIAN
 	memcpy(in, block, sizeof(in));
 #else
 	for (a = 0; a < MD5_BLOCK_LENGTH / 4; a++) {
-		in[a] = (u_int32_t)(
-		    (u_int32_t)(block[a * 4 + 0]) |
-		    (u_int32_t)(block[a * 4 + 1]) <<  8 |
-		    (u_int32_t)(block[a * 4 + 2]) << 16 |
-		    (u_int32_t)(block[a * 4 + 3]) << 24);
+		in[a] = (uint32_t)(
+		    (uint32_t)(block[a * 4 + 0]) |
+		    (uint32_t)(block[a * 4 + 1]) <<  8 |
+		    (uint32_t)(block[a * 4 + 2]) << 16 |
+		    (uint32_t)(block[a * 4 + 3]) << 24);
 	}
 #endif
 
diff --git a/src/rmd160.c b/src/rmd160.c
index 9bfc348..d68f2e4 100644
--- a/src/rmd160.c
+++ b/src/rmd160.c
@@ -86,7 +86,7 @@
 
 #define X(i)	x[i]
 
-static u_int8_t PADDING[RMD160_BLOCK_LENGTH] = {
+static uint8_t PADDING[RMD160_BLOCK_LENGTH] = {
 	0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
@@ -104,7 +104,7 @@ RMD160Init(RMD160_CTX *ctx)
 }
 
 void
-RMD160Update(RMD160_CTX *ctx, const u_int8_t *input, size_t len)
+RMD160Update(RMD160_CTX *ctx, const uint8_t *input, size_t len)
 {
 	size_t have, off, need;
 
@@ -133,7 +133,7 @@ RMD160Update(RMD160_CTX *ctx, const u_int8_t *input, size_t len)
 void
 RMD160Pad(RMD160_CTX *ctx)
 {
-	u_int8_t size[8];
+	uint8_t size[8];
 	size_t padlen;
 
 	PUT_64BIT_LE(size, ctx->count);
@@ -150,7 +150,7 @@ RMD160Pad(RMD160_CTX *ctx)
 }
 
 void
-RMD160Final(u_int8_t digest[RMD160_DIGEST_LENGTH], RMD160_CTX *ctx)
+RMD160Final(uint8_t digest[RMD160_DIGEST_LENGTH], RMD160_CTX *ctx)
 {
 	int i;
 
@@ -163,9 +163,9 @@ RMD160Final(u_int8_t digest[RMD160_DIGEST_LENGTH], RMD160_CTX *ctx)
 }
 
 void
-RMD160Transform(u_int32_t state[5], const u_int8_t block[RMD160_BLOCK_LENGTH])
+RMD160Transform(uint32_t state[5], const uint8_t block[RMD160_BLOCK_LENGTH])
 {
-	u_int32_t a, b, c, d, e, aa, bb, cc, dd, ee, t, x[16];
+	uint32_t a, b, c, d, e, aa, bb, cc, dd, ee, t, x[16];
 
 #if BYTE_ORDER == LITTLE_ENDIAN
 	memcpy(x, block, RMD160_BLOCK_LENGTH);
@@ -173,11 +173,11 @@ RMD160Transform(u_int32_t state[5], const u_int8_t block[RMD160_BLOCK_LENGTH])
 	int i;
 
 	for (i = 0; i < 16; i++)
-		x[i] = (u_int32_t)(
-		    (u_int32_t)(block[i*4 + 0]) |
-		    (u_int32_t)(block[i*4 + 1]) <<  8 |
-		    (u_int32_t)(block[i*4 + 2]) << 16 |
-		    (u_int32_t)(block[i*4 + 3]) << 24);
+		x[i] = (uint32_t)(
+		    (uint32_t)(block[i*4 + 0]) |
+		    (uint32_t)(block[i*4 + 1]) <<  8 |
+		    (uint32_t)(block[i*4 + 2]) << 16 |
+		    (uint32_t)(block[i*4 + 3]) << 24);
 #endif
 
 	a = state[0];
diff --git a/src/sha1.c b/src/sha1.c
index f2ca7c0..9f69f15 100644
--- a/src/sha1.c
+++ b/src/sha1.c
@@ -43,15 +43,15 @@
 #define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
 
 typedef union {
-	u_int8_t c[64];
-	u_int32_t l[16];
+	uint8_t c[64];
+	uint32_t l[16];
 } CHAR64LONG16;
 
 #ifdef __sh__
-static void do_R01(u_int32_t *a, u_int32_t *b, u_int32_t *c, u_int32_t *d, u_int32_t *e, CHAR64LONG16 *);
-static void do_R2(u_int32_t *a, u_int32_t *b, u_int32_t *c, u_int32_t *d, u_int32_t *e, CHAR64LONG16 *);
-static void do_R3(u_int32_t *a, u_int32_t *b, u_int32_t *c, u_int32_t *d, u_int32_t *e, CHAR64LONG16 *);
-static void do_R4(u_int32_t *a, u_int32_t *b, u_int32_t *c, u_int32_t *d, u_int32_t *e, CHAR64LONG16 *);
+static void do_R01(uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d, uint32_t *e, CHAR64LONG16 *);
+static void do_R2(uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d, uint32_t *e, CHAR64LONG16 *);
+static void do_R3(uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d, uint32_t *e, CHAR64LONG16 *);
+static void do_R4(uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d, uint32_t *e, CHAR64LONG16 *);
 
 #define nR0(v,w,x,y,z,i) R0(*v,*w,*x,*y,*z,i)
 #define nR1(v,w,x,y,z,i) R1(*v,*w,*x,*y,*z,i)
@@ -60,7 +60,7 @@ static void do_R4(u_int32_t *a, u_int32_t *b, u_int32_t *c, u_int32_t *d, u_int3
 #define nR4(v,w,x,y,z,i) R4(*v,*w,*x,*y,*z,i)
 
 static void
-do_R01(u_int32_t *a, u_int32_t *b, u_int32_t *c, u_int32_t *d, u_int32_t *e, CHAR64LONG16 *block)
+do_R01(uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d, uint32_t *e, CHAR64LONG16 *block)
 {
     nR0(a,b,c,d,e, 0); nR0(e,a,b,c,d, 1); nR0(d,e,a,b,c, 2); nR0(c,d,e,a,b, 3);
     nR0(b,c,d,e,a, 4); nR0(a,b,c,d,e, 5); nR0(e,a,b,c,d, 6); nR0(d,e,a,b,c, 7);
@@ -70,7 +70,7 @@ do_R01(u_int32_t *a, u_int32_t *b, u_int32_t *c, u_int32_t *d, u_int32_t *e, CHA
 }
 
 static void
-do_R2(u_int32_t *a, u_int32_t *b, u_int32_t *c, u_int32_t *d, u_int32_t *e, CHAR64LONG16 *block)
+do_R2(uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d, uint32_t *e, CHAR64LONG16 *block)
 {
     nR2(a,b,c,d,e,20); nR2(e,a,b,c,d,21); nR2(d,e,a,b,c,22); nR2(c,d,e,a,b,23);
     nR2(b,c,d,e,a,24); nR2(a,b,c,d,e,25); nR2(e,a,b,c,d,26); nR2(d,e,a,b,c,27);
@@ -80,7 +80,7 @@ do_R2(u_int32_t *a, u_int32_t *b, u_int32_t *c, u_int32_t *d, u_int32_t *e, CHAR
 }
 
 static void
-do_R3(u_int32_t *a, u_int32_t *b, u_int32_t *c, u_int32_t *d, u_int32_t *e, CHAR64LONG16 *block)
+do_R3(uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d, uint32_t *e, CHAR64LONG16 *block)
 {
     nR3(a,b,c,d,e,40); nR3(e,a,b,c,d,41); nR3(d,e,a,b,c,42); nR3(c,d,e,a,b,43);
     nR3(b,c,d,e,a,44); nR3(a,b,c,d,e,45); nR3(e,a,b,c,d,46); nR3(d,e,a,b,c,47);
@@ -90,7 +90,7 @@ do_R3(u_int32_t *a, u_int32_t *b, u_int32_t *c, u_int32_t *d, u_int32_t *e, CHAR
 }
 
 static void
-do_R4(u_int32_t *a, u_int32_t *b, u_int32_t *c, u_int32_t *d, u_int32_t *e, CHAR64LONG16 *block)
+do_R4(uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d, uint32_t *e, CHAR64LONG16 *block)
 {
     nR4(a,b,c,d,e,60); nR4(e,a,b,c,d,61); nR4(d,e,a,b,c,62); nR4(c,d,e,a,b,63);
     nR4(b,c,d,e,a,64); nR4(a,b,c,d,e,65); nR4(e,a,b,c,d,66); nR4(d,e,a,b,c,67);
@@ -104,10 +104,10 @@ do_R4(u_int32_t *a, u_int32_t *b, u_int32_t *c, u_int32_t *d, u_int32_t *e, CHAR
  * Hash a single 512-bit block. This is the core of the algorithm.
  */
 void
-SHA1Transform(u_int32_t state[5], const u_int8_t buffer[SHA1_BLOCK_LENGTH])
+SHA1Transform(uint32_t state[5], const uint8_t buffer[SHA1_BLOCK_LENGTH])
 {
-	u_int32_t a, b, c, d, e;
-	u_int8_t workspace[SHA1_BLOCK_LENGTH];
+	uint32_t a, b, c, d, e;
+	uint8_t workspace[SHA1_BLOCK_LENGTH];
 	CHAR64LONG16 *block = (CHAR64LONG16 *)workspace;
 
 	(void)memcpy(block, buffer, SHA1_BLOCK_LENGTH);
@@ -181,7 +181,7 @@ SHA1Init(SHA1_CTX *context)
  * Run your data through this.
  */
 void
-SHA1Update(SHA1_CTX *context, const u_int8_t *data, size_t len)
+SHA1Update(SHA1_CTX *context, const uint8_t *data, size_t len)
 {
 	size_t i, j;
 
@@ -191,7 +191,7 @@ SHA1Update(SHA1_CTX *context, const u_int8_t *data, size_t len)
 		(void)memcpy(&context->buffer[j], data, (i = 64-j));
 		SHA1Transform(context->state, context->buffer);
 		for ( ; i + 63 < len; i += 64)
-			SHA1Transform(context->state, (u_int8_t *)&data[i]);
+			SHA1Transform(context->state, (uint8_t *)&data[i]);
 		j = 0;
 	} else {
 		i = 0;
@@ -206,28 +206,28 @@ SHA1Update(SHA1_CTX *context, const u_int8_t *data, size_t len)
 void
 SHA1Pad(SHA1_CTX *context)
 {
-	u_int8_t finalcount[8];
-	u_int i;
+	uint8_t finalcount[8];
+	unsigned int i;
 
 	for (i = 0; i < 8; i++) {
-		finalcount[i] = (u_int8_t)((context->count >>
+		finalcount[i] = (uint8_t)((context->count >>
 		    ((7 - (i & 7)) * 8)) & 255);	/* Endian independent */
 	}
-	SHA1Update(context, (u_int8_t *)"\200", 1);
+	SHA1Update(context, (uint8_t *)"\200", 1);
 	while ((context->count & 504) != 448)
-		SHA1Update(context, (u_int8_t *)"\0", 1);
+		SHA1Update(context, (uint8_t *)"\0", 1);
 	SHA1Update(context, finalcount, 8); /* Should cause a SHA1Transform() */
 }
 
 void
-SHA1Final(u_int8_t digest[SHA1_DIGEST_LENGTH], SHA1_CTX *context)
+SHA1Final(uint8_t digest[SHA1_DIGEST_LENGTH], SHA1_CTX *context)
 {
-	u_int i;
+	unsigned int i;
 
 	SHA1Pad(context);
 	if (digest) {
 		for (i = 0; i < SHA1_DIGEST_LENGTH; i++) {
-			digest[i] = (u_int8_t)
+			digest[i] = (uint8_t)
 			   ((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255);
 		}
 		memset(context, 0, sizeof(*context));
diff --git a/src/sha2.c b/src/sha2.c
index b4f72e5..029d0d4 100644
--- a/src/sha2.c
+++ b/src/sha2.c
@@ -100,15 +100,15 @@
 
 /*** ENDIAN SPECIFIC COPY MACROS **************************************/
 #define BE_8_TO_32(dst, cp) do {					\
-	(dst) = (u_int32_t)(cp)[3] | ((u_int32_t)(cp)[2] << 8) |	\
-	    ((u_int32_t)(cp)[1] << 16) | ((u_int32_t)(cp)[0] << 24);	\
+	(dst) = (uint32_t)(cp)[3] | ((uint32_t)(cp)[2] << 8) |		\
+	    ((uint32_t)(cp)[1] << 16) | ((uint32_t)(cp)[0] << 24);	\
 } while(0)
 
 #define BE_8_TO_64(dst, cp) do {					\
-	(dst) = (u_int64_t)(cp)[7] | ((u_int64_t)(cp)[6] << 8) |	\
-	    ((u_int64_t)(cp)[5] << 16) | ((u_int64_t)(cp)[4] << 24) |	\
-	    ((u_int64_t)(cp)[3] << 32) | ((u_int64_t)(cp)[2] << 40) |	\
-	    ((u_int64_t)(cp)[1] << 48) | ((u_int64_t)(cp)[0] << 56);	\
+	(dst) = (uint64_t)(cp)[7] | ((uint64_t)(cp)[6] << 8) |		\
+	    ((uint64_t)(cp)[5] << 16) | ((uint64_t)(cp)[4] << 24) |	\
+	    ((uint64_t)(cp)[3] << 32) | ((uint64_t)(cp)[2] << 40) |	\
+	    ((uint64_t)(cp)[1] << 48) | ((uint64_t)(cp)[0] << 56);	\
 } while (0)
 
 #define BE_64_TO_8(cp, src) do {					\
@@ -135,7 +135,7 @@
  * 64-bit words):
  */
 #define ADDINC128(w,n) do {						\
-	(w)[0] += (u_int64_t)(n);					\
+	(w)[0] += (uint64_t)(n);					\
 	if ((w)[0] < (n)) {						\
 		(w)[1]++;						\
 	}								\
@@ -176,7 +176,7 @@
 
 /*** SHA-XYZ INITIAL HASH VALUES AND CONSTANTS ************************/
 /* Hash constant words K for SHA-256: */
-const static u_int32_t K256[64] = {
+const static uint32_t K256[64] = {
 	0x428a2f98UL, 0x71374491UL, 0xb5c0fbcfUL, 0xe9b5dba5UL,
 	0x3956c25bUL, 0x59f111f1UL, 0x923f82a4UL, 0xab1c5ed5UL,
 	0xd807aa98UL, 0x12835b01UL, 0x243185beUL, 0x550c7dc3UL,
@@ -196,7 +196,7 @@ const static u_int32_t K256[64] = {
 };
 
 /* Initial hash value H for SHA-256: */
-const static u_int32_t sha256_initial_hash_value[8] = {
+const static uint32_t sha256_initial_hash_value[8] = {
 	0x6a09e667UL,
 	0xbb67ae85UL,
 	0x3c6ef372UL,
@@ -209,7 +209,7 @@ const static u_int32_t sha256_initial_hash_value[8] = {
 
 #ifndef SHA256_ONLY
 /* Hash constant words K for SHA-384 and SHA-512: */
-const static u_int64_t K512[80] = {
+const static uint64_t K512[80] = {
 	0x428a2f98d728ae22ULL, 0x7137449123ef65cdULL,
 	0xb5c0fbcfec4d3b2fULL, 0xe9b5dba58189dbbcULL,
 	0x3956c25bf348b538ULL, 0x59f111f1b605d019ULL,
@@ -253,7 +253,7 @@ const static u_int64_t K512[80] = {
 };
 
 /* Initial hash value H for SHA-384 */
-const static u_int64_t sha384_initial_hash_value[8] = {
+const static uint64_t sha384_initial_hash_value[8] = {
 	0xcbbb9d5dc1059ed8ULL,
 	0x629a292a367cd507ULL,
 	0x9159015a3070dd17ULL,
@@ -265,7 +265,7 @@ const static u_int64_t sha384_initial_hash_value[8] = {
 };
 
 /* Initial hash value H for SHA-512 */
-const static u_int64_t sha512_initial_hash_value[8] = {
+const static uint64_t sha512_initial_hash_value[8] = {
 	0x6a09e667f3bcc908ULL,
 	0xbb67ae8584caa73bULL,
 	0x3c6ef372fe94f82bULL,
@@ -315,10 +315,10 @@ SHA256Init(SHA2_CTX *context)
 } while(0)
 
 void
-SHA256Transform(u_int32_t state[8], const u_int8_t data[SHA256_BLOCK_LENGTH])
+SHA256Transform(uint32_t state[8], const uint8_t data[SHA256_BLOCK_LENGTH])
 {
-	u_int32_t	a, b, c, d, e, f, g, h, s0, s1;
-	u_int32_t	T1, W256[16];
+	uint32_t	a, b, c, d, e, f, g, h, s0, s1;
+	uint32_t	T1, W256[16];
 	int		j;
 
 	/* Initialize registers with the prev. intermediate value */
@@ -373,10 +373,10 @@ SHA256Transform(u_int32_t state[8], const u_int8_t data[SHA256_BLOCK_LENGTH])
 #else /* SHA2_UNROLL_TRANSFORM */
 
 void
-SHA256Transform(u_int32_t state[8], const u_int8_t data[SHA256_BLOCK_LENGTH])
+SHA256Transform(uint32_t state[8], const uint8_t data[SHA256_BLOCK_LENGTH])
 {
-	u_int32_t	a, b, c, d, e, f, g, h, s0, s1;
-	u_int32_t	T1, T2, W256[16];
+	uint32_t	a, b, c, d, e, f, g, h, s0, s1;
+	uint32_t	T1, T2, W256[16];
 	int		j;
 
 	/* Initialize registers with the prev. intermediate value */
@@ -448,7 +448,7 @@ SHA256Transform(u_int32_t state[8], const u_int8_t data[SHA256_BLOCK_LENGTH])
 #endif /* SHA2_UNROLL_TRANSFORM */
 
 void
-SHA256Update(SHA2_CTX *context, const u_int8_t *data, size_t len)
+SHA256Update(SHA2_CTX *context, const uint8_t *data, size_t len)
 {
 	size_t	freespace, usedspace;
 
@@ -537,7 +537,7 @@ SHA256Pad(SHA2_CTX *context)
 }
 
 void
-SHA256Final(u_int8_t digest[SHA256_DIGEST_LENGTH], SHA2_CTX *context)
+SHA256Final(uint8_t digest[SHA256_DIGEST_LENGTH], SHA2_CTX *context)
 {
 	SHA256Pad(context);
 
@@ -597,10 +597,10 @@ SHA512Init(SHA2_CTX *context)
 } while(0)
 
 void
-SHA512Transform(u_int64_t state[8], const u_int8_t data[SHA512_BLOCK_LENGTH])
+SHA512Transform(uint64_t state[8], const uint8_t data[SHA512_BLOCK_LENGTH])
 {
-	u_int64_t	a, b, c, d, e, f, g, h, s0, s1;
-	u_int64_t	T1, W512[16];
+	uint64_t	a, b, c, d, e, f, g, h, s0, s1;
+	uint64_t	T1, W512[16];
 	int		j;
 
 	/* Initialize registers with the prev. intermediate value */
@@ -655,10 +655,10 @@ SHA512Transform(u_int64_t state[8], const u_int8_t data[SHA512_BLOCK_LENGTH])
 #else /* SHA2_UNROLL_TRANSFORM */
 
 void
-SHA512Transform(u_int64_t state[8], const u_int8_t data[SHA512_BLOCK_LENGTH])
+SHA512Transform(uint64_t state[8], const uint8_t data[SHA512_BLOCK_LENGTH])
 {
-	u_int64_t	a, b, c, d, e, f, g, h, s0, s1;
-	u_int64_t	T1, T2, W512[16];
+	uint64_t	a, b, c, d, e, f, g, h, s0, s1;
+	uint64_t	T1, T2, W512[16];
 	int		j;
 
 	/* Initialize registers with the prev. intermediate value */
@@ -730,7 +730,7 @@ SHA512Transform(u_int64_t state[8], const u_int8_t data[SHA512_BLOCK_LENGTH])
 #endif /* SHA2_UNROLL_TRANSFORM */
 
 void
-SHA512Update(SHA2_CTX *context, const u_int8_t *data, size_t len)
+SHA512Update(SHA2_CTX *context, const uint8_t *data, size_t len)
 {
 	size_t	freespace, usedspace;
 
@@ -819,7 +819,7 @@ SHA512Pad(SHA2_CTX *context)
 }
 
 void
-SHA512Final(u_int8_t digest[SHA512_DIGEST_LENGTH], SHA2_CTX *context)
+SHA512Final(uint8_t digest[SHA512_DIGEST_LENGTH], SHA2_CTX *context)
 {
 	SHA512Pad(context);
 
@@ -856,7 +856,7 @@ __weak_alias(SHA384Update, SHA512Update);
 __weak_alias(SHA384Pad, SHA512Pad);
 
 void
-SHA384Final(u_int8_t digest[SHA384_DIGEST_LENGTH], SHA2_CTX *context)
+SHA384Final(uint8_t digest[SHA384_DIGEST_LENGTH], SHA2_CTX *context)
 {
 	SHA384Pad(context);