wolfssl-sys 4.0.0

System bindings for WolfSSL
Documentation
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
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
/*!
    \ingroup ECC

    \brief This function generates a new ecc_key and stores it in key.

    \return 0 Returned on success.
    \return ECC_BAD_ARG_E Returned if rng or key evaluate to NULL
    \return BAD_FUNC_ARG Returned if the specified key size is not in the
    correct range of supported keys
    \return MEMORY_E Returned if there is an error allocating memory while
    computing the ecc key
    \return MP_INIT_E may be returned if there is an error while computing
    the ecc key
    \return MP_READ_E may be returned if there is an error while computing
    the ecc key
    \return MP_CMP_E may be returned if there is an error while computing the
    ecc key
    \return MP_INVMOD_E may be returned if there is an error while computing
    the ecc key
    \return MP_EXPTMOD_E may be returned if there is an error while computing
    the ecc key
    \return MP_MOD_E may be returned if there is an error while computing the
    ecc key
    \return MP_MUL_E may be returned if there is an error while computing the
    ecc key
    \return MP_ADD_E may be returned if there is an error while computing the
    ecc key
    \return MP_MULMOD_E may be returned if there is an error while computing
    the ecc key
    \return MP_TO_E may be returned if there is an error while computing the
    ecc key
    \return MP_MEM may be returned if there is an error while computing the
    ecc key

    \param rng pointer to an initialized RNG object with which to generate
    the key
    \param keysize desired length for the ecc_key
    \param key pointer to the ecc_key for which to generate a key

    _Example_
    \code
    ecc_key key;
    wc_ecc_init(&key);
    WC_RNG rng;
    wc_InitRng(&rng);
    wc_ecc_make_key(&rng, 32, &key); // initialize 32 byte ecc key
    \endcode

    \sa wc_ecc_init
    \sa wc_ecc_shared_secret
*/

int wc_ecc_make_key(WC_RNG* rng, int keysize, ecc_key* key);

/*!
    \ingroup ECC

    \brief This function generates a new ecc_key and stores it in key.

    \return 0 Returned on success.
    \return ECC_BAD_ARG_E Returned if rng or key evaluate to NULL
    \return BAD_FUNC_ARG Returned if the specified key size is not in the
    correct range of supported keys
    \return MEMORY_E Returned if there is an error allocating memory while
    computing the ecc key
    \return MP_INIT_E may be returned if there is an error while computing
    the ecc key
    \return MP_READ_E may be returned if there is an error while computing
    the ecc key
    \return MP_CMP_E may be returned if there is an error while computing the
    ecc key
    \return MP_INVMOD_E may be returned if there is an error while computing
    the ecc key
    \return MP_EXPTMOD_E may be returned if there is an error while computing
    the ecc key
    \return MP_MOD_E may be returned if there is an error while computing the
    ecc key
    \return MP_MUL_E may be returned if there is an error while computing the
    ecc key
    \return MP_ADD_E may be returned if there is an error while computing the
    ecc key
    \return MP_MULMOD_E may be returned if there is an error while computing
    the ecc key
    \return MP_TO_E may be returned if there is an error while computing the
    ecc key
    \return MP_MEM may be returned if there is an error while computing the
    ecc key

    \param key Pointer to store the created key.
    \param keysize size of key to be created in bytes, set based on curveId
    \param rng Rng to be used in key creation
    \param curve_id Curve to use for key

    _Example_
    \code
    ecc_key key;
    int ret;
    WC_RNG rng;
    wc_ecc_init(&key);
    wc_InitRng(&rng);
    int curveId = ECC_SECP521R1;
    int keySize = wc_ecc_get_curve_size_from_id(curveId);
    ret = wc_ecc_make_key_ex(&rng, keySize, &key, curveId);
    if (ret != MP_OKAY) {
        // error handling
    }

    \endcode

    \sa wc_ecc_make_key
    \sa wc_ecc_get_curve_size_from_id
*/

int wc_ecc_make_key_ex(WC_RNG* rng, int keysize, ecc_key* key, int curve_id);

/*!
    \ingroup ECC

    \brief wc_ecc_make_pub computes the public component from an ecc_key with an
    existing private component.  If pubOut is supplied, the computed public key
    is stored there, else it is stored in the supplied ecc_key public component
    slot.

    \return 0 Returned on success.
    \return ECC_BAD_ARG_E Returned if key is NULL
    \return BAD_FUNC_ARG Returned if the supplied key is not a valid ecc_key.
    \return MEMORY_E Returned if there is an error allocating memory while
    computing the public key
    \return MP_INIT_E may be returned if there is an error while computing
    the public key
    \return MP_READ_E may be returned if there is an error while computing
    the public key
    \return MP_CMP_E may be returned if there is an error while computing the
    public key
    \return MP_INVMOD_E may be returned if there is an error while computing
    the public key
    \return MP_EXPTMOD_E may be returned if there is an error while computing
    the public key
    \return MP_MOD_E may be returned if there is an error while computing the
    public key
    \return MP_MUL_E may be returned if there is an error while computing the
    public key
    \return MP_ADD_E may be returned if there is an error while computing the
    public key
    \return MP_MULMOD_E may be returned if there is an error while computing
    the public key
    \return MP_TO_E may be returned if there is an error while computing the
    public key
    \return MP_MEM may be returned if there is an error while computing the
    public key
    \return ECC_OUT_OF_RANGE_E may be returned if there is an error while computing the
    public key
    \return ECC_PRIV_KEY_E may be returned if there is an error while computing the
    public key
    \return ECC_INF_E may be returned if there is an error while computing the
    public key

    \param key Pointer to an ecc_key containing a valid private component
    \param pubOut Optional pointer to an ecc_point struct in which to store
    the computed public key

    \sa wc_ecc_make_pub_ex
    \sa wc_ecc_make_key
*/

int wc_ecc_make_pub(ecc_key* key, ecc_point* pubOut);

/*!
    \ingroup ECC

    \brief wc_ecc_make_pub_ex computes the public component from an ecc_key with
    an existing private component.  If pubOut is supplied, the computed public
    key is stored there, else it is stored in the supplied ecc_key public
    component slot.  The supplied rng, if non-NULL, is used to blind the private
    key value used in the computation.

    \return 0 Returned on success.
    \return ECC_BAD_ARG_E Returned if key is NULL
    \return BAD_FUNC_ARG Returned if the supplied key is not a valid ecc_key.
    \return MEMORY_E Returned if there is an error allocating memory while
    computing the public key
    \return MP_INIT_E may be returned if there is an error while computing
    the public key
    \return MP_READ_E may be returned if there is an error while computing
    the public key
    \return MP_CMP_E may be returned if there is an error while computing the
    public key
    \return MP_INVMOD_E may be returned if there is an error while computing
    the public key
    \return MP_EXPTMOD_E may be returned if there is an error while computing
    the public key
    \return MP_MOD_E may be returned if there is an error while computing the
    public key
    \return MP_MUL_E may be returned if there is an error while computing the
    public key
    \return MP_ADD_E may be returned if there is an error while computing the
    public key
    \return MP_MULMOD_E may be returned if there is an error while computing
    the public key
    \return MP_TO_E may be returned if there is an error while computing the
    public key
    \return MP_MEM may be returned if there is an error while computing the
    public key
    \return ECC_OUT_OF_RANGE_E may be returned if there is an error while computing the
    public key
    \return ECC_PRIV_KEY_E may be returned if there is an error while computing the
    public key
    \return ECC_INF_E may be returned if there is an error while computing the
    public key

    \param key Pointer to an ecc_key containing a valid private component
    \param pubOut Optional pointer to an ecc_point struct in which to store
    the computed public key
    \param rng Rng to be used in the public key computation

    \sa wc_ecc_make_pub
    \sa wc_ecc_make_key
    \sa wc_InitRng
*/

int wc_ecc_make_pub_ex(ecc_key* key, ecc_point* pubOut, WC_RNG* rng);

/*!
    \ingroup ECC

    \brief Perform sanity checks on ecc key validity.

    \return MP_OKAY Success, key is OK.
    \return BAD_FUNC_ARG Returns if key is NULL.
    \return ECC_INF_E Returns if wc_ecc_point_is_at_infinity returns 1.

    \param key Pointer to key to check.

    _Example_
    \code
    ecc_key key;
    WC_RNG rng;
    int check_result;
    wc_ecc_init(&key);
    wc_InitRng(&rng);
    wc_ecc_make_key(&rng, 32, &key);
    check_result = wc_ecc_check_key(&key);

    if (check_result == MP_OKAY)
    {
        // key check succeeded
    }
    else
    {
        // key check failed
    }
    \endcode

    \sa wc_ecc_point_is_at_infinity
*/

int wc_ecc_check_key(ecc_key* key);

/*!
    \ingroup ECC

    \brief This function frees an ecc_key key after it has been used.


    \param key pointer to the ecc_key structure to free

    _Example_
    \code
    // initialize key and perform ECC operations
    ...
    wc_ecc_key_free(&key);
    \endcode

    \sa wc_ecc_key_new
    \sa wc_ecc_init_ex
*/

void wc_ecc_key_free(ecc_key* key);

/*!
    \ingroup ECC

    \brief This function generates a new secret key using a local private key
    and a received public key. It stores this shared secret key in the buffer
    out and updates outlen to hold the number of bytes written to the output
    buffer.

    \return 0 Returned upon successfully generating a shared secret key
    \return BAD_FUNC_ARG Returned if any of the input parameters evaluate to
    NULL
    \return ECC_BAD_ARG_E Returned if the type of the private key given as
    argument, private_key, is not ECC_PRIVATEKEY, or if the public and private
    key types (given by ecc->dp) are not equivalent
    \return MEMORY_E Returned if there is an error generating a new ecc point
    \return BUFFER_E Returned if the generated shared secret key is too long
    to store in the provided buffer
    \return MP_INIT_E may be returned if there is an error while computing the
    shared key
    \return MP_READ_E may be returned if there is an error while computing the
    shared key
    \return MP_CMP_E may be returned if there is an error while computing the
    shared key
    \return MP_INVMOD_E may be returned if there is an error while computing
    the shared key
    \return MP_EXPTMOD_E may be returned if there is an error while computing
    the shared key
    \return MP_MOD_E may be returned if there is an error while computing the
    shared key
    \return MP_MUL_E may be returned if there is an error while computing the
    shared key
    \return MP_ADD_E may be returned if there is an error while computing the
    shared key
    \return MP_MULMOD_E may be returned if there is an error while computing
    the shared key
    \return MP_TO_E may be returned if there is an error while computing the
    shared key
    \return MP_MEM may be returned if there is an error while computing the
    shared key

    \param private_key pointer to the ecc_key structure containing the local
    private key
    \param public_key pointer to the ecc_key structure containing the received
    public key
    \param out pointer to an output buffer in which to store the generated
    shared secret key
    \param outlen pointer to the word32 object containing the length of the
    output buffer. Will be overwritten with the length written to the output
    buffer upon successfully generating a shared secret key

    _Example_
    \code
    ecc_key priv, pub;
    WC_RNG rng;
    byte secret[1024]; // can hold 1024 byte shared secret key
    word32 secretSz = sizeof(secret);
    int ret;

    wc_InitRng(&rng); // initialize rng
    wc_ecc_init(&priv); // initialize key
    wc_ecc_make_key(&rng, 32, &priv); // make public/private key pair
    // receive public key, and initialise into pub
    ret = wc_ecc_shared_secret(&priv, &pub, secret, &secretSz);
    // generate secret key
    if ( ret != 0 ) {
    	// error generating shared secret key
    }
    \endcode

    \sa wc_ecc_init
    \sa wc_ecc_make_key
*/

int wc_ecc_shared_secret(ecc_key* private_key, ecc_key* public_key, byte* out,
                      word32* outlen);

