Commit 5e898d7
committed
wolfcrypt: support CHAR_BIT != 8 (WOLFSSL_WIDE_BYTE) targets - infra, hashes, DRBG
Enables wolfCrypt on toolchains where a C byte/char is wider than 8 bits (e.g.
TI C2000 C28x, CHAR_BIT == 16), all gated on WOLFSSL_WIDE_BYTE and a no-op on
8-bit-byte targets (the default fast paths are left exactly as-is):
- types.h: auto-set WOLFSSL_WIDE_BYTE for CHAR_BIT != 8 / known TI C2000
toolchains (and define CHAR_BIT = 16 when <limits.h> is absent); wc_port.h/.c
widen the atomic init-state bitfield + CHAR_BIT static assert for 16-bit int.
- settings.h + sp_int.h: allow SP math on a 16-bit-int CPU via
WOLFSSL_SP_ALLOW_16BIT_CPU, and detect a 16-bit char in the SP smallest-type
selection.
- misc.c/misc.h: shared big-endian octet<->word helpers
(WordsFromBytesBE32/64, BytesFromWordsBE32/64) for WOLFSSL_WIDE_BYTE, where a
word cannot be aliased as an octet stream. They are CHAR_BIT-generic,
cl2000-safe (loads accumulate with <<= 8, since (word)octet << 24 is
miscompiled as a 16-bit shift), in-place safe for the SHA schedule, and store
by octet count for partial digests. misc.c rotate width uses CHAR_BIT.
- coding.c: mask the constant-time base64 result to an octet.
- sha256.c/sha512.c: use the shared helpers for the schedule load and digest
store, plus a CHAR_BIT*sizeof length carry; sha3.c: octet-wise Keccak squeeze.
- random.c: Hash-DRBG length + reseed-counter serialization via the shared
helpers (and an octet-masked carry) under WOLFSSL_WIDE_BYTE; default builds
keep the word-aliasing path unchanged.
WOLFSSL_WIDE_BYTE replaces the earlier WOLFSSL_NO_OCTET_BYTE working name.1 parent 3f9ae22 commit 5e898d7
13 files changed
Lines changed: 376 additions & 30 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
747 | 747 | | |
748 | 748 | | |
749 | 749 | | |
| 750 | + | |
750 | 751 | | |
751 | 752 | | |
752 | 753 | | |
| |||
1115 | 1116 | | |
1116 | 1117 | | |
1117 | 1118 | | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
1118 | 1125 | | |
1119 | 1126 | | |
1120 | 1127 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | | - | |
| 75 | + | |
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
111 | | - | |
| 111 | + | |
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
117 | | - | |
| 117 | + | |
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
125 | | - | |
| 125 | + | |
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
132 | | - | |
| 132 | + | |
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
| |||
329 | 329 | | |
330 | 330 | | |
331 | 331 | | |
332 | | - | |
| 332 | + | |
333 | 333 | | |
334 | 334 | | |
335 | 335 | | |
336 | 336 | | |
337 | 337 | | |
338 | | - | |
| 338 | + | |
339 | 339 | | |
340 | 340 | | |
341 | 341 | | |
| |||
410 | 410 | | |
411 | 411 | | |
412 | 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 | + | |
413 | 476 | | |
414 | 477 | | |
415 | 478 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
464 | 464 | | |
465 | 465 | | |
466 | 466 | | |
467 | | - | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
468 | 471 | | |
469 | 472 | | |
470 | 473 | | |
| |||
489 | 492 | | |
490 | 493 | | |
491 | 494 | | |
492 | | - | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
493 | 500 | | |
494 | 501 | | |
495 | 502 | | |
| |||
509 | 516 | | |
510 | 517 | | |
511 | 518 | | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
512 | 522 | | |
| 523 | + | |
513 | 524 | | |
514 | 525 | | |
515 | 526 | | |
| |||
666 | 677 | | |
667 | 678 | | |
668 | 679 | | |
669 | | - | |
| 680 | + | |
670 | 681 | | |
671 | 682 | | |
672 | 683 | | |
| |||
789 | 800 | | |
790 | 801 | | |
791 | 802 | | |
792 | | - | |
| 803 | + | |
793 | 804 | | |
794 | 805 | | |
795 | 806 | | |
796 | 807 | | |
797 | 808 | | |
798 | 809 | | |
799 | | - | |
| 810 | + | |
800 | 811 | | |
801 | 812 | | |
802 | 813 | | |
| |||
820 | 831 | | |
821 | 832 | | |
822 | 833 | | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
823 | 837 | | |
824 | 838 | | |
825 | 839 | | |
| |||
914 | 928 | | |
915 | 929 | | |
916 | 930 | | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
917 | 942 | | |
918 | 943 | | |
919 | 944 | | |
| |||
923 | 948 | | |
924 | 949 | | |
925 | 950 | | |
| 951 | + | |
926 | 952 | | |
927 | 953 | | |
928 | 954 | | |
| |||
1050 | 1076 | | |
1051 | 1077 | | |
1052 | 1078 | | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
1053 | 1082 | | |
1054 | 1083 | | |
1055 | 1084 | | |
| |||
1082 | 1111 | | |
1083 | 1112 | | |
1084 | 1113 | | |
1085 | | - | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
1086 | 1117 | | |
1087 | 1118 | | |
1088 | 1119 | | |
| |||
1102 | 1133 | | |
1103 | 1134 | | |
1104 | 1135 | | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
1105 | 1139 | | |
| 1140 | + | |
1106 | 1141 | | |
1107 | 1142 | | |
1108 | 1143 | | |
| |||
1300 | 1335 | | |
1301 | 1336 | | |
1302 | 1337 | | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
1303 | 1341 | | |
1304 | 1342 | | |
1305 | 1343 | | |
| |||
1377 | 1415 | | |
1378 | 1416 | | |
1379 | 1417 | | |
| 1418 | + | |
| 1419 | + | |
| 1420 | + | |
| 1421 | + | |
| 1422 | + | |
1380 | 1423 | | |
1381 | 1424 | | |
1382 | 1425 | | |
1383 | 1426 | | |
1384 | 1427 | | |
| 1428 | + | |
1385 | 1429 | | |
1386 | 1430 | | |
1387 | 1431 | | |
| |||
0 commit comments