Commit d6a9a58f64cd371cb74d970192c09a9235205907

Francois Perrad 2017-08-30T20:08:58

remove space after function name and cast

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
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
diff --git a/bn_fast_mp_invmod.c b/bn_fast_mp_invmod.c
index 6951261..09023ab 100644
--- a/bn_fast_mp_invmod.c
+++ b/bn_fast_mp_invmod.c
@@ -27,7 +27,7 @@ int fast_mp_invmod (mp_int * a, mp_int * b, mp_int * c)
   int     res, neg;
 
   /* 2. [modified] b must be odd   */
-  if (mp_iseven (b) == MP_YES) {
+  if (mp_iseven(b) == MP_YES) {
     return MP_VAL;
   }
 
@@ -37,92 +37,92 @@ int fast_mp_invmod (mp_int * a, mp_int * b, mp_int * c)
   }
 
   /* x == modulus, y == value to invert */
-  if ((res = mp_copy (b, &x)) != MP_OKAY) {
+  if ((res = mp_copy(b, &x)) != MP_OKAY) {
     goto LBL_ERR;
   }
 
   /* we need y = |a| */
-  if ((res = mp_mod (a, b, &y)) != MP_OKAY) {
+  if ((res = mp_mod(a, b, &y)) != MP_OKAY) {
     goto LBL_ERR;
   }
 
   /* 3. u=x, v=y, A=1, B=0, C=0,D=1 */
-  if ((res = mp_copy (&x, &u)) != MP_OKAY) {
+  if ((res = mp_copy(&x, &u)) != MP_OKAY) {
     goto LBL_ERR;
   }
-  if ((res = mp_copy (&y, &v)) != MP_OKAY) {
+  if ((res = mp_copy(&y, &v)) != MP_OKAY) {
     goto LBL_ERR;
   }
-  mp_set (&D, 1);
+  mp_set(&D, 1);
 
 top:
   /* 4.  while u is even do */
-  while (mp_iseven (&u) == MP_YES) {
+  while (mp_iseven(&u) == MP_YES) {
     /* 4.1 u = u/2 */
-    if ((res = mp_div_2 (&u, &u)) != MP_OKAY) {
+    if ((res = mp_div_2(&u, &u)) != MP_OKAY) {
       goto LBL_ERR;
     }
     /* 4.2 if B is odd then */
-    if (mp_isodd (&B) == MP_YES) {
-      if ((res = mp_sub (&B, &x, &B)) != MP_OKAY) {
+    if (mp_isodd(&B) == MP_YES) {
+      if ((res = mp_sub(&B, &x, &B)) != MP_OKAY) {
         goto LBL_ERR;
       }
     }
     /* B = B/2 */
-    if ((res = mp_div_2 (&B, &B)) != MP_OKAY) {
+    if ((res = mp_div_2(&B, &B)) != MP_OKAY) {
       goto LBL_ERR;
     }
   }
 
   /* 5.  while v is even do */
-  while (mp_iseven (&v) == MP_YES) {
+  while (mp_iseven(&v) == MP_YES) {
     /* 5.1 v = v/2 */
-    if ((res = mp_div_2 (&v, &v)) != MP_OKAY) {
+    if ((res = mp_div_2(&v, &v)) != MP_OKAY) {
       goto LBL_ERR;
     }
     /* 5.2 if D is odd then */
-    if (mp_isodd (&D) == MP_YES) {
+    if (mp_isodd(&D) == MP_YES) {
       /* D = (D-x)/2 */
-      if ((res = mp_sub (&D, &x, &D)) != MP_OKAY) {
+      if ((res = mp_sub(&D, &x, &D)) != MP_OKAY) {
         goto LBL_ERR;
       }
     }
     /* D = D/2 */
-    if ((res = mp_div_2 (&D, &D)) != MP_OKAY) {
+    if ((res = mp_div_2(&D, &D)) != MP_OKAY) {
       goto LBL_ERR;
     }
   }
 
   /* 6.  if u >= v then */
-  if (mp_cmp (&u, &v) != MP_LT) {
+  if (mp_cmp(&u, &v) != MP_LT) {
     /* u = u - v, B = B - D */
-    if ((res = mp_sub (&u, &v, &u)) != MP_OKAY) {
+    if ((res = mp_sub(&u, &v, &u)) != MP_OKAY) {
       goto LBL_ERR;
     }
 
-    if ((res = mp_sub (&B, &D, &B)) != MP_OKAY) {
+    if ((res = mp_sub(&B, &D, &B)) != MP_OKAY) {
       goto LBL_ERR;
     }
   } else {
     /* v - v - u, D = D - B */
-    if ((res = mp_sub (&v, &u, &v)) != MP_OKAY) {
+    if ((res = mp_sub(&v, &u, &v)) != MP_OKAY) {
       goto LBL_ERR;
     }
 
-    if ((res = mp_sub (&D, &B, &D)) != MP_OKAY) {
+    if ((res = mp_sub(&D, &B, &D)) != MP_OKAY) {
       goto LBL_ERR;
     }
   }
 
   /* if not zero goto step 4 */
-  if (mp_iszero (&u) == MP_NO) {
+  if (mp_iszero(&u) == MP_NO) {
     goto top;
   }
 
   /* now a = C, b = D, gcd == g*v */
 
   /* if v != 1 then there is no inverse */
-  if (mp_cmp_d (&v, 1) != MP_EQ) {
+  if (mp_cmp_d(&v, 1) != MP_EQ) {
     res = MP_VAL;
     goto LBL_ERR;
   }
@@ -130,15 +130,15 @@ top:
   /* b is now the inverse */
   neg = a->sign;
   while (D.sign == MP_NEG) {
-    if ((res = mp_add (&D, b, &D)) != MP_OKAY) {
+    if ((res = mp_add(&D, b, &D)) != MP_OKAY) {
       goto LBL_ERR;
     }
   }
-  mp_exch (&D, c);
+  mp_exch(&D, c);
   c->sign = neg;
   res = MP_OKAY;
 
-LBL_ERR:mp_clear_multi (&x, &y, &u, &v, &B, &D, NULL);
+LBL_ERR:mp_clear_multi(&x, &y, &u, &v, &B, &D, NULL);
   return res;
 }
 #endif
diff --git a/bn_fast_mp_montgomery_reduce.c b/bn_fast_mp_montgomery_reduce.c
index 16d5ff7..d3309d1 100644
--- a/bn_fast_mp_montgomery_reduce.c
+++ b/bn_fast_mp_montgomery_reduce.c
@@ -33,7 +33,7 @@ int fast_mp_montgomery_reduce (mp_int * x, mp_int * n, mp_digit rho)
 
   /* grow a as required */
   if (x->alloc < (n->used + 1)) {
-    if ((res = mp_grow (x, n->used + 1)) != MP_OKAY) {
+    if ((res = mp_grow(x, n->used + 1)) != MP_OKAY) {
       return res;
     }
   }
@@ -73,7 +73,7 @@ int fast_mp_montgomery_reduce (mp_int * x, mp_int * n, mp_digit rho)
      * that W[ix-1] have  the carry cleared (see after the inner loop)
      */
     mp_digit mu;
-    mu = (mp_digit) (((W[ix] & MP_MASK) * rho) & MP_MASK);
+    mu = (mp_digit)(((W[ix] & MP_MASK) * rho) & MP_MASK);
 
     /* a = a + mu * m * b**i
      *
@@ -157,11 +157,11 @@ int fast_mp_montgomery_reduce (mp_int * x, mp_int * n, mp_digit rho)
 
   /* set the max used and clamp */
   x->used = n->used + 1;
-  mp_clamp (x);
+  mp_clamp(x);
 
   /* if A >= m then A = A - m */
-  if (mp_cmp_mag (x, n) != MP_LT) {
-    return s_mp_sub (x, n, x);
+  if (mp_cmp_mag(x, n) != MP_LT) {
+    return s_mp_sub(x, n, x);
   }
   return MP_OKAY;
 }
diff --git a/bn_fast_s_mp_mul_digs.c b/bn_fast_s_mp_mul_digs.c
index a5a9999..a96af85 100644
--- a/bn_fast_s_mp_mul_digs.c
+++ b/bn_fast_s_mp_mul_digs.c
@@ -39,7 +39,7 @@ int fast_s_mp_mul_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
 
   /* grow the destination as required */
   if (c->alloc < digs) {
-    if ((res = mp_grow (c, digs)) != MP_OKAY) {
+    if ((res = mp_grow(c, digs)) != MP_OKAY) {
       return res;
     }
   }
@@ -97,7 +97,7 @@ int fast_s_mp_mul_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
       *tmpc++ = 0;
     }
   }
-  mp_clamp (c);
+  mp_clamp(c);
   return MP_OKAY;
 }
 #endif
diff --git a/bn_fast_s_mp_mul_high_digs.c b/bn_fast_s_mp_mul_high_digs.c
index 141464c..c5cd902 100644
--- a/bn_fast_s_mp_mul_high_digs.c
+++ b/bn_fast_s_mp_mul_high_digs.c
@@ -33,7 +33,7 @@ int fast_s_mp_mul_high_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
   /* grow the destination as required */
   pa = a->used + b->used;
   if (c->alloc < pa) {
-    if ((res = mp_grow (c, pa)) != MP_OKAY) {
+    if ((res = mp_grow(c, pa)) != MP_OKAY) {
       return res;
     }
   }
@@ -88,7 +88,7 @@ int fast_s_mp_mul_high_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
       *tmpc++ = 0;
     }
   }
-  mp_clamp (c);
+  mp_clamp(c);
   return MP_OKAY;
 }
 #endif
diff --git a/bn_fast_s_mp_sqr.c b/bn_fast_s_mp_sqr.c
index afc747e..6905311 100644
--- a/bn_fast_s_mp_sqr.c
+++ b/bn_fast_s_mp_sqr.c
@@ -34,7 +34,7 @@ int fast_s_mp_sqr (mp_int * a, mp_int * b)
   /* grow the destination as required */
   pa = a->used + a->used;
   if (b->alloc < pa) {
-    if ((res = mp_grow (b, pa)) != MP_OKAY) {
+    if ((res = mp_grow(b, pa)) != MP_OKAY) {
       return res;
     }
   }
@@ -104,7 +104,7 @@ int fast_s_mp_sqr (mp_int * a, mp_int * b)
       *tmpb++ = 0;
     }
   }
-  mp_clamp (b);
+  mp_clamp(b);
   return MP_OKAY;
 }
 #endif
diff --git a/bn_mp_2expt.c b/bn_mp_2expt.c
index 180480a..34259f3 100644
--- a/bn_mp_2expt.c
+++ b/bn_mp_2expt.c
@@ -26,10 +26,10 @@ mp_2expt (mp_int * a, int b)
   int     res;
 
   /* zero a as per default */
-  mp_zero (a);
+  mp_zero(a);
 
   /* grow a to accomodate the single bit */
-  if ((res = mp_grow (a, (b / DIGIT_BIT) + 1)) != MP_OKAY) {
+  if ((res = mp_grow(a, (b / DIGIT_BIT) + 1)) != MP_OKAY) {
     return res;
   }
 
diff --git a/bn_mp_abs.c b/bn_mp_abs.c
index 0c94548..815f423 100644
--- a/bn_mp_abs.c
+++ b/bn_mp_abs.c
@@ -26,7 +26,7 @@ mp_abs (mp_int * a, mp_int * b)
 
   /* copy a to b */
   if (a != b) {
-     if ((res = mp_copy (a, b)) != MP_OKAY) {
+     if ((res = mp_copy(a, b)) != MP_OKAY) {
        return res;
      }
   }
diff --git a/bn_mp_add.c b/bn_mp_add.c
index bdb166f..6151395 100644
--- a/bn_mp_add.c
+++ b/bn_mp_add.c
@@ -29,18 +29,18 @@ int mp_add (mp_int * a, mp_int * b, mp_int * c)
     /* both positive or both negative */
     /* add their magnitudes, copy the sign */
     c->sign = sa;
-    res = s_mp_add (a, b, c);
+    res = s_mp_add(a, b, c);
   } else {
     /* one positive, the other negative */
     /* subtract the one with the greater magnitude from */
     /* the one of the lesser magnitude.  The result gets */
     /* the sign of the one with the greater magnitude. */
-    if (mp_cmp_mag (a, b) == MP_LT) {
+    if (mp_cmp_mag(a, b) == MP_LT) {
       c->sign = sb;
-      res = s_mp_sub (b, a, c);
+      res = s_mp_sub(b, a, c);
     } else {
       c->sign = sa;
-      res = s_mp_sub (a, b, c);
+      res = s_mp_sub(a, b, c);
     }
   }
   return res;
diff --git a/bn_mp_addmod.c b/bn_mp_addmod.c
index dc06788..1ce7e4d 100644
--- a/bn_mp_addmod.c
+++ b/bn_mp_addmod.c
@@ -22,16 +22,16 @@ mp_addmod (mp_int * a, mp_int * b, mp_int * c, mp_int * d)
   int     res;
   mp_int  t;
 
-  if ((res = mp_init (&t)) != MP_OKAY) {
+  if ((res = mp_init(&t)) != MP_OKAY) {
     return res;
   }
 
-  if ((res = mp_add (a, b, &t)) != MP_OKAY) {
-    mp_clear (&t);
+  if ((res = mp_add(a, b, &t)) != MP_OKAY) {
+    mp_clear(&t);
     return res;
   }
-  res = mp_mod (&t, c, d);
-  mp_clear (&t);
+  res = mp_mod(&t, c, d);
+  mp_clear(&t);
   return res;
 }
 #endif
diff --git a/bn_mp_and.c b/bn_mp_and.c
index 53008a5..45b64f1 100644
--- a/bn_mp_and.c
+++ b/bn_mp_and.c
@@ -23,13 +23,13 @@ mp_and (mp_int * a, mp_int * b, mp_int * c)
   mp_int  t, *x;
 
   if (a->used > b->used) {
-    if ((res = mp_init_copy (&t, a)) != MP_OKAY) {
+    if ((res = mp_init_copy(&t, a)) != MP_OKAY) {
       return res;
     }
     px = b->used;
     x = b;
   } else {
-    if ((res = mp_init_copy (&t, b)) != MP_OKAY) {
+    if ((res = mp_init_copy(&t, b)) != MP_OKAY) {
       return res;
     }
     px = a->used;
@@ -45,9 +45,9 @@ mp_and (mp_int * a, mp_int * b, mp_int * c)
     t.dp[ix] = 0;
   }
 
-  mp_clamp (&t);
-  mp_exch (c, &t);
-  mp_clear (&t);
+  mp_clamp(&t);
+  mp_exch(c, &t);
+  mp_clear(&t);
   return MP_OKAY;
 }
 #endif
diff --git a/bn_mp_copy.c b/bn_mp_copy.c
index 84e839e..e3aa9a1 100644
--- a/bn_mp_copy.c
+++ b/bn_mp_copy.c
@@ -28,7 +28,7 @@ mp_copy (mp_int * a, mp_int * b)
 
   /* grow dest */
   if (b->alloc < a->used) {
-     if ((res = mp_grow (b, a->used)) != MP_OKAY) {
+     if ((res = mp_grow(b, a->used)) != MP_OKAY) {
         return res;
      }
   }
diff --git a/bn_mp_div.c b/bn_mp_div.c
index 0890e65..de318c2 100644
--- a/bn_mp_div.c
+++ b/bn_mp_div.c
@@ -24,19 +24,19 @@ int mp_div(mp_int * a, mp_int * b, mp_int * c, mp_int * d)
    int    res, n, n2;
 
   /* is divisor zero ? */
-  if (mp_iszero (b) == MP_YES) {
+  if (mp_iszero(b) == MP_YES) {
     return MP_VAL;
   }
 
   /* if a < b then q=0, r = a */
-  if (mp_cmp_mag (a, b) == MP_LT) {
+  if (mp_cmp_mag(a, b) == MP_LT) {
     if (d != NULL) {
-      res = mp_copy (a, d);
+      res = mp_copy(a, d);
     } else {
       res = MP_OKAY;
     }
     if (c != NULL) {
-      mp_zero (c);
+      mp_zero(c);
     }
     return res;
   }
@@ -106,41 +106,41 @@ int mp_div (mp_int * a, mp_int * b, mp_int * c, mp_int * d)
   int     res, n, t, i, norm, neg;
 
   /* is divisor zero ? */
-  if (mp_iszero (b) == MP_YES) {
+  if (mp_iszero(b) == MP_YES) {
     return MP_VAL;
   }
 
   /* if a < b then q=0, r = a */
-  if (mp_cmp_mag (a, b) == MP_LT) {
+  if (mp_cmp_mag(a, b) == MP_LT) {
     if (d != NULL) {
-      res = mp_copy (a, d);
+      res = mp_copy(a, d);
     } else {
       res = MP_OKAY;
     }
     if (c != NULL) {
-      mp_zero (c);
+      mp_zero(c);
     }
     return res;
   }
 
-  if ((res = mp_init_size (&q, a->used + 2)) != MP_OKAY) {
+  if ((res = mp_init_size(&q, a->used + 2)) != MP_OKAY) {
     return res;
   }
   q.used = a->used + 2;
 
-  if ((res = mp_init (&t1)) != MP_OKAY) {
+  if ((res = mp_init(&t1)) != MP_OKAY) {
     goto LBL_Q;
   }
 
-  if ((res = mp_init (&t2)) != MP_OKAY) {
+  if ((res = mp_init(&t2)) != MP_OKAY) {
     goto LBL_T1;
   }
 
-  if ((res = mp_init_copy (&x, a)) != MP_OKAY) {
+  if ((res = mp_init_copy(&x, a)) != MP_OKAY) {
     goto LBL_T2;
   }
 
-  if ((res = mp_init_copy (&y, b)) != MP_OKAY) {
+  if ((res = mp_init_copy(&y, b)) != MP_OKAY) {
     goto LBL_X;
   }
 
@@ -152,10 +152,10 @@ int mp_div (mp_int * a, mp_int * b, mp_int * c, mp_int * d)
   norm = mp_count_bits(&y) % DIGIT_BIT;
   if (norm < (int)(DIGIT_BIT-1)) {
      norm = (DIGIT_BIT-1) - norm;
-     if ((res = mp_mul_2d (&x, norm, &x)) != MP_OKAY) {
+     if ((res = mp_mul_2d(&x, norm, &x)) != MP_OKAY) {
        goto LBL_Y;
      }
-     if ((res = mp_mul_2d (&y, norm, &y)) != MP_OKAY) {
+     if ((res = mp_mul_2d(&y, norm, &y)) != MP_OKAY) {
        goto LBL_Y;
      }
   } else {
@@ -167,19 +167,19 @@ int mp_div (mp_int * a, mp_int * b, mp_int * c, mp_int * d)
   t = y.used - 1;
 
   /* while (x >= y*b**n-t) do { q[n-t] += 1; x -= y*b**{n-t} } */
-  if ((res = mp_lshd (&y, n - t)) != MP_OKAY) { /* y = y*b**{n-t} */
+  if ((res = mp_lshd(&y, n - t)) != MP_OKAY) { /* y = y*b**{n-t} */
     goto LBL_Y;
   }
 
-  while (mp_cmp (&x, &y) != MP_LT) {
+  while (mp_cmp(&x, &y) != MP_LT) {
     ++(q.dp[n - t]);
-    if ((res = mp_sub (&x, &y, &x)) != MP_OKAY) {
+    if ((res = mp_sub(&x, &y, &x)) != MP_OKAY) {
       goto LBL_Y;
     }
   }
 
   /* reset y by shifting it back down */
-  mp_rshd (&y, n - t);
+  mp_rshd(&y, n - t);
 
   /* step 3. for i from n down to (t + 1) */
   for (i = n; i >= (t + 1); i--) {
@@ -199,7 +199,7 @@ int mp_div (mp_int * a, mp_int * b, mp_int * c, mp_int * d)
       if (tmp > (mp_word) MP_MASK) {
         tmp = MP_MASK;
       }
-      q.dp[(i - t) - 1] = (mp_digit) (tmp & (mp_word) (MP_MASK));
+      q.dp[(i - t) - 1] = (mp_digit)(tmp & (mp_word)(MP_MASK));
     }
 
     /* while (q{i-t-1} * (yt * b + y{t-1})) >
@@ -212,11 +212,11 @@ int mp_div (mp_int * a, mp_int * b, mp_int * c, mp_int * d)
       q.dp[(i - t) - 1] = (q.dp[(i - t) - 1] - 1) & MP_MASK;
 
       /* find left hand */
-      mp_zero (&t1);
+      mp_zero(&t1);
       t1.dp[0] = ((t - 1) < 0) ? 0 : y.dp[t - 1];
       t1.dp[1] = y.dp[t];
       t1.used = 2;
-      if ((res = mp_mul_d (&t1, q.dp[(i - t) - 1], &t1)) != MP_OKAY) {
+      if ((res = mp_mul_d(&t1, q.dp[(i - t) - 1], &t1)) != MP_OKAY) {
         goto LBL_Y;
       }
 
@@ -228,27 +228,27 @@ int mp_div (mp_int * a, mp_int * b, mp_int * c, mp_int * d)
     } while (mp_cmp_mag(&t1, &t2) == MP_GT);
 
     /* step 3.3 x = x - q{i-t-1} * y * b**{i-t-1} */
-    if ((res = mp_mul_d (&y, q.dp[(i - t) - 1], &t1)) != MP_OKAY) {
+    if ((res = mp_mul_d(&y, q.dp[(i - t) - 1], &t1)) != MP_OKAY) {
       goto LBL_Y;
     }
 
-    if ((res = mp_lshd (&t1, (i - t) - 1)) != MP_OKAY) {
+    if ((res = mp_lshd(&t1, (i - t) - 1)) != MP_OKAY) {
       goto LBL_Y;
     }
 
-    if ((res = mp_sub (&x, &t1, &x)) != MP_OKAY) {
+    if ((res = mp_sub(&x, &t1, &x)) != MP_OKAY) {
       goto LBL_Y;
     }
 
     /* if x < 0 then { x = x + y*b**{i-t-1}; q{i-t-1} -= 1; } */
     if (x.sign == MP_NEG) {
-      if ((res = mp_copy (&y, &t1)) != MP_OKAY) {
+      if ((res = mp_copy(&y, &t1)) != MP_OKAY) {
         goto LBL_Y;
       }
-      if ((res = mp_lshd (&t1, (i - t) - 1)) != MP_OKAY) {
+      if ((res = mp_lshd(&t1, (i - t) - 1)) != MP_OKAY) {
         goto LBL_Y;
       }
-      if ((res = mp_add (&x, &t1, &x)) != MP_OKAY) {
+      if ((res = mp_add(&x, &t1, &x)) != MP_OKAY) {
         goto LBL_Y;
       }
 
@@ -264,25 +264,25 @@ int mp_div (mp_int * a, mp_int * b, mp_int * c, mp_int * d)
   x.sign = (x.used == 0) ? MP_ZPOS : a->sign;
 
   if (c != NULL) {
-    mp_clamp (&q);
-    mp_exch (&q, c);
+    mp_clamp(&q);
+    mp_exch(&q, c);
     c->sign = neg;
   }
 
   if (d != NULL) {
-    if ((res = mp_div_2d (&x, norm, &x, NULL)) != MP_OKAY) {
+    if ((res = mp_div_2d(&x, norm, &x, NULL)) != MP_OKAY) {
       goto LBL_Y;
     }
-    mp_exch (&x, d);
+    mp_exch(&x, d);
   }
 
   res = MP_OKAY;
 
-LBL_Y:mp_clear (&y);
-LBL_X:mp_clear (&x);
-LBL_T2:mp_clear (&t2);
-LBL_T1:mp_clear (&t1);
-LBL_Q:mp_clear (&q);
+LBL_Y:mp_clear(&y);
+LBL_X:mp_clear(&x);
+LBL_T2:mp_clear(&t2);
+LBL_T1:mp_clear(&t1);
+LBL_Q:mp_clear(&q);
   return res;
 }
 
diff --git a/bn_mp_div_2.c b/bn_mp_div_2.c
index 2b5bb49..cf43106 100644
--- a/bn_mp_div_2.c
+++ b/bn_mp_div_2.c
@@ -22,7 +22,7 @@ int mp_div_2(mp_int * a, mp_int * b)
 
   /* copy */
   if (b->alloc < a->used) {
-    if ((res = mp_grow (b, a->used)) != MP_OKAY) {
+    if ((res = mp_grow(b, a->used)) != MP_OKAY) {
       return res;
     }
   }
@@ -58,7 +58,7 @@ int mp_div_2(mp_int * a, mp_int * b)
     }
   }
   b->sign = a->sign;
-  mp_clamp (b);
+  mp_clamp(b);
   return MP_OKAY;
 }
 #endif
diff --git a/bn_mp_div_2d.c b/bn_mp_div_2d.c
index 635d374..4523737 100644
--- a/bn_mp_div_2d.c
+++ b/bn_mp_div_2d.c
@@ -23,33 +23,33 @@ int mp_div_2d (mp_int * a, int b, mp_int * c, mp_int * d)
 
   /* if the shift count is <= 0 then we do no work */
   if (b <= 0) {
-    res = mp_copy (a, c);
+    res = mp_copy(a, c);
     if (d != NULL) {
-      mp_zero (d);
+      mp_zero(d);
     }
     return res;
   }
 
   /* copy */
-  if ((res = mp_copy (a, c)) != MP_OKAY) {
+  if ((res = mp_copy(a, c)) != MP_OKAY) {
     return res;
   }
   /* 'a' should not be used after here - it might be the same as d */
 
   /* get the remainder */
   if (d != NULL) {
-    if ((res = mp_mod_2d (a, b, d)) != MP_OKAY) {
+    if ((res = mp_mod_2d(a, b, d)) != MP_OKAY) {
       return res;
     }
   }
 
   /* shift by as many digits in the bit count */
   if (b >= (int)DIGIT_BIT) {
-    mp_rshd (c, b / DIGIT_BIT);
+    mp_rshd(c, b / DIGIT_BIT);
   }
 
   /* shift any bit count < DIGIT_BIT */
-  D = (mp_digit) (b % DIGIT_BIT);
+  D = (mp_digit)(b % DIGIT_BIT);
   if (D != 0) {
     mp_digit *tmpc, mask, shift;
 
@@ -76,7 +76,7 @@ int mp_div_2d (mp_int * a, int b, mp_int * c, mp_int * d)
       r = rr;
     }
   }
-  mp_clamp (c);
+  mp_clamp(c);
   return MP_OKAY;
 }
 #endif
diff --git a/bn_mp_dr_reduce.c b/bn_mp_dr_reduce.c
index c85ee77..c269715 100644
--- a/bn_mp_dr_reduce.c
+++ b/bn_mp_dr_reduce.c
@@ -41,7 +41,7 @@ mp_dr_reduce (mp_int * x, mp_int * n, mp_digit k)
 
   /* ensure that "x" has at least 2m digits */
   if (x->alloc < (m + m)) {
-    if ((err = mp_grow (x, m + m)) != MP_OKAY) {
+    if ((err = mp_grow(x, m + m)) != MP_OKAY) {
       return err;
     }
   }
@@ -76,12 +76,12 @@ top:
   }
 
   /* clamp, sub and return */
-  mp_clamp (x);
+  mp_clamp(x);
 
   /* if x >= n then subtract and reduce again
    * Each successive "recursion" makes the input smaller and smaller.
    */
-  if (mp_cmp_mag (x, n) != MP_LT) {
+  if (mp_cmp_mag(x, n) != MP_LT) {
     if ((err = s_mp_sub(x, n, x)) != MP_OKAY) {
       return err;
     }
diff --git a/bn_mp_expt_d_ex.c b/bn_mp_expt_d_ex.c
index c361b27..9629e1c 100644
--- a/bn_mp_expt_d_ex.c
+++ b/bn_mp_expt_d_ex.c
@@ -23,27 +23,27 @@ int mp_expt_d_ex (mp_int * a, mp_digit b, mp_int * c, int fast)
 
   mp_int  g;
 
-  if ((res = mp_init_copy (&g, a)) != MP_OKAY) {
+  if ((res = mp_init_copy(&g, a)) != MP_OKAY) {
     return res;
   }
 
   /* set initial result */
-  mp_set (c, 1);
+  mp_set(c, 1);
 
   if (fast != 0) {
     while (b > 0) {
       /* if the bit is set multiply */
       if ((b & 1) != 0) {
-        if ((res = mp_mul (c, &g, c)) != MP_OKAY) {
-          mp_clear (&g);
+        if ((res = mp_mul(c, &g, c)) != MP_OKAY) {
+          mp_clear(&g);
           return res;
         }
       }
 
       /* square */
       if (b > 1) {
-        if ((res = mp_sqr (&g, &g)) != MP_OKAY) {
-          mp_clear (&g);
+        if ((res = mp_sqr(&g, &g)) != MP_OKAY) {
+          mp_clear(&g);
           return res;
         }
       }
@@ -55,15 +55,15 @@ int mp_expt_d_ex (mp_int * a, mp_digit b, mp_int * c, int fast)
   else {
     for (x = 0; x < DIGIT_BIT; x++) {
       /* square */
-      if ((res = mp_sqr (c, c)) != MP_OKAY) {
-        mp_clear (&g);
+      if ((res = mp_sqr(c, c)) != MP_OKAY) {
+        mp_clear(&g);
         return res;
       }
 
       /* if the bit is set multiply */
-      if ((b & (mp_digit) (((mp_digit)1) << (DIGIT_BIT - 1))) != 0) {
-        if ((res = mp_mul (c, &g, c)) != MP_OKAY) {
-           mp_clear (&g);
+      if ((b & (mp_digit)(((mp_digit)1) << (DIGIT_BIT - 1))) != 0) {
+        if ((res = mp_mul(c, &g, c)) != MP_OKAY) {
+           mp_clear(&g);
            return res;
         }
       }
@@ -73,7 +73,7 @@ int mp_expt_d_ex (mp_int * a, mp_digit b, mp_int * c, int fast)
     }
   } /* if ... else */
 
-  mp_clear (&g);
+  mp_clear(&g);
   return MP_OKAY;
 }
 #endif
diff --git a/bn_mp_exptmod.c b/bn_mp_exptmod.c
index 167b0b2..0c45444 100644
--- a/bn_mp_exptmod.c
+++ b/bn_mp_exptmod.c
@@ -89,13 +89,13 @@ int mp_exptmod (mp_int * G, mp_int * X, mp_int * P, mp_int * Y)
 
   /* if the modulus is odd or dr != 0 use the montgomery method */
 #ifdef BN_MP_EXPTMOD_FAST_C
-  if ((mp_isodd (P) == MP_YES) || (dr !=  0)) {
-    return mp_exptmod_fast (G, X, P, Y, dr);
+  if ((mp_isodd(P) == MP_YES) || (dr !=  0)) {
+    return mp_exptmod_fast(G, X, P, Y, dr);
   } else {
 #endif
 #ifdef BN_S_MP_EXPTMOD_C
     /* otherwise use the generic Barrett reduction technique */
-    return s_mp_exptmod (G, X, P, Y, 0);
+    return s_mp_exptmod(G, X, P, Y, 0);
 #else
     /* no exptmod for evens */
     return MP_VAL;
diff --git a/bn_mp_exptmod_fast.c b/bn_mp_exptmod_fast.c
index 379203f..76bb291 100644
--- a/bn_mp_exptmod_fast.c
+++ b/bn_mp_exptmod_fast.c
@@ -42,7 +42,7 @@ int mp_exptmod_fast (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, int redmode
   int     (*redux)(mp_int*,mp_int*,mp_digit);
 
   /* find window size */
-  x = mp_count_bits (X);
+  x = mp_count_bits(X);
   if (x <= 7) {
     winsize = 2;
   } else if (x <= 36) {
@@ -75,7 +75,7 @@ int mp_exptmod_fast (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, int redmode
   for (x = 1<<(winsize-1); x < (1 << winsize); x++) {
     if ((err = mp_init_size(&M[x], P->alloc)) != MP_OKAY) {
       for (y = 1<<(winsize-1); y < x; y++) {
-        mp_clear (&M[y]);
+        mp_clear(&M[y]);
       }
       mp_clear(&M[1]);
       return err;
@@ -86,7 +86,7 @@ int mp_exptmod_fast (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, int redmode
   if (redmode == 0) {
 #ifdef BN_MP_MONTGOMERY_SETUP_C
      /* now setup montgomery  */
-     if ((err = mp_montgomery_setup (P, &mp)) != MP_OKAY) {
+     if ((err = mp_montgomery_setup(P, &mp)) != MP_OKAY) {
         goto LBL_M;
      }
 #else
@@ -133,7 +133,7 @@ int mp_exptmod_fast (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, int redmode
   }
 
   /* setup result */
-  if ((err = mp_init_size (&res, P->alloc)) != MP_OKAY) {
+  if ((err = mp_init_size(&res, P->alloc)) != MP_OKAY) {
     goto LBL_M;
   }
 
@@ -147,12 +147,12 @@ int mp_exptmod_fast (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, int redmode
   if (redmode == 0) {
 #ifdef BN_MP_MONTGOMERY_CALC_NORMALIZATION_C
      /* now we need R mod m */
-     if ((err = mp_montgomery_calc_normalization (&res, P)) != MP_OKAY) {
+     if ((err = mp_montgomery_calc_normalization(&res, P)) != MP_OKAY) {
        goto LBL_RES;
      }
 
      /* now set M[1] to G * R mod m */
-     if ((err = mp_mulmod (G, &res, P, &M[1])) != MP_OKAY) {
+     if ((err = mp_mulmod(G, &res, P, &M[1])) != MP_OKAY) {
        goto LBL_RES;
      }
 #else
@@ -167,25 +167,25 @@ int mp_exptmod_fast (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, int redmode
   }
 
   /* compute the value at M[1<<(winsize-1)] by squaring M[1] (winsize-1) times */
-  if ((err = mp_copy (&M[1], &M[1 << (winsize - 1)])) != MP_OKAY) {
+  if ((err = mp_copy(&M[1], &M[1 << (winsize - 1)])) != MP_OKAY) {
     goto LBL_RES;
   }
 
   for (x = 0; x < (winsize - 1); x++) {
-    if ((err = mp_sqr (&M[1 << (winsize - 1)], &M[1 << (winsize - 1)])) != MP_OKAY) {
+    if ((err = mp_sqr(&M[1 << (winsize - 1)], &M[1 << (winsize - 1)])) != MP_OKAY) {
       goto LBL_RES;
     }
-    if ((err = redux (&M[1 << (winsize - 1)], P, mp)) != MP_OKAY) {
+    if ((err = redux(&M[1 << (winsize - 1)], P, mp)) != MP_OKAY) {
       goto LBL_RES;
     }
   }
 
   /* create upper table */
   for (x = (1 << (winsize - 1)) + 1; x < (1 << winsize); x++) {
-    if ((err = mp_mul (&M[x - 1], &M[1], &M[x])) != MP_OKAY) {
+    if ((err = mp_mul(&M[x - 1], &M[1], &M[x])) != MP_OKAY) {
       goto LBL_RES;
     }
-    if ((err = redux (&M[x], P, mp)) != MP_OKAY) {
+    if ((err = redux(&M[x], P, mp)) != MP_OKAY) {
       goto LBL_RES;
     }
   }
@@ -225,10 +225,10 @@ int mp_exptmod_fast (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, int redmode
 
     /* if the bit is zero and mode == 1 then we square */
     if ((mode == 1) && (y == 0)) {
-      if ((err = mp_sqr (&res, &res)) != MP_OKAY) {
+      if ((err = mp_sqr(&res, &res)) != MP_OKAY) {
         goto LBL_RES;
       }
-      if ((err = redux (&res, P, mp)) != MP_OKAY) {
+      if ((err = redux(&res, P, mp)) != MP_OKAY) {
         goto LBL_RES;
       }
       continue;
@@ -242,19 +242,19 @@ int mp_exptmod_fast (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, int redmode
       /* ok window is filled so square as required and multiply  */
       /* square first */
       for (x = 0; x < winsize; x++) {
-        if ((err = mp_sqr (&res, &res)) != MP_OKAY) {
+        if ((err = mp_sqr(&res, &res)) != MP_OKAY) {
           goto LBL_RES;
         }
-        if ((err = redux (&res, P, mp)) != MP_OKAY) {
+        if ((err = redux(&res, P, mp)) != MP_OKAY) {
           goto LBL_RES;
         }
       }
 
       /* then multiply */
-      if ((err = mp_mul (&res, &M[bitbuf], &res)) != MP_OKAY) {
+      if ((err = mp_mul(&res, &M[bitbuf], &res)) != MP_OKAY) {
         goto LBL_RES;
       }
-      if ((err = redux (&res, P, mp)) != MP_OKAY) {
+      if ((err = redux(&res, P, mp)) != MP_OKAY) {
         goto LBL_RES;
       }
 
@@ -269,10 +269,10 @@ int mp_exptmod_fast (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, int redmode
   if ((mode == 2) && (bitcpy > 0)) {
     /* square then multiply if the bit is set */
     for (x = 0; x < bitcpy; x++) {
-      if ((err = mp_sqr (&res, &res)) != MP_OKAY) {
+      if ((err = mp_sqr(&res, &res)) != MP_OKAY) {
         goto LBL_RES;
       }
-      if ((err = redux (&res, P, mp)) != MP_OKAY) {
+      if ((err = redux(&res, P, mp)) != MP_OKAY) {
         goto LBL_RES;
       }
 
@@ -280,10 +280,10 @@ int mp_exptmod_fast (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, int redmode
       bitbuf <<= 1;
       if ((bitbuf & (1 << winsize)) != 0) {
         /* then multiply */
-        if ((err = mp_mul (&res, &M[1], &res)) != MP_OKAY) {
+        if ((err = mp_mul(&res, &M[1], &res)) != MP_OKAY) {
           goto LBL_RES;
         }
-        if ((err = redux (&res, P, mp)) != MP_OKAY) {
+        if ((err = redux(&res, P, mp)) != MP_OKAY) {
           goto LBL_RES;
         }
       }
@@ -303,13 +303,13 @@ int mp_exptmod_fast (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, int redmode
   }
 
   /* swap res with Y */
-  mp_exch (&res, Y);
+  mp_exch(&res, Y);
   err = MP_OKAY;
-LBL_RES:mp_clear (&res);
+LBL_RES:mp_clear(&res);
 LBL_M:
   mp_clear(&M[1]);
   for (x = 1<<(winsize-1); x < (1 << winsize); x++) {
-    mp_clear (&M[x]);
+    mp_clear(&M[x]);
   }
   return err;
 }
diff --git a/bn_mp_fwrite.c b/bn_mp_fwrite.c
index 61eaeaa..f42c8f5 100644
--- a/bn_mp_fwrite.c
+++ b/bn_mp_fwrite.c
@@ -25,24 +25,24 @@ int mp_fwrite(mp_int *a, int radix, FILE *stream)
       return err;
    }
 
-   buf = OPT_CAST(char) XMALLOC (len);
+   buf = OPT_CAST(char) XMALLOC(len);
    if (buf == NULL) {
       return MP_MEM;
    }
 
    if ((err = mp_toradix(a, buf, radix)) != MP_OKAY) {
-      XFREE (buf);
+      XFREE(buf);
       return err;
    }
 
    for (x = 0; x < len; x++) {
        if (fputc(buf[x], stream) == EOF) {
-          XFREE (buf);
+          XFREE(buf);
           return MP_VAL;
        }
    }
 
-   XFREE (buf);
+   XFREE(buf);
    return MP_OKAY;
 }
 #endif
diff --git a/bn_mp_gcd.c b/bn_mp_gcd.c
index 1b9f3ed..0128078 100644
--- a/bn_mp_gcd.c
+++ b/bn_mp_gcd.c
@@ -22,19 +22,19 @@ int mp_gcd (mp_int * a, mp_int * b, mp_int * c)
   int     k, u_lsb, v_lsb, res;
 
   /* either zero than gcd is the largest */
-  if (mp_iszero (a) == MP_YES) {
-    return mp_abs (b, c);
+  if (mp_iszero(a) == MP_YES) {
+    return mp_abs(b, c);
   }
-  if (mp_iszero (b) == MP_YES) {
-    return mp_abs (a, c);
+  if (mp_iszero(b) == MP_YES) {
+    return mp_abs(a, c);
   }
 
   /* get copies of a and b we can modify */
-  if ((res = mp_init_copy (&u, a)) != MP_OKAY) {
+  if ((res = mp_init_copy(&u, a)) != MP_OKAY) {
     return res;
   }
 
-  if ((res = mp_init_copy (&v, b)) != MP_OKAY) {
+  if ((res = mp_init_copy(&v, b)) != MP_OKAY) {
     goto LBL_U;
   }
 
@@ -89,13 +89,13 @@ int mp_gcd (mp_int * a, mp_int * b, mp_int * c)
   }
 
   /* multiply by 2**k which we divided out at the beginning */
-  if ((res = mp_mul_2d (&u, k, c)) != MP_OKAY) {
+  if ((res = mp_mul_2d(&u, k, c)) != MP_OKAY) {
      goto LBL_V;
   }
   c->sign = MP_ZPOS;
   res = MP_OKAY;
-LBL_V:mp_clear (&u);
-LBL_U:mp_clear (&v);
+LBL_V:mp_clear(&u);
+LBL_U:mp_clear(&v);
   return res;
 }
 #endif
diff --git a/bn_mp_grow.c b/bn_mp_grow.c
index 74e07b1..445476e 100644
--- a/bn_mp_grow.c
+++ b/bn_mp_grow.c
@@ -32,7 +32,7 @@ int mp_grow (mp_int * a, int size)
      * in case the operation failed we don't want
      * to overwrite the dp member of a.
      */
-    tmp = OPT_CAST(mp_digit) XREALLOC (a->dp, sizeof (mp_digit) * size);
+    tmp = OPT_CAST(mp_digit) XREALLOC(a->dp, sizeof (mp_digit) * size);
     if (tmp == NULL) {
       /* reallocation failed but "a" is still valid [can be freed] */
       return MP_MEM;
diff --git a/bn_mp_init.c b/bn_mp_init.c
index ee374ae..d15a573 100644
--- a/bn_mp_init.c
+++ b/bn_mp_init.c
@@ -21,7 +21,7 @@ int mp_init (mp_int * a)
   int i;
 
   /* allocate memory required and clear it */
-  a->dp = OPT_CAST(mp_digit) XMALLOC (sizeof (mp_digit) * MP_PREC);
+  a->dp = OPT_CAST(mp_digit) XMALLOC(sizeof (mp_digit) * MP_PREC);
   if (a->dp == NULL) {
     return MP_MEM;
   }
diff --git a/bn_mp_init_copy.c b/bn_mp_init_copy.c
index 37a57ec..3321c47 100644
--- a/bn_mp_init_copy.c
+++ b/bn_mp_init_copy.c
@@ -20,11 +20,11 @@ int mp_init_copy (mp_int * a, mp_int * b)
 {
   int     res;
 
-  if ((res = mp_init_size (a, b->used)) != MP_OKAY) {
+  if ((res = mp_init_size(a, b->used)) != MP_OKAY) {
     return res;
   }
 
-  if((res = mp_copy (b, a)) != MP_OKAY) {
+  if((res = mp_copy(b, a)) != MP_OKAY) {
     mp_clear(a);
   }
 
diff --git a/bn_mp_init_size.c b/bn_mp_init_size.c
index fd05cf8..444c680 100644
--- a/bn_mp_init_size.c
+++ b/bn_mp_init_size.c
@@ -24,7 +24,7 @@ int mp_init_size (mp_int * a, int size)
   size += (MP_PREC * 2) - (size % MP_PREC);
 
   /* alloc mem */
-  a->dp = OPT_CAST(mp_digit) XMALLOC (sizeof (mp_digit) * size);
+  a->dp = OPT_CAST(mp_digit) XMALLOC(sizeof (mp_digit) * size);
   if (a->dp == NULL) {
     return MP_MEM;
   }
diff --git a/bn_mp_invmod.c b/bn_mp_invmod.c
index 36011d0..67ae0a4 100644
--- a/bn_mp_invmod.c
+++ b/bn_mp_invmod.c
@@ -26,7 +26,7 @@ int mp_invmod (mp_int * a, mp_int * b, mp_int * c)
 #ifdef BN_FAST_MP_INVMOD_C
   /* if the modulus is odd we can use a faster routine instead */
   if ((mp_isodd(b) == MP_YES) && (mp_cmp_d(b, 1) != MP_EQ)) {
-    return fast_mp_invmod (a, b, c);
+    return fast_mp_invmod(a, b, c);
   }
 #endif
 
diff --git a/bn_mp_invmod_slow.c b/bn_mp_invmod_slow.c
index 9f57dc0..c343845 100644
--- a/bn_mp_invmod_slow.c
+++ b/bn_mp_invmod_slow.c
@@ -36,114 +36,114 @@ int mp_invmod_slow (mp_int * a, mp_int * b, mp_int * c)
   if ((res = mp_mod(a, b, &x)) != MP_OKAY) {
       goto LBL_ERR;
   }
-  if ((res = mp_copy (b, &y)) != MP_OKAY) {
+  if ((res = mp_copy(b, &y)) != MP_OKAY) {
     goto LBL_ERR;
   }
 
   /* 2. [modified] if x,y are both even then return an error! */
-  if ((mp_iseven (&x) == MP_YES) && (mp_iseven (&y) == MP_YES)) {
+  if ((mp_iseven(&x) == MP_YES) && (mp_iseven(&y) == MP_YES)) {
     res = MP_VAL;
     goto LBL_ERR;
   }
 
   /* 3. u=x, v=y, A=1, B=0, C=0,D=1 */
-  if ((res = mp_copy (&x, &u)) != MP_OKAY) {
+  if ((res = mp_copy(&x, &u)) != MP_OKAY) {
     goto LBL_ERR;
   }
-  if ((res = mp_copy (&y, &v)) != MP_OKAY) {
+  if ((res = mp_copy(&y, &v)) != MP_OKAY) {
     goto LBL_ERR;
   }
-  mp_set (&A, 1);
-  mp_set (&D, 1);
+  mp_set(&A, 1);
+  mp_set(&D, 1);
 
 top:
   /* 4.  while u is even do */
-  while (mp_iseven (&u) == MP_YES) {
+  while (mp_iseven(&u) == MP_YES) {
     /* 4.1 u = u/2 */
-    if ((res = mp_div_2 (&u, &u)) != MP_OKAY) {
+    if ((res = mp_div_2(&u, &u)) != MP_OKAY) {
       goto LBL_ERR;
     }
     /* 4.2 if A or B is odd then */
-    if ((mp_isodd (&A) == MP_YES) || (mp_isodd (&B) == MP_YES)) {
+    if ((mp_isodd(&A) == MP_YES) || (mp_isodd(&B) == MP_YES)) {
       /* A = (A+y)/2, B = (B-x)/2 */
-      if ((res = mp_add (&A, &y, &A)) != MP_OKAY) {
+      if ((res = mp_add(&A, &y, &A)) != MP_OKAY) {
          goto LBL_ERR;
       }
-      if ((res = mp_sub (&B, &x, &B)) != MP_OKAY) {
+      if ((res = mp_sub(&B, &x, &B)) != MP_OKAY) {
          goto LBL_ERR;
       }
     }
     /* A = A/2, B = B/2 */
-    if ((res = mp_div_2 (&A, &A)) != MP_OKAY) {
+    if ((res = mp_div_2(&A, &A)) != MP_OKAY) {
       goto LBL_ERR;
     }
-    if ((res = mp_div_2 (&B, &B)) != MP_OKAY) {
+    if ((res = mp_div_2(&B, &B)) != MP_OKAY) {
       goto LBL_ERR;
     }
   }
 
   /* 5.  while v is even do */
-  while (mp_iseven (&v) == MP_YES) {
+  while (mp_iseven(&v) == MP_YES) {
     /* 5.1 v = v/2 */
-    if ((res = mp_div_2 (&v, &v)) != MP_OKAY) {
+    if ((res = mp_div_2(&v, &v)) != MP_OKAY) {
       goto LBL_ERR;
     }
     /* 5.2 if C or D is odd then */
-    if ((mp_isodd (&C) == MP_YES) || (mp_isodd (&D) == MP_YES)) {
+    if ((mp_isodd(&C) == MP_YES) || (mp_isodd(&D) == MP_YES)) {
       /* C = (C+y)/2, D = (D-x)/2 */
-      if ((res = mp_add (&C, &y, &C)) != MP_OKAY) {
+      if ((res = mp_add(&C, &y, &C)) != MP_OKAY) {
          goto LBL_ERR;
       }
-      if ((res = mp_sub (&D, &x, &D)) != MP_OKAY) {
+      if ((res = mp_sub(&D, &x, &D)) != MP_OKAY) {
          goto LBL_ERR;
       }
     }
     /* C = C/2, D = D/2 */
-    if ((res = mp_div_2 (&C, &C)) != MP_OKAY) {
+    if ((res = mp_div_2(&C, &C)) != MP_OKAY) {
       goto LBL_ERR;
     }
-    if ((res = mp_div_2 (&D, &D)) != MP_OKAY) {
+    if ((res = mp_div_2(&D, &D)) != MP_OKAY) {
       goto LBL_ERR;
     }
   }
 
   /* 6.  if u >= v then */
-  if (mp_cmp (&u, &v) != MP_LT) {
+  if (mp_cmp(&u, &v) != MP_LT) {
     /* u = u - v, A = A - C, B = B - D */
-    if ((res = mp_sub (&u, &v, &u)) != MP_OKAY) {
+    if ((res = mp_sub(&u, &v, &u)) != MP_OKAY) {
       goto LBL_ERR;
     }
 
-    if ((res = mp_sub (&A, &C, &A)) != MP_OKAY) {
+    if ((res = mp_sub(&A, &C, &A)) != MP_OKAY) {
       goto LBL_ERR;
     }
 
-    if ((res = mp_sub (&B, &D, &B)) != MP_OKAY) {
+    if ((res = mp_sub(&B, &D, &B)) != MP_OKAY) {
       goto LBL_ERR;
     }
   } else {
     /* v - v - u, C = C - A, D = D - B */
-    if ((res = mp_sub (&v, &u, &v)) != MP_OKAY) {
+    if ((res = mp_sub(&v, &u, &v)) != MP_OKAY) {
       goto LBL_ERR;
     }
 
-    if ((res = mp_sub (&C, &A, &C)) != MP_OKAY) {
+    if ((res = mp_sub(&C, &A, &C)) != MP_OKAY) {
       goto LBL_ERR;
     }
 
-    if ((res = mp_sub (&D, &B, &D)) != MP_OKAY) {
+    if ((res = mp_sub(&D, &B, &D)) != MP_OKAY) {
       goto LBL_ERR;
     }
   }
 
   /* if not zero goto step 4 */
-  if (mp_iszero (&u) == MP_NO)
+  if (mp_iszero(&u) == MP_NO)
     goto top;
 
   /* now a = C, b = D, gcd == g*v */
 
   /* if v != 1 then there is no inverse */
-  if (mp_cmp_d (&v, 1) != MP_EQ) {
+  if (mp_cmp_d(&v, 1) != MP_EQ) {
     res = MP_VAL;
     goto LBL_ERR;
   }
@@ -163,9 +163,9 @@ top:
   }
 
   /* C is now the inverse */
-  mp_exch (&C, c);
+  mp_exch(&C, c);
   res = MP_OKAY;
-LBL_ERR:mp_clear_multi (&x, &y, &u, &v, &A, &B, &C, &D, NULL);
+LBL_ERR:mp_clear_multi(&x, &y, &u, &v, &A, &B, &C, &D, NULL);
   return res;
 }
 #endif
diff --git a/bn_mp_jacobi.c b/bn_mp_jacobi.c
index 5fc8593..c6fe968 100644
--- a/bn_mp_jacobi.c
+++ b/bn_mp_jacobi.c
@@ -37,9 +37,9 @@ int mp_jacobi (mp_int * a, mp_int * n, int *c)
   }
 
   /* step 1. handle case of a == 0 */
-  if (mp_iszero (a) == MP_YES) {
+  if (mp_iszero(a) == MP_YES) {
      /* special case of a == 0 and n == 1 */
-     if (mp_cmp_d (n, 1) == MP_EQ) {
+     if (mp_cmp_d(n, 1) == MP_EQ) {
        *c = 1;
      } else {
        *c = 0;
@@ -48,7 +48,7 @@ int mp_jacobi (mp_int * a, mp_int * n, int *c)
   }
 
   /* step 2.  if a == 1, return 1 */
-  if (mp_cmp_d (a, 1) == MP_EQ) {
+  if (mp_cmp_d(a, 1) == MP_EQ) {
     *c = 1;
     return MP_OKAY;
   }
@@ -57,11 +57,11 @@ int mp_jacobi (mp_int * a, mp_int * n, int *c)
   s = 0;
 
   /* step 3.  write a = a1 * 2**k  */
-  if ((res = mp_init_copy (&a1, a)) != MP_OKAY) {
+  if ((res = mp_init_copy(&a1, a)) != MP_OKAY) {
     return res;
   }
 
-  if ((res = mp_init (&p1)) != MP_OKAY) {
+  if ((res = mp_init(&p1)) != MP_OKAY) {
     goto LBL_A1;
   }
 
@@ -91,14 +91,14 @@ int mp_jacobi (mp_int * a, mp_int * n, int *c)
   }
 
   /* if a1 == 1 we're done */
-  if (mp_cmp_d (&a1, 1) == MP_EQ) {
+  if (mp_cmp_d(&a1, 1) == MP_EQ) {
     *c = s;
   } else {
     /* n1 = n mod a1 */
-    if ((res = mp_mod (n, &a1, &p1)) != MP_OKAY) {
+    if ((res = mp_mod(n, &a1, &p1)) != MP_OKAY) {
       goto LBL_P1;
     }
-    if ((res = mp_jacobi (&p1, &a1, &r)) != MP_OKAY) {
+    if ((res = mp_jacobi(&p1, &a1, &r)) != MP_OKAY) {
       goto LBL_P1;
     }
     *c = s * r;
@@ -106,8 +106,8 @@ int mp_jacobi (mp_int * a, mp_int * n, int *c)
 
   /* done */
   res = MP_OKAY;
-LBL_P1:mp_clear (&p1);
-LBL_A1:mp_clear (&a1);
+LBL_P1:mp_clear(&p1);
+LBL_A1:mp_clear(&a1);
   return res;
 }
 #endif
diff --git a/bn_mp_karatsuba_mul.c b/bn_mp_karatsuba_mul.c
index e69958d..d636708 100644
--- a/bn_mp_karatsuba_mul.c
+++ b/bn_mp_karatsuba_mul.c
@@ -53,27 +53,27 @@ int mp_karatsuba_mul (mp_int * a, mp_int * b, mp_int * c)
   err = MP_MEM;
 
   /* min # of digits */
-  B = MIN (a->used, b->used);
+  B = MIN(a->used, b->used);
 
   /* now divide in two */
   B = B >> 1;
 
   /* init copy all the temps */
-  if (mp_init_size (&x0, B) != MP_OKAY)
+  if (mp_init_size(&x0, B) != MP_OKAY)
     goto ERR;
-  if (mp_init_size (&x1, a->used - B) != MP_OKAY)
+  if (mp_init_size(&x1, a->used - B) != MP_OKAY)
     goto X0;
-  if (mp_init_size (&y0, B) != MP_OKAY)
+  if (mp_init_size(&y0, B) != MP_OKAY)
     goto X1;
-  if (mp_init_size (&y1, b->used - B) != MP_OKAY)
+  if (mp_init_size(&y1, b->used - B) != MP_OKAY)
     goto Y0;
 
   /* init temps */
-  if (mp_init_size (&t1, B * 2) != MP_OKAY)
+  if (mp_init_size(&t1, B * 2) != MP_OKAY)
     goto Y1;
-  if (mp_init_size (&x0y0, B * 2) != MP_OKAY)
+  if (mp_init_size(&x0y0, B * 2) != MP_OKAY)
     goto T1;
-  if (mp_init_size (&x1y1, B * 2) != MP_OKAY)
+  if (mp_init_size(&x1y1, B * 2) != MP_OKAY)
     goto X0Y0;
 
   /* now shift the digits */
@@ -112,51 +112,51 @@ int mp_karatsuba_mul (mp_int * a, mp_int * b, mp_int * c)
   /* only need to clamp the lower words since by definition the
    * upper words x1/y1 must have a known number of digits
    */
-  mp_clamp (&x0);
-  mp_clamp (&y0);
+  mp_clamp(&x0);
+  mp_clamp(&y0);
 
   /* now calc the products x0y0 and x1y1 */
   /* after this x0 is no longer required, free temp [x0==t2]! */
-  if (mp_mul (&x0, &y0, &x0y0) != MP_OKAY)
+  if (mp_mul(&x0, &y0, &x0y0) != MP_OKAY)
     goto X1Y1;          /* x0y0 = x0*y0 */
-  if (mp_mul (&x1, &y1, &x1y1) != MP_OKAY)
+  if (mp_mul(&x1, &y1, &x1y1) != MP_OKAY)
     goto X1Y1;          /* x1y1 = x1*y1 */
 
   /* now calc x1+x0 and y1+y0 */
-  if (s_mp_add (&x1, &x0, &t1) != MP_OKAY)
+  if (s_mp_add(&x1, &x0, &t1) != MP_OKAY)
     goto X1Y1;          /* t1 = x1 - x0 */
-  if (s_mp_add (&y1, &y0, &x0) != MP_OKAY)
+  if (s_mp_add(&y1, &y0, &x0) != MP_OKAY)
     goto X1Y1;          /* t2 = y1 - y0 */
-  if (mp_mul (&t1, &x0, &t1) != MP_OKAY)
+  if (mp_mul(&t1, &x0, &t1) != MP_OKAY)
     goto X1Y1;          /* t1 = (x1 + x0) * (y1 + y0) */
 
   /* add x0y0 */
-  if (mp_add (&x0y0, &x1y1, &x0) != MP_OKAY)
+  if (mp_add(&x0y0, &x1y1, &x0) != MP_OKAY)
     goto X1Y1;          /* t2 = x0y0 + x1y1 */
-  if (s_mp_sub (&t1, &x0, &t1) != MP_OKAY)
+  if (s_mp_sub(&t1, &x0, &t1) != MP_OKAY)
     goto X1Y1;          /* t1 = (x1+x0)*(y1+y0) - (x1y1 + x0y0) */
 
   /* shift by B */
-  if (mp_lshd (&t1, B) != MP_OKAY)
+  if (mp_lshd(&t1, B) != MP_OKAY)
     goto X1Y1;          /* t1 = (x0y0 + x1y1 - (x1-x0)*(y1-y0))<<B */
-  if (mp_lshd (&x1y1, B * 2) != MP_OKAY)
+  if (mp_lshd(&x1y1, B * 2) != MP_OKAY)
     goto X1Y1;          /* x1y1 = x1y1 << 2*B */
 
-  if (mp_add (&x0y0, &t1, &t1) != MP_OKAY)
+  if (mp_add(&x0y0, &t1, &t1) != MP_OKAY)
     goto X1Y1;          /* t1 = x0y0 + t1 */
-  if (mp_add (&t1, &x1y1, c) != MP_OKAY)
+  if (mp_add(&t1, &x1y1, c) != MP_OKAY)
     goto X1Y1;          /* t1 = x0y0 + t1 + x1y1 */
 
   /* Algorithm succeeded set the return code to MP_OKAY */
   err = MP_OKAY;
 
-X1Y1:mp_clear (&x1y1);
-X0Y0:mp_clear (&x0y0);
-T1:mp_clear (&t1);
-Y1:mp_clear (&y1);
-Y0:mp_clear (&y0);
-X1:mp_clear (&x1);
-X0:mp_clear (&x0);
+X1Y1:mp_clear(&x1y1);
+X0Y0:mp_clear(&x0y0);
+T1:mp_clear(&t1);
+Y1:mp_clear(&y1);
+Y0:mp_clear(&y0);
+X1:mp_clear(&x1);
+X0:mp_clear(&x0);
 ERR:
   return err;
 }
diff --git a/bn_mp_karatsuba_sqr.c b/bn_mp_karatsuba_sqr.c
index eb525c1..944663a 100644
--- a/bn_mp_karatsuba_sqr.c
+++ b/bn_mp_karatsuba_sqr.c
@@ -36,19 +36,19 @@ int mp_karatsuba_sqr (mp_int * a, mp_int * b)
   B = B >> 1;
 
   /* init copy all the temps */
-  if (mp_init_size (&x0, B) != MP_OKAY)
+  if (mp_init_size(&x0, B) != MP_OKAY)
     goto ERR;
-  if (mp_init_size (&x1, a->used - B) != MP_OKAY)
+  if (mp_init_size(&x1, a->used - B) != MP_OKAY)
     goto X0;
 
   /* init temps */
-  if (mp_init_size (&t1, a->used * 2) != MP_OKAY)
+  if (mp_init_size(&t1, a->used * 2) != MP_OKAY)
     goto X1;
-  if (mp_init_size (&t2, a->used * 2) != MP_OKAY)
+  if (mp_init_size(&t2, a->used * 2) != MP_OKAY)
     goto T1;
-  if (mp_init_size (&x0x0, B * 2) != MP_OKAY)
+  if (mp_init_size(&x0x0, B * 2) != MP_OKAY)
     goto T2;
-  if (mp_init_size (&x1x1, (a->used - B) * 2) != MP_OKAY)
+  if (mp_init_size(&x1x1, (a->used - B) * 2) != MP_OKAY)
     goto X0X0;
 
   {
@@ -72,45 +72,45 @@ int mp_karatsuba_sqr (mp_int * a, mp_int * b)
   x0.used = B;
   x1.used = a->used - B;
 
-  mp_clamp (&x0);
+  mp_clamp(&x0);
 
   /* now calc the products x0*x0 and x1*x1 */
-  if (mp_sqr (&x0, &x0x0) != MP_OKAY)
+  if (mp_sqr(&x0, &x0x0) != MP_OKAY)
     goto X1X1;           /* x0x0 = x0*x0 */
-  if (mp_sqr (&x1, &x1x1) != MP_OKAY)
+  if (mp_sqr(&x1, &x1x1) != MP_OKAY)
     goto X1X1;           /* x1x1 = x1*x1 */
 
   /* now calc (x1+x0)**2 */
-  if (s_mp_add (&x1, &x0, &t1) != MP_OKAY)
+  if (s_mp_add(&x1, &x0, &t1) != MP_OKAY)
     goto X1X1;           /* t1 = x1 - x0 */
-  if (mp_sqr (&t1, &t1) != MP_OKAY)
+  if (mp_sqr(&t1, &t1) != MP_OKAY)
     goto X1X1;           /* t1 = (x1 - x0) * (x1 - x0) */
 
   /* add x0y0 */
-  if (s_mp_add (&x0x0, &x1x1, &t2) != MP_OKAY)
+  if (s_mp_add(&x0x0, &x1x1, &t2) != MP_OKAY)
     goto X1X1;           /* t2 = x0x0 + x1x1 */
-  if (s_mp_sub (&t1, &t2, &t1) != MP_OKAY)
+  if (s_mp_sub(&t1, &t2, &t1) != MP_OKAY)
     goto X1X1;           /* t1 = (x1+x0)**2 - (x0x0 + x1x1) */
 
   /* shift by B */
-  if (mp_lshd (&t1, B) != MP_OKAY)
+  if (mp_lshd(&t1, B) != MP_OKAY)
     goto X1X1;           /* t1 = (x0x0 + x1x1 - (x1-x0)*(x1-x0))<<B */
-  if (mp_lshd (&x1x1, B * 2) != MP_OKAY)
+  if (mp_lshd(&x1x1, B * 2) != MP_OKAY)
     goto X1X1;           /* x1x1 = x1x1 << 2*B */
 
-  if (mp_add (&x0x0, &t1, &t1) != MP_OKAY)
+  if (mp_add(&x0x0, &t1, &t1) != MP_OKAY)
     goto X1X1;           /* t1 = x0x0 + t1 */
-  if (mp_add (&t1, &x1x1, b) != MP_OKAY)
+  if (mp_add(&t1, &x1x1, b) != MP_OKAY)
     goto X1X1;           /* t1 = x0x0 + t1 + x1x1 */
 
   err = MP_OKAY;
 
-X1X1:mp_clear (&x1x1);
-X0X0:mp_clear (&x0x0);
-T2:mp_clear (&t2);
-T1:mp_clear (&t1);
-X1:mp_clear (&x1);
-X0:mp_clear (&x0);
+X1X1:mp_clear(&x1x1);
+X0X0:mp_clear(&x0x0);
+T2:mp_clear(&t2);
+T1:mp_clear(&t1);
+X1:mp_clear(&x1);
+X0:mp_clear(&x0);
 ERR:
   return err;
 }
diff --git a/bn_mp_lcm.c b/bn_mp_lcm.c
index 512e8ec..b9643a7 100644
--- a/bn_mp_lcm.c
+++ b/bn_mp_lcm.c
@@ -22,12 +22,12 @@ int mp_lcm (mp_int * a, mp_int * b, mp_int * c)
   mp_int  t1, t2;
 
 
-  if ((res = mp_init_multi (&t1, &t2, NULL)) != MP_OKAY) {
+  if ((res = mp_init_multi(&t1, &t2, NULL)) != MP_OKAY) {
     return res;
   }
 
   /* t1 = get the GCD of the two inputs */
-  if ((res = mp_gcd (a, b, &t1)) != MP_OKAY) {
+  if ((res = mp_gcd(a, b, &t1)) != MP_OKAY) {
     goto LBL_T;
   }
 
@@ -50,7 +50,7 @@ int mp_lcm (mp_int * a, mp_int * b, mp_int * c)
   c->sign = MP_ZPOS;
 
 LBL_T:
-  mp_clear_multi (&t1, &t2, NULL);
+  mp_clear_multi(&t1, &t2, NULL);
   return res;
 }
 #endif
diff --git a/bn_mp_lshd.c b/bn_mp_lshd.c
index 0143e94..ece2d63 100644
--- a/bn_mp_lshd.c
+++ b/bn_mp_lshd.c
@@ -27,7 +27,7 @@ int mp_lshd (mp_int * a, int b)
 
   /* grow to fit the new digits */
   if (a->alloc < (a->used + b)) {
-     if ((res = mp_grow (a, a->used + b)) != MP_OKAY) {
+     if ((res = mp_grow(a, a->used + b)) != MP_OKAY) {
        return res;
      }
   }
diff --git a/bn_mp_mod.c b/bn_mp_mod.c
index 06240a0..45f6dea 100644
--- a/bn_mp_mod.c
+++ b/bn_mp_mod.c
@@ -22,23 +22,23 @@ mp_mod (mp_int * a, mp_int * b, mp_int * c)
   mp_int  t;
   int     res;
 
-  if ((res = mp_init_size (&t, b->used)) != MP_OKAY) {
+  if ((res = mp_init_size(&t, b->used)) != MP_OKAY) {
     return res;
   }
 
-  if ((res = mp_div (a, b, NULL, &t)) != MP_OKAY) {
-    mp_clear (&t);
+  if ((res = mp_div(a, b, NULL, &t)) != MP_OKAY) {
+    mp_clear(&t);
     return res;
   }
 
   if ((mp_iszero(&t) != MP_NO) || (t.sign == b->sign)) {
     res = MP_OKAY;
-    mp_exch (&t, c);
+    mp_exch(&t, c);
   } else {
-    res = mp_add (b, &t, c);
+    res = mp_add(b, &t, c);
   }
 
-  mp_clear (&t);
+  mp_clear(&t);
   return res;
 }
 #endif
diff --git a/bn_mp_mod_2d.c b/bn_mp_mod_2d.c
index 2bb86da..fae5c3f 100644
--- a/bn_mp_mod_2d.c
+++ b/bn_mp_mod_2d.c
@@ -23,18 +23,18 @@ mp_mod_2d (mp_int * a, int b, mp_int * c)
 
   /* if b is <= 0 then zero the int */
   if (b <= 0) {
-    mp_zero (c);
+    mp_zero(c);
     return MP_OKAY;
   }
 
   /* if the modulus is larger than the value than return */
   if (b >= (int) (a->used * DIGIT_BIT)) {
-    res = mp_copy (a, c);
+    res = mp_copy(a, c);
     return res;
   }
 
   /* copy */
-  if ((res = mp_copy (a, c)) != MP_OKAY) {
+  if ((res = mp_copy(a, c)) != MP_OKAY) {
     return res;
   }
 
@@ -44,8 +44,8 @@ mp_mod_2d (mp_int * a, int b, mp_int * c)
   }
   /* clear the digit that is not completely outside/inside the modulus */
   c->dp[b / DIGIT_BIT] &=
-    (mp_digit) ((((mp_digit) 1) << (((mp_digit) b) % DIGIT_BIT)) - ((mp_digit) 1));
-  mp_clamp (c);
+    (mp_digit)((((mp_digit) 1) << (((mp_digit) b) % DIGIT_BIT)) - ((mp_digit) 1));
+  mp_clamp(c);
   return MP_OKAY;
 }
 #endif
diff --git a/bn_mp_montgomery_calc_normalization.c b/bn_mp_montgomery_calc_normalization.c
index 679a871..62a7d81 100644
--- a/bn_mp_montgomery_calc_normalization.c
+++ b/bn_mp_montgomery_calc_normalization.c
@@ -26,10 +26,10 @@ int mp_montgomery_calc_normalization (mp_int * a, mp_int * b)
   int     x, bits, res;
 
   /* how many bits of last digit does b use */
-  bits = mp_count_bits (b) % DIGIT_BIT;
+  bits = mp_count_bits(b) % DIGIT_BIT;
 
   if (b->used > 1) {
-     if ((res = mp_2expt (a, ((b->used - 1) * DIGIT_BIT) + bits - 1)) != MP_OKAY) {
+     if ((res = mp_2expt(a, ((b->used - 1) * DIGIT_BIT) + bits - 1)) != MP_OKAY) {
         return res;
      }
   } else {
@@ -40,11 +40,11 @@ int mp_montgomery_calc_normalization (mp_int * a, mp_int * b)
 
   /* now compute C = A * B mod b */
   for (x = bits - 1; x < (int)DIGIT_BIT; x++) {
-    if ((res = mp_mul_2 (a, a)) != MP_OKAY) {
+    if ((res = mp_mul_2(a, a)) != MP_OKAY) {
       return res;
     }
-    if (mp_cmp_mag (a, b) != MP_LT) {
-      if ((res = s_mp_sub (a, b, a)) != MP_OKAY) {
+    if (mp_cmp_mag(a, b) != MP_LT) {
+      if ((res = s_mp_sub(a, b, a)) != MP_OKAY) {
         return res;
       }
     }
diff --git a/bn_mp_montgomery_reduce.c b/bn_mp_montgomery_reduce.c
index 05e8bfa..ab5c77d 100644
--- a/bn_mp_montgomery_reduce.c
+++ b/bn_mp_montgomery_reduce.c
@@ -32,12 +32,12 @@ mp_montgomery_reduce (mp_int * x, mp_int * n, mp_digit rho)
   if ((digs < MP_WARRAY) &&
       (n->used <
       (1 << ((CHAR_BIT * sizeof(mp_word)) - (2 * DIGIT_BIT))))) {
-    return fast_mp_montgomery_reduce (x, n, rho);
+    return fast_mp_montgomery_reduce(x, n, rho);
   }
 
   /* grow the input as required */
   if (x->alloc < digs) {
-    if ((res = mp_grow (x, digs)) != MP_OKAY) {
+    if ((res = mp_grow(x, digs)) != MP_OKAY) {
       return res;
     }
   }
@@ -52,7 +52,7 @@ mp_montgomery_reduce (mp_int * x, mp_int * n, mp_digit rho)
      * following inner loop to reduce the
      * input one digit at a time
      */
-    mu = (mp_digit) (((mp_word)x->dp[ix] * (mp_word)rho) & MP_MASK);
+    mu = (mp_digit)(((mp_word)x->dp[ix] * (mp_word)rho) & MP_MASK);
 
     /* a = a + mu * m * b**i */
     {
@@ -102,11 +102,11 @@ mp_montgomery_reduce (mp_int * x, mp_int * n, mp_digit rho)
 
   /* x = x/b**n.used */
   mp_clamp(x);
-  mp_rshd (x, n->used);
+  mp_rshd(x, n->used);
 
   /* if x >= n then x = x - n */
-  if (mp_cmp_mag (x, n) != MP_LT) {
-    return s_mp_sub (x, n, x);
+  if (mp_cmp_mag(x, n) != MP_LT) {
+    return s_mp_sub(x, n, x);
   }
 
   return MP_OKAY;
diff --git a/bn_mp_mul.c b/bn_mp_mul.c
index f6f49e2..ee6bbf2 100644
--- a/bn_mp_mul.c
+++ b/bn_mp_mul.c
@@ -23,14 +23,14 @@ int mp_mul (mp_int * a, mp_int * b, mp_int * c)
 
   /* use Toom-Cook? */
 #ifdef BN_MP_TOOM_MUL_C
-  if (MIN (a->used, b->used) >= TOOM_MUL_CUTOFF) {
+  if (MIN(a->used, b->used) >= TOOM_MUL_CUTOFF) {
     res = mp_toom_mul(a, b, c);
   } else
 #endif
 #ifdef BN_MP_KARATSUBA_MUL_C
   /* use Karatsuba? */
-  if (MIN (a->used, b->used) >= KARATSUBA_MUL_CUTOFF) {
-    res = mp_karatsuba_mul (a, b, c);
+  if (MIN(a->used, b->used) >= KARATSUBA_MUL_CUTOFF) {
+    res = mp_karatsuba_mul(a, b, c);
   } else
 #endif
   {
@@ -46,12 +46,12 @@ int mp_mul (mp_int * a, mp_int * b, mp_int * c)
     if ((digs < MP_WARRAY) &&
         (MIN(a->used, b->used) <=
          (1 << ((CHAR_BIT * sizeof(mp_word)) - (2 * DIGIT_BIT))))) {
-      res = fast_s_mp_mul_digs (a, b, c, digs);
+      res = fast_s_mp_mul_digs(a, b, c, digs);
     } else
 #endif
     {
 #ifdef BN_S_MP_MUL_DIGS_C
-      res = s_mp_mul (a, b, c); /* uses s_mp_mul_digs */
+      res = s_mp_mul(a, b, c); /* uses s_mp_mul_digs */
 #else
       res = MP_VAL;
 #endif
diff --git a/bn_mp_mul_2.c b/bn_mp_mul_2.c
index 277a760..4d63e83 100644
--- a/bn_mp_mul_2.c
+++ b/bn_mp_mul_2.c
@@ -22,7 +22,7 @@ int mp_mul_2(mp_int * a, mp_int * b)
 
   /* grow to accomodate result */
   if (b->alloc < (a->used + 1)) {
-    if ((res = mp_grow (b, a->used + 1)) != MP_OKAY) {
+    if ((res = mp_grow(b, a->used + 1)) != MP_OKAY) {
       return res;
     }
   }
diff --git a/bn_mp_mul_2d.c b/bn_mp_mul_2d.c
index cf68570..811c2c5 100644
--- a/bn_mp_mul_2d.c
+++ b/bn_mp_mul_2d.c
@@ -23,26 +23,26 @@ int mp_mul_2d (mp_int * a, int b, mp_int * c)
 
   /* copy */
   if (a != c) {
-     if ((res = mp_copy (a, c)) != MP_OKAY) {
+     if ((res = mp_copy(a, c)) != MP_OKAY) {
        return res;
      }
   }
 
   if (c->alloc < (int)(c->used + (b / DIGIT_BIT) + 1)) {
-     if ((res = mp_grow (c, c->used + (b / DIGIT_BIT) + 1)) != MP_OKAY) {
+     if ((res = mp_grow(c, c->used + (b / DIGIT_BIT) + 1)) != MP_OKAY) {
        return res;
      }
   }
 
   /* shift by as many digits in the bit count */
   if (b >= (int)DIGIT_BIT) {
-    if ((res = mp_lshd (c, b / DIGIT_BIT)) != MP_OKAY) {
+    if ((res = mp_lshd(c, b / DIGIT_BIT)) != MP_OKAY) {
       return res;
     }
   }
 
   /* shift any bit count < DIGIT_BIT */
-  d = (mp_digit) (b % DIGIT_BIT);
+  d = (mp_digit)(b % DIGIT_BIT);
   if (d != 0) {
     mp_digit *tmpc, shift, mask, r, rr;
     int x;
@@ -75,7 +75,7 @@ int mp_mul_2d (mp_int * a, int b, mp_int * c)
        c->dp[(c->used)++] = r;
     }
   }
-  mp_clamp (c);
+  mp_clamp(c);
   return MP_OKAY;
 }
 #endif
diff --git a/bn_mp_mul_d.c b/bn_mp_mul_d.c
index 6954ed3..38de7c5 100644
--- a/bn_mp_mul_d.c
+++ b/bn_mp_mul_d.c
@@ -25,7 +25,7 @@ mp_mul_d (mp_int * a, mp_digit b, mp_int * c)
 
   /* make sure c is big enough to hold a*b */
   if (c->alloc < (a->used + 1)) {
-    if ((res = mp_grow (c, a->used + 1)) != MP_OKAY) {
+    if ((res = mp_grow(c, a->used + 1)) != MP_OKAY) {
       return res;
     }
   }
@@ -51,10 +51,10 @@ mp_mul_d (mp_int * a, mp_digit b, mp_int * c)
     r       = (mp_word)u + ((mp_word)*tmpa++ * (mp_word)b);
 
     /* mask off higher bits to get a single digit */
-    *tmpc++ = (mp_digit) (r & ((mp_word) MP_MASK));
+    *tmpc++ = (mp_digit)(r & ((mp_word)MP_MASK));
 
     /* send carry into next iteration */
-    u       = (mp_digit) (r >> ((mp_word) DIGIT_BIT));
+    u       = (mp_digit)(r >> ((mp_word)DIGIT_BIT));
   }
 
   /* store final carry [if any] and increment ix offset  */
diff --git a/bn_mp_mulmod.c b/bn_mp_mulmod.c
index d7a4d3c..0ff8861 100644
--- a/bn_mp_mulmod.c
+++ b/bn_mp_mulmod.c
@@ -21,16 +21,16 @@ int mp_mulmod (mp_int * a, mp_int * b, mp_int * c, mp_int * d)
   int     res;
   mp_int  t;
 
-  if ((res = mp_init_size (&t, c->used)) != MP_OKAY) {
+  if ((res = mp_init_size(&t, c->used)) != MP_OKAY) {
     return res;
   }
 
-  if ((res = mp_mul (a, b, &t)) != MP_OKAY) {
-    mp_clear (&t);
+  if ((res = mp_mul(a, b, &t)) != MP_OKAY) {
+    mp_clear(&t);
     return res;
   }
-  res = mp_mod (&t, c, d);
-  mp_clear (&t);
+  res = mp_mod(&t, c, d);
+  mp_clear(&t);
   return res;
 }
 #endif
diff --git a/bn_mp_n_root_ex.c b/bn_mp_n_root_ex.c
index 079b4f3..cf58e90 100644
--- a/bn_mp_n_root_ex.c
+++ b/bn_mp_n_root_ex.c
@@ -35,15 +35,15 @@ int mp_n_root_ex (mp_int * a, mp_digit b, mp_int * c, int fast)
     return MP_VAL;
   }
 
-  if ((res = mp_init (&t1)) != MP_OKAY) {
+  if ((res = mp_init(&t1)) != MP_OKAY) {
     return res;
   }
 
-  if ((res = mp_init (&t2)) != MP_OKAY) {
+  if ((res = mp_init(&t2)) != MP_OKAY) {
     goto LBL_T1;
   }
 
-  if ((res = mp_init (&t3)) != MP_OKAY) {
+  if ((res = mp_init(&t3)) != MP_OKAY) {
     goto LBL_T2;
   }
 
@@ -52,56 +52,56 @@ int mp_n_root_ex (mp_int * a, mp_digit b, mp_int * c, int fast)
   a->sign = MP_ZPOS;
 
   /* t2 = 2 */
-  mp_set (&t2, 2);
+  mp_set(&t2, 2);
 
   do {
     /* t1 = t2 */
-    if ((res = mp_copy (&t2, &t1)) != MP_OKAY) {
+    if ((res = mp_copy(&t2, &t1)) != MP_OKAY) {
       goto LBL_T3;
     }
 
     /* t2 = t1 - ((t1**b - a) / (b * t1**(b-1))) */
 
     /* t3 = t1**(b-1) */
-    if ((res = mp_expt_d_ex (&t1, b - 1, &t3, fast)) != MP_OKAY) {
+    if ((res = mp_expt_d_ex(&t1, b - 1, &t3, fast)) != MP_OKAY) {
       goto LBL_T3;
     }
 
     /* numerator */
     /* t2 = t1**b */
-    if ((res = mp_mul (&t3, &t1, &t2)) != MP_OKAY) {
+    if ((res = mp_mul(&t3, &t1, &t2)) != MP_OKAY) {
       goto LBL_T3;
     }
 
     /* t2 = t1**b - a */
-    if ((res = mp_sub (&t2, a, &t2)) != MP_OKAY) {
+    if ((res = mp_sub(&t2, a, &t2)) != MP_OKAY) {
       goto LBL_T3;
     }
 
     /* denominator */
     /* t3 = t1**(b-1) * b  */
-    if ((res = mp_mul_d (&t3, b, &t3)) != MP_OKAY) {
+    if ((res = mp_mul_d(&t3, b, &t3)) != MP_OKAY) {
       goto LBL_T3;
     }
 
     /* t3 = (t1**b - a)/(b * t1**(b-1)) */
-    if ((res = mp_div (&t2, &t3, &t3, NULL)) != MP_OKAY) {
+    if ((res = mp_div(&t2, &t3, &t3, NULL)) != MP_OKAY) {
       goto LBL_T3;
     }
 
-    if ((res = mp_sub (&t1, &t3, &t2)) != MP_OKAY) {
+    if ((res = mp_sub(&t1, &t3, &t2)) != MP_OKAY) {
       goto LBL_T3;
     }
-  }  while (mp_cmp (&t1, &t2) != MP_EQ);
+  }  while (mp_cmp(&t1, &t2) != MP_EQ);
 
   /* result can be off by a few so check */
   for (;;) {
-    if ((res = mp_expt_d_ex (&t1, b, &t2, fast)) != MP_OKAY) {
+    if ((res = mp_expt_d_ex(&t1, b, &t2, fast)) != MP_OKAY) {
       goto LBL_T3;
     }
 
-    if (mp_cmp (&t2, a) == MP_GT) {
-      if ((res = mp_sub_d (&t1, 1, &t1)) != MP_OKAY) {
+    if (mp_cmp(&t2, a) == MP_GT) {
+      if ((res = mp_sub_d(&t1, 1, &t1)) != MP_OKAY) {
          goto LBL_T3;
       }
     } else {
@@ -113,16 +113,16 @@ int mp_n_root_ex (mp_int * a, mp_digit b, mp_int * c, int fast)
   a->sign = neg;
 
   /* set the result */
-  mp_exch (&t1, c);
+  mp_exch(&t1, c);
 
   /* set the sign of the result */
   c->sign = neg;
 
   res = MP_OKAY;
 
-LBL_T3:mp_clear (&t3);
-LBL_T2:mp_clear (&t2);
-LBL_T1:mp_clear (&t1);
+LBL_T3:mp_clear(&t3);
+LBL_T2:mp_clear(&t2);
+LBL_T1:mp_clear(&t1);
   return res;
 }
 #endif
diff --git a/bn_mp_neg.c b/bn_mp_neg.c
index d03e92e..72ddcda 100644
--- a/bn_mp_neg.c
+++ b/bn_mp_neg.c
@@ -20,7 +20,7 @@ int mp_neg (mp_int * a, mp_int * b)
 {
   int     res;
   if (a != b) {
-     if ((res = mp_copy (a, b)) != MP_OKAY) {
+     if ((res = mp_copy(a, b)) != MP_OKAY) {
         return res;
      }
   }
diff --git a/bn_mp_or.c b/bn_mp_or.c
index b9775ce..e47a1db 100644
--- a/bn_mp_or.c
+++ b/bn_mp_or.c
@@ -22,13 +22,13 @@ int mp_or (mp_int * a, mp_int * b, mp_int * c)
   mp_int  t, *x;
 
   if (a->used > b->used) {
-    if ((res = mp_init_copy (&t, a)) != MP_OKAY) {
+    if ((res = mp_init_copy(&t, a)) != MP_OKAY) {
       return res;
     }
     px = b->used;
     x = b;
   } else {
-    if ((res = mp_init_copy (&t, b)) != MP_OKAY) {
+    if ((res = mp_init_copy(&t, b)) != MP_OKAY) {
       return res;
     }
     px = a->used;
@@ -38,9 +38,9 @@ int mp_or (mp_int * a, mp_int * b, mp_int * c)
   for (ix = 0; ix < px; ix++) {
     t.dp[ix] |= x->dp[ix];
   }
-  mp_clamp (&t);
-  mp_exch (c, &t);
-  mp_clear (&t);
+  mp_clamp(&t);
+  mp_exch(c, &t);
+  mp_clear(&t);
   return MP_OKAY;
 }
 #endif
diff --git a/bn_mp_prime_fermat.c b/bn_mp_prime_fermat.c
index c41f4c4..961ad6c 100644
--- a/bn_mp_prime_fermat.c
+++ b/bn_mp_prime_fermat.c
@@ -37,22 +37,22 @@ int mp_prime_fermat (mp_int * a, mp_int * b, int *result)
   }
 
   /* init t */
-  if ((err = mp_init (&t)) != MP_OKAY) {
+  if ((err = mp_init(&t)) != MP_OKAY) {
     return err;
   }
 
   /* compute t = b**a mod a */
-  if ((err = mp_exptmod (b, a, a, &t)) != MP_OKAY) {
+  if ((err = mp_exptmod(b, a, a, &t)) != MP_OKAY) {
     goto LBL_T;
   }
 
   /* is it equal to b? */
-  if (mp_cmp (&t, b) == MP_EQ) {
+  if (mp_cmp(&t, b) == MP_EQ) {
     *result = MP_YES;
   }
 
   err = MP_OKAY;
-LBL_T:mp_clear (&t);
+LBL_T:mp_clear(&t);
   return err;
 }
 #endif
diff --git a/bn_mp_prime_is_divisible.c b/bn_mp_prime_is_divisible.c
index 889b77c..57a3082 100644
--- a/bn_mp_prime_is_divisible.c
+++ b/bn_mp_prime_is_divisible.c
@@ -30,7 +30,7 @@ int mp_prime_is_divisible (mp_int * a, int *result)
 
   for (ix = 0; ix < PRIME_SIZE; ix++) {
     /* what is a mod LBL_prime_tab[ix] */
-    if ((err = mp_mod_d (a, ltm_prime_tab[ix], &res)) != MP_OKAY) {
+    if ((err = mp_mod_d(a, ltm_prime_tab[ix], &res)) != MP_OKAY) {
       return err;
     }
 
diff --git a/bn_mp_prime_is_prime.c b/bn_mp_prime_is_prime.c
index 3eda4fd..00422d9 100644
--- a/bn_mp_prime_is_prime.c
+++ b/bn_mp_prime_is_prime.c
@@ -44,7 +44,7 @@ int mp_prime_is_prime (mp_int * a, int t, int *result)
   }
 
   /* first perform trial division */
-  if ((err = mp_prime_is_divisible (a, &res)) != MP_OKAY) {
+  if ((err = mp_prime_is_divisible(a, &res)) != MP_OKAY) {
     return err;
   }
 
@@ -54,15 +54,15 @@ int mp_prime_is_prime (mp_int * a, int t, int *result)
   }
 
   /* now perform the miller-rabin rounds */
-  if ((err = mp_init (&b)) != MP_OKAY) {
+  if ((err = mp_init(&b)) != MP_OKAY) {
     return err;
   }
 
   for (ix = 0; ix < t; ix++) {
     /* set the prime */
-    mp_set (&b, ltm_prime_tab[ix]);
+    mp_set(&b, ltm_prime_tab[ix]);
 
-    if ((err = mp_prime_miller_rabin (a, &b, &res)) != MP_OKAY) {
+    if ((err = mp_prime_miller_rabin(a, &b, &res)) != MP_OKAY) {
       goto LBL_B;
     }
 
@@ -73,7 +73,7 @@ int mp_prime_is_prime (mp_int * a, int t, int *result)
 
   /* passed the test */
   *result = MP_YES;
-LBL_B:mp_clear (&b);
+LBL_B:mp_clear(&b);
   return err;
 }
 #endif
diff --git a/bn_mp_prime_miller_rabin.c b/bn_mp_prime_miller_rabin.c
index f3f4efd..f98a95c 100644
--- a/bn_mp_prime_miller_rabin.c
+++ b/bn_mp_prime_miller_rabin.c
@@ -36,15 +36,15 @@ int mp_prime_miller_rabin (mp_int * a, mp_int * b, int *result)
   }
 
   /* get n1 = a - 1 */
-  if ((err = mp_init_copy (&n1, a)) != MP_OKAY) {
+  if ((err = mp_init_copy(&n1, a)) != MP_OKAY) {
     return err;
   }
-  if ((err = mp_sub_d (&n1, 1, &n1)) != MP_OKAY) {
+  if ((err = mp_sub_d(&n1, 1, &n1)) != MP_OKAY) {
     goto LBL_N1;
   }
 
   /* set 2**s * r = n1 */
-  if ((err = mp_init_copy (&r, &n1)) != MP_OKAY) {
+  if ((err = mp_init_copy(&r, &n1)) != MP_OKAY) {
     goto LBL_N1;
   }
 
@@ -54,29 +54,29 @@ int mp_prime_miller_rabin (mp_int * a, mp_int * b, int *result)
   s = mp_cnt_lsb(&r);
 
   /* now divide n - 1 by 2**s */
-  if ((err = mp_div_2d (&r, s, &r, NULL)) != MP_OKAY) {
+  if ((err = mp_div_2d(&r, s, &r, NULL)) != MP_OKAY) {
     goto LBL_R;
   }
 
   /* compute y = b**r mod a */
-  if ((err = mp_init (&y)) != MP_OKAY) {
+  if ((err = mp_init(&y)) != MP_OKAY) {
     goto LBL_R;
   }
-  if ((err = mp_exptmod (b, &r, a, &y)) != MP_OKAY) {
+  if ((err = mp_exptmod(b, &r, a, &y)) != MP_OKAY) {
     goto LBL_Y;
   }
 
   /* if y != 1 and y != n1 do */
-  if ((mp_cmp_d (&y, 1) != MP_EQ) && (mp_cmp (&y, &n1) != MP_EQ)) {
+  if ((mp_cmp_d(&y, 1) != MP_EQ) && (mp_cmp(&y, &n1) != MP_EQ)) {
     j = 1;
     /* while j <= s-1 and y != n1 */
-    while ((j <= (s - 1)) && (mp_cmp (&y, &n1) != MP_EQ)) {
-      if ((err = mp_sqrmod (&y, a, &y)) != MP_OKAY) {
+    while ((j <= (s - 1)) && (mp_cmp(&y, &n1) != MP_EQ)) {
+      if ((err = mp_sqrmod(&y, a, &y)) != MP_OKAY) {
          goto LBL_Y;
       }
 
       /* if y == 1 then composite */
-      if (mp_cmp_d (&y, 1) == MP_EQ) {
+      if (mp_cmp_d(&y, 1) == MP_EQ) {
          goto LBL_Y;
       }
 
@@ -84,16 +84,16 @@ int mp_prime_miller_rabin (mp_int * a, mp_int * b, int *result)
     }
 
     /* if y != n1 then composite */
-    if (mp_cmp (&y, &n1) != MP_EQ) {
+    if (mp_cmp(&y, &n1) != MP_EQ) {
       goto LBL_Y;
     }
   }
 
   /* probably prime now */
   *result = MP_YES;
-LBL_Y:mp_clear (&y);
-LBL_R:mp_clear (&r);
-LBL_N1:mp_clear (&n1);
+LBL_Y:mp_clear(&y);
+LBL_R:mp_clear(&r);
+LBL_N1:mp_clear(&n1);
   return err;
 }
 #endif
diff --git a/bn_mp_radix_size.c b/bn_mp_radix_size.c
index 053fda5..3a0c482 100644
--- a/bn_mp_radix_size.c
+++ b/bn_mp_radix_size.c
@@ -36,7 +36,7 @@ int mp_radix_size (mp_int * a, int radix, int *size)
 
   /* special case for binary */
   if (radix == 2) {
-    *size = mp_count_bits (a) + ((a->sign == MP_NEG) ? 1 : 0) + 1;
+    *size = mp_count_bits(a) + ((a->sign == MP_NEG) ? 1 : 0) + 1;
     return MP_OKAY;
   }
 
@@ -49,7 +49,7 @@ int mp_radix_size (mp_int * a, int radix, int *size)
   }
 
   /* init a copy of the input */
-  if ((res = mp_init_copy (&t, a)) != MP_OKAY) {
+  if ((res = mp_init_copy(&t, a)) != MP_OKAY) {
     return res;
   }
 
@@ -57,14 +57,14 @@ int mp_radix_size (mp_int * a, int radix, int *size)
   t.sign = MP_ZPOS;
 
   /* fetch out all of the digits */
-  while (mp_iszero (&t) == MP_NO) {
-    if ((res = mp_div_d (&t, (mp_digit) radix, &t, &d)) != MP_OKAY) {
-      mp_clear (&t);
+  while (mp_iszero(&t) == MP_NO) {
+    if ((res = mp_div_d(&t, (mp_digit)radix, &t, &d)) != MP_OKAY) {
+      mp_clear(&t);
       return res;
     }
     ++digs;
   }
-  mp_clear (&t);
+  mp_clear(&t);
 
   /* return digs + 1, the 1 is for the NULL byte that would be required. */
   *size = digs + 1;
diff --git a/bn_mp_rand.c b/bn_mp_rand.c
index 93e255a..2992d53 100644
--- a/bn_mp_rand.c
+++ b/bn_mp_rand.c
@@ -47,7 +47,7 @@ mp_rand (mp_int * a, int digits)
   int     res;
   mp_digit d;
 
-  mp_zero (a);
+  mp_zero(a);
   if (digits <= 0) {
     return MP_OKAY;
   }
@@ -57,16 +57,16 @@ mp_rand (mp_int * a, int digits)
     d = s_gen_random();
   } while (d == 0);
 
-  if ((res = mp_add_d (a, d, a)) != MP_OKAY) {
+  if ((res = mp_add_d(a, d, a)) != MP_OKAY) {
     return res;
   }
 
   while (--digits > 0) {
-    if ((res = mp_lshd (a, 1)) != MP_OKAY) {
+    if ((res = mp_lshd(a, 1)) != MP_OKAY) {
       return res;
     }
 
-    if ((res = mp_add_d (a, s_gen_random(), a)) != MP_OKAY) {
+    if ((res = mp_add_d(a, s_gen_random(), a)) != MP_OKAY) {
       return res;
     }
   }
diff --git a/bn_mp_read_radix.c b/bn_mp_read_radix.c
index 4319062..1d8b423 100644
--- a/bn_mp_read_radix.c
+++ b/bn_mp_read_radix.c
@@ -40,7 +40,7 @@ int mp_read_radix (mp_int * a, const char *str, int radix)
   }
 
   /* set the integer to the default of zero */
-  mp_zero (a);
+  mp_zero(a);
 
   /* process each digit of the string */
   while (*str != '\0') {
@@ -60,10 +60,10 @@ int mp_read_radix (mp_int * a, const char *str, int radix)
      * to the number, otherwise exit the loop.
      */
     if (y < radix) {
-      if ((res = mp_mul_d (a, (mp_digit) radix, a)) != MP_OKAY) {
+      if ((res = mp_mul_d(a, (mp_digit)radix, a)) != MP_OKAY) {
          return res;
       }
-      if ((res = mp_add_d (a, (mp_digit) y, a)) != MP_OKAY) {
+      if ((res = mp_add_d(a, (mp_digit)y, a)) != MP_OKAY) {
          return res;
       }
     } else {
diff --git a/bn_mp_read_signed_bin.c b/bn_mp_read_signed_bin.c
index 363e11f..4aa3237 100644
--- a/bn_mp_read_signed_bin.c
+++ b/bn_mp_read_signed_bin.c
@@ -21,7 +21,7 @@ int mp_read_signed_bin (mp_int * a, const unsigned char *b, int c)
   int     res;
 
   /* read magnitude */
-  if ((res = mp_read_unsigned_bin (a, b + 1, c - 1)) != MP_OKAY) {
+  if ((res = mp_read_unsigned_bin(a, b + 1, c - 1)) != MP_OKAY) {
     return res;
   }
 
diff --git a/bn_mp_read_unsigned_bin.c b/bn_mp_read_unsigned_bin.c
index 1a50b58..ca12f25 100644
--- a/bn_mp_read_unsigned_bin.c
+++ b/bn_mp_read_unsigned_bin.c
@@ -28,11 +28,11 @@ int mp_read_unsigned_bin (mp_int * a, const unsigned char *b, int c)
   }
 
   /* zero the int */
-  mp_zero (a);
+  mp_zero(a);
 
   /* read the bytes in */
   while (c-- > 0) {
-    if ((res = mp_mul_2d (a, 8, a)) != MP_OKAY) {
+    if ((res = mp_mul_2d(a, 8, a)) != MP_OKAY) {
       return res;
     }
 
@@ -45,7 +45,7 @@ int mp_read_unsigned_bin (mp_int * a, const unsigned char *b, int c)
     a->used += 2;
 #endif
   }
-  mp_clamp (a);
+  mp_clamp(a);
   return MP_OKAY;
 }
 #endif
diff --git a/bn_mp_reduce.c b/bn_mp_reduce.c
index 367383f..4700c3b 100644
--- a/bn_mp_reduce.c
+++ b/bn_mp_reduce.c
@@ -25,25 +25,25 @@ int mp_reduce (mp_int * x, mp_int * m, mp_int * mu)
   int     res, um = m->used;
 
   /* q = x */
-  if ((res = mp_init_copy (&q, x)) != MP_OKAY) {
+  if ((res = mp_init_copy(&q, x)) != MP_OKAY) {
     return res;
   }
 
   /* q1 = x / b**(k-1)  */
-  mp_rshd (&q, um - 1);
+  mp_rshd(&q, um - 1);
 
   /* according to HAC this optimization is ok */
   if (((mp_digit) um) > (((mp_digit)1) << (DIGIT_BIT - 1))) {
-    if ((res = mp_mul (&q, mu, &q)) != MP_OKAY) {
+    if ((res = mp_mul(&q, mu, &q)) != MP_OKAY) {
       goto CLEANUP;
     }
   } else {
 #ifdef BN_S_MP_MUL_HIGH_DIGS_C
-    if ((res = s_mp_mul_high_digs (&q, mu, &q, um)) != MP_OKAY) {
+    if ((res = s_mp_mul_high_digs(&q, mu, &q, um)) != MP_OKAY) {
       goto CLEANUP;
     }
 #elif defined(BN_FAST_S_MP_MUL_HIGH_DIGS_C)
-    if ((res = fast_s_mp_mul_high_digs (&q, mu, &q, um)) != MP_OKAY) {
+    if ((res = fast_s_mp_mul_high_digs(&q, mu, &q, um)) != MP_OKAY) {
       goto CLEANUP;
     }
 #else
@@ -55,41 +55,41 @@ int mp_reduce (mp_int * x, mp_int * m, mp_int * mu)
   }
 
   /* q3 = q2 / b**(k+1) */
-  mp_rshd (&q, um + 1);
+  mp_rshd(&q, um + 1);
 
   /* x = x mod b**(k+1), quick (no division) */
-  if ((res = mp_mod_2d (x, DIGIT_BIT * (um + 1), x)) != MP_OKAY) {
+  if ((res = mp_mod_2d(x, DIGIT_BIT * (um + 1), x)) != MP_OKAY) {
     goto CLEANUP;
   }
 
   /* q = q * m mod b**(k+1), quick (no division) */
-  if ((res = s_mp_mul_digs (&q, m, &q, um + 1)) != MP_OKAY) {
+  if ((res = s_mp_mul_digs(&q, m, &q, um + 1)) != MP_OKAY) {
     goto CLEANUP;
   }
 
   /* x = x - q */
-  if ((res = mp_sub (x, &q, x)) != MP_OKAY) {
+  if ((res = mp_sub(x, &q, x)) != MP_OKAY) {
     goto CLEANUP;
   }
 
   /* If x < 0, add b**(k+1) to it */
-  if (mp_cmp_d (x, 0) == MP_LT) {
-    mp_set (&q, 1);
-    if ((res = mp_lshd (&q, um + 1)) != MP_OKAY)
+  if (mp_cmp_d(x, 0) == MP_LT) {
+    mp_set(&q, 1);
+    if ((res = mp_lshd(&q, um + 1)) != MP_OKAY)
       goto CLEANUP;
-    if ((res = mp_add (x, &q, x)) != MP_OKAY)
+    if ((res = mp_add(x, &q, x)) != MP_OKAY)
       goto CLEANUP;
   }
 
   /* Back off if it's too big */
-  while (mp_cmp (x, m) != MP_LT) {
-    if ((res = s_mp_sub (x, m, x)) != MP_OKAY) {
+  while (mp_cmp(x, m) != MP_LT) {
+    if ((res = s_mp_sub(x, m, x)) != MP_OKAY) {
       goto CLEANUP;
     }
   }
 
 CLEANUP:
-  mp_clear (&q);
+  mp_clear(&q);
 
   return res;
 }
diff --git a/bn_mp_reduce_setup.c b/bn_mp_reduce_setup.c
index a81e799..1c9ce10 100644
--- a/bn_mp_reduce_setup.c
+++ b/bn_mp_reduce_setup.c
@@ -22,10 +22,10 @@ int mp_reduce_setup (mp_int * a, mp_int * b)
 {
   int     res;
 
-  if ((res = mp_2expt (a, b->used * 2 * DIGIT_BIT)) != MP_OKAY) {
+  if ((res = mp_2expt(a, b->used * 2 * DIGIT_BIT)) != MP_OKAY) {
     return res;
   }
-  return mp_div (a, b, a, NULL);
+  return mp_div(a, b, a, NULL);
 }
 #endif
 
diff --git a/bn_mp_rshd.c b/bn_mp_rshd.c
index c74e15a..8768751 100644
--- a/bn_mp_rshd.c
+++ b/bn_mp_rshd.c
@@ -27,7 +27,7 @@ void mp_rshd (mp_int * a, int b)
 
   /* if b > used then simply zero it and return */
   if (a->used <= b) {
-    mp_zero (a);
+    mp_zero(a);
     return;
   }
 
diff --git a/bn_mp_set.c b/bn_mp_set.c
index dd4de3c..85e1bfe 100644
--- a/bn_mp_set.c
+++ b/bn_mp_set.c
@@ -18,7 +18,7 @@
 /* set to a digit */
 void mp_set (mp_int * a, mp_digit b)
 {
-  mp_zero (a);
+  mp_zero(a);
   a->dp[0] = b & MP_MASK;
   a->used  = (a->dp[0] != 0) ? 1 : 0;
 }
diff --git a/bn_mp_set_int.c b/bn_mp_set_int.c
index 4066471..9ced0ab 100644
--- a/bn_mp_set_int.c
+++ b/bn_mp_set_int.c
@@ -20,12 +20,12 @@ int mp_set_int (mp_int * a, unsigned long b)
 {
   int     x, res;
 
-  mp_zero (a);
+  mp_zero(a);
 
   /* set four bits at a time */
   for (x = 0; x < 8; x++) {
     /* shift the number up four bits */
-    if ((res = mp_mul_2d (a, 4, a)) != MP_OKAY) {
+    if ((res = mp_mul_2d(a, 4, a)) != MP_OKAY) {
       return res;
     }
 
@@ -38,7 +38,7 @@ int mp_set_int (mp_int * a, unsigned long b)
     /* ensure that digits are not clamped off */
     a->used += 1;
   }
-  mp_clamp (a);
+  mp_clamp(a);
   return MP_OKAY;
 }
 #endif
diff --git a/bn_mp_shrink.c b/bn_mp_shrink.c
index cd1159b..5f08631 100644
--- a/bn_mp_shrink.c
+++ b/bn_mp_shrink.c
@@ -26,7 +26,7 @@ int mp_shrink (mp_int * a)
   }
 
   if (a->alloc != used) {
-    if ((tmp = OPT_CAST(mp_digit) XREALLOC (a->dp, sizeof (mp_digit) * used)) == NULL) {
+    if ((tmp = OPT_CAST(mp_digit) XREALLOC(a->dp, sizeof (mp_digit) * used)) == NULL) {
       return MP_MEM;
     }
     a->dp    = tmp;
diff --git a/bn_mp_signed_bin_size.c b/bn_mp_signed_bin_size.c
index 0910333..e94a396 100644
--- a/bn_mp_signed_bin_size.c
+++ b/bn_mp_signed_bin_size.c
@@ -18,7 +18,7 @@
 /* get the size for an signed equivalent */
 int mp_signed_bin_size (mp_int * a)
 {
-  return 1 + mp_unsigned_bin_size (a);
+  return 1 + mp_unsigned_bin_size(a);
 }
 #endif
 
diff --git a/bn_mp_sqr.c b/bn_mp_sqr.c
index 250d802..9aed3d9 100644
--- a/bn_mp_sqr.c
+++ b/bn_mp_sqr.c
@@ -30,7 +30,7 @@ mp_sqr (mp_int * a, mp_int * b)
 #endif
 #ifdef BN_MP_KARATSUBA_SQR_C
   if (a->used >= KARATSUBA_SQR_CUTOFF) {
-    res = mp_karatsuba_sqr (a, b);
+    res = mp_karatsuba_sqr(a, b);
   } else
 #endif
   {
@@ -39,12 +39,12 @@ mp_sqr (mp_int * a, mp_int * b)
     if ((((a->used * 2) + 1) < MP_WARRAY) &&
          (a->used <
          (1 << (((sizeof(mp_word) * CHAR_BIT) - (2 * DIGIT_BIT)) - 1)))) {
-      res = fast_s_mp_sqr (a, b);
+      res = fast_s_mp_sqr(a, b);
     } else
 #endif
     {
 #ifdef BN_S_MP_SQR_C
-      res = s_mp_sqr (a, b);
+      res = s_mp_sqr(a, b);
 #else
       res = MP_VAL;
 #endif
diff --git a/bn_mp_sqrmod.c b/bn_mp_sqrmod.c
index 3b29fbc..6a03fac 100644
--- a/bn_mp_sqrmod.c
+++ b/bn_mp_sqrmod.c
@@ -22,16 +22,16 @@ mp_sqrmod (mp_int * a, mp_int * b, mp_int * c)
   int     res;
   mp_int  t;
 
-  if ((res = mp_init (&t)) != MP_OKAY) {
+  if ((res = mp_init(&t)) != MP_OKAY) {
     return res;
   }
 
-  if ((res = mp_sqr (a, &t)) != MP_OKAY) {
-    mp_clear (&t);
+  if ((res = mp_sqr(a, &t)) != MP_OKAY) {
+    mp_clear(&t);
     return res;
   }
-  res = mp_mod (&t, b, c);
-  mp_clear (&t);
+  res = mp_mod(&t, b, c);
+  mp_clear(&t);
   return res;
 }
 #endif
diff --git a/bn_mp_sqrt.c b/bn_mp_sqrt.c
index 6adb2fb..779a896 100644
--- a/bn_mp_sqrt.c
+++ b/bn_mp_sqrt.c
@@ -41,7 +41,7 @@ int mp_sqrt(mp_int *arg, mp_int *ret)
   }
 
   /* First approx. (not very bad for large arg) */
-  mp_rshd (&t1, t1.used/2);
+  mp_rshd(&t1, t1.used/2);
 
   /* t1 > 0  */
   if ((res = mp_div(arg, &t1, &t2, NULL)) != MP_OKAY) {
diff --git a/bn_mp_sub.c b/bn_mp_sub.c
index 2f73faa..d458102 100644
--- a/bn_mp_sub.c
+++ b/bn_mp_sub.c
@@ -30,23 +30,23 @@ mp_sub (mp_int * a, mp_int * b, mp_int * c)
     /* In either case, ADD their magnitudes, */
     /* and use the sign of the first number. */
     c->sign = sa;
-    res = s_mp_add (a, b, c);
+    res = s_mp_add(a, b, c);
   } else {
     /* subtract a positive from a positive, OR */
     /* subtract a negative from a negative. */
     /* First, take the difference between their */
     /* magnitudes, then... */
-    if (mp_cmp_mag (a, b) != MP_LT) {
+    if (mp_cmp_mag(a, b) != MP_LT) {
       /* Copy the sign from the first */
       c->sign = sa;
       /* The first has a larger or equal magnitude */
-      res = s_mp_sub (a, b, c);
+      res = s_mp_sub(a, b, c);
     } else {
       /* The result has the *opposite* sign from */
       /* the first number. */
       c->sign = (sa == MP_ZPOS) ? MP_NEG : MP_ZPOS;
       /* The second has a larger magnitude */
-      res = s_mp_sub (b, a, c);
+      res = s_mp_sub(b, a, c);
     }
   }
   return res;
diff --git a/bn_mp_submod.c b/bn_mp_submod.c
index 138863c..4817e47 100644
--- a/bn_mp_submod.c
+++ b/bn_mp_submod.c
@@ -23,16 +23,16 @@ mp_submod (mp_int * a, mp_int * b, mp_int * c, mp_int * d)
   mp_int  t;
 
 
-  if ((res = mp_init (&t)) != MP_OKAY) {
+  if ((res = mp_init(&t)) != MP_OKAY) {
     return res;
   }
 
-  if ((res = mp_sub (a, b, &t)) != MP_OKAY) {
-    mp_clear (&t);
+  if ((res = mp_sub(a, b, &t)) != MP_OKAY) {
+    mp_clear(&t);
     return res;
   }
-  res = mp_mod (&t, c, d);
-  mp_clear (&t);
+  res = mp_mod(&t, c, d);
+  mp_clear(&t);
   return res;
 }
 #endif
diff --git a/bn_mp_to_signed_bin.c b/bn_mp_to_signed_bin.c
index c49c87d..f5568be 100644
--- a/bn_mp_to_signed_bin.c
+++ b/bn_mp_to_signed_bin.c
@@ -20,7 +20,7 @@ int mp_to_signed_bin (mp_int * a, unsigned char *b)
 {
   int     res;
 
-  if ((res = mp_to_unsigned_bin (a, b + 1)) != MP_OKAY) {
+  if ((res = mp_to_unsigned_bin(a, b + 1)) != MP_OKAY) {
     return res;
   }
   b[0] = (a->sign == MP_ZPOS) ? (unsigned char)0 : (unsigned char)1;
diff --git a/bn_mp_to_unsigned_bin.c b/bn_mp_to_unsigned_bin.c
index d249359..bb03818 100644
--- a/bn_mp_to_unsigned_bin.c
+++ b/bn_mp_to_unsigned_bin.c
@@ -21,24 +21,24 @@ int mp_to_unsigned_bin (mp_int * a, unsigned char *b)
   int     x, res;
   mp_int  t;
 
-  if ((res = mp_init_copy (&t, a)) != MP_OKAY) {
+  if ((res = mp_init_copy(&t, a)) != MP_OKAY) {
     return res;
   }
 
   x = 0;
-  while (mp_iszero (&t) == MP_NO) {
+  while (mp_iszero(&t) == MP_NO) {
 #ifndef MP_8BIT
-      b[x++] = (unsigned char) (t.dp[0] & 255);
+      b[x++] = (unsigned char)(t.dp[0] & 255);
 #else
-      b[x++] = (unsigned char) (t.dp[0] | ((t.dp[1] & 0x01) << 7));
+      b[x++] = (unsigned char)(t.dp[0] | ((t.dp[1] & 0x01) << 7));
 #endif
-    if ((res = mp_div_2d (&t, 8, &t, NULL)) != MP_OKAY) {
-      mp_clear (&t);
+    if ((res = mp_div_2d(&t, 8, &t, NULL)) != MP_OKAY) {
+      mp_clear(&t);
       return res;
     }
   }
-  bn_reverse (b, x);
-  mp_clear (&t);
+  bn_reverse(b, x);
+  mp_clear(&t);
   return MP_OKAY;
 }
 #endif
diff --git a/bn_mp_toradix.c b/bn_mp_toradix.c
index 3337765..766aa6d 100644
--- a/bn_mp_toradix.c
+++ b/bn_mp_toradix.c
@@ -35,7 +35,7 @@ int mp_toradix (mp_int * a, char *str, int radix)
      return MP_OKAY;
   }
 
-  if ((res = mp_init_copy (&t, a)) != MP_OKAY) {
+  if ((res = mp_init_copy(&t, a)) != MP_OKAY) {
     return res;
   }
 
@@ -47,9 +47,9 @@ int mp_toradix (mp_int * a, char *str, int radix)
   }
 
   digs = 0;
-  while (mp_iszero (&t) == MP_NO) {
-    if ((res = mp_div_d (&t, (mp_digit) radix, &t, &d)) != MP_OKAY) {
-      mp_clear (&t);
+  while (mp_iszero(&t) == MP_NO) {
+    if ((res = mp_div_d(&t, (mp_digit)radix, &t, &d)) != MP_OKAY) {
+      mp_clear(&t);
       return res;
     }
     *str++ = mp_s_rmap[d];
@@ -59,12 +59,12 @@ int mp_toradix (mp_int * a, char *str, int radix)
   /* reverse the digits of the string.  In this case _s points
    * to the first digit [exluding the sign] of the number]
    */
-  bn_reverse ((unsigned char *)_s, digs);
+  bn_reverse((unsigned char *)_s, digs);
 
   /* append a NULL so the string is properly terminated */
   *str = '\0';
 
-  mp_clear (&t);
+  mp_clear(&t);
   return MP_OKAY;
 }
 
diff --git a/bn_mp_toradix_n.c b/bn_mp_toradix_n.c
index 5c39ec3..c394e92 100644
--- a/bn_mp_toradix_n.c
+++ b/bn_mp_toradix_n.c
@@ -38,7 +38,7 @@ int mp_toradix_n(mp_int * a, char *str, int radix, int maxlen)
      return MP_OKAY;
   }
 
-  if ((res = mp_init_copy (&t, a)) != MP_OKAY) {
+  if ((res = mp_init_copy(&t, a)) != MP_OKAY) {
     return res;
   }
 
@@ -56,13 +56,13 @@ int mp_toradix_n(mp_int * a, char *str, int radix, int maxlen)
   }
 
   digs = 0;
-  while (mp_iszero (&t) == MP_NO) {
+  while (mp_iszero(&t) == MP_NO) {
     if (--maxlen < 1) {
        /* no more room */
        break;
     }
-    if ((res = mp_div_d (&t, (mp_digit) radix, &t, &d)) != MP_OKAY) {
-      mp_clear (&t);
+    if ((res = mp_div_d(&t, (mp_digit)radix, &t, &d)) != MP_OKAY) {
+      mp_clear(&t);
       return res;
     }
     *str++ = mp_s_rmap[d];
@@ -72,12 +72,12 @@ int mp_toradix_n(mp_int * a, char *str, int radix, int maxlen)
   /* reverse the digits of the string.  In this case _s points
    * to the first digit [exluding the sign] of the number
    */
-  bn_reverse ((unsigned char *)_s, digs);
+  bn_reverse((unsigned char *)_s, digs);
 
   /* append a NULL so the string is properly terminated */
   *str = '\0';
 
-  mp_clear (&t);
+  mp_clear(&t);
   return MP_OKAY;
 }
 
diff --git a/bn_mp_unsigned_bin_size.c b/bn_mp_unsigned_bin_size.c
index f46d0ba..9cc0d8c 100644
--- a/bn_mp_unsigned_bin_size.c
+++ b/bn_mp_unsigned_bin_size.c
@@ -18,7 +18,7 @@
 /* get the size for an unsigned equivalent */
 int mp_unsigned_bin_size (mp_int * a)
 {
-  int     size = mp_count_bits (a);
+  int     size = mp_count_bits(a);
   return (size / 8) + (((size & 7) != 0) ? 1 : 0);
 }
 #endif
diff --git a/bn_mp_xor.c b/bn_mp_xor.c
index f51fc8e..3cf312b 100644
--- a/bn_mp_xor.c
+++ b/bn_mp_xor.c
@@ -23,13 +23,13 @@ mp_xor (mp_int * a, mp_int * b, mp_int * c)
   mp_int  t, *x;
 
   if (a->used > b->used) {
-    if ((res = mp_init_copy (&t, a)) != MP_OKAY) {
+    if ((res = mp_init_copy(&t, a)) != MP_OKAY) {
       return res;
     }
     px = b->used;
     x = b;
   } else {
-    if ((res = mp_init_copy (&t, b)) != MP_OKAY) {
+    if ((res = mp_init_copy(&t, b)) != MP_OKAY) {
       return res;
     }
     px = a->used;
@@ -39,9 +39,9 @@ mp_xor (mp_int * a, mp_int * b, mp_int * c)
   for (ix = 0; ix < px; ix++) {
      t.dp[ix] ^= x->dp[ix];
   }
-  mp_clamp (&t);
-  mp_exch (c, &t);
-  mp_clear (&t);
+  mp_clamp(&t);
+  mp_exch(c, &t);
+  mp_clear(&t);
   return MP_OKAY;
 }
 #endif
diff --git a/bn_s_mp_add.c b/bn_s_mp_add.c
index 562c721..9bd46c1 100644
--- a/bn_s_mp_add.c
+++ b/bn_s_mp_add.c
@@ -37,7 +37,7 @@ s_mp_add (mp_int * a, mp_int * b, mp_int * c)
 
   /* init result */
   if (c->alloc < (max + 1)) {
-    if ((res = mp_grow (c, max + 1)) != MP_OKAY) {
+    if ((res = mp_grow(c, max + 1)) != MP_OKAY) {
       return res;
     }
   }
@@ -99,7 +99,7 @@ s_mp_add (mp_int * a, mp_int * b, mp_int * c)
     }
   }
 
-  mp_clamp (c);
+  mp_clamp(c);
   return MP_OKAY;
 }
 #endif
diff --git a/bn_s_mp_exptmod.c b/bn_s_mp_exptmod.c
index 7d63aef..fc318b1 100644
--- a/bn_s_mp_exptmod.c
+++ b/bn_s_mp_exptmod.c
@@ -28,7 +28,7 @@ int s_mp_exptmod (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, int redmode)
   int (*redux)(mp_int*,mp_int*,mp_int*);
 
   /* find window size */
-  x = mp_count_bits (X);
+  x = mp_count_bits(X);
   if (x <= 7) {
     winsize = 2;
   } else if (x <= 36) {
@@ -61,7 +61,7 @@ int s_mp_exptmod (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, int redmode)
   for (x = 1<<(winsize-1); x < (1 << winsize); x++) {
     if ((err = mp_init(&M[x])) != MP_OKAY) {
       for (y = 1<<(winsize-1); y < x; y++) {
-        mp_clear (&M[y]);
+        mp_clear(&M[y]);
       }
       mp_clear(&M[1]);
       return err;
@@ -69,17 +69,17 @@ int s_mp_exptmod (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, int redmode)
   }
 
   /* create mu, used for Barrett reduction */
-  if ((err = mp_init (&mu)) != MP_OKAY) {
+  if ((err = mp_init(&mu)) != MP_OKAY) {
     goto LBL_M;
   }
 
   if (redmode == 0) {
-     if ((err = mp_reduce_setup (&mu, P)) != MP_OKAY) {
+     if ((err = mp_reduce_setup(&mu, P)) != MP_OKAY) {
         goto LBL_MU;
      }
      redux = mp_reduce;
   } else {
-     if ((err = mp_reduce_2k_setup_l (P, &mu)) != MP_OKAY) {
+     if ((err = mp_reduce_2k_setup_l(P, &mu)) != MP_OKAY) {
         goto LBL_MU;
      }
      redux = mp_reduce_2k_l;
@@ -93,26 +93,26 @@ int s_mp_exptmod (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, int redmode)
    * The first half of the table is not
    * computed though accept for M[0] and M[1]
    */
-  if ((err = mp_mod (G, P, &M[1])) != MP_OKAY) {
+  if ((err = mp_mod(G, P, &M[1])) != MP_OKAY) {
     goto LBL_MU;
   }
 
   /* compute the value at M[1<<(winsize-1)] by squaring
    * M[1] (winsize-1) times
    */
-  if ((err = mp_copy (&M[1], &M[1 << (winsize - 1)])) != MP_OKAY) {
+  if ((err = mp_copy(&M[1], &M[1 << (winsize - 1)])) != MP_OKAY) {
     goto LBL_MU;
   }
 
   for (x = 0; x < (winsize - 1); x++) {
     /* square it */
-    if ((err = mp_sqr (&M[1 << (winsize - 1)],
-                       &M[1 << (winsize - 1)])) != MP_OKAY) {
+    if ((err = mp_sqr(&M[1 << (winsize - 1)],
+                      &M[1 << (winsize - 1)])) != MP_OKAY) {
       goto LBL_MU;
     }
 
     /* reduce modulo P */
-    if ((err = redux (&M[1 << (winsize - 1)], P, &mu)) != MP_OKAY) {
+    if ((err = redux(&M[1 << (winsize - 1)], P, &mu)) != MP_OKAY) {
       goto LBL_MU;
     }
   }
@@ -121,19 +121,19 @@ int s_mp_exptmod (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, int redmode)
    * for x = (2**(winsize - 1) + 1) to (2**winsize - 1)
    */
   for (x = (1 << (winsize - 1)) + 1; x < (1 << winsize); x++) {
-    if ((err = mp_mul (&M[x - 1], &M[1], &M[x])) != MP_OKAY) {
+    if ((err = mp_mul(&M[x - 1], &M[1], &M[x])) != MP_OKAY) {
       goto LBL_MU;
     }
-    if ((err = redux (&M[x], P, &mu)) != MP_OKAY) {
+    if ((err = redux(&M[x], P, &mu)) != MP_OKAY) {
       goto LBL_MU;
     }
   }
 
   /* setup result */
-  if ((err = mp_init (&res)) != MP_OKAY) {
+  if ((err = mp_init(&res)) != MP_OKAY) {
     goto LBL_MU;
   }
-  mp_set (&res, 1);
+  mp_set(&res, 1);
 
   /* set initial mode and bit cnt */
   mode   = 0;
@@ -152,7 +152,7 @@ int s_mp_exptmod (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, int redmode)
       }
       /* read next digit and reset the bitcnt */
       buf    = X->dp[digidx--];
-      bitcnt = (int) DIGIT_BIT;
+      bitcnt = (int)DIGIT_BIT;
     }
 
     /* grab the next msb from the exponent */
@@ -170,10 +170,10 @@ int s_mp_exptmod (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, int redmode)
 
     /* if the bit is zero and mode == 1 then we square */
     if ((mode == 1) && (y == 0)) {
-      if ((err = mp_sqr (&res, &res)) != MP_OKAY) {
+      if ((err = mp_sqr(&res, &res)) != MP_OKAY) {
         goto LBL_RES;
       }
-      if ((err = redux (&res, P, &mu)) != MP_OKAY) {
+      if ((err = redux(&res, P, &mu)) != MP_OKAY) {
         goto LBL_RES;
       }
       continue;
@@ -187,19 +187,19 @@ int s_mp_exptmod (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, int redmode)
       /* ok window is filled so square as required and multiply  */
       /* square first */
       for (x = 0; x < winsize; x++) {
-        if ((err = mp_sqr (&res, &res)) != MP_OKAY) {
+        if ((err = mp_sqr(&res, &res)) != MP_OKAY) {
           goto LBL_RES;
         }
-        if ((err = redux (&res, P, &mu)) != MP_OKAY) {
+        if ((err = redux(&res, P, &mu)) != MP_OKAY) {
           goto LBL_RES;
         }
       }
 
       /* then multiply */
-      if ((err = mp_mul (&res, &M[bitbuf], &res)) != MP_OKAY) {
+      if ((err = mp_mul(&res, &M[bitbuf], &res)) != MP_OKAY) {
         goto LBL_RES;
       }
-      if ((err = redux (&res, P, &mu)) != MP_OKAY) {
+      if ((err = redux(&res, P, &mu)) != MP_OKAY) {
         goto LBL_RES;
       }
 
@@ -214,34 +214,34 @@ int s_mp_exptmod (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, int redmode)
   if ((mode == 2) && (bitcpy > 0)) {
     /* square then multiply if the bit is set */
     for (x = 0; x < bitcpy; x++) {
-      if ((err = mp_sqr (&res, &res)) != MP_OKAY) {
+      if ((err = mp_sqr(&res, &res)) != MP_OKAY) {
         goto LBL_RES;
       }
-      if ((err = redux (&res, P, &mu)) != MP_OKAY) {
+      if ((err = redux(&res, P, &mu)) != MP_OKAY) {
         goto LBL_RES;
       }
 
       bitbuf <<= 1;
       if ((bitbuf & (1 << winsize)) != 0) {
         /* then multiply */
-        if ((err = mp_mul (&res, &M[1], &res)) != MP_OKAY) {
+        if ((err = mp_mul(&res, &M[1], &res)) != MP_OKAY) {
           goto LBL_RES;
         }
-        if ((err = redux (&res, P, &mu)) != MP_OKAY) {
+        if ((err = redux(&res, P, &mu)) != MP_OKAY) {
           goto LBL_RES;
         }
       }
     }
   }
 
-  mp_exch (&res, Y);
+  mp_exch(&res, Y);
   err = MP_OKAY;
-LBL_RES:mp_clear (&res);
-LBL_MU:mp_clear (&mu);
+LBL_RES:mp_clear(&res);
+LBL_MU:mp_clear(&mu);
 LBL_M:
   mp_clear(&M[1]);
   for (x = 1<<(winsize-1); x < (1 << winsize); x++) {
-    mp_clear (&M[x]);
+    mp_clear(&M[x]);
   }
   return err;
 }
diff --git a/bn_s_mp_mul_digs.c b/bn_s_mp_mul_digs.c
index 9eb4609..47ddb5f 100644
--- a/bn_s_mp_mul_digs.c
+++ b/bn_s_mp_mul_digs.c
@@ -31,10 +31,10 @@ int s_mp_mul_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
   if (((digs) < MP_WARRAY) &&
       (MIN (a->used, b->used) <
           (1 << ((CHAR_BIT * sizeof(mp_word)) - (2 * DIGIT_BIT))))) {
-    return fast_s_mp_mul_digs (a, b, c, digs);
+    return fast_s_mp_mul_digs(a, b, c, digs);
   }
 
-  if ((res = mp_init_size (&t, digs)) != MP_OKAY) {
+  if ((res = mp_init_size(&t, digs)) != MP_OKAY) {
     return res;
   }
   t.used = digs;
@@ -46,7 +46,7 @@ int s_mp_mul_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
     u = 0;
 
     /* limit ourselves to making digs digits of output */
-    pb = MIN (b->used, digs - ix);
+    pb = MIN(b->used, digs - ix);
 
     /* setup some aliases */
     /* copy of the digit from a used within the nested loop */
@@ -77,10 +77,10 @@ int s_mp_mul_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
     }
   }
 
-  mp_clamp (&t);
-  mp_exch (&t, c);
+  mp_clamp(&t);
+  mp_exch(&t, c);
 
-  mp_clear (&t);
+  mp_clear(&t);
   return MP_OKAY;
 }
 #endif
diff --git a/bn_s_mp_mul_high_digs.c b/bn_s_mp_mul_high_digs.c
index 031f17b..e1f671c 100644
--- a/bn_s_mp_mul_high_digs.c
+++ b/bn_s_mp_mul_high_digs.c
@@ -30,12 +30,12 @@ s_mp_mul_high_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
   /* can we use the fast multiplier? */
 #ifdef BN_FAST_S_MP_MUL_HIGH_DIGS_C
   if (((a->used + b->used + 1) < MP_WARRAY)
-      && (MIN (a->used, b->used) < (1 << ((CHAR_BIT * sizeof(mp_word)) - (2 * DIGIT_BIT))))) {
-    return fast_s_mp_mul_high_digs (a, b, c, digs);
+      && (MIN(a->used, b->used) < (1 << ((CHAR_BIT * sizeof(mp_word)) - (2 * DIGIT_BIT))))) {
+    return fast_s_mp_mul_high_digs(a, b, c, digs);
   }
 #endif
 
-  if ((res = mp_init_size (&t, a->used + b->used + 1)) != MP_OKAY) {
+  if ((res = mp_init_size(&t, a->used + b->used + 1)) != MP_OKAY) {
     return res;
   }
   t.used = a->used + b->used + 1;
@@ -62,16 +62,16 @@ s_mp_mul_high_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
                 (mp_word)u;
 
       /* get the lower part */
-      *tmpt++ = (mp_digit) (r & ((mp_word) MP_MASK));
+      *tmpt++ = (mp_digit)(r & ((mp_word) MP_MASK));
 
       /* carry the carry */
-      u       = (mp_digit) (r >> ((mp_word) DIGIT_BIT));
+      u       = (mp_digit)(r >> ((mp_word) DIGIT_BIT));
     }
     *tmpt = u;
   }
-  mp_clamp (&t);
-  mp_exch (&t, c);
-  mp_clear (&t);
+  mp_clamp(&t);
+  mp_exch(&t, c);
+  mp_clear(&t);
   return MP_OKAY;
 }
 #endif
diff --git a/bn_s_mp_sqr.c b/bn_s_mp_sqr.c
index 7266b97..382a9cf 100644
--- a/bn_s_mp_sqr.c
+++ b/bn_s_mp_sqr.c
@@ -24,7 +24,7 @@ int s_mp_sqr (mp_int * a, mp_int * b)
   mp_digit u, tmpx, *tmpt;
 
   pa = a->used;
-  if ((res = mp_init_size (&t, (2 * pa) + 1)) != MP_OKAY) {
+  if ((res = mp_init_size(&t, (2 * pa) + 1)) != MP_OKAY) {
     return res;
   }
 
@@ -38,10 +38,10 @@ int s_mp_sqr (mp_int * a, mp_int * b)
         ((mp_word)a->dp[ix] * (mp_word)a->dp[ix]);
 
     /* store lower part in result */
-    t.dp[ix+ix] = (mp_digit) (r & ((mp_word) MP_MASK));
+    t.dp[ix+ix] = (mp_digit) (r & ((mp_word)MP_MASK));
 
     /* get the carry */
-    u           = (mp_digit)(r >> ((mp_word) DIGIT_BIT));
+    u           = (mp_digit)(r >> ((mp_word)DIGIT_BIT));
 
     /* left hand side of A[ix] * A[iy] */
     tmpx        = a->dp[ix];
@@ -59,7 +59,7 @@ int s_mp_sqr (mp_int * a, mp_int * b)
       r       = ((mp_word) *tmpt) + r + r + ((mp_word) u);
 
       /* store lower part */
-      *tmpt++ = (mp_digit) (r & ((mp_word) MP_MASK));
+      *tmpt++ = (mp_digit)(r & ((mp_word) MP_MASK));
 
       /* get carry */
       u       = (mp_digit)(r >> ((mp_word) DIGIT_BIT));
@@ -67,14 +67,14 @@ int s_mp_sqr (mp_int * a, mp_int * b)
     /* propagate upwards */
     while (u != ((mp_digit) 0)) {
       r       = ((mp_word) *tmpt) + ((mp_word) u);
-      *tmpt++ = (mp_digit) (r & ((mp_word) MP_MASK));
+      *tmpt++ = (mp_digit)(r & ((mp_word) MP_MASK));
       u       = (mp_digit)(r >> ((mp_word) DIGIT_BIT));
     }
   }
 
-  mp_clamp (&t);
-  mp_exch (&t, b);
-  mp_clear (&t);
+  mp_clamp(&t);
+  mp_exch(&t, b);
+  mp_clear(&t);
   return MP_OKAY;
 }
 #endif
diff --git a/bn_s_mp_sub.c b/bn_s_mp_sub.c
index 8091f4a..2f35988 100644
--- a/bn_s_mp_sub.c
+++ b/bn_s_mp_sub.c
@@ -27,7 +27,7 @@ s_mp_sub (mp_int * a, mp_int * b, mp_int * c)
 
   /* init result */
   if (c->alloc < max) {
-    if ((res = mp_grow (c, max)) != MP_OKAY) {
+    if ((res = mp_grow(c, max)) != MP_OKAY) {
       return res;
     }
   }
@@ -78,7 +78,7 @@ s_mp_sub (mp_int * a, mp_int * b, mp_int * c)
     }
   }
 
-  mp_clamp (c);
+  mp_clamp(c);
   return MP_OKAY;
 }