/*!
    \ingroup ECC

    \brief Create an ECC shared secret between private key and public point.

    \return MP_OKAY Indicates success.
    \return BAD_FUNC_ARG Error returned when any arguments are null.
    \return ECC_BAD_ARG_E Error returned if private_key->type is not
    ECC_PRIVATEKEY or private_key->idx fails to validate.
    \return BUFFER_E Error when outlen is too small.
    \return MEMORY_E Error to create a new point.
    \return MP_VAL possible when an initialization failure occurs.
    \return MP_MEM possible when an initialization failure occurs.

    \param private_key The private ECC key.
    \param point The point to use (public key).
    \param out Output destination of the shared secret. Conforms to
    EC-DH from ANSI X9.63.
    \param outlen Input the max size and output the resulting size of
    the shared secret.

    _Example_
    \code
    ecc_key key;
    ecc_point* point;
    byte shared_secret[];
    int secret_size;
    int result;

    point = wc_ecc_new_point();

    result = wc_ecc_shared_secret_ex(&key, point,
    &shared_secret, &secret_size);

    if (result != MP_OKAY)
    {
        // Handle error
    }
    \endcode

    \sa wc_ecc_verify_hash_ex
*/

int wc_ecc_shared_secret_ex(ecc_key* private_key, ecc_point* point,
                             byte* out, word32 *outlen);

/*!
    \ingroup ECC

    \brief This function signs a message digest using an ecc_key object to
    guarantee authenticity.

    \return 0 Returned upon successfully generating a signature for the
    message digest
    \return BAD_FUNC_ARG Returned if any of the input parameters evaluate to
    NULL, or if the output buffer is too small to store the generated signature
    \return ECC_BAD_ARG_E Returned if the input key is not a private key, or
    if the ECC OID is invalid
    \return RNG_FAILURE_E Returned if the rng cannot successfully generate a
    satisfactory key
    \return MP_INIT_E may be returned if there is an error while computing
    the message signature
    \return MP_READ_E may be returned if there is an error while computing
    the message signature
    \return MP_CMP_E may be returned if there is an error while computing the
    message signature
    \return MP_INVMOD_E may be returned if there is an error while computing
    the message signature
    \return MP_EXPTMOD_E may be returned if there is an error while computing
    the message signature
    \return MP_MOD_E may be returned if there is an error while computing the
    message signature
    \return MP_MUL_E may be returned if there is an error while computing the
    message signature
    \return MP_ADD_E may be returned if there is an error while computing the
    message signature
    \return MP_MULMOD_E may be returned if there is an error while computing
    the message signature
    \return MP_TO_E may be returned if there is an error while computing the
    message signature
    \return MP_MEM may be returned if there is an error while computing the
    message signature

    \param in pointer to the buffer containing the message hash to sign
    \param inlen length of the message hash to sign
    \param out buffer in which to store the generated signature
    \param outlen max length of the output buffer. Will store the bytes
    written to out upon successfully generating a message signature
    \param key pointer to a private ECC key with which to generate the
    signature

    _Example_
    \code
    ecc_key key;
    WC_RNG rng;
    int ret, sigSz;

    byte sig[512]; // will hold generated signature
    sigSz = sizeof(sig);
    byte digest[] = { // initialize with message hash };
    wc_InitRng(&rng); // initialize rng
    wc_ecc_init(&key); // initialize key
    wc_ecc_make_key(&rng, 32, &key); // make public/private key pair
    ret = wc_ecc_sign_hash(digest, sizeof(digest), sig, &sigSz, &key);
    if ( ret != 0 ) {
	    // error generating message signature
    }
    \endcode

    \sa wc_ecc_verify_hash
*/

int wc_ecc_sign_hash(const byte* in, word32 inlen, byte* out, word32 *outlen,
                     WC_RNG* rng, ecc_key* key);

/*!
    \ingroup ECC

    \brief Sign a message digest.

    \return MP_OKAY Returned upon successfully generating a signature for the
    message digest
    \return ECC_BAD_ARG_E Returned if the input key is not a private key, or
    if the ECC IDX is invalid, or if any of the input parameters evaluate to
    NULL, or if the output buffer is too small to store the generated signature
    \return RNG_FAILURE_E Returned if the rng cannot successfully generate a
    satisfactory key
    \return MP_INIT_E may be returned if there is an error while computing the
    message signature
    \return MP_READ_E may be returned if there is an error while computing the
    message signature
    \return MP_CMP_E may be returned if there is an error while computing the
    message signature
    \return MP_INVMOD_E may be returned if there is an error while computing
    the message signature
    \return MP_EXPTMOD_E may be returned if there is an error while computing
    the message signature
    \return MP_MOD_E may be returned if there is an error while computing the
    message signature
    \return MP_MUL_E may be returned if there is an error while computing the
    message signature
    \return MP_ADD_E may be returned if there is an error while computing the
    message signature
    \return MP_MULMOD_E may be returned if there is an error while computing
    the message signature
    \return MP_TO_E may be returned if there is an error while computing the
    message signature
    \return MP_MEM may be returned if there is an error while computing the
    message signature

    \param in The message digest to sign.
    \param inlen The length of the digest.
    \param rng Pointer to WC_RNG struct.
    \param key A private ECC key.
    \param r The destination for r component of the signature.
    \param s The destination for s component of the signature.

    _Example_
    \code
    ecc_key key;
    WC_RNG rng;
    int ret, sigSz;
    mp_int r; // destination for r component of signature.
    mp_int s; // destination for s component of signature.

    byte sig[512]; // will hold generated signature
    sigSz = sizeof(sig);
    byte digest[] = { initialize with message hash };
    wc_InitRng(&rng); // initialize rng
    wc_ecc_init(&key); // initialize key
    mp_init(&r); // initialize r component
    mp_init(&s); // initialize s component
    wc_ecc_make_key(&rng, 32, &key); // make public/private key pair
    ret = wc_ecc_sign_hash_ex(digest, sizeof(digest), &rng, &key, &r, &s);

    if ( ret != MP_OKAY ) {
    	// error generating message signature
    }
    \endcode

    \sa wc_ecc_verify_hash_ex
*/

int wc_ecc_sign_hash_ex(const byte* in, word32 inlen, WC_RNG* rng,
                        ecc_key* key, mp_int *r, mp_int *s);

/*!
    \ingroup ECC

    \brief This function verifies the ECC signature of a hash to ensure
    authenticity. It returns the answer through res, with 1 corresponding
    to a valid signature, and 0 corresponding to an invalid signature.

    \return 0 Returned upon successfully performing the signature
    verification. Note: This does not mean that the signature is verified.
    The authenticity information is stored instead in res
    \return BAD_FUNC_ARG Returned any of the input parameters evaluate to NULL
    \return MEMORY_E Returned if there is an error allocating memory
    \return MP_INIT_E  may be returned if there is an error while computing
    the message signature
    \return MP_READ_E  may be returned if there is an error while computing
    the message signature
    \return MP_CMP_E  may be returned if there is an error while computing
    the message signature
    \return MP_INVMOD_E  may be returned if there is an error while computing
    the message signature
    \return MP_EXPTMOD_E  may be returned if there is an error while
    computing the message signature
    \return MP_MOD_E  may be returned if there is an error while computing
    the message signature
    \return MP_MUL_E  may be returned if there is an error while computing
    the message signature
    \return MP_ADD_E  may be returned if there is an error while computing
    the message signature
    \return MP_MULMOD_E  may be returned if there is an error while computing
    the message signature
    \return MP_TO_E  may be returned if there is an error while computing the
    message signature
    \return MP_MEM may be returned if there is an error while computing the
    message signature

    \param sig pointer to the buffer containing the signature to verify
    \param siglen length of the signature to verify
    \param hash pointer to the buffer containing the hash of the message
    verified
    \param hashlen length of the hash of the message verified
    \param res pointer to the result of the verification. 1 indicates the
    message was successfully verified
    \param key pointer to a public ECC key with which to verify the signature

    _Example_
    \code
    ecc_key key;
    int ret, verified = 0;

    byte sig[1024] { initialize with received signature };
    byte digest[] = { initialize with message hash };
    // initialize key with received public key
    ret = wc_ecc_verify_hash(sig, sizeof(sig), digest,sizeof(digest),
    &verified, &key);
    if ( ret != 0 ) {
	    // error performing verification
    } else if ( verified == 0 ) {
	    // the signature is invalid
    }
    \endcode

    \sa wc_ecc_sign_hash
    \sa wc_ecc_verify_hash_ex
*/

int wc_ecc_verify_hash(const byte* sig, word32 siglen, const byte* hash,
                    word32 hashlen, int* res, ecc_key* key);

/*!
    \ingroup ECC

    \brief Verify an ECC signature.  Result is written to res.
    1 is valid, 0 is invalid.
    Note: Do not use the return value to test for valid.  Only use res.

    \return MP_OKAY If successful (even if the signature is not valid)
    \return ECC_BAD_ARG_E Returns if arguments are null or if
    key-idx is invalid.
    \return MEMORY_E Error allocating ints or points.

    \param r The signature R component to verify
    \param s The signature S component to verify
    \param hash The hash (message digest) that was signed
    \param hashlen The length of the hash (octets)
    \param res Result of signature, 1==valid, 0==invalid
    \param key The corresponding public ECC key

    _Example_
    \code
    mp_int r;
    mp_int s;
    int res;
    byte hash[] = { Some hash }
    ecc_key key;

    if(wc_ecc_verify_hash_ex(&r, &s, hash, hashlen, &res, &key) == MP_OKAY)
    {
        // Check res
    }
    \endcode

    \sa wc_ecc_verify_hash
*/

int wc_ecc_verify_hash_ex(mp_int *r, mp_int *s, const byte* hash,
                          word32 hashlen, int* res, ecc_key* key);

/*!
    \ingroup ECC

    \brief This function initializes an ecc_key object for future
    use with message verification or key negotiation.

    \return 0 Returned upon successfully initializing the ecc_key object
    \return MEMORY_E Returned if there is an error allocating memory

    \param key pointer to the ecc_key object to initialize

    _Example_
    \code
    ecc_key key;
    wc_ecc_init(&key);
    \endcode

    \sa wc_ecc_make_key
    \sa wc_ecc_free
*/

int wc_ecc_init(ecc_key* key);

/*!
    \ingroup ECC

    \brief This function initializes an ecc_key object for future
    use with message verification or key negotiation.

    \return 0 Returned upon successfully initializing the ecc_key object
    \return MEMORY_E Returned if there is an error allocating memory

    \param key pointer to the ecc_key object to initialize
    \param heap pointer to a heap identifier
    \param devId ID to use with crypto callbacks or async hardware. Set to INVALID_DEVID (-2) if not used

    _Example_
    \code
    ecc_key key;
    wc_ecc_init_ex(&key, heap, devId);
    \endcode

    \sa wc_ecc_make_key
    \sa wc_ecc_free
    \sa wc_ecc_init
*/

int wc_ecc_init_ex(ecc_key* key, void* heap, int devId);

/*!
    \ingroup ECC

    \brief This function uses a user defined heap and allocates space for the
    key structure.

    \return 0 Returned upon successfully initializing the ecc_key object
    \return MEMORY_E Returned if there is an error allocating memory


    _Example_
    \code
    wc_ecc_key_new(&heap);
    \endcode

    \sa wc_ecc_make_key
    \sa wc_ecc_key_free
    \sa wc_ecc_init
*/

ecc_key* wc_ecc_key_new(void* heap);

/*!
    \ingroup ECC

    \brief This function frees an ecc_key object after it has been used.

    \return int integer returned indicating wolfSSL error or success status.

    \param key pointer to the ecc_key object to free

    _Example_
    \code
    // initialize key and perform secure exchanges
    ...
    wc_ecc_free(&key);
    \endcode

    \sa wc_ecc_init
*/

int wc_ecc_free(ecc_key* key);

/*!
    \ingroup ECC

    \brief This function frees the fixed-point cache, which can be used
    with ecc to speed up computation times. To use this functionality,
    FP_ECC (fixed-point ecc), should be defined. Threaded applications should
    call this function before exiting the thread.

    \return none No returns.

    \param none No parameters.

    _Example_
    \code
    ecc_key key;
    // initialize key and perform secure exchanges
    ...

    wc_ecc_fp_free();
    \endcode

    \sa wc_ecc_free
*/

void wc_ecc_fp_free(void);

/*!
    \ingroup ECC

    \brief Checks if an ECC idx is valid.

    \return 1 Return if valid.
    \return 0 Return if not valid.

    \param n The idx number to check.

    _Example_
    \code
    ecc_key key;
    WC_RNG rng;
    int is_valid;
    wc_ecc_init(&key);
    wc_InitRng(&rng);
    wc_ecc_make_key(&rng, 32, &key);
    is_valid = wc_ecc_is_valid_idx(key.idx);
    if (is_valid == 1)
    {
        // idx is valid
    }
    else if (is_valid == 0)
    {
        // idx is not valid
    }
    \endcode

    \sa none
*/

int wc_ecc_is_valid_idx(int n);

/*!
    \ingroup ECC

    \brief Allocate a new ECC point.

    \return p A newly allocated point.
    \return NULL Returns NULL on error.

    \param none No parameters.

    _Example_
    \code
    ecc_point* point;
    point = wc_ecc_new_point();
    if (point == NULL)
    {
        // Handle point creation error
    }
    // Do stuff with point
    \endcode

    \sa wc_ecc_del_point
    \sa wc_ecc_cmp_point
    \sa wc_ecc_copy_point
*/

ecc_point* wc_ecc_new_point(void);

/*!
    \ingroup ECC

    \brief Free an ECC point from memory.

    \return none No returns.

    \param p The point to free.

    _Example_
    \code
    ecc_point* point;
    point = wc_ecc_new_point();
    if (point == NULL)
    {
        // Handle point creation error
    }
    // Do stuff with point
    wc_ecc_del_point(point);
    \endcode

    \sa wc_ecc_new_point
    \sa wc_ecc_cmp_point
    \sa wc_ecc_copy_point
*/

void wc_ecc_del_point(ecc_point* p);

/*!
    \ingroup ECC

    \brief Copy the value of one point to another one.

    \return ECC_BAD_ARG_E Error thrown when p or r is null.
    \return MP_OKAY Point copied successfully
    \return ret Error from internal functions.  Can be...

    \param p The point to copy.
    \param r The created point.

    _Example_
    \code
    ecc_point* point;
    ecc_point* copied_point;
    int copy_return;

    point = wc_ecc_new_point();
    copy_return = wc_ecc_copy_point(point, copied_point);
    if (copy_return != MP_OKAY)
    {
        // Handle error
    }
    \endcode

    \sa wc_ecc_new_point
    \sa wc_ecc_cmp_point
    \sa wc_ecc_del_point
*/

int wc_ecc_copy_point(const ecc_point* p, ecc_point *r);

/*!
    \ingroup ECC

    \brief Compare the value of a point with another one.

    \return BAD_FUNC_ARG One or both arguments are NULL.
    \return MP_EQ The points are equal.
    \return ret Either MP_LT or MP_GT and signifies that the
    points are not equal.

    \param a First point to compare.
    \param b Second point to compare.

    _Example_
    \code
    ecc_point* point;
    ecc_point* point_to_compare;
    int cmp_result;

    point = wc_ecc_new_point();
    point_to_compare = wc_ecc_new_point();
    cmp_result = wc_ecc_cmp_point(point, point_to_compare);
    if (cmp_result == BAD_FUNC_ARG)
    {
        // arguments are invalid
    }
    else if (cmp_result == MP_EQ)
    {
        // Points are equal
    }
    else
    {
        // Points are not equal
    }
    \endcode

    \sa wc_ecc_new_point
    \sa wc_ecc_del_point
    \sa wc_ecc_copy_point
*/

int wc_ecc_cmp_point(ecc_point* a, ecc_point *b);

/*!
    \ingroup ECC

    \brief Checks if a point is at infinity.  Returns 1 if point is
    at infinity, 0 if not, < 0 on error

    \return 1 p is at infinity.
    \return 0 p is not at infinity.
    \return <0 Error.

    \param p The point to check.

    _Example_
    \code
    ecc_point* point;
    int is_infinity;
    point = wc_ecc_new_point();

    is_infinity = wc_ecc_point_is_at_infinity(point);
    if (is_infinity < 0)
    {
        // Handle error
    }
    else if (is_infinity == 0)
    {
        // Point is not at infinity
    }
    else if (is_infinity == 1)
    {
        // Point is at infinity
    }
    \endcode

    \sa wc_ecc_new_point
    \sa wc_ecc_del_point
    \sa wc_ecc_cmp_point
    \sa wc_ecc_copy_point
*/

int wc_ecc_point_is_at_infinity(ecc_point *p);

/*!
    \ingroup ECC

    \brief Perform ECC Fixed Point multiplication.

    \return MP_OKAY Returns on successful operation.
    \return MP_INIT_E Returned if there is an error initializing an integer
    for use with the multiple precision integer (mp_int) library.

    \param k The multiplicand.
    \param G Base point to multiply.
    \param R Destination of product.
    \param a ECC curve parameter a.
    \param modulus The modulus for the curve.
    \param map If non-zero maps the point back to affine coordinates,
    otherwise it's left in jacobian-montgomery form.

    _Example_
    \code
    ecc_point* base;
    ecc_point* destination;
    // Initialize points
    base = wc_ecc_new_point();
    destination = wc_ecc_new_point();
    // Setup other arguments
    mp_int multiplicand;
    mp_int modulus;
    mp_int a;
    int map;
    int rc;
    rc = wc_ecc_mulmod(&multiplicand, base, destination, &a, &modulus, map);
    \endcode

    \sa none
*/

int wc_ecc_mulmod(const mp_int* k, ecc_point *G, ecc_point *R,
                  mp_int* a, mp_int* modulus, int map);

/*!
    \ingroup ECC

    \brief This function exports the ECC key from the ecc_key structure,
    storing the result in out. The key will be stored in ANSI X9.63 format.
    It stores the bytes written to the output buffer in outLen.

    \return 0 Returned on successfully exporting the ecc_key
    \return LENGTH_ONLY_E Returned if the output buffer evaluates to NULL,
    but the other two input parameters are valid. Indicates that the function
    is only returning the length required to store the key
    \return ECC_BAD_ARG_E Returned if any of the input parameters are NULL,
    or the key is unsupported (has an invalid index)
    \return BUFFER_E Returned if the output buffer is too small to store the
    ecc key. If the output buffer is too small, the size needed will be
    returned in outLen
    \return MEMORY_E Returned if there is an error allocating memory with
    XMALLOC
    \return MP_INIT_E may be returned if there is an error processing the
    ecc_key
    \return MP_READ_E may be returned if there is an error processing the
    ecc_key
    \return MP_CMP_E may be returned if there is an error processing the
    ecc_key
    \return MP_INVMOD_E may be returned if there is an error processing the
    ecc_key
    \return MP_EXPTMOD_E may be returned if there is an error processing the
    ecc_key
    \return MP_MOD_E may be returned if there is an error processing the
    ecc_key
    \return MP_MUL_E may be returned if there is an error processing the
    ecc_key
    \return MP_ADD_E may be returned if there is an error processing the
    ecc_key
    \return MP_MULMOD_E may be returned if there is an error processing the
    ecc_key
    \return MP_TO_E may be returned if there is an error processing the ecc_key
    \return MP_MEM may be returned if there is an error processing the ecc_key

    \param key pointer to the ecc_key object to export
    \param out pointer to the buffer in which to store the ANSI X9.63
    formatted key
    \param outLen size of the output buffer. On successfully storing the
    key, will hold the bytes written to the output buffer

    _Example_
    \code
    int ret;
    byte buff[1024];
    word32 buffSz = sizeof(buff);

    ecc_key key;
    // initialize key, make key
    ret = wc_ecc_export_x963(&key, buff, &buffSz);
    if ( ret != 0) {
    	// error exporting key
    }
    \endcode

    \sa wc_ecc_export_x963_ex
    \sa wc_ecc_import_x963
    \sa wc_ecc_make_pub
*/

int wc_ecc_export_x963(ecc_key* key, byte* out, word32* outLen);

/*!
    \ingroup ECC

    \brief This function exports the public key from the ecc_key structure,
    storing the result in out. The key will be stored in ANSI X9.63 format.
    It stores the bytes written to the output buffer in outLen. This function
    allows the additional option of compressing the certificate through the
    compressed parameter. When this parameter is true, the key will be stored
    in ANSI X9.63 compressed format.

    \return 0 Returned on successfully exporting the ecc_key public component
    \return ECC_PRIVATEKEY_ONLY Returned if the ecc_key public component is
    missing
    \return NOT_COMPILED_IN Returned if the HAVE_COMP_KEY was not enabled at
    compile time, but the key was requested in compressed format
    \return LENGTH_ONLY_E Returned if the output buffer evaluates to NULL, but
    the other two input parameters are valid. Indicates that the function is
    only returning the length required to store the public key
    \return ECC_BAD_ARG_E Returned if any of the input parameters are NULL, or
    the key is unsupported (has an invalid index)
    \return BUFFER_E Returned if the output buffer is too small to store the
    public key. If the output buffer is too small, the size needed will be
    returned in outLen
    \return MEMORY_E Returned if there is an error allocating memory with
    XMALLOC
    \return MP_INIT_E may be returned if there is an error processing the
    ecc_key
    \return MP_READ_E may be returned if there is an error processing the
    ecc_key
    \return MP_CMP_E may be returned if there is an error processing the
    ecc_key
    \return MP_INVMOD_E may be returned if there is an error processing the
    ecc_key
    \return MP_EXPTMOD_E may be returned if there is an error processing
    the ecc_key
    \return MP_MOD_E may be returned if there is an error processing the
    ecc_key
    \return MP_MUL_E may be returned if there is an error processing the
    ecc_key
    \return MP_ADD_E may be returned if there is an error processing the
    ecc_key
    \return MP_MULMOD_E may be returned if there is an error processing
    the ecc_key
    \return MP_TO_E may be returned if there is an error processing the ecc_key
    \return MP_MEM may be returned if there is an error processing the ecc_key

    \param key pointer to the ecc_key object to export
    \param out pointer to the buffer in which to store the ANSI X9.63
    formatted public key
    \param outLen size of the output buffer. On successfully storing the
    public key, will hold the bytes written to the output buffer
    \param compressed indicator of whether to store the key in compressed
    format. 1==compressed, 0==uncompressed

    _Example_
    \code
    int ret;
    byte buff[1024];
    word32 buffSz = sizeof(buff);
    ecc_key key;
    // initialize key, make key
    ret = wc_ecc_export_x963_ex(&key, buff, &buffSz, 1);
    if ( ret != 0) {
	    // error exporting key
    }
    \endcode

    \sa wc_ecc_export_x963
    \sa wc_ecc_import_x963
    \sa wc_ecc_make_pub
*/

int wc_ecc_export_x963_ex(ecc_key* key, byte* out, word32* outLen, int compressed);

/*!
    \ingroup ECC

    \brief This function imports a public ECC key from a buffer containing the
    key stored in ANSI X9.63 format. This function will handle both compressed
    and uncompressed keys, as long as compressed keys are enabled at compile
    time through the HAVE_COMP_KEY option.

    \return 0 Returned on successfully importing the ecc_key
    \return NOT_COMPILED_IN Returned if the HAVE_COMP_KEY was not enabled at
    compile time, but the key is stored in compressed format
    \return ECC_BAD_ARG_E Returned if in or key evaluate to NULL, or the
    inLen is even (according to the x9.63 standard, the key must be odd)
    \return MEMORY_E Returned if there is an error allocating memory
    \return ASN_PARSE_E Returned if there is an error parsing the ECC key;
    may indicate that the ECC key is not stored in valid ANSI X9.63 format
    \return IS_POINT_E Returned if the public key exported is not a point
    on the ECC curve
    \return MP_INIT_E may be returned if there is an error processing the
    ecc_key
    \return MP_READ_E may be returned if there is an error processing the
    ecc_key
    \return MP_CMP_E may be returned if there is an error processing the
    ecc_key
    \return MP_INVMOD_E may be returned if there is an error processing the
    ecc_key
    \return MP_EXPTMOD_E may be returned if there is an error processing the
    ecc_key
    \return MP_MOD_E may be returned if there is an error processing the
    ecc_key
    \return MP_MUL_E may be returned if there is an error processing the
    ecc_key
    \return MP_ADD_E may be returned if there is an error processing the
    ecc_key
    \return MP_MULMOD_E may be returned if there is an error processing the
    ecc_key
    \return MP_TO_E may be returned if there is an error processing the ecc_key
    \return MP_MEM may be returned if there is an error processing the ecc_key

    \param in pointer to the buffer containing the ANSI x9.63 formatted ECC key
    \param inLen length of the input buffer
    \param key pointer to the ecc_key object in which to store the imported key

    _Example_
    \code
    int ret;
    byte buff[] = { initialize with ANSI X9.63 formatted key };

    ecc_key pubKey;
    wc_ecc_init(&pubKey);

    ret = wc_ecc_import_x963(buff, sizeof(buff), &pubKey);
    if ( ret != 0) {
    	// error importing key
    }
    \endcode

    \sa wc_ecc_export_x963
    \sa wc_ecc_import_private_key
*/

int wc_ecc_import_x963(const byte* in, word32 inLen, ecc_key* key);

/*!
    \ingroup ECC

    \brief This function imports a public/private ECC key pair from a buffer
    containing the raw private key, and a second buffer containing the ANSI
    X9.63 formatted public key. This function will handle both compressed and
    uncompressed keys, as long as compressed keys are enabled at compile time
    through the HAVE_COMP_KEY option.

    \return 0 Returned on successfully importing the ecc_key
    NOT_COMPILED_IN Returned if the HAVE_COMP_KEY was not enabled at compile
    time, but the key is stored in compressed format
    \return ECC_BAD_ARG_E Returned if in or key evaluate to NULL, or the
    inLen is even (according to the x9.63 standard, the key must be odd)
    \return MEMORY_E Returned if there is an error allocating memory
    \return ASN_PARSE_E Returned if there is an error parsing the ECC key;
    may indicate that the ECC key is not stored in valid ANSI X9.63 format
    \return IS_POINT_E Returned if the public key exported is not a point
    on the ECC curve
    \return MP_INIT_E may be returned if there is an error processing the
    ecc_key
    \return MP_READ_E may be returned if there is an error processing the
    ecc_key
    \return MP_CMP_E may be returned if there is an error processing the
    ecc_key
    \return MP_INVMOD_E may be returned if there is an error processing
    the ecc_key
    \return MP_EXPTMOD_E may be returned if there is an error processing
    the ecc_key
    \return MP_MOD_E may be returned if there is an error processing the
    ecc_key
    \return MP_MUL_E may be returned if there is an error processing the
    ecc_key
    \return MP_ADD_E may be returned if there is an error processing the
    ecc_key
    \return MP_MULMOD_E may be returned if there is an error processing
    the ecc_key
    \return MP_TO_E may be returned if there is an error processing the ecc_key
    \return MP_MEM may be returned if there is an error processing the ecc_key

    \param priv pointer to the buffer containing the raw private key
    \param privSz size of the private key buffer
    \param pub pointer to the buffer containing the ANSI x9.63 formatted ECC
    public key
    \param pubSz length of the public key input buffer
    \param key pointer to the ecc_key object in which to store the imported
    private/public key pair

    _Example_
    \code
    int ret;
    byte pub[] = { initialize with ANSI X9.63 formatted key };
    byte priv[] = { initialize with the raw private key };

    ecc_key key;
    wc_ecc_init(&key);
    ret = wc_ecc_import_private_key(priv, sizeof(priv), pub, sizeof(pub),
    &key);
    if ( ret != 0) {
    	// error importing key
    }
    \endcode

    \sa wc_ecc_export_x963
    \sa wc_ecc_import_private_key
*/

int wc_ecc_import_private_key(const byte* priv, word32 privSz, const byte* pub,
                           word32 pubSz, ecc_key* key);

/*!
    \ingroup ECC

    \brief This function converts the R and S portions of an ECC signature
    into a DER-encoded ECDSA signature. This function also stores the length
    written to the output buffer, out, in outlen.

    \return 0 Returned on successfully converting the signature
    \return ECC_BAD_ARG_E Returned if any of the input parameters evaluate
    to NULL, or if the input buffer is not large enough to hold the
    DER-encoded ECDSA signature
    \return MP_INIT_E may be returned if there is an error processing
    the ecc_key
    \return MP_READ_E may be returned if there is an error processing
    the ecc_key
    \return MP_CMP_E may be returned if there is an error processing
    the ecc_key
    \return MP_INVMOD_E may be returned if there is an error processing
    the ecc_key
    \return MP_EXPTMOD_E may be returned if there is an error processing
    the ecc_key
    \return MP_MOD_E may be returned if there is an error processing the
    ecc_key
    \return MP_MUL_E may be returned if there is an error processing the
    ecc_key
    \return MP_ADD_E may be returned if there is an error processing the
    ecc_key
    \return MP_MULMOD_E may be returned if there is an error processing
    the ecc_key
    \return MP_TO_E may be returned if there is an error processing the ecc_key
    \return MP_MEM may be returned if there is an error processing the ecc_key

    \param r pointer to the buffer containing the R portion of the signature
    as a string
    \param s pointer to the buffer containing the S portion of the signature
    as a string
    \param out pointer to the buffer in which to store the DER-encoded ECDSA
    signature
    \param outlen length of the output buffer available. Will store the bytes
    written to the buffer after successfully converting the signature to
    ECDSA format

    _Example_
    \code
    int ret;
    ecc_key key;
    // initialize key, generate R and S

    char r[] = { initialize with R };
    char s[] = { initialize with S };
    byte sig[wc_ecc_sig_size(key)];
    // signature size will be 2 * ECC key size + ~10 bytes for ASN.1 overhead
    word32 sigSz = sizeof(sig);
    ret = wc_ecc_rs_to_sig(r, s, sig, &sigSz);
    if ( ret != 0) {
    	// error converting parameters to signature
    }
    \endcode

    \sa wc_ecc_sign_hash
    \sa wc_ecc_sig_size
*/

int wc_ecc_rs_to_sig(const char* r, const char* s, byte* out, word32* outlen);

/*!
    \ingroup ECC

    \brief This function fills an ecc_key structure with the raw components
    of an ECC signature.

    \return 0 Returned upon successfully importing into the ecc_key structure
    \return ECC_BAD_ARG_E Returned if any of the input values evaluate to NULL
    \return MEMORY_E Returned if there is an error initializing space to
    store the parameters of the ecc_key
    \return ASN_PARSE_E Returned if the input curveName is not defined
    in ecc_sets
    \return MP_INIT_E may be returned if there is an error processing the
    input parameters
    \return MP_READ_E may be returned if there is an error processing the
    input parameters
    \return MP_CMP_E may be returned if there is an error processing the
    input parameters
    \return MP_INVMOD_E may be returned if there is an error processing the
    input parameters
    \return MP_EXPTMOD_E may be returned if there is an error processing the
    input parameters
    \return MP_MOD_E may be returned if there is an error processing the
    input parameters
    \return MP_MUL_E may be returned if there is an error processing the
    input parameters
    \return MP_ADD_E may be returned if there is an error processing the
    input parameters
    \return MP_MULMOD_E may be returned if there is an error processing
    the input parameters
    \return MP_TO_E may be returned if there is an error processing the
    input parameters
    \return MP_MEM may be returned if there is an error processing the
    input parameters

    \param key pointer to an ecc_key structure to fill
    \param qx pointer to a buffer containing the x component of the base
    point as an ASCII hex string
    \param qy pointer to a buffer containing the y component of the base
    point as an ASCII hex string
    \param d pointer to a buffer containing the private key as an ASCII
    hex string
    \param curveName pointer to a string containing the ECC curve name,
    as found in ecc_sets

    _Example_
    \code
    int ret;
    ecc_key key;
    wc_ecc_init(&key);

    char qx[] = { initialize with x component of base point };
    char qy[] = { initialize with y component of base point };
    char d[]  = { initialize with private key };
    ret = wc_ecc_import_raw(&key,qx, qy, d, "ECC-256");
    if ( ret != 0) {
    	// error initializing key with given inputs
    }
    \endcode

    \sa wc_ecc_import_private_key
*/

int wc_ecc_import_raw(ecc_key* key, const char* qx, const char* qy,
                   const char* d, const char* curveName);

/*!
    \ingroup ECC

    \brief This function exports only the private key from an ecc_key
    structure. It stores the private key in the buffer out, and sets
    the bytes written to this buffer in outLen.

    \return 0 Returned upon successfully exporting the private key
    \return ECC_BAD_ARG_E Returned if any of the input values evaluate to NULL
    \return MEMORY_E Returned if there is an error initializing space
    to store the parameters of the ecc_key
    \return ASN_PARSE_E Returned if the input curveName is not defined
    in ecc_sets
    \return MP_INIT_E may be returned if there is an error processing
    the input parameters
    \return MP_READ_E may be returned if there is an error processing the
    input parameters
    \return MP_CMP_E may be returned if there is an error processing the
    input parameters
    \return MP_INVMOD_E may be returned if there is an error processing
    the input parameters
    \return MP_EXPTMOD_E may be returned if there is an error processing
    the input parameters
    \return MP_MOD_E may be returned if there is an error processing the
    input parameters
    \return MP_MUL_E may be returned if there is an error processing the
    input parameters
    \return MP_ADD_E may be returned if there is an error processing the
    input parameters
    \return MP_MULMOD_E may be returned if there is an error processing
    the input parameters
    \return MP_TO_E may be returned if there is an error processing the
    input parameters
    \return MP_MEM may be returned if there is an error processing the
    input parameters

    \param key pointer to an ecc_key structure from which to export the
    private key
    \param out pointer to the buffer in which to store the private key
    \param outLen pointer to a word32 object with the size available in
    out. Set with the number of bytes written to out after successfully
    exporting the private key

    _Example_
    \code
    int ret;
    ecc_key key;
    // initialize key, make key

    char priv[ECC_KEY_SIZE];
    word32 privSz = sizeof(priv);
    ret = wc_ecc_export_private_only(&key, priv, &privSz);
    if ( ret != 0) {
    	// error exporting private key
    }
    \endcode

    \sa wc_ecc_import_private_key
*/

int wc_ecc_export_private_only(ecc_key* key, byte* out, word32* outLen);

/*!
    \ingroup ECC

    \brief Export point to der.

    \return 0 Returned on success.
    \return ECC_BAD_ARG_E Returns if curve_idx is less than 0 or
    invalid.  Also returns when
    \return LENGTH_ONLY_E outLen is set but nothing else.
    \return BUFFER_E Returns if outLen is less than 1 + 2 * the curve size.
    \return MEMORY_E Returns if there is a problem allocating memory.

    \param curve_idx Index of the curve used from ecc_sets.
    \param point Point to export to der.
    \param out Destination for the output.
    \param outLen Maxsize allowed for output, destination for
    final size of output

    _Example_
    \code
    int curve_idx;
    ecc_point* point;
    byte out[];
    word32 outLen;
    wc_ecc_export_point_der(curve_idx, point, out, &outLen);
    \endcode

    \sa wc_ecc_import_point_der
*/

int wc_ecc_export_point_der(const int curve_idx, ecc_point* point,
                            byte* out, word32* outLen);

/*!
    \ingroup ECC

    \brief Import point from der format.

    \return ECC_BAD_ARG_E Returns if any arguments are null or if
    inLen is even.
    \return MEMORY_E Returns if there is an error initializing
    \return NOT_COMPILED_IN Returned if HAVE_COMP_KEY is not true
    and in is a compressed cert
    \return MP_OKAY Successful operation.

    \param in der buffer to import point from.
    \param inLen Length of der buffer.
    \param curve_idx Index of curve.
    \param point Destination for point.

    _Example_
    \code
    byte in[];
    word32 inLen;
    int curve_idx;
    ecc_point* point;
    wc_ecc_import_point_der(in, inLen, curve_idx, point);
    \endcode

    \sa wc_ecc_export_point_der
*/

int wc_ecc_import_point_der(const byte* in, word32 inLen, const int curve_idx,
                            ecc_point* point);

/*!
    \ingroup ECC

    \brief This function returns the key size of an ecc_key
    structure in octets.

    \return Given a valid key, returns the key size in octets
    \return 0 Returned if the given key is NULL

    \param key pointer to an ecc_key structure for which to get the key size

    _Example_
    \code
    int keySz;
    ecc_key key;
    // initialize key, make key
    keySz = wc_ecc_size(&key);
    if ( keySz == 0) {
    	// error determining key size
    }
    \endcode

    \sa wc_ecc_make_key
*/

int wc_ecc_size(ecc_key* key);

/*!
    \ingroup ECC

    \brief This function returns the worst case size for an ECC signature,
    given by: (keySz * 2) + SIG_HEADER_SZ + ECC_MAX_PAD_SZ.
    The actual signature size can be computed with wc_ecc_sign_hash.

    \return returns the maximum signature
    size, in octets

    \param key size

    _Example_
    \code
    int sigSz = wc_ecc_sig_size_calc(32);
    if ( sigSz == 0) {
    	// error determining sig size
    }
    \endcode

    \sa wc_ecc_sign_hash
    \sa wc_ecc_sig_size
*/

int wc_ecc_sig_size_calc(int sz);


/*!
    \ingroup ECC

    \brief This function returns the worst case size for an ECC signature,
    given by: (keySz * 2) + SIG_HEADER_SZ + ECC_MAX_PAD_SZ.
    The actual signature size can be computed with wc_ecc_sign_hash.

    \return Success Given a valid key, returns the maximum signature
    size, in octets
    \return 0 Returned if the given key is NULL

    \param key pointer to an ecc_key structure for which to get the
    signature size

    _Example_
    \code
    int sigSz;
    ecc_key key;
    // initialize key, make key

    sigSz = wc_ecc_sig_size(&key);
    if ( sigSz == 0) {
        // error determining sig size
    }
    \endcode

    \sa wc_ecc_sign_hash
    \sa wc_ecc_sig_size_calc
*/

int wc_ecc_sig_size(const ecc_key* key);


/*!
    \ingroup ECC

    \brief This function allocates and initializes space for a new ECC
    context object to allow secure message exchange with ECC.

    \return Success On successfully generating a new ecEncCtx object,
    returns a pointer to that object
    \return NULL Returned if the function fails to generate a new
    ecEncCtx object

    \param flags indicate whether this is a server or client context
    Options are: REQ_RESP_CLIENT, and REQ_RESP_SERVER
    \param rng pointer to a RNG object with which to generate a salt

    _Example_
    \code
    ecEncCtx* ctx;
    WC_RNG rng;
    wc_InitRng(&rng);
    ctx = wc_ecc_ctx_new(REQ_RESP_CLIENT, &rng);
    if(ctx == NULL) {
        // error generating new ecEncCtx object
    }
    \endcode

    \sa wc_ecc_encrypt
    \sa wc_ecc_encrypt_ex
    \sa wc_ecc_decrypt
*/

ecEncCtx* wc_ecc_ctx_new(int flags, WC_RNG* rng);

/*!
    \ingroup ECC

    \brief This function frees the ecEncCtx object used for encrypting
    and decrypting messages.

    \return none Returns.

    \param ctx pointer to the ecEncCtx object to free

    _Example_
    \code
    ecEncCtx* ctx;
    WC_RNG rng;
    wc_InitRng(&rng);
    ctx = wc_ecc_ctx_new(REQ_RESP_CLIENT, &rng);
    // do secure communication
    ...
    wc_ecc_ctx_free(&ctx);
    \endcode

    \sa wc_ecc_ctx_new
*/

void wc_ecc_ctx_free(ecEncCtx* ctx);

/*!
    \ingroup ECC

    \brief This function resets an ecEncCtx structure to avoid having
    to free and allocate a new context object.

    \return 0 Returned if the ecEncCtx structure is successfully reset
    \return BAD_FUNC_ARG Returned if either rng or ctx is NULL
    \return RNG_FAILURE_E Returned if there is an error generating a
    new salt for the ECC object

    \param ctx pointer to the ecEncCtx object to reset
    \param rng pointer to an RNG object with which to generate a new salt

    _Example_
    \code
    ecEncCtx* ctx;
    WC_RNG rng;
    wc_InitRng(&rng);
    ctx = wc_ecc_ctx_new(REQ_RESP_CLIENT, &rng);
    // do secure communication
    ...
    wc_ecc_ctx_reset(&ctx, &rng);
    // do more secure communication
    \endcode

    \sa wc_ecc_ctx_new
*/

int wc_ecc_ctx_reset(ecEncCtx* ctx, WC_RNG* rng);  /* reset for use again w/o alloc/free */

/*!
    \ingroup ECC

    \brief This function can optionally be called after
    wc_ecc_ctx_new. It sets the encryption, KDF, and MAC algorithms
    into an ecEncCtx object.

    \return 0 Returned upon successfully setting the information
    for the ecEncCtx object.
    \return BAD_FUNC_ARG Returned if the given ecEncCtx object is
    NULL.

    \param ctx pointer to the ecEncCtx for which to set the info
    \param encAlgo encryption algorithm to use.
    \param kdfAlgo KDF algorithm to use.
    \param macAlgo MAC algorithm to use.

    _Example_
    \code
    ecEncCtx* ctx;
    // initialize ctx
    if(wc_ecc_ctx_set_algo(&ctx, ecAES_128_CTR, ecHKDF_SHA256, ecHMAC_SHA256))) {
	    // error setting info
    }
    \endcode

    \sa wc_ecc_ctx_new
*/

int wc_ecc_ctx_set_algo(ecEncCtx* ctx, byte encAlgo, byte kdfAlgo,
    byte macAlgo);

/*!
    \ingroup ECC

    \brief This function returns the salt of an ecEncCtx object. This
    function should only be called when the ecEncCtx's state is
    ecSRV_INIT or ecCLI_INIT.

    \return Success On success, returns the ecEncCtx salt
    \return NULL Returned if the ecEncCtx object is NULL, or the ecEncCtx's
    state is not ecSRV_INIT or ecCLI_INIT. In the latter two cases, this
    function also sets the ecEncCtx's state to ecSRV_BAD_STATE or
    ecCLI_BAD_STATE, respectively

    \param ctx pointer to the ecEncCtx object from which to get the salt

    _Example_
    \code
    ecEncCtx* ctx;
    WC_RNG rng;
    const byte* salt;
    wc_InitRng(&rng);
    ctx = wc_ecc_ctx_new(REQ_RESP_CLIENT, &rng);
    salt = wc_ecc_ctx_get_own_salt(&ctx);
    if(salt == NULL) {
    	// error getting salt
    }
    \endcode

    \sa wc_ecc_ctx_new
    \sa wc_ecc_ctx_set_peer_salt
    \sa wc_ecc_ctx_set_kdf_salt
*/

const byte* wc_ecc_ctx_get_own_salt(ecEncCtx* ctx);

/*!
    \ingroup ECC

    \brief This function sets the peer salt of an ecEncCtx object.

    \return 0 Returned upon successfully setting the peer salt for the
    ecEncCtx object.
    \return BAD_FUNC_ARG Returned if the given ecEncCtx object is NULL
    or has an invalid protocol, or if the given salt is NULL
    \return BAD_ENC_STATE_E Returned if the ecEncCtx's state is
    ecSRV_SALT_GET or ecCLI_SALT_GET. In the latter two cases, this
    function also sets the ecEncCtx's state to ecSRV_BAD_STATE or
    ecCLI_BAD_STATE, respectively

    \param ctx pointer to the ecEncCtx for which to set the salt
    \param salt pointer to the peer's salt

    _Example_
    \code
    ecEncCtx* cliCtx, srvCtx;
    WC_RNG rng;
    const byte* cliSalt, srvSalt;
    int ret;

    wc_InitRng(&rng);
    cliCtx = wc_ecc_ctx_new(REQ_RESP_CLIENT, &rng);
    srvCtx = wc_ecc_ctx_new(REQ_RESP_SERVER, &rng);

    cliSalt = wc_ecc_ctx_get_own_salt(&cliCtx);
    srvSalt = wc_ecc_ctx_get_own_salt(&srvCtx);
    ret = wc_ecc_ctx_set_peer_salt(&cliCtx, srvSalt);
    \endcode

    \sa wc_ecc_ctx_get_own_salt
    \sa wc_ecc_ctx_set_kdf_salt
*/

int wc_ecc_ctx_set_peer_salt(ecEncCtx* ctx, const byte* salt);

/*!
    \ingroup ECC

    \brief This function sets the salt pointer and length to use with KDF
    into the ecEncCtx object.

    \return 0 Returned upon successfully setting the salt for the
    ecEncCtx object.
    \return BAD_FUNC_ARG Returned if the given ecEncCtx object is NULL
    or if the given salt is NULL and length is not NULL.

    \param ctx pointer to the ecEncCtx for which to set the salt
    \param salt pointer to salt buffer
    \param sz length salt in bytes

    _Example_
    \code
    ecEncCtx* srvCtx;
    WC_RNG rng;
    byte cliSalt[] = { fixed salt data };
    word32 cliSaltLen = (word32)sizeof(cliSalt);
    int ret;

    wc_InitRng(&rng);
    cliCtx = wc_ecc_ctx_new(REQ_RESP_SERVER, &rng);

    ret = wc_ecc_ctx_set_kdf_salt(&cliCtx, cliSalt, cliSaltLen);
    \endcode

    \sa wc_ecc_ctx_get_own_salt
    \sa wc_ecc_ctx_get_peer_salt
*/

int wc_ecc_ctx_set_kdf_salt(ecEncCtx* ctx, const byte* salt, word32 sz);

/*!
    \ingroup ECC

    \brief This function can optionally be called before or after
    wc_ecc_ctx_set_peer_salt. It sets optional information for
    an ecEncCtx object.

    \return 0 Returned upon successfully setting the information
    for the ecEncCtx object.
    \return BAD_FUNC_ARG Returned if the given ecEncCtx object is
    NULL, the input info is NULL or it's size is invalid

    \param ctx pointer to the ecEncCtx for which to set the info
    \param info pointer to a buffer containing the info to set
    \param sz size of the info buffer

    _Example_
    \code
    ecEncCtx* ctx;
    byte info[] = { initialize with information };
    // initialize ctx, get salt,
    if(wc_ecc_ctx_set_info(&ctx, info, sizeof(info))) {
	    // error setting info
    }
    \endcode

    \sa wc_ecc_ctx_new
*/

int wc_ecc_ctx_set_info(ecEncCtx* ctx, const byte* info, int sz);

/*!
    \ingroup ECC

    \brief This function encrypts the given input message from msg
    to out. This function takes an optional ctx object as parameter.
    When supplied, encryption proceeds based on the ecEncCtx's
    encAlgo, kdfAlgo, and macAlgo. If ctx is not supplied, processing
    completes with the default algorithms, ecAES_128_CBC,
    ecHKDF_SHA256 and ecHMAC_SHA256. This function requires that
    the messages are padded according to the encryption type specified by ctx.

    \return 0 Returned upon successfully encrypting the input message
    \return BAD_FUNC_ARG Returned if privKey, pubKey, msg, msgSz, out,
    or outSz are NULL, or the ctx object specifies an unsupported
    encryption type
    \return BAD_ENC_STATE_E Returned if the ctx object given is in a
    state that is not appropriate for encryption
    \return BUFFER_E Returned if the supplied output buffer is too
    small to store the encrypted ciphertext
    \return MEMORY_E Returned if there is an error allocating memory
    for the shared secret key

    \param privKey pointer to the ecc_key object containing the
    private key to use for encryption
    \param pubKey pointer to the ecc_key object containing the public
    key of the peer with whom one wishes to communicate
    \param msg pointer to the buffer holding the message to encrypt
    \param msgSz size of the buffer to encrypt
    \param out pointer to the buffer in which to store the encrypted
    ciphertext
    \param outSz pointer to a word32 object containing the available
    size in the out buffer. Upon successfully encrypting the message,
    holds the number of bytes written to the output buffer
    \param ctx Optional: pointer to an ecEncCtx object specifying different
    encryption algorithms to use

    _Example_
    \code
    byte msg[] = { initialize with msg to encrypt. Ensure padded to block size };
    byte out[sizeof(msg)];
    word32 outSz = sizeof(out);
    int ret;
    ecc_key cli, serv;
    // initialize cli with private key
    // initialize serv with received public key

    ecEncCtx* cliCtx, servCtx;
    // initialize cliCtx and servCtx
    // exchange salts
    ret = wc_ecc_encrypt(&cli, &serv, msg, sizeof(msg), out, &outSz, cliCtx);
    if(ret != 0) {
    	// error encrypting message
    }
    \endcode

    \sa wc_ecc_encrypt_ex
    \sa wc_ecc_decrypt
*/

int wc_ecc_encrypt(ecc_key* privKey, ecc_key* pubKey, const byte* msg,
                word32 msgSz, byte* out, word32* outSz, ecEncCtx* ctx);

/*!
    \ingroup ECC

    \brief This function encrypts the given input message from msg
    to out. This function takes an optional ctx object as parameter.
    When supplied, encryption proceeds based on the ecEncCtx's
    encAlgo, kdfAlgo, and macAlgo. If ctx is not supplied, processing
    completes with the default algorithms, ecAES_128_CBC,
    ecHKDF_SHA256 and ecHMAC_SHA256. This function requires that
    the messages are padded according to the encryption type specified by ctx.

    \return 0 Returned upon successfully encrypting the input message
    \return BAD_FUNC_ARG Returned if privKey, pubKey, msg, msgSz, out,
    or outSz are NULL, or the ctx object specifies an unsupported
    encryption type
    \return BAD_ENC_STATE_E Returned if the ctx object given is in a
    state that is not appropriate for encryption
    \return BUFFER_E Returned if the supplied output buffer is too
    small to store the encrypted ciphertext
    \return MEMORY_E Returned if there is an error allocating memory
    for the shared secret key

    \param privKey pointer to the ecc_key object containing the
    private key to use for encryption
    \param pubKey pointer to the ecc_key object containing the public
    key of the peer with whom one wishes to communicate
    \param msg pointer to the buffer holding the message to encrypt
    \param msgSz size of the buffer to encrypt
    \param out pointer to the buffer in which to store the encrypted
    ciphertext
    \param outSz pointer to a word32 object containing the available
    size in the out buffer. Upon successfully encrypting the message,
    holds the number of bytes written to the output buffer
    \param ctx Optional: pointer to an ecEncCtx object specifying different
    encryption algorithms to use
    \param compressed Public key field is to be output in compressed format.

    _Example_
    \code
    byte msg[] = { initialize with msg to encrypt. Ensure padded to block size };
    byte out[sizeof(msg)];
    word32 outSz = sizeof(out);
    int ret;
    ecc_key cli, serv;
    // initialize cli with private key
    // initialize serv with received public key

    ecEncCtx* cliCtx, servCtx;
    // initialize cliCtx and servCtx
    // exchange salts
    ret = wc_ecc_encrypt_ex(&cli, &serv, msg, sizeof(msg), out, &outSz, cliCtx,
        1);
    if(ret != 0) {
    	// error encrypting message
    }
    \endcode

    \sa wc_ecc_encrypt
    \sa wc_ecc_decrypt
*/

int wc_ecc_encrypt_ex(ecc_key* privKey, ecc_key* pubKey, const byte* msg,
    word32 msgSz, byte* out, word32* outSz, ecEncCtx* ctx, int compressed);

/*!
    \ingroup ECC

    \brief This function decrypts the ciphertext from msg to out. This
    function takes an optional ctx object as parameter. When supplied,
    encryption proceeds based on the ecEncCtx's encAlgo, kdfAlgo, and
    macAlgo. If ctx is not supplied, processing completes with the
    default algorithms, ecAES_128_CBC, ecHKDF_SHA256 and ecHMAC_SHA256.
    This function requires that the messages are padded according to
    the encryption type specified by ctx.

    \return 0 Returned upon successfully decrypting the input message
    \return BAD_FUNC_ARG Returned if privKey, pubKey, msg, msgSz, out,
    or outSz are NULL, or the ctx object specifies an unsupported
    encryption type
    \return BAD_ENC_STATE_E Returned if the ctx object given is in
    a state that is not appropriate for decryption
    \return BUFFER_E Returned if the supplied output buffer is too
    small to store the decrypted plaintext
    \return MEMORY_E Returned if there is an error allocating memory
    for the shared secret key

    \param privKey pointer to the ecc_key object containing the private
    key to use for decryption
    \param pubKey pointer to the ecc_key object containing the public
    key of the peer with whom one wishes to communicate
    \param msg pointer to the buffer holding the ciphertext to decrypt
    \param msgSz size of the buffer to decrypt
    \param out pointer to the buffer in which to store the decrypted plaintext
    \param outSz pointer to a word32 object containing the available
    size in the out buffer. Upon successfully decrypting the
    ciphertext, holds the number of bytes written to the output buffer
    \param ctx Optional: pointer to an ecEncCtx object specifying
    different decryption algorithms to use

    _Example_
    \code
    byte cipher[] = { initialize with
    ciphertext to decrypt. Ensure padded to block size };
    byte plain[sizeof(cipher)];
    word32 plainSz = sizeof(plain);
    int ret;
    ecc_key cli, serv;
    // initialize cli with private key
    // initialize serv with received public key
    ecEncCtx* cliCtx, servCtx;
    // initialize cliCtx and servCtx
    // exchange salts
    ret = wc_ecc_decrypt(&cli, &serv, cipher, sizeof(cipher),
    plain, &plainSz, cliCtx);

    if(ret != 0) {
    	// error decrypting message
    }
    \endcode

    \sa wc_ecc_encrypt
    \sa wc_ecc_encrypt_ex
*/

int wc_ecc_decrypt(ecc_key* privKey, ecc_key* pubKey, const byte* msg,
                word32 msgSz, byte* out, word32* outSz, ecEncCtx* ctx);


/*!
    \ingroup ECC

    \brief Enable ECC support for non-blocking operations. Supported for
        Single Precision (SP) math with the following build options:
            WOLFSSL_SP_NONBLOCK
            WOLFSSL_SP_SMALL
            WOLFSSL_SP_NO_MALLOC
            WC_ECC_NONBLOCK

    \return 0 Returned upon successfully setting the callback context the input message

    \param key pointer to the ecc_key object
    \param ctx pointer to ecc nb_ctx_t structure with stack data cache for SP

    _Example_
    \code
    int ret;
    ecc_key ecc;
    ecc_nb_ctx_t nb_ctx;

    ret = wc_ecc_init(&ecc);
    if (ret == 0) {
        ret = wc_ecc_set_nonblock(&ecc, &nb_ctx);
        if (ret == 0) {
            do {
                ret = wc_ecc_verify_hash_ex(
                    &r, &s,       // r/s as mp_int
                    hash, hashSz, // computed hash digest
                    &verify_res,  // verification result 1=success
                    &key
                );

                // TODO: Real-time work can be called here
            } while (ret == FP_WOULDBLOCK);
        }
        wc_ecc_free(&key);
    }
    \endcode
*/
int wc_ecc_set_nonblock(ecc_key *key, ecc_nb_ctx_t* ctx);

/*!
    \ingroup ECC

    \brief Compare a curve which has larger key than specified size or the curve matched curve ID,
         set a curve with smaller key size to the key.

    \return 0 Returned upon successfully setting the key

    \param keysize Key size in bytes
    \param curve_id Curve ID

                                                                                                        _Example_
    \code int ret;
    ecc_key ecc;

    ret = wc_ecc_init(&ecc);
    if (ret != 0)
        return ret;
        ret = wc_ecc_set_curve(&ecc, 32, ECC_SECP256R1));
        if (ret != 0)
            return ret;

    \endcode
*/
int wc_ecc_set_curve(ecc_key *key, int keysize, int curve_id);

/*!
    \ingroup ECC
    \brief Gets private key mp_int from ECC key.

    \return mp_int pointer on success
    \return NULL on failure

    \param key ECC key structure

    _Example_
    \code
    ecc_key key;
    mp_int* priv = wc_ecc_key_get_priv(&key);
    \endcode

    \sa wc_ecc_init
*/
mp_int* wc_ecc_key_get_priv(ecc_key* key);

/*!
    \ingroup ECC
    \brief Allocates and initializes new ECC key.

    \return ecc_key pointer on success
    \return NULL on failure

    \param heap Heap hint for memory allocation

    _Example_
    \code
    ecc_key* key = wc_ecc_key_new(NULL);
    if (key != NULL) {
        // use key
        wc_ecc_key_free(key);
    }
    \endcode

    \sa wc_ecc_key_free
*/
ecc_key* wc_ecc_key_new(void* heap);

/*!
    \ingroup ECC
    \brief Returns number of supported ECC curve sets.

    \return Number of curve sets

    _Example_
    \code
    size_t count = wc_ecc_get_sets_count();
    \endcode

    \sa wc_ecc_get_curve_params
*/
size_t wc_ecc_get_sets_count(void);

/*!
    \ingroup ECC
    \brief Gets curve name from curve ID.

    \return Curve name string on success
    \return NULL on failure

    \param curve_id Curve identifier

    _Example_
    \code
    const char* name = wc_ecc_get_name(ECC_SECP256R1);
    \endcode

    \sa wc_ecc_get_curve_id
*/
const char* wc_ecc_get_name(int curve_id);

/*!
    \ingroup ECC
    \brief Makes ECC key with extended options.

    \return 0 on success
    \return negative on error

    \param rng Random number generator
    \param keysize Key size in bytes
    \param key ECC key structure
    \param curve_id Curve identifier
    \param flags Additional flags

    _Example_
    \code
    WC_RNG rng;
    ecc_key key;
    int ret = wc_ecc_make_key_ex2(&rng, 32, &key,
                                  ECC_SECP256R1, 0);
    \endcode

    \sa wc_ecc_make_key_ex
*/
int wc_ecc_make_key_ex2(WC_RNG* rng, int keysize, ecc_key* key,
    int curve_id, int flags);

/*!
    \ingroup ECC
    \brief Checks if point is on curve.

    \return 1 if point is on curve
    \return 0 if not on curve
    \return negative on error

    \param ecp ECC point
    \param a Curve parameter a
    \param b Curve parameter b
    \param prime Curve prime

    _Example_
    \code
    ecc_point* point;
    mp_int a, b, prime;
    int ret = wc_ecc_is_point(point, &a, &b, &prime);
    \endcode

    \sa wc_ecc_point_is_on_curve
*/
int wc_ecc_is_point(ecc_point* ecp, mp_int* a, mp_int* b,
    mp_int* prime);

/*!
    \ingroup ECC
    \brief Gets generator point for curve.

    \return 0 on success
    \return negative on error

    \param ecp ECC point to store generator
    \param curve_idx Curve index

    _Example_
    \code
    ecc_point* gen = wc_ecc_new_point();
    int ret = wc_ecc_get_generator(gen, 0);
    \endcode

    \sa wc_ecc_get_curve_params
*/
int wc_ecc_get_generator(ecc_point* ecp, int curve_idx);

/*!
    \ingroup ECC
    \brief Sets deterministic signing mode.

    \return 0 on success
    \return negative on error

    \param key ECC key
    \param flag Enable/disable flag

    _Example_
    \code
    ecc_key key;
    int ret = wc_ecc_set_deterministic(&key, 1);
    \endcode

    \sa wc_ecc_set_deterministic_ex
*/
int wc_ecc_set_deterministic(ecc_key* key, byte flag);

/*!
    \ingroup ECC
    \brief Sets deterministic signing with hash type.

    \return 0 on success
    \return negative on error

    \param key ECC key
    \param flag Enable/disable flag
    \param hashType Hash algorithm type

    _Example_
    \code
    ecc_key key;
    int ret = wc_ecc_set_deterministic_ex(&key, 1, WC_HASH_TYPE_SHA256);
    \endcode

    \sa wc_ecc_set_deterministic
*/
int wc_ecc_set_deterministic_ex(ecc_key* key, byte flag,
    enum wc_HashType hashType);

/*!
    \ingroup ECC
    \brief Generates deterministic k value for signing.

    \return 0 on success
    \return negative on error

    \param hash Hash value
    \param hashSz Hash size
    \param hashType Hash algorithm type
    \param priv Private key
    \param k Output k value
    \param order Curve order
    \param heap Heap hint

    _Example_
    \code
    byte hash[32];
    mp_int priv, k, order;
    int ret = wc_ecc_gen_deterministic_k(hash, 32,
                                         WC_HASH_TYPE_SHA256,
                                         &priv, &k, &order, NULL);
    \endcode

    \sa wc_ecc_sign_set_k
*/
int wc_ecc_gen_deterministic_k(const byte* hash, word32 hashSz,
    enum wc_HashType hashType, mp_int* priv, mp_int* k,
    mp_int* order, void* heap);

/*!
    \ingroup ECC
    \brief Sets k value for signing.

    \return 0 on success
    \return negative on error

    \param k K value buffer
    \param klen K value length
    \param key ECC key

    _Example_
    \code
    byte k[32];
    ecc_key key;
    int ret = wc_ecc_sign_set_k(k, sizeof(k), &key);
    \endcode

    \sa wc_ecc_gen_deterministic_k
*/
int wc_ecc_sign_set_k(const byte* k, word32 klen, ecc_key* key);

/*!
    \ingroup ECC
    \brief Initializes ECC key with ID.

    \note This API is only available when WOLF_PRIVATE_KEY_ID is defined,
    which is set for PKCS11 support.

    \return 0 on success
    \return negative on error

    \param key ECC key
    \param id ID buffer
    \param len ID length
    \param heap Heap hint
    \param devId Device ID

    _Example_
    \code
    ecc_key key;
    unsigned char id[] = "mykey";
    int ret = wc_ecc_init_id(&key, id, sizeof(id), NULL,
                             INVALID_DEVID);
    \endcode

    \sa wc_ecc_init_label
*/
int wc_ecc_init_id(ecc_key* key, unsigned char* id, int len,
    void* heap, int devId);

/*!
    \ingroup ECC
    \brief Initializes ECC key with label.

    \note This API is only available when WOLF_PRIVATE_KEY_ID is defined,
    which is set for PKCS11 support.

    \return 0 on success
    \return negative on error

    \param key ECC key
    \param label Label string
    \param heap Heap hint
    \param devId Device ID

    _Example_
    \code
    ecc_key key;
    int ret = wc_ecc_init_label(&key, "mykey", NULL,
                                INVALID_DEVID);
    \endcode

    \sa wc_ecc_init_id
*/
int wc_ecc_init_label(ecc_key* key, const char* label, void* heap,
    int devId);

/*!
    \ingroup ECC
    \brief Sets flags on ECC key.

    \return 0 on success
    \return negative on error

    \param key ECC key
    \param flags Flags to set

    _Example_
    \code
    ecc_key key;
    int ret = wc_ecc_set_flags(&key, WC_ECC_FLAG_COFACTOR);
    \endcode

    \sa wc_ecc_init
*/
int wc_ecc_set_flags(ecc_key* key, word32 flags);

/*!
    \ingroup ECC
    \brief Initializes fixed-point cache.

    \return none No returns

    _Example_
    \code
    wc_ecc_fp_init();
    \endcode

    \sa wc_ecc_init
*/
void wc_ecc_fp_init(void);

/*!
    \ingroup ECC
    \brief Sets RNG for ECC key.

    \return 0 on success
    \return negative on error

    \param key ECC key
    \param rng Random number generator

    _Example_
    \code
    ecc_key key;
    WC_RNG rng;
    int ret = wc_ecc_set_rng(&key, &rng);
    \endcode

    \sa wc_ecc_make_key
*/
int wc_ecc_set_rng(ecc_key* key, WC_RNG* rng);

/*!
    \ingroup ECC
    \brief Gets curve index from curve ID.

    \return Curve index on success
    \return negative on error

    \param curve_id Curve identifier

    _Example_
    \code
    int idx = wc_ecc_get_curve_idx(ECC_SECP256R1);
    \endcode

    \sa wc_ecc_get_curve_id
*/
int wc_ecc_get_curve_idx(int curve_id);

/*!
    \ingroup ECC
    \brief Gets curve ID from curve index.

    \return Curve ID on success
    \return negative on error

    \param curve_idx Curve index

    _Example_
    \code
    int id = wc_ecc_get_curve_id(0);
    \endcode

    \sa wc_ecc_get_curve_idx
*/
int wc_ecc_get_curve_id(int curve_idx);

/*!
    \ingroup ECC
    \brief Gets curve size from curve ID.

    \return Key size in bytes on success
    \return negative on error

    \param curve_id Curve identifier

    _Example_
    \code
    int size = wc_ecc_get_curve_size_from_id(ECC_SECP256R1);
    \endcode

    \sa wc_ecc_get_curve_id
*/
int wc_ecc_get_curve_size_from_id(int curve_id);

/*!
    \ingroup ECC
    \brief Gets curve index from curve name.

    \return Curve index on success
    \return negative on error

    \param curveName Curve name string

    _Example_
    \code
    int idx = wc_ecc_get_curve_idx_from_name("SECP256R1");
    \endcode

    \sa wc_ecc_get_name
*/
int wc_ecc_get_curve_idx_from_name(const char* curveName);

/*!
    \ingroup ECC
    \brief Gets curve size from curve name.

    \return Key size in bytes on success
    \return negative on error

    \param curveName Curve name string

    _Example_
    \code
    int size = wc_ecc_get_curve_size_from_name("SECP256R1");
    \endcode

    \sa wc_ecc_get_curve_idx_from_name
*/
int wc_ecc_get_curve_size_from_name(const char* curveName);

/*!
    \ingroup ECC
    \brief Gets curve ID from curve name.

    \return Curve ID on success
    \return negative on error

    \param curveName Curve name string

    _Example_
    \code
    int id = wc_ecc_get_curve_id_from_name("SECP256R1");
    \endcode

    \sa wc_ecc_get_name
*/
int wc_ecc_get_curve_id_from_name(const char* curveName);

/*!
    \ingroup ECC
    \brief Gets curve ID from curve parameters.

    \return Curve ID on success
    \return negative on error

    \param fieldSize Field size
    \param prime Prime modulus
    \param primeSz Prime size
    \param Af Curve parameter A
    \param AfSz A size
    \param Bf Curve parameter B
    \param BfSz B size
    \param order Curve order
    \param orderSz Order size
    \param Gx Generator X coordinate
    \param GxSz Gx size
    \param Gy Generator Y coordinate
    \param GySz Gy size
    \param cofactor Curve cofactor

    _Example_
    \code
    int id = wc_ecc_get_curve_id_from_params(256, prime, 32,
                                             Af, 32, Bf, 32,
                                             order, 32, Gx, 32,
                                             Gy, 32, 1);
    \endcode

    \sa wc_ecc_get_curve_params
*/
int wc_ecc_get_curve_id_from_params(int fieldSize,
    const byte* prime, word32 primeSz, const byte* Af, word32 AfSz,
    const byte* Bf, word32 BfSz, const byte* order, word32 orderSz,
    const byte* Gx, word32 GxSz, const byte* Gy, word32 GySz,
    int cofactor);

/*!
    \ingroup ECC
    \brief Gets curve ID from domain parameters.

    \return Curve ID on success
    \return negative on error

    \param dp Domain parameters

    _Example_
    \code
    const ecc_set_type* dp;
    int id = wc_ecc_get_curve_id_from_dp_params(dp);
    \endcode

    \sa wc_ecc_get_curve_params
*/
int wc_ecc_get_curve_id_from_dp_params(const ecc_set_type* dp);

/*!
    \ingroup ECC
    \brief Gets curve ID from OID.

    \return Curve ID on success
    \return negative on error

    \param oid OID buffer
    \param len OID length

    _Example_
    \code
    byte oid[] = {0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x03, 0x01, 0x07};
    int id = wc_ecc_get_curve_id_from_oid(oid, sizeof(oid));
    \endcode

    \sa wc_ecc_get_oid
*/
int wc_ecc_get_curve_id_from_oid(const byte* oid, word32 len);

/*!
    \ingroup ECC
    \brief Gets curve parameters from curve index.

    \return ecc_set_type pointer on success
    \return NULL on failure

    \param curve_idx Curve index

    _Example_
    \code
    const ecc_set_type* params = wc_ecc_get_curve_params(0);
    \endcode

    \sa wc_ecc_get_curve_idx
*/
const ecc_set_type* wc_ecc_get_curve_params(int curve_idx);

/*!
    \ingroup ECC
    \brief Allocates new ECC point.

    \return ecc_point pointer on success
    \return NULL on failure

    _Example_
    \code
    ecc_point* point = wc_ecc_new_point();
    if (point != NULL) {
        // use point
        wc_ecc_del_point(point);
    }
    \endcode

    \sa wc_ecc_del_point
*/
ecc_point* wc_ecc_new_point(void);

/*!
    \ingroup ECC
    \brief Allocates new ECC point with heap hint.

    \return ecc_point pointer on success
    \return NULL on failure

    \param h Heap hint

    _Example_
    \code
    ecc_point* point = wc_ecc_new_point_h(NULL);
    if (point != NULL) {
        // use point
        wc_ecc_del_point_h(point, NULL);
    }
    \endcode

    \sa wc_ecc_del_point_h
*/
ecc_point* wc_ecc_new_point_h(void* h);

/*!
    \ingroup ECC
    \brief Frees ECC point with heap hint.

    \return none No returns

    \param p ECC point to free
    \param h Heap hint

    _Example_
    \code
    ecc_point* point = wc_ecc_new_point_h(NULL);
    // use point
    wc_ecc_del_point_h(point, NULL);
    \endcode

    \sa wc_ecc_new_point_h
*/
void wc_ecc_del_point_h(ecc_point* p, void* h);

/*!
    \ingroup ECC
    \brief Securely zeros ECC point.

    \return none No returns

    \param p ECC point to zero

    _Example_
    \code
    ecc_point* point;
    wc_ecc_forcezero_point(point);
    \endcode

    \sa wc_ecc_del_point
*/
void wc_ecc_forcezero_point(ecc_point* p);

/*!
    \ingroup ECC
    \brief Checks if point is on curve.

    \return 1 if on curve
    \return 0 if not on curve
    \return negative on error

    \param p ECC point
    \param curve_idx Curve index

    _Example_
    \code
    ecc_point* point;
    int ret = wc_ecc_point_is_on_curve(point, 0);
    \endcode

    \sa wc_ecc_is_point
*/
int wc_ecc_point_is_on_curve(ecc_point *p, int curve_idx);

/*!
    \ingroup ECC
    \brief Imports X9.63 format with curve ID.

    \return 0 on success
    \return negative on error

    \param in Input buffer
    \param inLen Input length
    \param key ECC key
    \param curve_id Curve identifier

    _Example_
    \code
    byte x963[65];
    ecc_key key;
    int ret = wc_ecc_import_x963_ex(x963, sizeof(x963), &key,
                                    ECC_SECP256R1);
    \endcode

    \sa wc_ecc_import_x963
*/
int wc_ecc_import_x963_ex(const byte* in, word32 inLen,
    ecc_key* key, int curve_id);

/*!
    \ingroup ECC
    \brief Imports private key with curve ID.

    \return 0 on success
    \return negative on error

    \param priv Private key buffer
    \param privSz Private key size
    \param pub Public key buffer
    \param pubSz Public key size
    \param key ECC key
    \param curve_id Curve identifier

    _Example_
    \code
    byte priv[32], pub[65];
    ecc_key key;
    int ret = wc_ecc_import_private_key_ex(priv, 32, pub, 65,
                                           &key, ECC_SECP256R1);
    \endcode

    \sa wc_ecc_import_private_key
*/
int wc_ecc_import_private_key_ex(const byte* priv, word32 privSz,
    const byte* pub, word32 pubSz, ecc_key* key, int curve_id);

/*!
    \ingroup ECC
    \brief Converts raw r,s to signature.

    \return 0 on success
    \return negative on error

    \param r R value buffer
    \param rSz R value size
    \param s S value buffer
    \param sSz S value size
    \param out Output signature buffer
    \param outlen Output signature length

    _Example_
    \code
    byte r[32], s[32], sig[72];
    word32 sigLen = sizeof(sig);
    int ret = wc_ecc_rs_raw_to_sig(r, 32, s, 32, sig, &sigLen);
    \endcode

    \sa wc_ecc_sig_to_rs
*/
int wc_ecc_rs_raw_to_sig(const byte* r, word32 rSz, const byte* s,
    word32 sSz, byte* out, word32* outlen);

/*!
    \ingroup ECC
    \brief Converts signature to raw r,s.

    \return 0 on success
    \return negative on error

    \param sig Signature buffer
    \param sigLen Signature length
    \param r R value buffer
    \param rLen R value length
    \param s S value buffer
    \param sLen S value length

    _Example_
    \code
    byte sig[72], r[32], s[32];
    word32 rLen = 32, sLen = 32;
    int ret = wc_ecc_sig_to_rs(sig, 72, r, &rLen, s, &sLen);
    \endcode

    \sa wc_ecc_rs_raw_to_sig
*/
int wc_ecc_sig_to_rs(const byte* sig, word32 sigLen, byte* r,
    word32* rLen, byte* s, word32* sLen);

/*!
    \ingroup ECC
    \brief Imports raw key with curve ID.

    \return 0 on success
    \return negative on error

    \param key ECC key
    \param qx X coordinate string
    \param qy Y coordinate string
    \param d Private key string
    \param curve_id Curve identifier

    _Example_
    \code
    ecc_key key;
    int ret = wc_ecc_import_raw_ex(&key, qxStr, qyStr, dStr,
                                   ECC_SECP256R1);
    \endcode

    \sa wc_ecc_import_raw
*/
int wc_ecc_import_raw_ex(ecc_key* key, const char* qx,
    const char* qy, const char* d, int curve_id);

/*!
    \ingroup ECC
    \brief Imports unsigned key with curve ID.

    \return 0 on success
    \return negative on error

    \param key ECC key
    \param qx X coordinate buffer
    \param qy Y coordinate buffer
    \param d Private key buffer
    \param curve_id Curve identifier

    _Example_
    \code
    ecc_key key;
    byte qx[32], qy[32], d[32];
    int ret = wc_ecc_import_unsigned(&key, qx, qy, d,
                                     ECC_SECP256R1);
    \endcode

    \sa wc_ecc_import_raw_ex
*/
int wc_ecc_import_unsigned(ecc_key* key, const byte* qx,
    const byte* qy, const byte* d, int curve_id);

/*!
    \ingroup ECC
    \brief Exports key with encoding type.

    \return 0 on success
    \return negative on error

    \param key ECC key
    \param qx X coordinate buffer
    \param qxLen X coordinate length
    \param qy Y coordinate buffer
    \param qyLen Y coordinate length
    \param d Private key buffer
    \param dLen Private key length
    \param encType Encoding type

    _Example_
    \code
    ecc_key key;
    byte qx[32], qy[32], d[32];
    word32 qxLen = 32, qyLen = 32, dLen = 32;
    int ret = wc_ecc_export_ex(&key, qx, &qxLen, qy, &qyLen,
                               d, &dLen, 0);
    \endcode

    \sa wc_ecc_export_public_raw
*/
int wc_ecc_export_ex(ecc_key* key, byte* qx, word32* qxLen,
    byte* qy, word32* qyLen, byte* d, word32* dLen, int encType);

/*!
    \ingroup ECC
    \brief Exports public key in raw format.

    \return 0 on success
    \return negative on error

    \param key ECC key
    \param qx X coordinate buffer
    \param qxLen X coordinate length
    \param qy Y coordinate buffer
    \param qyLen Y coordinate length

    _Example_
    \code
    ecc_key key;
    byte qx[32], qy[32];
    word32 qxLen = 32, qyLen = 32;
    int ret = wc_ecc_export_public_raw(&key, qx, &qxLen, qy,
                                       &qyLen);
    \endcode

    \sa wc_ecc_export_private_raw
*/
int wc_ecc_export_public_raw(ecc_key* key, byte* qx,
    word32* qxLen, byte* qy, word32* qyLen);

/*!
    \ingroup ECC
    \brief Exports private key in raw format.

    \return 0 on success
    \return negative on error

    \param key ECC key
    \param qx X coordinate buffer
    \param qxLen X coordinate length
    \param qy Y coordinate buffer
    \param qyLen Y coordinate length
    \param d Private key buffer
    \param dLen Private key length

    _Example_
    \code
    ecc_key key;
    byte qx[32], qy[32], d[32];
    word32 qxLen = 32, qyLen = 32, dLen = 32;
    int ret = wc_ecc_export_private_raw(&key, qx, &qxLen, qy,
                                        &qyLen, d, &dLen);
    \endcode

    \sa wc_ecc_export_public_raw
*/
int wc_ecc_export_private_raw(ecc_key* key, byte* qx,
    word32* qxLen, byte* qy, word32* qyLen, byte* d, word32* dLen);

/*!
    \ingroup ECC
    \brief Exports point in DER format with compression.

    \return Size on success
    \return negative on error

    \param curve_idx Curve index
    \param point ECC point
    \param out Output buffer
    \param outLen Output length
    \param compressed Compression flag

    _Example_
    \code
    ecc_point* point;
    byte out[65];
    word32 outLen = sizeof(out);
    int ret = wc_ecc_export_point_der_ex(0, point, out, &outLen,
                                         0);
    \endcode

    \sa wc_ecc_export_point_der
*/
int wc_ecc_export_point_der_ex(const int curve_idx,
    ecc_point* point, byte* out, word32* outLen, int compressed);

/*!
    \ingroup ECC
    \brief Imports point from DER format.

    \return 0 on success
    \return negative on error

    \param in Input buffer
    \param inLen Input length
    \param curve_idx Curve index
    \param point ECC point
    \param shortKeySize Short key size flag

    _Example_
    \code
    byte der[65];
    ecc_point* point = wc_ecc_new_point();
    int ret = wc_ecc_import_point_der_ex(der, sizeof(der), 0,
                                         point, 0);
    \endcode

    \sa wc_ecc_import_point_der
*/
int wc_ecc_import_point_der_ex(const byte* in, word32 inLen,
    const int curve_idx, ecc_point* point, int shortKeySize);

/*!
    \ingroup ECC
    \brief Gets OID for curve.

    \return 0 on success
    \return negative on error

    \param oidSum OID sum
    \param oid OID buffer pointer
    \param oidSz OID size pointer

    _Example_
    \code
    const byte* oid;
    word32 oidSz;
    int ret = wc_ecc_get_oid(0x2A8648CE3D030107, &oid, &oidSz);
    \endcode

    \sa wc_ecc_get_curve_id_from_oid
*/
int wc_ecc_get_oid(word32 oidSum, const byte** oid, word32* oidSz);

/*!
    \ingroup ECC
    \brief Sets custom curve parameters.

    \return 0 on success
    \return negative on error

    \param key ECC key
    \param dp Domain parameters

    _Example_
    \code
    ecc_key key;
    ecc_set_type dp;
    int ret = wc_ecc_set_custom_curve(&key, &dp);
    \endcode

    \sa wc_ecc_get_curve_params
*/
int wc_ecc_set_custom_curve(ecc_key* key, const ecc_set_type* dp);

/*!
    \ingroup ECC
    \brief Creates new ECC encryption context.

    \return ecEncCtx pointer on success
    \return NULL on failure

    \param flags Context flags
    \param rng Random number generator

    _Example_
    \code
    WC_RNG rng;
    ecEncCtx* ctx = wc_ecc_ctx_new(0, &rng);
    \endcode

    \sa wc_ecc_ctx_free
*/
ecEncCtx* wc_ecc_ctx_new(int flags, WC_RNG* rng);

/*!
    \ingroup ECC
    \brief Creates new ECC encryption context with heap.

    \return ecEncCtx pointer on success
    \return NULL on failure

    \param flags Context flags
    \param rng Random number generator
    \param heap Heap hint

    _Example_
    \code
    WC_RNG rng;
    ecEncCtx* ctx = wc_ecc_ctx_new_ex(0, &rng, NULL);
    \endcode

    \sa wc_ecc_ctx_new
*/
ecEncCtx* wc_ecc_ctx_new_ex(int flags, WC_RNG* rng, void* heap);

/*!
    \ingroup ECC
    \brief Resets ECC encryption context.

    \return 0 on success
    \return negative on error

    \param ctx ECC encryption context
    \param rng Random number generator

    _Example_
    \code
    ecEncCtx* ctx;
    WC_RNG rng;
    int ret = wc_ecc_ctx_reset(ctx, &rng);
    \endcode

    \sa wc_ecc_ctx_new
*/
int wc_ecc_ctx_reset(ecEncCtx* ctx, WC_RNG* rng);

/*!
    \ingroup ECC
    \brief Gets own salt from context.

    \return Salt pointer on success
    \return NULL on failure

    \param ctx ECC encryption context

    _Example_
    \code
    ecEncCtx* ctx;
    const byte* salt = wc_ecc_ctx_get_own_salt(ctx);
    \endcode

    \sa wc_ecc_ctx_set_own_salt
*/
const byte* wc_ecc_ctx_get_own_salt(ecEncCtx* ctx);

/*!
    \ingroup ECC
    \brief Sets own salt in context.

    \return 0 on success
    \return negative on error

    \param ctx ECC encryption context
    \param salt Salt buffer
    \param sz Salt size

    _Example_
    \code
    ecEncCtx* ctx;
    byte salt[16];
    int ret = wc_ecc_ctx_set_own_salt(ctx, salt, sizeof(salt));
    \endcode

    \sa wc_ecc_ctx_get_own_salt
*/
int wc_ecc_ctx_set_own_salt(ecEncCtx* ctx, const byte* salt,
    word32 sz);

/*!
    \ingroup ECC
    \brief X9.63 Key Derivation Function.

    \return 0 on success
    \return negative on error

    \param type Hash type
    \param secret Shared secret
    \param secretSz Secret size
    \param sinfo Shared info
    \param sinfoSz Shared info size
    \param out Output buffer
    \param outSz Output size

    _Example_
    \code
    byte secret[32], sinfo[10], out[32];
    int ret = wc_X963_KDF(WC_HASH_TYPE_SHA256, secret, 32,
                          sinfo, 10, out, 32);
    \endcode

    \sa wc_ecc_shared_secret
*/
int wc_X963_KDF(enum wc_HashType type, const byte* secret,
    word32 secretSz, const byte* sinfo, word32 sinfoSz,
    byte* out, word32 outSz);

/*!
    \ingroup ECC
    \brief Initializes curve cache.

    \return 0 on success
    \return negative on error

    _Example_
    \code
    int ret = wc_ecc_curve_cache_init();
    \endcode

    \sa wc_ecc_curve_cache_free
*/
int wc_ecc_curve_cache_init(void);

/*!
    \ingroup ECC
    \brief Frees curve cache.

    \return none No returns

    _Example_
    \code
    wc_ecc_curve_cache_free();
    \endcode

    \sa wc_ecc_curve_cache_init
*/
void wc_ecc_curve_cache_free(void);

/*!
    \ingroup ECC
    \brief Generates random k value.

    \return 0 on success
    \return negative on error

    \param rng Random number generator
    \param size Key size
    \param k Output k value
    \param order Curve order

    _Example_
    \code
    WC_RNG rng;
    mp_int k, order;
    int ret = wc_ecc_gen_k(&rng, 32, &k, &order);
    \endcode

    \sa wc_ecc_sign_hash
*/
int wc_ecc_gen_k(WC_RNG* rng, int size, mp_int* k, mp_int* order);

/*!
    \ingroup ECC
    \brief Sets remote handle for hardware.

    \return 0 on success
    \return negative on error

    \param key ECC key
    \param handle Remote handle

    _Example_
    \code
    ecc_key key;
    remote_handle64 handle = 0x1234;
    int ret = wc_ecc_set_handle(&key, handle);
    \endcode

    \sa wc_ecc_init
*/
int wc_ecc_set_handle(ecc_key* key, remote_handle64 handle);

/*!
    \ingroup ECC
    \brief Uses key ID for hardware.

    \return 0 on success
    \return negative on error

    \param key ECC key
    \param keyId Key identifier
    \param flags Flags

    _Example_
    \code
    ecc_key key;
    int ret = wc_ecc_use_key_id(&key, 1, 0);
    \endcode

    \sa wc_ecc_get_key_id
*/
int wc_ecc_use_key_id(ecc_key* key, word32 keyId, word32 flags);

/*!
    \ingroup ECC
    \brief Gets key ID from hardware key.

    \return 0 on success
    \return negative on error

    \param key ECC key
    \param keyId Key identifier pointer

    _Example_
    \code
    ecc_key key;
    word32 keyId;
    int ret = wc_ecc_get_key_id(&key, &keyId);
    \endcode

    \sa wc_ecc_use_key_id
*/
int wc_ecc_get_key_id(ecc_key* key, word32* keyId);