libsignal-protocol-sys 0.1.0

*-sys crate for the libsignal-protocol-c library.
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
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
/* automatically generated by rust-bindgen */

pub const RATCHET_CIPHER_KEY_LENGTH: u32 = 32;
pub const RATCHET_MAC_KEY_LENGTH: u32 = 32;
pub const RATCHET_IV_LENGTH: u32 = 16;
pub const CURVE_SIGNATURE_LEN: u32 = 64;
pub const PRE_KEY_MEDIUM_MAX_VALUE: u32 = 16777215;
pub const SG_SUCCESS: u32 = 0;
pub const SG_ERR_NOMEM: i32 = -12;
pub const SG_ERR_INVAL: i32 = -22;
pub const SG_ERR_UNKNOWN: i32 = -1000;
pub const SG_ERR_DUPLICATE_MESSAGE: i32 = -1001;
pub const SG_ERR_INVALID_KEY: i32 = -1002;
pub const SG_ERR_INVALID_KEY_ID: i32 = -1003;
pub const SG_ERR_INVALID_MAC: i32 = -1004;
pub const SG_ERR_INVALID_MESSAGE: i32 = -1005;
pub const SG_ERR_INVALID_VERSION: i32 = -1006;
pub const SG_ERR_LEGACY_MESSAGE: i32 = -1007;
pub const SG_ERR_NO_SESSION: i32 = -1008;
pub const SG_ERR_STALE_KEY_EXCHANGE: i32 = -1009;
pub const SG_ERR_UNTRUSTED_IDENTITY: i32 = -1010;
pub const SG_ERR_VRF_SIG_VERIF_FAILED: i32 = -1011;
pub const SG_ERR_INVALID_PROTO_BUF: i32 = -1100;
pub const SG_ERR_FP_VERSION_MISMATCH: i32 = -1200;
pub const SG_ERR_FP_IDENT_MISMATCH: i32 = -1201;
pub const SG_ERR_MINIMUM: i32 = -9999;
pub const SG_LOG_ERROR: u32 = 0;
pub const SG_LOG_WARNING: u32 = 1;
pub const SG_LOG_NOTICE: u32 = 2;
pub const SG_LOG_INFO: u32 = 3;
pub const SG_LOG_DEBUG: u32 = 4;
pub const SG_CIPHER_AES_CTR_NOPADDING: u32 = 1;
pub const SG_CIPHER_AES_CBC_PKCS5: u32 = 2;
pub const KEY_EXCHANGE_INITIATE_FLAG: u32 = 1;
pub const KEY_EXCHANGE_SIMULTAENOUS_INITIATE_FLAG: u32 = 4;
pub const CIPHERTEXT_UNSUPPORTED_VERSION: u32 = 1;
pub const CIPHERTEXT_CURRENT_VERSION: u32 = 3;
pub const CIPHERTEXT_SIGNAL_TYPE: u32 = 2;
pub const CIPHERTEXT_PREKEY_TYPE: u32 = 3;
pub const CIPHERTEXT_SENDERKEY_TYPE: u32 = 4;
pub const CIPHERTEXT_SENDERKEY_DISTRIBUTION_TYPE: u32 = 5;
pub const CIPHERTEXT_ENCRYPTED_MESSAGE_OVERHEAD: u32 = 53;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct signal_type_base {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct signal_buffer {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct signal_buffer_list {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct signal_int_list {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct signal_context {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct signal_protocol_store_context {
    _unused: [u8; 0],
}
#[repr(C)]
pub struct signal_protocol_address {
    pub name: *const ::std::os::raw::c_char,
    pub name_len: usize,
    pub device_id: i32,
}
#[test]
fn bindgen_test_layout_signal_protocol_address() {
    assert_eq!(
        ::std::mem::size_of::<signal_protocol_address>(),
        24usize,
        concat!("Size of: ", stringify!(signal_protocol_address))
    );
    assert_eq!(
        ::std::mem::align_of::<signal_protocol_address>(),
        8usize,
        concat!("Alignment of ", stringify!(signal_protocol_address))
    );
    assert_eq!(
        unsafe {
            &(*(::std::ptr::null::<signal_protocol_address>())).name as *const _
                as usize
        },
        0usize,
        concat!(
            "Offset of field: ",
            stringify!(signal_protocol_address),
            "::",
            stringify!(name)
        )
    );
    assert_eq!(
        unsafe {
            &(*(::std::ptr::null::<signal_protocol_address>())).name_len
                as *const _ as usize
        },
        8usize,
        concat!(
            "Offset of field: ",
            stringify!(signal_protocol_address),
            "::",
            stringify!(name_len)
        )
    );
    assert_eq!(
        unsafe {
            &(*(::std::ptr::null::<signal_protocol_address>())).device_id
                as *const _ as usize
        },
        16usize,
        concat!(
            "Offset of field: ",
            stringify!(signal_protocol_address),
            "::",
            stringify!(device_id)
        )
    );
}
#[repr(C)]
pub struct signal_protocol_sender_key_name {
    pub group_id: *const ::std::os::raw::c_char,
    pub group_id_len: usize,
    pub sender: signal_protocol_address,
}
#[test]
fn bindgen_test_layout_signal_protocol_sender_key_name() {
    assert_eq!(
        ::std::mem::size_of::<signal_protocol_sender_key_name>(),
        40usize,
        concat!("Size of: ", stringify!(signal_protocol_sender_key_name))
    );
    assert_eq!(
        ::std::mem::align_of::<signal_protocol_sender_key_name>(),
        8usize,
        concat!("Alignment of ", stringify!(signal_protocol_sender_key_name))
    );
    assert_eq!(
        unsafe {
            &(*(::std::ptr::null::<signal_protocol_sender_key_name>())).group_id
                as *const _ as usize
        },
        0usize,
        concat!(
            "Offset of field: ",
            stringify!(signal_protocol_sender_key_name),
            "::",
            stringify!(group_id)
        )
    );
    assert_eq!(
        unsafe {
            &(*(::std::ptr::null::<signal_protocol_sender_key_name>()))
                .group_id_len as *const _ as usize
        },
        8usize,
        concat!(
            "Offset of field: ",
            stringify!(signal_protocol_sender_key_name),
            "::",
            stringify!(group_id_len)
        )
    );
    assert_eq!(
        unsafe {
            &(*(::std::ptr::null::<signal_protocol_sender_key_name>())).sender
                as *const _ as usize
        },
        16usize,
        concat!(
            "Offset of field: ",
            stringify!(signal_protocol_sender_key_name),
            "::",
            stringify!(sender)
        )
    );
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct ec_public_key {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct ec_private_key {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct ec_key_pair {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct ec_public_key_list {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct hkdf_context {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct signal_protocol_key_helper_pre_key_list_node {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct ciphertext_message {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct signal_message {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct pre_key_signal_message {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct sender_key_message {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct sender_key_distribution_message {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct ratchet_chain_key {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct ratchet_root_key {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct ratchet_identity_key_pair {
    _unused: [u8; 0],
}
#[repr(C)]
pub struct ratchet_message_keys {
    pub cipher_key: [u8; 32usize],
    pub mac_key: [u8; 32usize],
    pub iv: [u8; 16usize],
    pub counter: u32,
}
#[test]
fn bindgen_test_layout_ratchet_message_keys() {
    assert_eq!(
        ::std::mem::size_of::<ratchet_message_keys>(),
        84usize,
        concat!("Size of: ", stringify!(ratchet_message_keys))
    );
    assert_eq!(
        ::std::mem::align_of::<ratchet_message_keys>(),
        4usize,
        concat!("Alignment of ", stringify!(ratchet_message_keys))
    );
    assert_eq!(
        unsafe {
            &(*(::std::ptr::null::<ratchet_message_keys>())).cipher_key
                as *const _ as usize
        },
        0usize,
        concat!(
            "Offset of field: ",
            stringify!(ratchet_message_keys),
            "::",
            stringify!(cipher_key)
        )
    );
    assert_eq!(
        unsafe {
            &(*(::std::ptr::null::<ratchet_message_keys>())).mac_key as *const _
                as usize
        },
        32usize,
        concat!(
            "Offset of field: ",
            stringify!(ratchet_message_keys),
            "::",
            stringify!(mac_key)
        )
    );
    assert_eq!(
        unsafe {
            &(*(::std::ptr::null::<ratchet_message_keys>())).iv as *const _
                as usize
        },
        64usize,
        concat!(
            "Offset of field: ",
            stringify!(ratchet_message_keys),
            "::",
            stringify!(iv)
        )
    );
    assert_eq!(
        unsafe {
            &(*(::std::ptr::null::<ratchet_message_keys>())).counter as *const _
                as usize
        },
        80usize,
        concat!(
            "Offset of field: ",
            stringify!(ratchet_message_keys),
            "::",
            stringify!(counter)
        )
    );
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct session_pre_key {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct session_signed_pre_key {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct session_pre_key_bundle {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct session_builder {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct session_record {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct session_record_state_node {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct session_state {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct session_cipher {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct sender_message_key {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct sender_chain_key {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct sender_key_state {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct sender_key_record {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct group_session_builder {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct group_cipher {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct fingerprint {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct displayable_fingerprint {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct scannable_fingerprint {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct fingerprint_generator {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct device_consistency_signature {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct device_consistency_commitment {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct device_consistency_message {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct device_consistency_signature_list {
    _unused: [u8; 0],
}
extern "C" {
    pub fn ratchet_chain_key_create(
        chain_key: *mut *mut ratchet_chain_key,
        kdf: *mut hkdf_context,
        key: *const u8,
        key_len: usize,
        index: u32,
        global_context: *mut signal_context,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn ratchet_chain_key_get_key(
        chain_key: *const ratchet_chain_key,
        buffer: *mut *mut signal_buffer,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn ratchet_chain_key_get_index(
        chain_key: *const ratchet_chain_key,
    ) -> u32;
}
extern "C" {
    pub fn ratchet_chain_key_get_message_keys(
        chain_key: *mut ratchet_chain_key,
        message_keys: *mut ratchet_message_keys,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn ratchet_chain_key_create_next(
        chain_key: *const ratchet_chain_key,
        next_chain_key: *mut *mut ratchet_chain_key,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn ratchet_chain_key_destroy(type_: *mut signal_type_base);
}
extern "C" {
    pub fn ratchet_root_key_create(
        root_key: *mut *mut ratchet_root_key,
        kdf: *mut hkdf_context,
        key: *const u8,
        key_len: usize,
        global_context: *mut signal_context,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn ratchet_root_key_create_chain(
        root_key: *mut ratchet_root_key,
        new_root_key: *mut *mut ratchet_root_key,
        new_chain_key: *mut *mut ratchet_chain_key,
        their_ratchet_key: *mut ec_public_key,
        our_ratchet_key_private: *mut ec_private_key,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn ratchet_root_key_get_key(
        root_key: *mut ratchet_root_key,
        buffer: *mut *mut signal_buffer,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn ratchet_root_key_compare(
        key1: *const ratchet_root_key,
        key2: *const ratchet_root_key,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn ratchet_root_key_destroy(type_: *mut signal_type_base);
}
extern "C" {
    pub fn ratchet_identity_key_pair_create(
        key_pair: *mut *mut ratchet_identity_key_pair,
        public_key: *mut ec_public_key,
        private_key: *mut ec_private_key,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn ratchet_identity_key_pair_serialize(
        buffer: *mut *mut signal_buffer,
        key_pair: *const ratchet_identity_key_pair,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn ratchet_identity_key_pair_deserialize(
        key_pair: *mut *mut ratchet_identity_key_pair,
        data: *const u8,
        len: usize,
        global_context: *mut signal_context,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn ratchet_identity_key_pair_get_public(
        key_pair: *const ratchet_identity_key_pair,
    ) -> *mut ec_public_key;
}
extern "C" {
    pub fn ratchet_identity_key_pair_get_private(
        key_pair: *const ratchet_identity_key_pair,
    ) -> *mut ec_private_key;
}
extern "C" {
    pub fn ratchet_identity_key_pair_destroy(type_: *mut signal_type_base);
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct symmetric_signal_protocol_parameters {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct alice_signal_protocol_parameters {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct bob_signal_protocol_parameters {
    _unused: [u8; 0],
}
extern "C" {
    pub fn symmetric_signal_protocol_parameters_create(
        parameters: *mut *mut symmetric_signal_protocol_parameters,
        our_identity_key: *mut ratchet_identity_key_pair,
        our_base_key: *mut ec_key_pair,
        our_ratchet_key: *mut ec_key_pair,
        their_base_key: *mut ec_public_key,
        their_ratchet_key: *mut ec_public_key,
        their_identity_key: *mut ec_public_key,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn symmetric_signal_protocol_parameters_get_our_identity_key(
        parameters: *const symmetric_signal_protocol_parameters,
    ) -> *mut ratchet_identity_key_pair;
}
extern "C" {
    pub fn symmetric_signal_protocol_parameters_get_our_base_key(
        parameters: *const symmetric_signal_protocol_parameters,
    ) -> *mut ec_key_pair;
}
extern "C" {
    pub fn symmetric_signal_protocol_parameters_get_our_ratchet_key(
        parameters: *const symmetric_signal_protocol_parameters,
    ) -> *mut ec_key_pair;
}
extern "C" {
    pub fn symmetric_signal_protocol_parameters_get_their_base_key(
        parameters: *const symmetric_signal_protocol_parameters,
    ) -> *mut ec_public_key;
}
extern "C" {
    pub fn symmetric_signal_protocol_parameters_get_their_ratchet_key(
        parameters: *const symmetric_signal_protocol_parameters,
    ) -> *mut ec_public_key;
}
extern "C" {
    pub fn symmetric_signal_protocol_parameters_get_their_identity_key(
        parameters: *const symmetric_signal_protocol_parameters,
    ) -> *mut ec_public_key;
}
extern "C" {
    pub fn symmetric_signal_protocol_parameters_destroy(
        type_: *mut signal_type_base,
    );
}
extern "C" {
    pub fn alice_signal_protocol_parameters_create(
        parameters: *mut *mut alice_signal_protocol_parameters,
        our_identity_key: *mut ratchet_identity_key_pair,
        our_base_key: *mut ec_key_pair,
        their_identity_key: *mut ec_public_key,
        their_signed_pre_key: *mut ec_public_key,
        their_one_time_pre_key: *mut ec_public_key,
        their_ratchet_key: *mut ec_public_key,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn alice_signal_protocol_parameters_destroy(
        type_: *mut signal_type_base,
    );
}
extern "C" {
    pub fn bob_signal_protocol_parameters_create(
        parameters: *mut *mut bob_signal_protocol_parameters,
        our_identity_key: *mut ratchet_identity_key_pair,
        our_signed_pre_key: *mut ec_key_pair,
        our_one_time_pre_key: *mut ec_key_pair,
        our_ratchet_key: *mut ec_key_pair,
        their_identity_key: *mut ec_public_key,
        their_base_key: *mut ec_public_key,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn bob_signal_protocol_parameters_destroy(type_: *mut signal_type_base);
}
extern "C" {
    pub fn ratcheting_session_symmetric_initialize(
        state: *mut session_state,
        parameters: *mut symmetric_signal_protocol_parameters,
        global_context: *mut signal_context,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn ratcheting_session_alice_initialize(
        state: *mut session_state,
        parameters: *mut alice_signal_protocol_parameters,
        global_context: *mut signal_context,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn ratcheting_session_bob_initialize(
        state: *mut session_state,
        parameters: *mut bob_signal_protocol_parameters,
        global_context: *mut signal_context,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn curve_internal_fast_tests(
        silent: ::std::os::raw::c_int,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn curve_decode_point(
        public_key: *mut *mut ec_public_key,
        key_data: *const u8,
        key_len: usize,
        global_context: *mut signal_context,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn ec_public_key_compare(
        key1: *const ec_public_key,
        key2: *const ec_public_key,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn ec_public_key_memcmp(
        key1: *const ec_public_key,
        key2: *const ec_public_key,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    /// Serialize the public key into a buffer that can be stored.
    /// The format of this data is compatible with the input format of
    /// curve_decode_point().
    ///
    /// @param buffer Pointer to a buffer that will be allocated by this
    /// function
    ///     and filled with the contents of the key. The caller is responsible
    /// for
    ///     freeing this buffer with signal_buffer_free().
    /// @param key Key to serialize
    /// @return 0 on success, negative on failure
    pub fn ec_public_key_serialize(
        buffer: *mut *mut signal_buffer,
        key: *const ec_public_key,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn ec_public_key_destroy(type_: *mut signal_type_base);
}
extern "C" {
    pub fn curve_decode_private_point(
        private_key: *mut *mut ec_private_key,
        key_data: *const u8,
        key_len: usize,
        global_context: *mut signal_context,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn ec_private_key_compare(
        key1: *const ec_private_key,
        key2: *const ec_private_key,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    /// Serialize the private key into a buffer that can be stored.
    /// The format of this data is compatible with the input format of
    /// curve_decode_private_point().
    ///
    /// @param buffer Pointer to a buffer that will be allocated by this
    /// function
    ///     and filled with the contents of the key. The caller is responsible
    /// for
    ///     freeing this buffer with signal_buffer_free().
    /// @param key Key to serialize
    /// @return 0 on success, negative on failure
    pub fn ec_private_key_serialize(
        buffer: *mut *mut signal_buffer,
        key: *const ec_private_key,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn ec_private_key_destroy(type_: *mut signal_type_base);
}
extern "C" {
    pub fn ec_key_pair_create(
        key_pair: *mut *mut ec_key_pair,
        public_key: *mut ec_public_key,
        private_key: *mut ec_private_key,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn ec_key_pair_get_public(
        key_pair: *const ec_key_pair,
    ) -> *mut ec_public_key;
}
extern "C" {
    pub fn ec_key_pair_get_private(
        key_pair: *const ec_key_pair,
    ) -> *mut ec_private_key;
}
extern "C" {
    pub fn ec_key_pair_destroy(type_: *mut signal_type_base);
}
extern "C" {
    pub fn curve_generate_private_key(
        context: *mut signal_context,
        private_key: *mut *mut ec_private_key,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn curve_generate_public_key(
        public_key: *mut *mut ec_public_key,
        private_key: *const ec_private_key,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    /// Generates a Curve25519 keypair.
    ///
    /// @param key_pair Set to a randomly generated Curve25519 keypair on
    /// success.
    /// @return 0 on success, negative on failure
    pub fn curve_generate_key_pair(
        context: *mut signal_context,
        key_pair: *mut *mut ec_key_pair,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    /// Allocate a new ec_public_key list
    ///
    /// @return pointer to the allocated list, or 0 on failure
    pub fn ec_public_key_list_alloc() -> *mut ec_public_key_list;
}
extern "C" {
    /// Copy an ec_public_key list
    ///
    /// @return pointer to the copy of the list, or 0 on failure
    pub fn ec_public_key_list_copy(
        list: *const ec_public_key_list,
    ) -> *mut ec_public_key_list;
}
extern "C" {
    /// Push a new value onto the end of the list
    ///
    /// @param list the list
    /// @param value the value to push
    /// @return 0 on success, negative on failure
    pub fn ec_public_key_list_push_back(
        list: *mut ec_public_key_list,
        value: *mut ec_public_key,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    /// Gets the size of the list.
    ///
    /// @param list the list
    /// @return the size of the list
    pub fn ec_public_key_list_size(
        list: *const ec_public_key_list,
    ) -> ::std::os::raw::c_uint;
}
extern "C" {
    /// Gets the value of the element at a particular index in the list
    ///
    /// @param list the list
    /// @param index the index within the list
    /// @return the value
    pub fn ec_public_key_list_at(
        list: *const ec_public_key_list,
        index: ::std::os::raw::c_uint,
    ) -> *mut ec_public_key;
}
extern "C" {
    /// Sorts the list based on a comparison of the key data.
    ///
    /// @param list the list
    pub fn ec_public_key_list_sort(list: *mut ec_public_key_list);
}
extern "C" {
    /// Free the ec_public_key list
    /// @param list the list to free
    pub fn ec_public_key_list_free(list: *mut ec_public_key_list);
}
extern "C" {
    /// Calculates an ECDH agreement.
    ///
    /// @param shared_key_data Set to a 32-byte shared secret on success.
    /// @param public_key The Curve25519 (typically remote party's) public key.
    /// @param private_key The Curve25519 (typically yours) private key.
    /// @return length of the shared secret on success, negative on failure
    pub fn curve_calculate_agreement(
        shared_key_data: *mut *mut u8,
        public_key: *const ec_public_key,
        private_key: *const ec_private_key,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    /// Verify a Curve25519 signature.
    ///
    /// @param signing_key The Curve25519 public key the signature belongs to.
    /// @param message_data The message that was signed.
    /// @param message_len The length of the message that was signed.
    /// @param signature_data The signature to verify.
    /// @param signature_len The length of the signature to verify.
    /// @return 1 if valid, 0 if invalid, negative on failure
    pub fn curve_verify_signature(
        signing_key: *const ec_public_key,
        message_data: *const u8,
        message_len: usize,
        signature_data: *const u8,
        signature_len: usize,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    /// Calculates a Curve25519 signature.
    ///
    /// @param signature Set to a 64-byte signature on success.
    /// @param signing_key The private Curve25519 key to create the signature
    /// with.
    /// @param message_data The message to sign.
    /// @param message_len The length of the message to sign.
    /// @return 0 on success, negative on failure
    pub fn curve_calculate_signature(
        context: *mut signal_context,
        signature: *mut *mut signal_buffer,
        signing_key: *const ec_private_key,
        message_data: *const u8,
        message_len: usize,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    /// Verify a Unique Curve25519 signature.
    ///
    /// @param vrf_output Set to VRF output on success
    /// @param signing_key The Curve25519 public key the unique signature
    /// belongs to.
    /// @param message_data The message that was signed.
    /// @param message_len The length of the message that was signed.
    /// @param signature_data The signature to verify.
    /// @param signature_len The length of the signature to verify.
    /// @return 1 if valid, 0 if invalid, negative on failure
    pub fn curve_verify_vrf_signature(
        context: *mut signal_context,
        vrf_output: *mut *mut signal_buffer,
        signing_key: *const ec_public_key,
        message_data: *const u8,
        message_len: usize,
        signature_data: *const u8,
        signature_len: usize,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    /// Calculates a Unique Curve25519 signature.
    ///
    /// @param signature Set to a 96-byte signature on success.
    /// @param signing_key The private Curve25519 key to create the signature
    /// with.
    /// @param message_data The message to sign.
    /// @param message_len The length of the message to sign.
    /// @return 0 on success, negative on failure
    pub fn curve_calculate_vrf_signature(
        context: *mut signal_context,
        signature: *mut *mut signal_buffer,
        signing_key: *const ec_private_key,
        message_data: *const u8,
        message_len: usize,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn session_record_create(
        record: *mut *mut session_record,
        state: *mut session_state,
        global_context: *mut signal_context,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn session_record_serialize(
        buffer: *mut *mut signal_buffer,
        record: *const session_record,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn session_record_deserialize(
        record: *mut *mut session_record,
        data: *const u8,
        len: usize,
        global_context: *mut signal_context,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn session_record_copy(
        record: *mut *mut session_record,
        other_record: *mut session_record,
        global_context: *mut signal_context,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn session_record_has_session_state(
        record: *mut session_record,
        version: u32,
        alice_base_key: *const ec_public_key,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn session_record_get_state(
        record: *mut session_record,
    ) -> *mut session_state;
}
extern "C" {
    pub fn session_record_set_state(
        record: *mut session_record,
        state: *mut session_state,
    );
}
extern "C" {
    pub fn session_record_get_previous_states_head(
        record: *const session_record,
    ) -> *mut session_record_state_node;
}
extern "C" {
    pub fn session_record_get_previous_states_element(
        node: *const session_record_state_node,
    ) -> *mut session_state;
}
extern "C" {
    pub fn session_record_get_previous_states_next(
        node: *const session_record_state_node,
    ) -> *mut session_record_state_node;
}
extern "C" {
    /// Removes the specified node in the previous states list.
    /// @param node the node to remove
    /// @return the node immediately following the removed node, or null if at
    /// the end of the list
    pub fn session_record_get_previous_states_remove(
        record: *mut session_record,
        node: *mut session_record_state_node,
    ) -> *mut session_record_state_node;
}
extern "C" {
    pub fn session_record_is_fresh(
        record: *mut session_record,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    /// Move the current session_state into the list of "previous" session
    /// states,
    /// and replace the current session_state with a fresh reset instance.
    ///
    /// @return 0 on success, negative on failure
    pub fn session_record_archive_current_state(
        record: *mut session_record,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn session_record_promote_state(
        record: *mut session_record,
        promoted_state: *mut session_state,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn session_record_get_user_record(
        record: *const session_record,
    ) -> *mut signal_buffer;
}
extern "C" {
    pub fn session_record_set_user_record(
        record: *mut session_record,
        user_record: *mut signal_buffer,
    );
}
extern "C" {
    pub fn session_record_destroy(type_: *mut signal_type_base);
}
extern "C" {
    pub fn session_pre_key_create(
        pre_key: *mut *mut session_pre_key,
        id: u32,
        key_pair: *mut ec_key_pair,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn session_pre_key_serialize(
        buffer: *mut *mut signal_buffer,
        pre_key: *const session_pre_key,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn session_pre_key_deserialize(
        pre_key: *mut *mut session_pre_key,
        data: *const u8,
        len: usize,
        global_context: *mut signal_context,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn session_pre_key_get_id(pre_key: *const session_pre_key) -> u32;
}
extern "C" {
    pub fn session_pre_key_get_key_pair(
        pre_key: *const session_pre_key,
    ) -> *mut ec_key_pair;
}
extern "C" {
    pub fn session_pre_key_destroy(type_: *mut signal_type_base);
}
extern "C" {
    pub fn session_signed_pre_key_create(
        pre_key: *mut *mut session_signed_pre_key,
        id: u32,
        timestamp: u64,
        key_pair: *mut ec_key_pair,
        signature: *const u8,
        signature_len: usize,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn session_signed_pre_key_serialize(
        buffer: *mut *mut signal_buffer,
        pre_key: *const session_signed_pre_key,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn session_signed_pre_key_deserialize(
        pre_key: *mut *mut session_signed_pre_key,
        data: *const u8,
        len: usize,
        global_context: *mut signal_context,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn session_signed_pre_key_get_id(
        pre_key: *const session_signed_pre_key,
    ) -> u32;
}
extern "C" {
    pub fn session_signed_pre_key_get_timestamp(
        pre_key: *const session_signed_pre_key,
    ) -> u64;
}
extern "C" {
    pub fn session_signed_pre_key_get_key_pair(
        pre_key: *const session_signed_pre_key,
    ) -> *mut ec_key_pair;
}
extern "C" {
    pub fn session_signed_pre_key_get_signature(
        pre_key: *const session_signed_pre_key,
    ) -> *const u8;
}
extern "C" {
    pub fn session_signed_pre_key_get_signature_len(
        pre_key: *const session_signed_pre_key,
    ) -> usize;
}
extern "C" {
    pub fn session_signed_pre_key_destroy(type_: *mut signal_type_base);
}
extern "C" {
    pub fn session_pre_key_bundle_create(
        bundle: *mut *mut session_pre_key_bundle,
        registration_id: u32,
        device_id: ::std::os::raw::c_int,
        pre_key_id: u32,
        pre_key_public: *mut ec_public_key,
        signed_pre_key_id: u32,
        signed_pre_key_public: *mut ec_public_key,
        signed_pre_key_signature_data: *const u8,
        signed_pre_key_signature_len: usize,
        identity_key: *mut ec_public_key,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn session_pre_key_bundle_get_registration_id(
        bundle: *const session_pre_key_bundle,
    ) -> u32;
}
extern "C" {
    pub fn session_pre_key_bundle_get_device_id(
        bundle: *const session_pre_key_bundle,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn session_pre_key_bundle_get_pre_key_id(
        bundle: *const session_pre_key_bundle,
    ) -> u32;
}
extern "C" {
    pub fn session_pre_key_bundle_get_pre_key(
        bundle: *const session_pre_key_bundle,
    ) -> *mut ec_public_key;
}
extern "C" {
    pub fn session_pre_key_bundle_get_signed_pre_key_id(
        bundle: *const session_pre_key_bundle,
    ) -> u32;
}
extern "C" {
    pub fn session_pre_key_bundle_get_signed_pre_key(
        bundle: *const session_pre_key_bundle,
    ) -> *mut ec_public_key;
}
extern "C" {
    pub fn session_pre_key_bundle_get_signed_pre_key_signature(
        bundle: *const session_pre_key_bundle,
    ) -> *mut signal_buffer;
}
extern "C" {
    pub fn session_pre_key_bundle_get_identity_key(
        bundle: *const session_pre_key_bundle,
    ) -> *mut ec_public_key;
}
extern "C" {
    pub fn session_pre_key_bundle_destroy(type_: *mut signal_type_base);
}
extern "C" {
    pub fn sender_key_record_create(
        record: *mut *mut sender_key_record,
        global_context: *mut signal_context,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn sender_key_record_serialize(
        buffer: *mut *mut signal_buffer,
        record: *mut sender_key_record,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn sender_key_record_deserialize(
        record: *mut *mut sender_key_record,
        data: *const u8,
        len: usize,
        global_context: *mut signal_context,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn sender_key_record_copy(
        record: *mut *mut sender_key_record,
        other_state: *mut sender_key_record,
        global_context: *mut signal_context,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn sender_key_record_is_empty(
        record: *mut sender_key_record,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn sender_key_record_get_sender_key_state(
        record: *mut sender_key_record,
        state: *mut *mut sender_key_state,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn sender_key_record_get_sender_key_state_by_id(
        record: *mut sender_key_record,
        state: *mut *mut sender_key_state,
        key_id: u32,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn sender_key_record_add_sender_key_state(
        record: *mut sender_key_record,
        id: u32,
        iteration: u32,
        chain_key: *mut signal_buffer,
        signature_key: *mut ec_public_key,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn sender_key_record_set_sender_key_state(
        record: *mut sender_key_record,
        id: u32,
        iteration: u32,
        chain_key: *mut signal_buffer,
        signature_key_pair: *mut ec_key_pair,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn sender_key_record_get_user_record(
        record: *const sender_key_record,
    ) -> *mut signal_buffer;
}
extern "C" {
    pub fn sender_key_record_set_user_record(
        record: *mut sender_key_record,
        user_record: *mut signal_buffer,
    );
}
extern "C" {
    pub fn sender_key_record_destroy(type_: *mut signal_type_base);
}
extern "C" {
    pub fn signal_type_ref(instance: *mut signal_type_base);
}
extern "C" {
    pub fn signal_type_unref(instance: *mut signal_type_base);
}
extern "C" {
    /// Allocate a new buffer to store data of the provided length.
    ///
    /// @param len length of the buffer to allocate
    /// @return pointer to the allocated buffer, or 0 on failure
    pub fn signal_buffer_alloc(len: usize) -> *mut signal_buffer;
}
extern "C" {
    /// Create a new buffer and copy the provided data into it.
    ///
    /// @param data pointer to the start of the data
    /// @param len length of the data
    /// @return pointer to the allocated buffer, or 0 on failure
    pub fn signal_buffer_create(
        data: *const u8,
        len: usize,
    ) -> *mut signal_buffer;
}
extern "C" {
    /// Create a copy of an existing buffer.
    ///
    /// @param buffer the existing buffer to copy
    /// @return pointer to the updated buffer, or 0 on failure
    pub fn signal_buffer_copy(
        buffer: *const signal_buffer,
    ) -> *mut signal_buffer;
}
extern "C" {
    /// Create a copy of an existing buffer.
    ///
    /// @param buffer the existing buffer to copy
    /// @param n the maximum number of bytes to copy
    /// @return pointer to the updated buffer, or 0 on failure
    pub fn signal_buffer_n_copy(
        buffer: *const signal_buffer,
        n: usize,
    ) -> *mut signal_buffer;
}
extern "C" {
    /// Append the provided data to an existing buffer.
    /// Note: The underlying buffer is only expanded by an amount sufficient
    /// to hold the data being appended. There is no additional reserved space
    /// to reduce the need for memory allocations.
    ///
    /// @param buffer the existing buffer to append to
    /// @param data pointer to the start of the data
    /// @param len length of the data
    /// @return pointer to the updated buffer, or 0 on failure
    pub fn signal_buffer_append(
        buffer: *mut signal_buffer,
        data: *const u8,
        len: usize,
    ) -> *mut signal_buffer;
}
extern "C" {
    /// Gets the data pointer for the buffer.
    /// This can be used to read and write data stored in the buffer.
    ///
    /// @param buffer pointer to the buffer instance
    /// @return data pointer
    pub fn signal_buffer_data(buffer: *mut signal_buffer) -> *mut u8;
}
extern "C" {
    /// Gets the data pointer for the buffer.
    /// This can be used to read and write data stored in the buffer.
    ///
    /// @param buffer pointer to the buffer instance
    /// @return data pointer
    pub fn signal_buffer_const_data(buffer: *const signal_buffer) -> *const u8;
}
extern "C" {
    /// Gets the length of the data stored within the buffer.
    ///
    /// @param buffer pointer to the buffer instance
    /// @return data length
    pub fn signal_buffer_len(buffer: *const signal_buffer) -> usize;
}
extern "C" {
    /// Compare two buffers.
    ///
    /// @param buffer1 first buffer to compare
    /// @param buffer2 second buffer to compare
    /// @return 0 if the two buffers are equal, negative or positive otherwise
    pub fn signal_buffer_compare(
        buffer1: *mut signal_buffer,
        buffer2: *mut signal_buffer,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    /// Free the data buffer.
    ///
    /// @param buffer pointer to the buffer instance to free
    pub fn signal_buffer_free(buffer: *mut signal_buffer);
}
extern "C" {
    /// Zero and free the data buffer.
    /// This function should be used when the buffer contains sensitive
    /// data, to make sure the memory is cleared before being freed.
    ///
    /// @param buffer pointer to the buffer instance to free
    pub fn signal_buffer_bzero_free(buffer: *mut signal_buffer);
}
extern "C" {
    /// Allocate a new buffer list.
    ///
    /// @return pointer to the allocated buffer, or 0 on failure
    pub fn signal_buffer_list_alloc() -> *mut signal_buffer_list;
}
extern "C" {
    /// Create a copy of an existing buffer list.
    ///
    /// @param list the existing buffer list to copy
    /// @return pointer to the updated buffer, or 0 on failure
    pub fn signal_buffer_list_copy(
        list: *const signal_buffer_list,
    ) -> *mut signal_buffer_list;
}
extern "C" {
    /// Push the provided buffer onto the end of the list.
    /// The list will take ownership of the buffer, and free it when the list is
    /// freed.
    ///
    /// @param list the buffer list
    /// @param buffer the buffer to push
    /// @return 0 on success, or negative on failure
    pub fn signal_buffer_list_push_back(
        list: *mut signal_buffer_list,
        buffer: *mut signal_buffer,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    /// Gets the size of the buffer list.
    ///
    /// @param list the buffer list
    /// @return the size of the list
    pub fn signal_buffer_list_size(
        list: *mut signal_buffer_list,
    ) -> ::std::os::raw::c_uint;
}
extern "C" {
    /// Gets the value of the element at a particular index in the list
    ///
    /// @param list the list
    /// @param index the index within the list
    /// @return the value
    pub fn signal_buffer_list_at(
        list: *mut signal_buffer_list,
        index: ::std::os::raw::c_uint,
    ) -> *mut signal_buffer;
}
extern "C" {
    /// Free the buffer list, including all the buffers added to it.
    ///
    /// @param list the buffer list
    pub fn signal_buffer_list_free(list: *mut signal_buffer_list);
}
extern "C" {
    /// Free the buffer list, including all the buffers added to it.
    /// This function should be used when the buffer list contains sensitive
    /// data, to make sure the memory is cleared before being freed.
    ///
    /// @param list the buffer list
    pub fn signal_buffer_list_bzero_free(list: *mut signal_buffer_list);
}
extern "C" {
    /// Allocate a new int list
    ///
    /// @return pointer to the allocated buffer, or 0 on failure
    pub fn signal_int_list_alloc() -> *mut signal_int_list;
}
extern "C" {
    /// Push a new value onto the end of the list
    ///
    /// @param list the list
    /// @param value the value to push
    /// @return 0 on success, or negative on failure
    pub fn signal_int_list_push_back(
        list: *mut signal_int_list,
        value: ::std::os::raw::c_int,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    /// Gets the size of the list.
    ///
    /// @param list the list
    /// @return the size of the list
    pub fn signal_int_list_size(
        list: *mut signal_int_list,
    ) -> ::std::os::raw::c_uint;
}
extern "C" {
    /// Gets the value of the element at a particular index in the list
    ///
    /// @param list the list
    /// @param index the index within the list
    /// @return the value
    pub fn signal_int_list_at(
        list: *mut signal_int_list,
        index: ::std::os::raw::c_uint,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    /// Free the int list
    /// @param list the list to free
    pub fn signal_int_list_free(list: *mut signal_int_list);
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct signal_crypto_provider {
    /// Callback for a secure random number generator.
    /// This function shall fill the provided buffer with random bytes.
    ///
    /// @param data pointer to the output buffer
    /// @param len size of the output buffer
    /// @return 0 on success, negative on failure
    pub random_func: ::std::option::Option<
        unsafe extern "C" fn(
            data: *mut u8,
            len: usize,
            user_data: *mut ::std::os::raw::c_void,
        ) -> ::std::os::raw::c_int,
    >,
    /// Callback for an HMAC-SHA256 implementation.
    /// This function shall initialize an HMAC context with the provided key.
    ///
    /// @param hmac_context private HMAC context pointer
    /// @param key pointer to the key
    /// @param key_len length of the key
    /// @return 0 on success, negative on failure
    pub hmac_sha256_init_func: ::std::option::Option<
        unsafe extern "C" fn(
            hmac_context: *mut *mut ::std::os::raw::c_void,
            key: *const u8,
            key_len: usize,
            user_data: *mut ::std::os::raw::c_void,
        ) -> ::std::os::raw::c_int,
    >,
    /// Callback for an HMAC-SHA256 implementation.
    /// This function shall update the HMAC context with the provided data
    ///
    /// @param hmac_context private HMAC context pointer
    /// @param data pointer to the data
    /// @param data_len length of the data
    /// @return 0 on success, negative on failure
    pub hmac_sha256_update_func: ::std::option::Option<
        unsafe extern "C" fn(
            hmac_context: *mut ::std::os::raw::c_void,
            data: *const u8,
            data_len: usize,
            user_data: *mut ::std::os::raw::c_void,
        ) -> ::std::os::raw::c_int,
    >,
    /// Callback for an HMAC-SHA256 implementation.
    /// This function shall finalize an HMAC calculation and populate the
    /// output
    /// buffer with the result.
    ///
    /// @param hmac_context private HMAC context pointer
    /// @param output buffer to be allocated and populated with the result
    /// @return 0 on success, negative on failure
    pub hmac_sha256_final_func: ::std::option::Option<
        unsafe extern "C" fn(
            hmac_context: *mut ::std::os::raw::c_void,
            output: *mut *mut signal_buffer,
            user_data: *mut ::std::os::raw::c_void,
        ) -> ::std::os::raw::c_int,
    >,
    /// Callback for an HMAC-SHA256 implementation.
    /// This function shall free the private context allocated in
    /// hmac_sha256_init_func.
    ///
    /// @param hmac_context private HMAC context pointer
    pub hmac_sha256_cleanup_func: ::std::option::Option<
        unsafe extern "C" fn(
            hmac_context: *mut ::std::os::raw::c_void,
            user_data: *mut ::std::os::raw::c_void,
        ),
    >,
    /// Callback for a SHA512 message digest implementation.
    /// This function shall initialize a digest context.
    ///
    /// @param digest_context private digest context pointer
    /// @return 0 on success, negative on failure
    pub sha512_digest_init_func: ::std::option::Option<
        unsafe extern "C" fn(
            digest_context: *mut *mut ::std::os::raw::c_void,
            user_data: *mut ::std::os::raw::c_void,
        ) -> ::std::os::raw::c_int,
    >,
    /// Callback for a SHA512 message digest implementation.
    /// This function shall update the digest context with the provided data.
    ///
    /// @param digest_context private digest context pointer
    /// @param data pointer to the data
    /// @param data_len length of the data
    /// @return 0 on success, negative on failure
    pub sha512_digest_update_func: ::std::option::Option<
        unsafe extern "C" fn(
            digest_context: *mut ::std::os::raw::c_void,
            data: *const u8,
            data_len: usize,
            user_data: *mut ::std::os::raw::c_void,
        ) -> ::std::os::raw::c_int,
    >,
    /// Callback for a SHA512 message digest implementation.
    /// This function shall finalize the digest calculation, populate the
    /// output buffer with the result, and prepare the context for reuse.
    ///
    /// @param digest_context private digest context pointer
    /// @param output buffer to be allocated and populated with the result
    /// @return 0 on success, negative on failure
    pub sha512_digest_final_func: ::std::option::Option<
        unsafe extern "C" fn(
            digest_context: *mut ::std::os::raw::c_void,
            output: *mut *mut signal_buffer,
            user_data: *mut ::std::os::raw::c_void,
        ) -> ::std::os::raw::c_int,
    >,
    /// Callback for a SHA512 message digest implementation.
    /// This function shall free the private context allocated in
    /// sha512_digest_init_func.
    ///
    /// @param digest_context private digest context pointer
    pub sha512_digest_cleanup_func: ::std::option::Option<
        unsafe extern "C" fn(
            digest_context: *mut ::std::os::raw::c_void,
            user_data: *mut ::std::os::raw::c_void,
        ),
    >,
    /// Callback for an AES encryption implementation.
    ///
    /// @param output buffer to be allocated and populated with the ciphertext
    /// @param cipher specific cipher variant to use, either
    /// SG_CIPHER_AES_CTR_NOPADDING or SG_CIPHER_AES_CBC_PKCS5
    /// @param key the encryption key
    /// @param key_len length of the encryption key
    /// @param iv the initialization vector
    /// @param iv_len length of the initialization vector
    /// @param plaintext the plaintext to encrypt
    /// @param plaintext_len length of the plaintext
    /// @return 0 on success, negative on failure
    pub encrypt_func: ::std::option::Option<
        unsafe extern "C" fn(
            output: *mut *mut signal_buffer,
            cipher: ::std::os::raw::c_int,
            key: *const u8,
            key_len: usize,
            iv: *const u8,
            iv_len: usize,
            plaintext: *const u8,
            plaintext_len: usize,
            user_data: *mut ::std::os::raw::c_void,
        ) -> ::std::os::raw::c_int,
    >,
    /// Callback for an AES decryption implementation.
    ///
    /// @param output buffer to be allocated and populated with the plaintext
    /// @param cipher specific cipher variant to use, either
    /// SG_CIPHER_AES_CTR_NOPADDING or SG_CIPHER_AES_CBC_PKCS5
    /// @param key the encryption key
    /// @param key_len length of the encryption key
    /// @param iv the initialization vector
    /// @param iv_len length of the initialization vector
    /// @param ciphertext the ciphertext to decrypt
    /// @param ciphertext_len length of the ciphertext
    /// @return 0 on success, negative on failure
    pub decrypt_func: ::std::option::Option<
        unsafe extern "C" fn(
            output: *mut *mut signal_buffer,
            cipher: ::std::os::raw::c_int,
            key: *const u8,
            key_len: usize,
            iv: *const u8,
            iv_len: usize,
            ciphertext: *const u8,
            ciphertext_len: usize,
            user_data: *mut ::std::os::raw::c_void,
        ) -> ::std::os::raw::c_int,
    >,
    /// User data pointer
    pub user_data: *mut ::std::os::raw::c_void,
}
#[test]
fn bindgen_test_layout_signal_crypto_provider() {
    assert_eq!(
        ::std::mem::size_of::<signal_crypto_provider>(),
        96usize,
        concat!("Size of: ", stringify!(signal_crypto_provider))
    );
    assert_eq!(
        ::std::mem::align_of::<signal_crypto_provider>(),
        8usize,
        concat!("Alignment of ", stringify!(signal_crypto_provider))
    );
    assert_eq!(
        unsafe {
            &(*(::std::ptr::null::<signal_crypto_provider>())).random_func
                as *const _ as usize
        },
        0usize,
        concat!(
            "Offset of field: ",
            stringify!(signal_crypto_provider),
            "::",
            stringify!(random_func)
        )
    );
    assert_eq!(
        unsafe {
            &(*(::std::ptr::null::<signal_crypto_provider>()))
                .hmac_sha256_init_func as *const _ as usize
        },
        8usize,
        concat!(
            "Offset of field: ",
            stringify!(signal_crypto_provider),
            "::",
            stringify!(hmac_sha256_init_func)
        )
    );
    assert_eq!(
        unsafe {
            &(*(::std::ptr::null::<signal_crypto_provider>()))
                .hmac_sha256_update_func as *const _ as usize
        },
        16usize,
        concat!(
            "Offset of field: ",
            stringify!(signal_crypto_provider),
            "::",
            stringify!(hmac_sha256_update_func)
        )
    );
    assert_eq!(
        unsafe {
            &(*(::std::ptr::null::<signal_crypto_provider>()))
                .hmac_sha256_final_func as *const _ as usize
        },
        24usize,
        concat!(
            "Offset of field: ",
            stringify!(signal_crypto_provider),
            "::",
            stringify!(hmac_sha256_final_func)
        )
    );
    assert_eq!(
        unsafe {
            &(*(::std::ptr::null::<signal_crypto_provider>()))
                .hmac_sha256_cleanup_func as *const _ as usize
        },
        32usize,
        concat!(
            "Offset of field: ",
            stringify!(signal_crypto_provider),
            "::",
            stringify!(hmac_sha256_cleanup_func)
        )
    );
    assert_eq!(
        unsafe {
            &(*(::std::ptr::null::<signal_crypto_provider>()))
                .sha512_digest_init_func as *const _ as usize
        },
        40usize,
        concat!(
            "Offset of field: ",
            stringify!(signal_crypto_provider),
            "::",
            stringify!(sha512_digest_init_func)
        )
    );
    assert_eq!(
        unsafe {
            &(*(::std::ptr::null::<signal_crypto_provider>()))
                .sha512_digest_update_func as *const _ as usize
        },
        48usize,
        concat!(
            "Offset of field: ",
            stringify!(signal_crypto_provider),
            "::",
            stringify!(sha512_digest_update_func)
        )
    );
    assert_eq!(
        unsafe {
            &(*(::std::ptr::null::<signal_crypto_provider>()))
                .sha512_digest_final_func as *const _ as usize
        },
        56usize,
        concat!(
            "Offset of field: ",
            stringify!(signal_crypto_provider),
            "::",
            stringify!(sha512_digest_final_func)
        )
    );
    assert_eq!(
        unsafe {
            &(*(::std::ptr::null::<signal_crypto_provider>()))
                .sha512_digest_cleanup_func as *const _ as usize
        },
        64usize,
        concat!(
            "Offset of field: ",
            stringify!(signal_crypto_provider),
            "::",
            stringify!(sha512_digest_cleanup_func)
        )
    );
    assert_eq!(
        unsafe {
            &(*(::std::ptr::null::<signal_crypto_provider>())).encrypt_func
                as *const _ as usize
        },
        72usize,
        concat!(
            "Offset of field: ",
            stringify!(signal_crypto_provider),
            "::",
            stringify!(encrypt_func)
        )
    );
    assert_eq!(
        unsafe {
            &(*(::std::ptr::null::<signal_crypto_provider>())).decrypt_func
                as *const _ as usize
        },
        80usize,
        concat!(
            "Offset of field: ",
            stringify!(signal_crypto_provider),
            "::",
            stringify!(decrypt_func)
        )
    );
    assert_eq!(
        unsafe {
            &(*(::std::ptr::null::<signal_crypto_provider>())).user_data
                as *const _ as usize
        },
        88usize,
        concat!(
            "Offset of field: ",
            stringify!(signal_crypto_provider),
            "::",
            stringify!(user_data)
        )
    );
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct signal_protocol_session_store {
    /// Returns a copy of the serialized session record corresponding to the
    /// provided recipient ID + device ID tuple.
    ///
    /// @param record pointer to a freshly allocated buffer containing the
    ///     serialized session record. Unset if no record was found.
    ///     The Signal Protocol library is responsible for freeing this buffer.
    /// @param user_record pointer to a freshly allocated buffer containing
    ///     application specific data stored alongside the serialized session
    ///     record. If no such data exists, then this pointer may be left
    /// unset.
    ///     The Signal Protocol library is responsible for freeing this buffer.
    /// @param address the address of the remote client
    /// @return 1 if the session was loaded, 0 if the session was not found,
    /// negative on failure
    pub load_session_func: ::std::option::Option<
        unsafe extern "C" fn(
            record: *mut *mut signal_buffer,
            user_record: *mut *mut signal_buffer,
            address: *const signal_protocol_address,
            user_data: *mut ::std::os::raw::c_void,
        ) -> ::std::os::raw::c_int,
    >,
    /// Returns all known devices with active sessions for a recipient
    ///
    /// @param pointer to an array that will be allocated and populated with
    /// the result
    /// @param name the name of the remote client
    /// @param name_len the length of the name
    /// @return size of the sessions array, or negative on failure
    pub get_sub_device_sessions_func: ::std::option::Option<
        unsafe extern "C" fn(
            sessions: *mut *mut signal_int_list,
            name: *const ::std::os::raw::c_char,
            name_len: usize,
            user_data: *mut ::std::os::raw::c_void,
        ) -> ::std::os::raw::c_int,
    >,
    /// Commit to storage the session record for a given
    /// recipient ID + device ID tuple.
    ///
    /// @param address the address of the remote client
    /// @param record pointer to a buffer containing the serialized session
    ///     record for the remote client
    /// @param record_len length of the serialized session record
    /// @param user_record pointer to a buffer containing application specific
    ///     data to be stored alongside the serialized session record for the
    ///     remote client. If no such data exists, then this pointer will be
    /// null.
    /// @param user_record_len length of the application specific data
    /// @return 0 on success, negative on failure
    pub store_session_func: ::std::option::Option<
        unsafe extern "C" fn(
            address: *const signal_protocol_address,
            record: *mut u8,
            record_len: usize,
            user_record: *mut u8,
            user_record_len: usize,
            user_data: *mut ::std::os::raw::c_void,
        ) -> ::std::os::raw::c_int,
    >,
    /// Determine whether there is a committed session record for a
    /// recipient ID + device ID tuple.
    ///
    /// @param address the address of the remote client
    /// @return 1 if a session record exists, 0 otherwise.
    pub contains_session_func: ::std::option::Option<
        unsafe extern "C" fn(
            address: *const signal_protocol_address,
            user_data: *mut ::std::os::raw::c_void,
        ) -> ::std::os::raw::c_int,
    >,
    /// Remove a session record for a recipient ID + device ID tuple.
    ///
    /// @param address the address of the remote client
    /// @return 1 if a session was deleted, 0 if a session was not deleted,
    /// negative on error
    pub delete_session_func: ::std::option::Option<
        unsafe extern "C" fn(
            address: *const signal_protocol_address,
            user_data: *mut ::std::os::raw::c_void,
        ) -> ::std::os::raw::c_int,
    >,
    /// Remove the session records corresponding to all devices of a recipient
    /// ID.
    ///
    /// @param name the name of the remote client
    /// @param name_len the length of the name
    /// @return the number of deleted sessions on success, negative on failure
    pub delete_all_sessions_func: ::std::option::Option<
        unsafe extern "C" fn(
            name: *const ::std::os::raw::c_char,
            name_len: usize,
            user_data: *mut ::std::os::raw::c_void,
        ) -> ::std::os::raw::c_int,
    >,
    /// Function called to perform cleanup when the data store context is being
    /// destroyed.
    pub destroy_func: ::std::option::Option<
        unsafe extern "C" fn(user_data: *mut ::std::os::raw::c_void),
    >,
    /// User data pointer
    pub user_data: *mut ::std::os::raw::c_void,
}
#[test]
fn bindgen_test_layout_signal_protocol_session_store() {
    assert_eq!(
        ::std::mem::size_of::<signal_protocol_session_store>(),
        64usize,
        concat!("Size of: ", stringify!(signal_protocol_session_store))
    );
    assert_eq!(
        ::std::mem::align_of::<signal_protocol_session_store>(),
        8usize,
        concat!("Alignment of ", stringify!(signal_protocol_session_store))
    );
    assert_eq!(
        unsafe {
            &(*(::std::ptr::null::<signal_protocol_session_store>()))
                .load_session_func as *const _ as usize
        },
        0usize,
        concat!(
            "Offset of field: ",
            stringify!(signal_protocol_session_store),
            "::",
            stringify!(load_session_func)
        )
    );
    assert_eq!(
        unsafe {
            &(*(::std::ptr::null::<signal_protocol_session_store>()))
                .get_sub_device_sessions_func as *const _ as usize
        },
        8usize,
        concat!(
            "Offset of field: ",
            stringify!(signal_protocol_session_store),
            "::",
            stringify!(get_sub_device_sessions_func)
        )
    );
    assert_eq!(
        unsafe {
            &(*(::std::ptr::null::<signal_protocol_session_store>()))
                .store_session_func as *const _ as usize
        },
        16usize,
        concat!(
            "Offset of field: ",
            stringify!(signal_protocol_session_store),
            "::",
            stringify!(store_session_func)
        )
    );
    assert_eq!(
        unsafe {
            &(*(::std::ptr::null::<signal_protocol_session_store>()))
                .contains_session_func as *const _ as usize
        },
        24usize,
        concat!(
            "Offset of field: ",
            stringify!(signal_protocol_session_store),
            "::",
            stringify!(contains_session_func)
        )
    );
    assert_eq!(
        unsafe {
            &(*(::std::ptr::null::<signal_protocol_session_store>()))
                .delete_session_func as *const _ as usize
        },
        32usize,
        concat!(
            "Offset of field: ",
            stringify!(signal_protocol_session_store),
            "::",
            stringify!(delete_session_func)
        )
    );
    assert_eq!(
        unsafe {
            &(*(::std::ptr::null::<signal_protocol_session_store>()))
                .delete_all_sessions_func as *const _ as usize
        },
        40usize,
        concat!(
            "Offset of field: ",
            stringify!(signal_protocol_session_store),
            "::",
            stringify!(delete_all_sessions_func)
        )
    );
    assert_eq!(
        unsafe {
            &(*(::std::ptr::null::<signal_protocol_session_store>()))
                .destroy_func as *const _ as usize
        },
        48usize,
        concat!(
            "Offset of field: ",
            stringify!(signal_protocol_session_store),
            "::",
            stringify!(destroy_func)
        )
    );
    assert_eq!(
        unsafe {
            &(*(::std::ptr::null::<signal_protocol_session_store>())).user_data
                as *const _ as usize
        },
        56usize,
        concat!(
            "Offset of field: ",
            stringify!(signal_protocol_session_store),
            "::",
            stringify!(user_data)
        )
    );
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct signal_protocol_pre_key_store {
    /// Load a local serialized PreKey record.
    ///
    /// @param record pointer to a newly allocated buffer containing the
    /// record,
    ///     if found. Unset if no record was found.
    ///     The Signal Protocol library is responsible for freeing this buffer.
    /// @param pre_key_id the ID of the local serialized PreKey record
    /// @retval SG_SUCCESS if the key was found
    /// @retval SG_ERR_INVALID_KEY_ID if the key could not be found
    pub load_pre_key: ::std::option::Option<
        unsafe extern "C" fn(
            record: *mut *mut signal_buffer,
            pre_key_id: u32,
            user_data: *mut ::std::os::raw::c_void,
        ) -> ::std::os::raw::c_int,
    >,
    /// Store a local serialized PreKey record.
    ///
    /// @param pre_key_id the ID of the PreKey record to store.
    /// @param record pointer to a buffer containing the serialized record
    /// @param record_len length of the serialized record
    /// @return 0 on success, negative on failure
    pub store_pre_key: ::std::option::Option<
        unsafe extern "C" fn(
            pre_key_id: u32,
            record: *mut u8,
            record_len: usize,
            user_data: *mut ::std::os::raw::c_void,
        ) -> ::std::os::raw::c_int,
    >,
    /// Determine whether there is a committed PreKey record matching the
    /// provided ID.
    ///
    /// @param pre_key_id A PreKey record ID.
    /// @return 1 if the store has a record for the PreKey ID, 0 otherwise
    pub contains_pre_key: ::std::option::Option<
        unsafe extern "C" fn(
            pre_key_id: u32,
            user_data: *mut ::std::os::raw::c_void,
        ) -> ::std::os::raw::c_int,
    >,
    /// Delete a PreKey record from local storage.
    ///
    /// @param pre_key_id The ID of the PreKey record to remove.
    /// @return 0 on success, negative on failure
    pub remove_pre_key: ::std::option::Option<
        unsafe extern "C" fn(
            pre_key_id: u32,
            user_data: *mut ::std::os::raw::c_void,
        ) -> ::std::os::raw::c_int,
    >,
    /// Function called to perform cleanup when the data store context is being
    /// destroyed.
    pub destroy_func: ::std::option::Option<
        unsafe extern "C" fn(user_data: *mut ::std::os::raw::c_void),
    >,
    /// User data pointer
    pub user_data: *mut ::std::os::raw::c_void,
}
#[test]
fn bindgen_test_layout_signal_protocol_pre_key_store() {
    assert_eq!(
        ::std::mem::size_of::<signal_protocol_pre_key_store>(),
        48usize,
        concat!("Size of: ", stringify!(signal_protocol_pre_key_store))
    );
    assert_eq!(
        ::std::mem::align_of::<signal_protocol_pre_key_store>(),
        8usize,
        concat!("Alignment of ", stringify!(signal_protocol_pre_key_store))
    );
    assert_eq!(
        unsafe {
            &(*(::std::ptr::null::<signal_protocol_pre_key_store>()))
                .load_pre_key as *const _ as usize
        },
        0usize,
        concat!(
            "Offset of field: ",
            stringify!(signal_protocol_pre_key_store),
            "::",
            stringify!(load_pre_key)
        )
    );
    assert_eq!(
        unsafe {
            &(*(::std::ptr::null::<signal_protocol_pre_key_store>()))
                .store_pre_key as *const _ as usize
        },
        8usize,
        concat!(
            "Offset of field: ",
            stringify!(signal_protocol_pre_key_store),
            "::",
            stringify!(store_pre_key)
        )
    );
    assert_eq!(
        unsafe {
            &(*(::std::ptr::null::<signal_protocol_pre_key_store>()))
                .contains_pre_key as *const _ as usize
        },
        16usize,
        concat!(
            "Offset of field: ",
            stringify!(signal_protocol_pre_key_store),
            "::",
            stringify!(contains_pre_key)
        )
    );
    assert_eq!(
        unsafe {
            &(*(::std::ptr::null::<signal_protocol_pre_key_store>()))
                .remove_pre_key as *const _ as usize
        },
        24usize,
        concat!(
            "Offset of field: ",
            stringify!(signal_protocol_pre_key_store),
            "::",
            stringify!(remove_pre_key)
        )
    );
    assert_eq!(
        unsafe {
            &(*(::std::ptr::null::<signal_protocol_pre_key_store>()))
                .destroy_func as *const _ as usize
        },
        32usize,
        concat!(
            "Offset of field: ",
            stringify!(signal_protocol_pre_key_store),
            "::",
            stringify!(destroy_func)
        )
    );
    assert_eq!(
        unsafe {
            &(*(::std::ptr::null::<signal_protocol_pre_key_store>())).user_data
                as *const _ as usize
        },
        40usize,
        concat!(
            "Offset of field: ",
            stringify!(signal_protocol_pre_key_store),
            "::",
            stringify!(user_data)
        )
    );
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct signal_protocol_signed_pre_key_store {
    /// Load a local serialized signed PreKey record.
    ///
    /// @param record pointer to a newly allocated buffer containing the
    /// record,
    ///     if found. Unset if no record was found.
    ///     The Signal Protocol library is responsible for freeing this buffer.
    /// @param signed_pre_key_id the ID of the local signed PreKey record
    /// @retval SG_SUCCESS if the key was found
    /// @retval SG_ERR_INVALID_KEY_ID if the key could not be found
    pub load_signed_pre_key: ::std::option::Option<
        unsafe extern "C" fn(
            record: *mut *mut signal_buffer,
            signed_pre_key_id: u32,
            user_data: *mut ::std::os::raw::c_void,
        ) -> ::std::os::raw::c_int,
    >,
    /// Store a local serialized signed PreKey record.
    ///
    /// @param signed_pre_key_id the ID of the signed PreKey record to store
    /// @param record pointer to a buffer containing the serialized record
    /// @param record_len length of the serialized record
    /// @return 0 on success, negative on failure
    pub store_signed_pre_key: ::std::option::Option<
        unsafe extern "C" fn(
            signed_pre_key_id: u32,
            record: *mut u8,
            record_len: usize,
            user_data: *mut ::std::os::raw::c_void,
        ) -> ::std::os::raw::c_int,
    >,
    /// Determine whether there is a committed signed PreKey record matching
    /// the provided ID.
    ///
    /// @param signed_pre_key_id A signed PreKey record ID.
    /// @return 1 if the store has a record for the signed PreKey ID, 0
    /// otherwise
    pub contains_signed_pre_key: ::std::option::Option<
        unsafe extern "C" fn(
            signed_pre_key_id: u32,
            user_data: *mut ::std::os::raw::c_void,
        ) -> ::std::os::raw::c_int,
    >,
    /// Delete a SignedPreKeyRecord from local storage.
    ///
    /// @param signed_pre_key_id The ID of the signed PreKey record to remove.
    /// @return 0 on success, negative on failure
    pub remove_signed_pre_key: ::std::option::Option<
        unsafe extern "C" fn(
            signed_pre_key_id: u32,
            user_data: *mut ::std::os::raw::c_void,
        ) -> ::std::os::raw::c_int,
    >,
    /// Function called to perform cleanup when the data store context is being
    /// destroyed.
    pub destroy_func: ::std::option::Option<
        unsafe extern "C" fn(user_data: *mut ::std::os::raw::c_void),
    >,
    /// User data pointer
    pub user_data: *mut ::std::os::raw::c_void,
}
#[test]
fn bindgen_test_layout_signal_protocol_signed_pre_key_store() {
    assert_eq!(
        ::std::mem::size_of::<signal_protocol_signed_pre_key_store>(),
        48usize,
        concat!(
            "Size of: ",
            stringify!(signal_protocol_signed_pre_key_store)
        )
    );
    assert_eq!(
        ::std::mem::align_of::<signal_protocol_signed_pre_key_store>(),
        8usize,
        concat!(
            "Alignment of ",
            stringify!(signal_protocol_signed_pre_key_store)
        )
    );
    assert_eq!(
        unsafe {
            &(*(::std::ptr::null::<signal_protocol_signed_pre_key_store>()))
                .load_signed_pre_key as *const _ as usize
        },
        0usize,
        concat!(
            "Offset of field: ",
            stringify!(signal_protocol_signed_pre_key_store),
            "::",
            stringify!(load_signed_pre_key)
        )
    );
    assert_eq!(
        unsafe {
            &(*(::std::ptr::null::<signal_protocol_signed_pre_key_store>()))
                .store_signed_pre_key as *const _ as usize
        },
        8usize,
        concat!(
            "Offset of field: ",
            stringify!(signal_protocol_signed_pre_key_store),
            "::",
            stringify!(store_signed_pre_key)
        )
    );
    assert_eq!(
        unsafe {
            &(*(::std::ptr::null::<signal_protocol_signed_pre_key_store>()))
                .contains_signed_pre_key as *const _ as usize
        },
        16usize,
        concat!(
            "Offset of field: ",
            stringify!(signal_protocol_signed_pre_key_store),
            "::",
            stringify!(contains_signed_pre_key)
        )
    );
    assert_eq!(
        unsafe {
            &(*(::std::ptr::null::<signal_protocol_signed_pre_key_store>()))
                .remove_signed_pre_key as *const _ as usize
        },
        24usize,
        concat!(
            "Offset of field: ",
            stringify!(signal_protocol_signed_pre_key_store),
            "::",
            stringify!(remove_signed_pre_key)
        )
    );
    assert_eq!(
        unsafe {
            &(*(::std::ptr::null::<signal_protocol_signed_pre_key_store>()))
                .destroy_func as *const _ as usize
        },
        32usize,
        concat!(
            "Offset of field: ",
            stringify!(signal_protocol_signed_pre_key_store),
            "::",
            stringify!(destroy_func)
        )
    );
    assert_eq!(
        unsafe {
            &(*(::std::ptr::null::<signal_protocol_signed_pre_key_store>()))
                .user_data as *const _ as usize
        },
        40usize,
        concat!(
            "Offset of field: ",
            stringify!(signal_protocol_signed_pre_key_store),
            "::",
            stringify!(user_data)
        )
    );
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct signal_protocol_identity_key_store {
    /// Get the local client's identity key pair.
    ///
    /// @param public_data pointer to a newly allocated buffer containing the
    ///     public key, if found. Unset if no record was found.
    ///     The Signal Protocol library is responsible for freeing this buffer.
    /// @param private_data pointer to a newly allocated buffer containing the
    ///     private key, if found. Unset if no record was found.
    ///     The Signal Protocol library is responsible for freeing this buffer.
    /// @return 0 on success, negative on failure
    pub get_identity_key_pair: ::std::option::Option<
        unsafe extern "C" fn(
            public_data: *mut *mut signal_buffer,
            private_data: *mut *mut signal_buffer,
            user_data: *mut ::std::os::raw::c_void,
        ) -> ::std::os::raw::c_int,
    >,
    /// Return the local client's registration ID.
    ///
    /// Clients should maintain a registration ID, a random number
    /// between 1 and 16380 that's generated once at install time.
    ///
    /// @param registration_id pointer to be set to the local client's
    ///     registration ID, if it was successfully retrieved.
    /// @return 0 on success, negative on failure
    pub get_local_registration_id: ::std::option::Option<
        unsafe extern "C" fn(
            user_data: *mut ::std::os::raw::c_void,
            registration_id: *mut u32,
        ) -> ::std::os::raw::c_int,
    >,
    /// Save a remote client's identity key
    /// <p>
    /// Store a remote client's identity key as trusted.
    /// The value of key_data may be null. In this case remove the key data
    /// from the identity store, but retain any metadata that may be kept
    /// alongside it.
    ///
    /// @param address the address of the remote client
    /// @param key_data Pointer to the remote client's identity key, may be
    /// null
    /// @param key_len Length of the remote client's identity key
    /// @return 0 on success, negative on failure
    pub save_identity: ::std::option::Option<
        unsafe extern "C" fn(
            address: *const signal_protocol_address,
            key_data: *mut u8,
            key_len: usize,
            user_data: *mut ::std::os::raw::c_void,
        ) -> ::std::os::raw::c_int,
    >,
    /// Verify a remote client's identity key.
    ///
    /// Determine whether a remote client's identity is trusted.  Convention is
    /// that the TextSecure protocol is 'trust on first use.'  This means that
    /// an identity key is considered 'trusted' if there is no entry for the
    /// recipient
    /// in the local store, or if it matches the saved key for a recipient in
    /// the local
    /// store.  Only if it mismatches an entry in the local store is it
    /// considered
    /// 'untrusted.'
    ///
    /// @param address the address of the remote client
    /// @param identityKey The identity key to verify.
    /// @param key_data Pointer to the identity key to verify
    /// @param key_len Length of the identity key to verify
    /// @return 1 if trusted, 0 if untrusted, negative on failure
    pub is_trusted_identity: ::std::option::Option<
        unsafe extern "C" fn(
            address: *const signal_protocol_address,
            key_data: *mut u8,
            key_len: usize,
            user_data: *mut ::std::os::raw::c_void,
        ) -> ::std::os::raw::c_int,
    >,
    /// Function called to perform cleanup when the data store context is being
    /// destroyed.
    pub destroy_func: ::std::option::Option<
        unsafe extern "C" fn(user_data: *mut ::std::os::raw::c_void),
    >,
    /// User data pointer
    pub user_data: *mut ::std::os::raw::c_void,
}
#[test]
fn bindgen_test_layout_signal_protocol_identity_key_store() {
    assert_eq!(
        ::std::mem::size_of::<signal_protocol_identity_key_store>(),
        48usize,
        concat!("Size of: ", stringify!(signal_protocol_identity_key_store))
    );
    assert_eq!(
        ::std::mem::align_of::<signal_protocol_identity_key_store>(),
        8usize,
        concat!(
            "Alignment of ",
            stringify!(signal_protocol_identity_key_store)
        )
    );
    assert_eq!(
        unsafe {
            &(*(::std::ptr::null::<signal_protocol_identity_key_store>()))
                .get_identity_key_pair as *const _ as usize
        },
        0usize,
        concat!(
            "Offset of field: ",
            stringify!(signal_protocol_identity_key_store),
            "::",
            stringify!(get_identity_key_pair)
        )
    );
    assert_eq!(
        unsafe {
            &(*(::std::ptr::null::<signal_protocol_identity_key_store>()))
                .get_local_registration_id as *const _ as usize
        },
        8usize,
        concat!(
            "Offset of field: ",
            stringify!(signal_protocol_identity_key_store),
            "::",
            stringify!(get_local_registration_id)
        )
    );
    assert_eq!(
        unsafe {
            &(*(::std::ptr::null::<signal_protocol_identity_key_store>()))
                .save_identity as *const _ as usize
        },
        16usize,
        concat!(
            "Offset of field: ",
            stringify!(signal_protocol_identity_key_store),
            "::",
            stringify!(save_identity)
        )
    );
    assert_eq!(
        unsafe {
            &(*(::std::ptr::null::<signal_protocol_identity_key_store>()))
                .is_trusted_identity as *const _ as usize
        },
        24usize,
        concat!(
            "Offset of field: ",
            stringify!(signal_protocol_identity_key_store),
            "::",
            stringify!(is_trusted_identity)
        )
    );
    assert_eq!(
        unsafe {
            &(*(::std::ptr::null::<signal_protocol_identity_key_store>()))
                .destroy_func as *const _ as usize
        },
        32usize,
        concat!(
            "Offset of field: ",
            stringify!(signal_protocol_identity_key_store),
            "::",
            stringify!(destroy_func)
        )
    );
    assert_eq!(
        unsafe {
            &(*(::std::ptr::null::<signal_protocol_identity_key_store>()))
                .user_data as *const _ as usize
        },
        40usize,
        concat!(
            "Offset of field: ",
            stringify!(signal_protocol_identity_key_store),
            "::",
            stringify!(user_data)
        )
    );
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct signal_protocol_sender_key_store {
    /// Store a serialized sender key record for a given
    /// (groupId + senderId + deviceId) tuple.
    ///
    /// @param sender_key_name the (groupId + senderId + deviceId) tuple
    /// @param record pointer to a buffer containing the serialized record
    /// @param record_len length of the serialized record
    /// @param user_record pointer to a buffer containing application specific
    ///     data to be stored alongside the serialized record. If no such
    ///     data exists, then this pointer will be null.
    /// @param user_record_len length of the application specific data
    /// @return 0 on success, negative on failure
    pub store_sender_key: ::std::option::Option<
        unsafe extern "C" fn(
            sender_key_name: *const signal_protocol_sender_key_name,
            record: *mut u8,
            record_len: usize,
            user_record: *mut u8,
            user_record_len: usize,
            user_data: *mut ::std::os::raw::c_void,
        ) -> ::std::os::raw::c_int,
    >,
    /// Returns a copy of the sender key record corresponding to the
    /// (groupId + senderId + deviceId) tuple.
    ///
    /// @param record pointer to a newly allocated buffer containing the
    /// record,
    ///     if found. Unset if no record was found.
    ///     The Signal Protocol library is responsible for freeing this buffer.
    /// @param user_record pointer to a newly allocated buffer containing
    ///     application-specific data stored alongside the record. If no such
    ///     data exists, then this pointer may be left unset.
    ///     The Signal Protocol library is responsible for freeing this buffer.
    /// @param sender_key_name the (groupId + senderId + deviceId) tuple
    /// @return 1 if the record was loaded, 0 if the record was not found,
    /// negative on failure
    pub load_sender_key: ::std::option::Option<
        unsafe extern "C" fn(
            record: *mut *mut signal_buffer,
            user_record: *mut *mut signal_buffer,
            sender_key_name: *const signal_protocol_sender_key_name,
            user_data: *mut ::std::os::raw::c_void,
        ) -> ::std::os::raw::c_int,
    >,
    /// Function called to perform cleanup when the data store context is being
    /// destroyed.
    pub destroy_func: ::std::option::Option<
        unsafe extern "C" fn(user_data: *mut ::std::os::raw::c_void),
    >,
    /// User data pointer
    pub user_data: *mut ::std::os::raw::c_void,
}
#[test]
fn bindgen_test_layout_signal_protocol_sender_key_store() {
    assert_eq!(
        ::std::mem::size_of::<signal_protocol_sender_key_store>(),
        32usize,
        concat!("Size of: ", stringify!(signal_protocol_sender_key_store))
    );
    assert_eq!(
        ::std::mem::align_of::<signal_protocol_sender_key_store>(),
        8usize,
        concat!(
            "Alignment of ",
            stringify!(signal_protocol_sender_key_store)
        )
    );
    assert_eq!(
        unsafe {
            &(*(::std::ptr::null::<signal_protocol_sender_key_store>()))
                .store_sender_key as *const _ as usize
        },
        0usize,
        concat!(
            "Offset of field: ",
            stringify!(signal_protocol_sender_key_store),
            "::",
            stringify!(store_sender_key)
        )
    );
    assert_eq!(
        unsafe {
            &(*(::std::ptr::null::<signal_protocol_sender_key_store>()))
                .load_sender_key as *const _ as usize
        },
        8usize,
        concat!(
            "Offset of field: ",
            stringify!(signal_protocol_sender_key_store),
            "::",
            stringify!(load_sender_key)
        )
    );
    assert_eq!(
        unsafe {
            &(*(::std::ptr::null::<signal_protocol_sender_key_store>()))
                .destroy_func as *const _ as usize
        },
        16usize,
        concat!(
            "Offset of field: ",
            stringify!(signal_protocol_sender_key_store),
            "::",
            stringify!(destroy_func)
        )
    );
    assert_eq!(
        unsafe {
            &(*(::std::ptr::null::<signal_protocol_sender_key_store>()))
                .user_data as *const _ as usize
        },
        24usize,
        concat!(
            "Offset of field: ",
            stringify!(signal_protocol_sender_key_store),
            "::",
            stringify!(user_data)
        )
    );
}
extern "C" {
    /// Create a new instance of the global library context.
    pub fn signal_context_create(
        context: *mut *mut signal_context,
        user_data: *mut ::std::os::raw::c_void,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    /// Set the crypto provider to be used by the Signal Protocol library.
    ///
    /// @param crypto_provider Populated structure of crypto provider function
    ///     pointers. The contents of this structure are copied, so the caller
    ///     does not need to maintain its instance.
    /// @return 0 on success, negative on failure
    pub fn signal_context_set_crypto_provider(
        context: *mut signal_context,
        crypto_provider: *const signal_crypto_provider,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    /// Set the locking functions to be used by the Signal Protocol library for
    /// synchronization.
    ///
    /// Note: These functions must allow recursive locking (e.g.
    /// PTHREAD_MUTEX_RECURSIVE)
    ///
    /// @param lock function to lock a mutex
    /// @param unlock function to unlock a mutex
    /// @return 0 on success, negative on failure
    pub fn signal_context_set_locking_functions(
        context: *mut signal_context,
        lock: ::std::option::Option<
            unsafe extern "C" fn(user_data: *mut ::std::os::raw::c_void),
        >,
        unlock: ::std::option::Option<
            unsafe extern "C" fn(user_data: *mut ::std::os::raw::c_void),
        >,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    /// Set the log function to be used by the Signal Protocol library for
    /// logging.
    ///
    /// @return 0 on success, negative on failure
    pub fn signal_context_set_log_function(
        context: *mut signal_context,
        log: ::std::option::Option<
            unsafe extern "C" fn(
                level: ::std::os::raw::c_int,
                message: *const ::std::os::raw::c_char,
                len: usize,
                user_data: *mut ::std::os::raw::c_void,
            ),
        >,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn signal_context_destroy(context: *mut signal_context);
}
extern "C" {
    /// Create a new instance of the Signal Protocol data store interface.
    pub fn signal_protocol_store_context_create(
        context: *mut *mut signal_protocol_store_context,
        global_context: *mut signal_context,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn signal_protocol_store_context_set_session_store(
        context: *mut signal_protocol_store_context,
        store: *const signal_protocol_session_store,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn signal_protocol_store_context_set_pre_key_store(
        context: *mut signal_protocol_store_context,
        store: *const signal_protocol_pre_key_store,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn signal_protocol_store_context_set_signed_pre_key_store(
        context: *mut signal_protocol_store_context,
        store: *const signal_protocol_signed_pre_key_store,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn signal_protocol_store_context_set_identity_key_store(
        context: *mut signal_protocol_store_context,
        store: *const signal_protocol_identity_key_store,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn signal_protocol_store_context_set_sender_key_store(
        context: *mut signal_protocol_store_context,
        store: *const signal_protocol_sender_key_store,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn signal_protocol_store_context_destroy(
        context: *mut signal_protocol_store_context,
    );
}
extern "C" {
    pub fn signal_protocol_session_load_session(
        context: *mut signal_protocol_store_context,
        record: *mut *mut session_record,
        address: *const signal_protocol_address,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn signal_protocol_session_get_sub_device_sessions(
        context: *mut signal_protocol_store_context,
        sessions: *mut *mut signal_int_list,
        name: *const ::std::os::raw::c_char,
        name_len: usize,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn signal_protocol_session_store_session(
        context: *mut signal_protocol_store_context,
        address: *const signal_protocol_address,
        record: *mut session_record,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn signal_protocol_session_contains_session(
        context: *mut signal_protocol_store_context,
        address: *const signal_protocol_address,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn signal_protocol_session_delete_session(
        context: *mut signal_protocol_store_context,
        address: *const signal_protocol_address,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn signal_protocol_session_delete_all_sessions(
        context: *mut signal_protocol_store_context,
        name: *const ::std::os::raw::c_char,
        name_len: usize,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn signal_protocol_pre_key_load_key(
        context: *mut signal_protocol_store_context,
        pre_key: *mut *mut session_pre_key,
        pre_key_id: u32,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn signal_protocol_pre_key_store_key(
        context: *mut signal_protocol_store_context,
        pre_key: *mut session_pre_key,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn signal_protocol_pre_key_contains_key(
        context: *mut signal_protocol_store_context,
        pre_key_id: u32,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn signal_protocol_pre_key_remove_key(
        context: *mut signal_protocol_store_context,
        pre_key_id: u32,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn signal_protocol_signed_pre_key_load_key(
        context: *mut signal_protocol_store_context,
        pre_key: *mut *mut session_signed_pre_key,
        signed_pre_key_id: u32,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn signal_protocol_signed_pre_key_store_key(
        context: *mut signal_protocol_store_context,
        pre_key: *mut session_signed_pre_key,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn signal_protocol_signed_pre_key_contains_key(
        context: *mut signal_protocol_store_context,
        signed_pre_key_id: u32,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn signal_protocol_signed_pre_key_remove_key(
        context: *mut signal_protocol_store_context,
        signed_pre_key_id: u32,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn signal_protocol_identity_get_key_pair(
        context: *mut signal_protocol_store_context,
        key_pair: *mut *mut ratchet_identity_key_pair,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn signal_protocol_identity_get_local_registration_id(
        context: *mut signal_protocol_store_context,
        registration_id: *mut u32,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn signal_protocol_identity_save_identity(
        context: *mut signal_protocol_store_context,
        address: *const signal_protocol_address,
        identity_key: *mut ec_public_key,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn signal_protocol_identity_is_trusted_identity(
        context: *mut signal_protocol_store_context,
        address: *const signal_protocol_address,
        identity_key: *mut ec_public_key,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn signal_protocol_sender_key_store_key(
        context: *mut signal_protocol_store_context,
        sender_key_name: *const signal_protocol_sender_key_name,
        record: *mut sender_key_record,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn signal_protocol_sender_key_load_key(
        context: *mut signal_protocol_store_context,
        record: *mut *mut sender_key_record,
        sender_key_name: *const signal_protocol_sender_key_name,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn hkdf_create(
        context: *mut *mut hkdf_context,
        message_version: ::std::os::raw::c_int,
        global_context: *mut signal_context,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn hkdf_derive_secrets(
        context: *mut hkdf_context,
        output: *mut *mut u8,
        input_key_material: *const u8,
        input_key_material_len: usize,
        salt: *const u8,
        salt_len: usize,
        info: *const u8,
        info_len: usize,
        output_len: usize,
    ) -> isize;
}
extern "C" {
    pub fn hkdf_compare(
        context1: *const hkdf_context,
        context2: *const hkdf_context,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn hkdf_destroy(type_: *mut signal_type_base);
}
extern "C" {
    pub fn ciphertext_message_get_type(
        message: *const ciphertext_message,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn ciphertext_message_get_serialized(
        message: *const ciphertext_message,
    ) -> *mut signal_buffer;
}
extern "C" {
    pub fn signal_message_create(
        message: *mut *mut signal_message,
        message_version: u8,
        mac_key: *const u8,
        mac_key_len: usize,
        sender_ratchet_key: *mut ec_public_key,
        counter: u32,
        previous_counter: u32,
        ciphertext: *const u8,
        ciphertext_len: usize,
        sender_identity_key: *mut ec_public_key,
        receiver_identity_key: *mut ec_public_key,
        global_context: *mut signal_context,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn signal_message_deserialize(
        message: *mut *mut signal_message,
        data: *const u8,
        len: usize,
        global_context: *mut signal_context,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn signal_message_copy(
        message: *mut *mut signal_message,
        other_message: *mut signal_message,
        global_context: *mut signal_context,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn signal_message_get_sender_ratchet_key(
        message: *const signal_message,
    ) -> *mut ec_public_key;
}
extern "C" {
    pub fn signal_message_get_message_version(
        message: *const signal_message,
    ) -> u8;
}
extern "C" {
    pub fn signal_message_get_counter(message: *const signal_message) -> u32;
}
extern "C" {
    pub fn signal_message_get_body(
        message: *const signal_message,
    ) -> *mut signal_buffer;
}
extern "C" {
    /// Verify the MAC on the Signal message.
    ///
    /// @return 1 if verified, 0 if invalid, negative on error
    pub fn signal_message_verify_mac(
        message: *mut signal_message,
        sender_identity_key: *mut ec_public_key,
        receiver_identity_key: *mut ec_public_key,
        mac_key: *const u8,
        mac_key_len: usize,
        global_context: *mut signal_context,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn signal_message_is_legacy(
        data: *const u8,
        len: usize,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn signal_message_destroy(type_: *mut signal_type_base);
}
extern "C" {
    pub fn pre_key_signal_message_create(
        pre_key_message: *mut *mut pre_key_signal_message,
        message_version: u8,
        registration_id: u32,
        pre_key_id: *const u32,
        signed_pre_key_id: u32,
        base_key: *mut ec_public_key,
        identity_key: *mut ec_public_key,
        message: *mut signal_message,
        global_context: *mut signal_context,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn pre_key_signal_message_deserialize(
        message: *mut *mut pre_key_signal_message,
        data: *const u8,
        len: usize,
        global_context: *mut signal_context,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn pre_key_signal_message_copy(
        message: *mut *mut pre_key_signal_message,
        other_message: *mut pre_key_signal_message,
        global_context: *mut signal_context,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn pre_key_signal_message_get_message_version(
        message: *const pre_key_signal_message,
    ) -> u8;
}
extern "C" {
    pub fn pre_key_signal_message_get_identity_key(
        message: *const pre_key_signal_message,
    ) -> *mut ec_public_key;
}
extern "C" {
    pub fn pre_key_signal_message_get_registration_id(
        message: *const pre_key_signal_message,
    ) -> u32;
}
extern "C" {
    pub fn pre_key_signal_message_has_pre_key_id(
        message: *const pre_key_signal_message,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn pre_key_signal_message_get_pre_key_id(
        message: *const pre_key_signal_message,
    ) -> u32;
}
extern "C" {
    pub fn pre_key_signal_message_get_signed_pre_key_id(
        message: *const pre_key_signal_message,
    ) -> u32;
}
extern "C" {
    pub fn pre_key_signal_message_get_base_key(
        message: *const pre_key_signal_message,
    ) -> *mut ec_public_key;
}
extern "C" {
    pub fn pre_key_signal_message_get_signal_message(
        message: *const pre_key_signal_message,
    ) -> *mut signal_message;
}
extern "C" {
    pub fn pre_key_signal_message_destroy(type_: *mut signal_type_base);
}
extern "C" {
    pub fn sender_key_message_create(
        message: *mut *mut sender_key_message,
        key_id: u32,
        iteration: u32,
        ciphertext: *const u8,
        ciphertext_len: usize,
        signature_key: *mut ec_private_key,
        global_context: *mut signal_context,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn sender_key_message_deserialize(
        message: *mut *mut sender_key_message,
        data: *const u8,
        len: usize,
        global_context: *mut signal_context,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn sender_key_message_copy(
        message: *mut *mut sender_key_message,
        other_message: *mut sender_key_message,
        global_context: *mut signal_context,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn sender_key_message_get_key_id(
        message: *mut sender_key_message,
    ) -> u32;
}
extern "C" {
    pub fn sender_key_message_get_iteration(
        message: *mut sender_key_message,
    ) -> u32;
}
extern "C" {
    pub fn sender_key_message_get_ciphertext(
        message: *mut sender_key_message,
    ) -> *mut signal_buffer;
}
extern "C" {
    pub fn sender_key_message_verify_signature(
        message: *mut sender_key_message,
        signature_key: *mut ec_public_key,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn sender_key_message_destroy(type_: *mut signal_type_base);
}
extern "C" {
    pub fn sender_key_distribution_message_create(
        message: *mut *mut sender_key_distribution_message,
        id: u32,
        iteration: u32,
        chain_key: *const u8,
        chain_key_len: usize,
        signature_key: *mut ec_public_key,
        global_context: *mut signal_context,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn sender_key_distribution_message_deserialize(
        message: *mut *mut sender_key_distribution_message,
        data: *const u8,
        len: usize,
        global_context: *mut signal_context,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn sender_key_distribution_message_copy(
        message: *mut *mut sender_key_distribution_message,
        other_message: *mut sender_key_distribution_message,
        global_context: *mut signal_context,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn sender_key_distribution_message_get_id(
        message: *mut sender_key_distribution_message,
    ) -> u32;
}
extern "C" {
    pub fn sender_key_distribution_message_get_iteration(
        message: *mut sender_key_distribution_message,
    ) -> u32;
}
extern "C" {
    pub fn sender_key_distribution_message_get_chain_key(
        message: *mut sender_key_distribution_message,
    ) -> *mut signal_buffer;
}
extern "C" {
    pub fn sender_key_distribution_message_get_signature_key(
        message: *mut sender_key_distribution_message,
    ) -> *mut ec_public_key;
}
extern "C" {
    pub fn sender_key_distribution_message_destroy(
        type_: *mut signal_type_base,
    );
}
extern "C" {
    pub fn session_state_create(
        state: *mut *mut session_state,
        global_context: *mut signal_context,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn session_state_serialize(
        buffer: *mut *mut signal_buffer,
        state: *mut session_state,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn session_state_deserialize(
        state: *mut *mut session_state,
        data: *const u8,
        len: usize,
        global_context: *mut signal_context,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn session_state_copy(
        state: *mut *mut session_state,
        other_state: *mut session_state,
        global_context: *mut signal_context,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn session_state_set_session_version(
        state: *mut session_state,
        version: u32,
    );
}
extern "C" {
    pub fn session_state_get_session_version(
        state: *const session_state,
    ) -> u32;
}
extern "C" {
    pub fn session_state_set_local_identity_key(
        state: *mut session_state,
        identity_key: *mut ec_public_key,
    );
}
extern "C" {
    pub fn session_state_get_local_identity_key(
        state: *const session_state,
    ) -> *mut ec_public_key;
}
extern "C" {
    pub fn session_state_set_remote_identity_key(
        state: *mut session_state,
        identity_key: *mut ec_public_key,
    );
}
extern "C" {
    pub fn session_state_get_remote_identity_key(
        state: *const session_state,
    ) -> *mut ec_public_key;
}
extern "C" {
    pub fn session_state_set_root_key(
        state: *mut session_state,
        root_key: *mut ratchet_root_key,
    );
}
extern "C" {
    pub fn session_state_get_root_key(
        state: *const session_state,
    ) -> *mut ratchet_root_key;
}
extern "C" {
    pub fn session_state_set_previous_counter(
        state: *mut session_state,
        counter: u32,
    );
}
extern "C" {
    pub fn session_state_get_previous_counter(
        state: *const session_state,
    ) -> u32;
}
extern "C" {
    pub fn session_state_set_sender_chain(
        state: *mut session_state,
        sender_ratchet_key_pair: *mut ec_key_pair,
        chain_key: *mut ratchet_chain_key,
    );
}
extern "C" {
    pub fn session_state_get_sender_ratchet_key(
        state: *const session_state,
    ) -> *mut ec_public_key;
}
extern "C" {
    pub fn session_state_get_sender_ratchet_key_pair(
        state: *const session_state,
    ) -> *mut ec_key_pair;
}
extern "C" {
    pub fn session_state_get_sender_chain_key(
        state: *const session_state,
    ) -> *mut ratchet_chain_key;
}
extern "C" {
    pub fn session_state_set_sender_chain_key(
        state: *mut session_state,
        chain_key: *mut ratchet_chain_key,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn session_state_has_sender_chain(
        state: *const session_state,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn session_state_has_message_keys(
        state: *mut session_state,
        sender_ephemeral: *mut ec_public_key,
        counter: u32,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn session_state_remove_message_keys(
        state: *mut session_state,
        message_keys_result: *mut ratchet_message_keys,
        sender_ephemeral: *mut ec_public_key,
        counter: u32,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn session_state_set_message_keys(
        state: *mut session_state,
        sender_ephemeral: *mut ec_public_key,
        message_keys: *mut ratchet_message_keys,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn session_state_add_receiver_chain(
        state: *mut session_state,
        sender_ratchet_key: *mut ec_public_key,
        chain_key: *mut ratchet_chain_key,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn session_state_set_receiver_chain_key(
        state: *mut session_state,
        sender_ephemeral: *mut ec_public_key,
        chain_key: *mut ratchet_chain_key,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn session_state_get_receiver_chain_key(
        state: *mut session_state,
        sender_ephemeral: *mut ec_public_key,
    ) -> *mut ratchet_chain_key;
}
extern "C" {
    pub fn session_state_set_pending_key_exchange(
        state: *mut session_state,
        sequence: u32,
        our_base_key: *mut ec_key_pair,
        our_ratchet_key: *mut ec_key_pair,
        our_identity_key: *mut ratchet_identity_key_pair,
    );
}
extern "C" {
    pub fn session_state_get_pending_key_exchange_sequence(
        state: *mut session_state,
    ) -> u32;
}
extern "C" {
    pub fn session_state_get_pending_key_exchange_base_key(
        state: *const session_state,
    ) -> *mut ec_key_pair;
}
extern "C" {
    pub fn session_state_get_pending_key_exchange_ratchet_key(
        state: *const session_state,
    ) -> *mut ec_key_pair;
}
extern "C" {
    pub fn session_state_get_pending_key_exchange_identity_key(
        state: *const session_state,
    ) -> *mut ratchet_identity_key_pair;
}
extern "C" {
    pub fn session_state_has_pending_key_exchange(
        state: *const session_state,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn session_state_set_unacknowledged_pre_key_message(
        state: *mut session_state,
        pre_key_id: *const u32,
        signed_pre_key_id: u32,
        base_key: *mut ec_public_key,
    );
}
extern "C" {
    pub fn session_state_unacknowledged_pre_key_message_has_pre_key_id(
        state: *const session_state,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn session_state_unacknowledged_pre_key_message_get_pre_key_id(
        state: *const session_state,
    ) -> u32;
}
extern "C" {
    pub fn session_state_unacknowledged_pre_key_message_get_signed_pre_key_id(
        state: *const session_state,
    ) -> u32;
}
extern "C" {
    pub fn session_state_unacknowledged_pre_key_message_get_base_key(
        state: *const session_state,
    ) -> *mut ec_public_key;
}
extern "C" {
    pub fn session_state_has_unacknowledged_pre_key_message(
        state: *const session_state,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn session_state_clear_unacknowledged_pre_key_message(
        state: *mut session_state,
    );
}
extern "C" {
    pub fn session_state_set_remote_registration_id(
        state: *mut session_state,
        id: u32,
    );
}
extern "C" {
    pub fn session_state_get_remote_registration_id(
        state: *const session_state,
    ) -> u32;
}
extern "C" {
    pub fn session_state_set_local_registration_id(
        state: *mut session_state,
        id: u32,
    );
}
extern "C" {
    pub fn session_state_get_local_registration_id(
        state: *const session_state,
    ) -> u32;
}
extern "C" {
    pub fn session_state_set_needs_refresh(
        state: *mut session_state,
        value: ::std::os::raw::c_int,
    );
}
extern "C" {
    pub fn session_state_get_needs_refresh(
        state: *const session_state,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn session_state_set_alice_base_key(
        state: *mut session_state,
        key: *mut ec_public_key,
    );
}
extern "C" {
    pub fn session_state_get_alice_base_key(
        state: *const session_state,
    ) -> *mut ec_public_key;
}
extern "C" {
    pub fn session_state_destroy(type_: *mut signal_type_base);
}
extern "C" {
    /// Constructs a session builder.
    ///
    /// The store and global contexts must remain valid for the lifetime of the
    /// session builder.
    ///
    /// When finished, free the returned instance by calling
    /// session_builder_free().
    ///
    /// @param builder set to a freshly allocated session builder instance
    /// @param store the signal_protocol_store_context to store all state
    /// information in
    /// @param remote_address the address of the remote user to build a session
    /// with
    /// @param global_context the global library context
    /// @return 0 on success, or negative on failure
    pub fn session_builder_create(
        builder: *mut *mut session_builder,
        store: *mut signal_protocol_store_context,
        remote_address: *const signal_protocol_address,
        global_context: *mut signal_context,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    /// Build a new session from a session_pre_key_bundle retrieved from a
    /// server.
    ///
    /// @param bundle A pre key bundle for the destination recipient, retrieved
    /// from a server.
    /// @retval SG_SUCCESS Success
    /// @retval SG_ERR_INVALID_KEY when the session_pre_key_bundle is badly
    /// formatted.
    /// @retval SG_ERR_UNTRUSTED_IDENTITY when the sender's identity key is not
    /// trusted.
    pub fn session_builder_process_pre_key_bundle(
        builder: *mut session_builder,
        bundle: *mut session_pre_key_bundle,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn session_builder_free(builder: *mut session_builder);
}
extern "C" {
    /// Construct a session cipher for encrypt/decrypt operations on a session.
    /// In order to use session_cipher, a session must have already been created
    /// and stored using session_builder.
    ///
    /// The store and global contexts must remain valid for the lifetime of the
    /// session cipher.
    ///
    /// When finished, free the returned instance by calling
    /// session_cipher_free().
    ///
    /// @param cipher set to a freshly allocated session cipher instance
    /// @param store the signal_protocol_store_context to store all state
    /// information in
    /// @param remote_address the remote address that messages will be encrypted
    /// to or decrypted from.
    /// @param global_context the global library context
    /// @return 0 on success, or negative on failure
    pub fn session_cipher_create(
        cipher: *mut *mut session_cipher,
        store: *mut signal_protocol_store_context,
        remote_address: *const signal_protocol_address,
        global_context: *mut signal_context,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    /// Set the optional user data pointer for the session cipher.
    ///
    /// This is to give callback functions a way of accessing app specific
    /// context information for this cipher.
    pub fn session_cipher_set_user_data(
        cipher: *mut session_cipher,
        user_data: *mut ::std::os::raw::c_void,
    );
}
extern "C" {
    /// Get the optional user data pointer for the session cipher.
    ///
    /// This is to give callback functions a way of accessing app specific
    /// context information for this cipher.
    pub fn session_cipher_get_user_data(
        cipher: *mut session_cipher,
    ) -> *mut ::std::os::raw::c_void;
}
extern "C" {
    /// Set the callback function that is called during the decrypt process.
    ///
    /// The callback function is called from within
    /// session_cipher_decrypt_pre_key_signal_message() and
    /// session_cipher_decrypt_signal_message() after decryption is complete
    /// but before the updated session state has been committed to the session
    /// store. If the callback function returns a negative value, then the
    /// decrypt function will immediately fail with an error.
    ///
    /// This a callback allows some implementations to store the committed
    /// plaintext
    /// to their local message store first, in case they are concerned with a
    /// crash
    /// or write error happening between the time the session state is updated
    /// but
    /// before they're able to successfully store the plaintext to disk.
    ///
    /// @param callback the callback function to set
    pub fn session_cipher_set_decryption_callback(
        cipher: *mut session_cipher,
        callback: ::std::option::Option<
            unsafe extern "C" fn(
                cipher: *mut session_cipher,
                plaintext: *mut signal_buffer,
                decrypt_context: *mut ::std::os::raw::c_void,
            ) -> ::std::os::raw::c_int,
        >,
    );
}
extern "C" {
    /// Encrypt a message.
    ///
    /// @param padded_message The plaintext message bytes, optionally padded to
    /// a constant multiple.
    /// @param padded_message_len The length of the data pointed to by
    /// padded_message
    /// @param encrypted_message Set to a ciphertext message encrypted to the
    /// recipient+device tuple.
    ///
    /// @return SG_SUCCESS on success, negative on error
    pub fn session_cipher_encrypt(
        cipher: *mut session_cipher,
        padded_message: *const u8,
        padded_message_len: usize,
        encrypted_message: *mut *mut ciphertext_message,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    /// Decrypt a message.
    ///
    /// @param ciphertext The pre_key_signal_message to decrypt.
    /// @param decrypt_context Optional context pointer associated with the
    ///   ciphertext, which is passed to the decryption callback function
    /// @param plaintext Set to a newly allocated buffer containing the
    /// plaintext.
    ///
    /// @retval SG_SUCCESS Success
    /// @retval SG_ERR_INVALID_MESSAGE if the input is not valid ciphertext.
    /// @retval SG_ERR_DUPLICATE_MESSAGE if the input is a message that has
    /// already been received.
    /// @retval SG_ERR_LEGACY_MESSAGE if the input is a message formatted by a
    /// protocol version that
    ///                               is no longer supported.
    /// @retval SG_ERR_INVALID_KEY_ID when there is no local pre_key_record
    ///                               that corresponds to the pre key ID in the
    /// message.
    /// @retval SG_ERR_INVALID_KEY when the message is formatted incorrectly.
    /// @retval SG_ERR_UNTRUSTED_IDENTITY when the identity key of the sender is
    /// untrusted.
    pub fn session_cipher_decrypt_pre_key_signal_message(
        cipher: *mut session_cipher,
        ciphertext: *mut pre_key_signal_message,
        decrypt_context: *mut ::std::os::raw::c_void,
        plaintext: *mut *mut signal_buffer,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    /// Decrypt a message.
    ///
    /// @param ciphertext The signal_message to decrypt.
    /// @param decrypt_context Optional context pointer associated with the
    ///   ciphertext, which is passed to the decryption callback function
    /// @param plaintext Set to a newly allocated buffer containing the
    /// plaintext.
    ///
    /// @retval SG_SUCCESS Success
    /// @retval SG_ERR_INVALID_MESSAGE if the input is not valid ciphertext.
    /// @retval SG_ERR_DUPLICATE_MESSAGE if the input is a message that has
    /// already been received.
    /// @retval SG_ERR_LEGACY_MESSAGE if the input is a message formatted by a
    /// protocol version that
    ///                               is no longer supported.
    /// @retval SG_ERR_NO_SESSION if there is no established session for this
    /// contact.
    pub fn session_cipher_decrypt_signal_message(
        cipher: *mut session_cipher,
        ciphertext: *mut signal_message,
        decrypt_context: *mut ::std::os::raw::c_void,
        plaintext: *mut *mut signal_buffer,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    /// Gets the remote registration ID for this session cipher.
    ///
    /// @param remote_id Set to the value of the remote registration ID
    ///
    /// @return SG_SUCCESS on success, negative on error
    pub fn session_cipher_get_remote_registration_id(
        cipher: *mut session_cipher,
        remote_id: *mut u32,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    /// Gets the version of the session associated with this session cipher.
    ///
    /// @param version Set to the value of the session version
    ///
    /// @retval SG_SUCCESS Success
    /// @retval SG_ERR_NO_SESSION if no session could be found
    pub fn session_cipher_get_session_version(
        cipher: *mut session_cipher,
        version: *mut u32,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn session_cipher_free(cipher: *mut session_cipher);
}
extern "C" {
    /// Generate an identity key pair.  Clients should only do this once,
    /// at install time.
    ///
    /// @param key_pair the generated identity key pair
    /// @return 0 on success, or negative on failure
    pub fn signal_protocol_key_helper_generate_identity_key_pair(
        key_pair: *mut *mut ratchet_identity_key_pair,
        global_context: *mut signal_context,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    /// Generate a registration ID.  Clients should only do this once,
    /// at install time.
    ///
    /// @param registration_id set to the generated registration ID
    /// @param extended_range By default (0), the generated registration
    ///                      ID is sized to require the minimal possible
    /// protobuf
    ///                      encoding overhead. Specify true (1) if the caller
    /// needs
    ///                      the full range of MAX_INT at the cost of slightly
    ///                      higher encoding overhead.
    /// @return 0 on success, or negative on failure
    pub fn signal_protocol_key_helper_generate_registration_id(
        registration_id: *mut u32,
        extended_range: ::std::os::raw::c_int,
        global_context: *mut signal_context,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    /// Generate a random number between 0 (inclusive) and the provided maximum
    /// (exclusive).
    ///
    /// @param value set to the next random number
    /// @param max the maximum bound on the value of the random number
    /// @return 0 on success, or negative on failure
    pub fn signal_protocol_key_helper_get_random_sequence(
        value: *mut ::std::os::raw::c_int,
        max: ::std::os::raw::c_int,
        global_context: *mut signal_context,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    /// Generate a list of PreKeys.  Clients should do this at install time, and
    /// subsequently any time the list of PreKeys stored on the server runs low.
    ///
    /// Pre key IDs are shorts, so they will eventually be repeated.  Clients
    /// should
    /// store pre keys in a circular buffer, so that they are repeated as
    /// infrequently
    /// as possible.
    ///
    /// When finished with this list, the caller should free it by calling
    /// signal_protocol_key_helper_key_list_free().
    ///
    /// @param head pointer to the head of the key list
    /// @param start the starting pre key ID, inclusive.
    /// @param count the number of pre keys to generate.
    /// @return 0 on success, or negative on failure
    pub fn signal_protocol_key_helper_generate_pre_keys(
        head: *mut *mut signal_protocol_key_helper_pre_key_list_node,
        start: ::std::os::raw::c_uint,
        count: ::std::os::raw::c_uint,
        global_context: *mut signal_context,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    /// Get the pre key element for the current node in the key list.
    ///
    /// @param node current list node
    /// @return pre key element
    pub fn signal_protocol_key_helper_key_list_element(
        node: *const signal_protocol_key_helper_pre_key_list_node,
    ) -> *mut session_pre_key;
}
extern "C" {
    /// Get the next element in the key list.
    ///
    /// @param node current list node
    /// @return next list node, or 0 if at the end of the list
    pub fn signal_protocol_key_helper_key_list_next(
        node: *const signal_protocol_key_helper_pre_key_list_node,
    ) -> *mut signal_protocol_key_helper_pre_key_list_node;
}
extern "C" {
    /// Free the key list.
    ///
    /// @param head pointer to the head of the list to free
    pub fn signal_protocol_key_helper_key_list_free(
        head: *mut signal_protocol_key_helper_pre_key_list_node,
    );
}
extern "C" {
    /// Generate a signed pre key
    ///
    /// @param signed_pre_key set to the generated pre key
    /// @param identity_key_pair the local client's identity key pair.
    /// @param signed_pre_key_id the pre key ID to assign the generated signed
    /// pre key
    /// @param timestamp the current time in milliseconds since the UNIX epoch
    ///
    /// @return 0 on success, or negative on failure
    pub fn signal_protocol_key_helper_generate_signed_pre_key(
        signed_pre_key: *mut *mut session_signed_pre_key,
        identity_key_pair: *const ratchet_identity_key_pair,
        signed_pre_key_id: u32,
        timestamp: u64,
        global_context: *mut signal_context,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn signal_protocol_key_helper_generate_sender_signing_key(
        key_pair: *mut *mut ec_key_pair,
        global_context: *mut signal_context,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn signal_protocol_key_helper_generate_sender_key(
        key_buffer: *mut *mut signal_buffer,
        global_context: *mut signal_context,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn signal_protocol_key_helper_generate_sender_key_id(
        key_id: *mut u32,
        global_context: *mut signal_context,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn sender_message_key_create(
        key: *mut *mut sender_message_key,
        iteration: u32,
        seed: *mut signal_buffer,
        global_context: *mut signal_context,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn sender_message_key_get_iteration(
        key: *mut sender_message_key,
    ) -> u32;
}
extern "C" {
    pub fn sender_message_key_get_iv(
        key: *mut sender_message_key,
    ) -> *mut signal_buffer;
}
extern "C" {
    pub fn sender_message_key_get_cipher_key(
        key: *mut sender_message_key,
    ) -> *mut signal_buffer;
}
extern "C" {
    pub fn sender_message_key_get_seed(
        key: *mut sender_message_key,
    ) -> *mut signal_buffer;
}
extern "C" {
    pub fn sender_message_key_destroy(type_: *mut signal_type_base);
}
extern "C" {
    pub fn sender_chain_key_create(
        key: *mut *mut sender_chain_key,
        iteration: u32,
        chain_key: *mut signal_buffer,
        global_context: *mut signal_context,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn sender_chain_key_get_iteration(key: *mut sender_chain_key) -> u32;
}
extern "C" {
    pub fn sender_chain_key_create_message_key(
        key: *mut sender_chain_key,
        message_key: *mut *mut sender_message_key,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn sender_chain_key_create_next(
        key: *mut sender_chain_key,
        next_key: *mut *mut sender_chain_key,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn sender_chain_key_get_seed(
        key: *mut sender_chain_key,
    ) -> *mut signal_buffer;
}
extern "C" {
    pub fn sender_chain_key_destroy(type_: *mut signal_type_base);
}
extern "C" {
    pub fn sender_key_state_create(
        state: *mut *mut sender_key_state,
        id: u32,
        chain_key: *mut sender_chain_key,
        signature_public_key: *mut ec_public_key,
        signature_private_key: *mut ec_private_key,
        global_context: *mut signal_context,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn sender_key_state_serialize(
        buffer: *mut *mut signal_buffer,
        state: *mut sender_key_state,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn sender_key_state_deserialize(
        state: *mut *mut sender_key_state,
        data: *const u8,
        len: usize,
        global_context: *mut signal_context,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn sender_key_state_copy(
        state: *mut *mut sender_key_state,
        other_state: *mut sender_key_state,
        global_context: *mut signal_context,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn sender_key_state_get_key_id(state: *mut sender_key_state) -> u32;
}
extern "C" {
    pub fn sender_key_state_get_chain_key(
        state: *mut sender_key_state,
    ) -> *mut sender_chain_key;
}
extern "C" {
    pub fn sender_key_state_set_chain_key(
        state: *mut sender_key_state,
        chain_key: *mut sender_chain_key,
    );
}
extern "C" {
    pub fn sender_key_state_get_signing_key_public(
        state: *mut sender_key_state,
    ) -> *mut ec_public_key;
}
extern "C" {
    pub fn sender_key_state_get_signing_key_private(
        state: *mut sender_key_state,
    ) -> *mut ec_private_key;
}
extern "C" {
    pub fn sender_key_state_has_sender_message_key(
        state: *mut sender_key_state,
        iteration: u32,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn sender_key_state_add_sender_message_key(
        state: *mut sender_key_state,
        message_key: *mut sender_message_key,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn sender_key_state_remove_sender_message_key(
        state: *mut sender_key_state,
        iteration: u32,
    ) -> *mut sender_message_key;
}
extern "C" {
    pub fn sender_key_state_destroy(type_: *mut signal_type_base);
}
extern "C" {
    /// Constructs a group session builder.
    ///
    /// The store and global contexts must remain valid for the lifetime of the
    /// session builder.
    ///
    /// When finished, free the returned instance by calling
    /// group_session_builder_free().
    ///
    /// @param builder set to a freshly allocated group session builder instance
    /// @param store the signal_protocol_store_context to store all state
    /// information in
    /// @param global_context the global library context
    /// @return 0 on success, or negative on failure
    pub fn group_session_builder_create(
        builder: *mut *mut group_session_builder,
        store: *mut signal_protocol_store_context,
        global_context: *mut signal_context,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    /// Construct a group session for receiving messages from senderKeyName.
    ///
    /// @param sender_key_name the (groupId, senderId, deviceId) tuple
    /// associated
    ///     with the sender_key_distribution_message
    /// @param distribution_message a received sender_key_distribution_message
    /// @return 0 on success, or negative on failure
    pub fn group_session_builder_process_session(
        builder: *mut group_session_builder,
        sender_key_name: *const signal_protocol_sender_key_name,
        distribution_message: *mut sender_key_distribution_message,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    /// Construct a group session for sending messages.
    ///
    /// @param distribution_message a distribution message to be allocated and
    /// populated
    /// @param sender_key_name the (groupId, senderId, deviceId) tuple. In this
    ///     case, the sender should be the caller
    /// @return 0 on success, or negative on failure
    pub fn group_session_builder_create_session(
        builder: *mut group_session_builder,
        distribution_message: *mut *mut sender_key_distribution_message,
        sender_key_name: *const signal_protocol_sender_key_name,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn group_session_builder_free(builder: *mut group_session_builder);
}
extern "C" {
    /// Construct a group cipher for encrypt/decrypt operations.
    ///
    /// The store and global contexts must remain valid for the lifetime of the
    /// group cipher.
    ///
    /// When finished, free the returned instance by calling
    /// group_cipher_free().
    ///
    /// @param cipher set to a freshly allocated group cipher instance
    /// @param store the signal_protocol_store_context to store all state
    /// information in
    /// @param sender_key_id the sender that messages will be encrypted to or
    /// decrypted from
    /// @param global_context the global library context
    /// @return 0 on success, or negative on failure
    pub fn group_cipher_create(
        cipher: *mut *mut group_cipher,
        store: *mut signal_protocol_store_context,
        sender_key_id: *const signal_protocol_sender_key_name,
        global_context: *mut signal_context,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    /// Set the optional user data pointer for the group cipher.
    ///
    /// This is to give callback functions a way of accessing app specific
    /// context information for this cipher.
    pub fn group_cipher_set_user_data(
        cipher: *mut group_cipher,
        user_data: *mut ::std::os::raw::c_void,
    );
}
extern "C" {
    /// Get the optional user data pointer for the group cipher.
    ///
    /// This is to give callback functions a way of accessing app specific
    /// context information for this cipher.
    pub fn group_cipher_get_user_data(
        cipher: *mut group_cipher,
    ) -> *mut ::std::os::raw::c_void;
}
extern "C" {
    /// Set the callback function that is called during the decrypt process.
    ///
    /// The callback function is called from within group_cipher_decrypt() after
    /// decryption is complete but before the updated session state has been
    /// committed to the session store. If the callback function returns a
    /// negative value, then the decrypt function will immediately fail with
    /// an error.
    ///
    /// This a callback allows some implementations to store the committed
    /// plaintext
    /// to their local message store first, in case they are concerned with a
    /// crash
    /// or write error happening between the time the session state is updated
    /// but
    /// before they're able to successfully store the plaintext to disk.
    ///
    /// @param callback the callback function to set
    pub fn group_cipher_set_decryption_callback(
        cipher: *mut group_cipher,
        callback: ::std::option::Option<
            unsafe extern "C" fn(
                cipher: *mut group_cipher,
                plaintext: *mut signal_buffer,
                decrypt_context: *mut ::std::os::raw::c_void,
            ) -> ::std::os::raw::c_int,
        >,
    );
}
extern "C" {
    /// Encrypt a message.
    ///
    /// @param padded_plaintext The plaintext message bytes, optionally padded
    /// to a constant multiple.
    /// @param padded_plaintext_len The length of the data pointed to by
    /// padded_message
    /// @param encrypted_message Set to a ciphertext message encrypted to the
    /// group+sender+device tuple.
    ///
    /// @retval SG_SUCCESS Success
    /// @retval SG_ERR_NO_SESSION if there is no established session for this
    /// contact.
    /// @retval SG_ERR_INVALID_KEY if there is no valid private key for this
    /// session.
    pub fn group_cipher_encrypt(
        cipher: *mut group_cipher,
        padded_plaintext: *const u8,
        padded_plaintext_len: usize,
        encrypted_message: *mut *mut ciphertext_message,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    /// Decrypt a message.
    ///
    /// @param ciphertext The sender_key_message to decrypt.
    /// @param decrypt_context Optional context pointer associated with the
    ///   ciphertext, which is passed to the decryption callback function
    /// @param plaintext Set to a newly allocated buffer containing the
    /// plaintext.
    ///
    /// @retval SG_SUCCESS Success
    /// @retval SG_ERR_INVALID_MESSAGE if the input is not valid ciphertext.
    /// @retval SG_ERR_DUPLICATE_MESSAGE if the input is a message that has
    /// already been received.
    /// @retval SG_ERR_LEGACY_MESSAGE if the input is a message formatted by a
    /// protocol version that
    ///                               is no longer supported.
    /// @retval SG_ERR_NO_SESSION if there is no established session for this
    /// contact.
    pub fn group_cipher_decrypt(
        cipher: *mut group_cipher,
        ciphertext: *mut sender_key_message,
        decrypt_context: *mut ::std::os::raw::c_void,
        plaintext: *mut *mut signal_buffer,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn group_cipher_free(cipher: *mut group_cipher);
}
extern "C" {
    pub fn device_consistency_signature_create(
        signature: *mut *mut device_consistency_signature,
        signature_data: *const u8,
        signature_len: usize,
        vrf_output_data: *const u8,
        vrf_output_len: usize,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn device_consistency_signature_get_signature(
        signature: *const device_consistency_signature,
    ) -> *mut signal_buffer;
}
extern "C" {
    pub fn device_consistency_signature_get_vrf_output(
        signature: *const device_consistency_signature,
    ) -> *mut signal_buffer;
}
extern "C" {
    pub fn device_consistency_signature_destroy(type_: *mut signal_type_base);
}
extern "C" {
    pub fn device_consistency_commitment_create(
        commitment: *mut *mut device_consistency_commitment,
        generation: u32,
        identity_key_list: *mut ec_public_key_list,
        global_context: *mut signal_context,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn device_consistency_commitment_get_generation(
        commitment: *const device_consistency_commitment,
    ) -> u32;
}
extern "C" {
    pub fn device_consistency_commitment_get_serialized(
        commitment: *const device_consistency_commitment,
    ) -> *mut signal_buffer;
}
extern "C" {
    pub fn device_consistency_commitment_destroy(type_: *mut signal_type_base);
}
extern "C" {
    pub fn device_consistency_message_create_from_pair(
        message: *mut *mut device_consistency_message,
        commitment: *mut device_consistency_commitment,
        identity_key_pair: *mut ec_key_pair,
        global_context: *mut signal_context,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn device_consistency_message_create_from_serialized(
        message: *mut *mut device_consistency_message,
        commitment: *mut device_consistency_commitment,
        serialized_data: *const u8,
        serialized_len: usize,
        identity_key: *mut ec_public_key,
        global_context: *mut signal_context,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn device_consistency_message_get_serialized(
        message: *const device_consistency_message,
    ) -> *mut signal_buffer;
}
extern "C" {
    pub fn device_consistency_message_get_signature(
        message: *const device_consistency_message,
    ) -> *mut device_consistency_signature;
}
extern "C" {
    pub fn device_consistency_signature_get_generation(
        message: *const device_consistency_message,
    ) -> u32;
}
extern "C" {
    pub fn device_consistency_message_destroy(type_: *mut signal_type_base);
}
extern "C" {
    pub fn device_consistency_code_generate_for(
        commitment: *mut device_consistency_commitment,
        signatures: *mut device_consistency_signature_list,
        code_string: *mut *mut ::std::os::raw::c_char,
        global_context: *mut signal_context,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn device_consistency_signature_list_alloc(
    ) -> *mut device_consistency_signature_list;
}
extern "C" {
    pub fn device_consistency_signature_list_copy(
        list: *const device_consistency_signature_list,
    ) -> *mut device_consistency_signature_list;
}
extern "C" {
    pub fn device_consistency_signature_list_push_back(
        list: *mut device_consistency_signature_list,
        value: *mut device_consistency_signature,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn device_consistency_signature_list_size(
        list: *const device_consistency_signature_list,
    ) -> ::std::os::raw::c_uint;
}
extern "C" {
    pub fn device_consistency_signature_list_at(
        list: *const device_consistency_signature_list,
        index: ::std::os::raw::c_uint,
    ) -> *mut device_consistency_signature;
}
extern "C" {
    pub fn device_consistency_signature_list_free(
        list: *mut device_consistency_signature_list,
    );
}
extern "C" {
    /// Generate a scannable and displayble fingerprint.
    ///
    /// @param local_stable_identifier The client's "stable" identifier.
    /// @param local_identity_key The client's identity key.
    /// @param remote_stable_identifier The remote party's "stable" identifier.
    /// @param remote_identity_key The remote party's identity key.
    /// @param fingerprint_val Set to a freshly allocated unique fingerprint for
    /// this conversation
    /// @return 0 on success, or negative on failure
    pub fn fingerprint_generator_create_for(
        generator: *mut fingerprint_generator,
        local_stable_identifier: *const ::std::os::raw::c_char,
        local_identity_key: *const ec_public_key,
        remote_stable_identifier: *const ::std::os::raw::c_char,
        remote_identity_key: *const ec_public_key,
        fingerprint_val: *mut *mut fingerprint,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    /// Generate a scannable and displayble fingerprint for a list of keys
    ///
    /// @param local_stable_identifier The client's "stable" identifier.
    /// @param local_identity_key_list The client's identity key list.
    /// @param remote_stable_identifier The remote party's "stable" identifier.
    /// @param remote_identity_key_list The remote party's identity key list.
    /// @param fingerprint_val Set to a freshly allocated unique fingerprint for
    /// this conversation
    /// @return 0 on success, or negative on failure
    pub fn fingerprint_generator_create_for_list(
        generator: *mut fingerprint_generator,
        local_stable_identifier: *const ::std::os::raw::c_char,
        local_identity_key_list: *const ec_public_key_list,
        remote_stable_identifier: *const ::std::os::raw::c_char,
        remote_identity_key_list: *const ec_public_key_list,
        fingerprint_val: *mut *mut fingerprint,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn fingerprint_generator_free(generator: *mut fingerprint_generator);
}
extern "C" {
    pub fn fingerprint_create(
        fingerprint_val: *mut *mut fingerprint,
        displayable: *mut displayable_fingerprint,
        scannable: *mut scannable_fingerprint,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn fingerprint_get_displayable(
        fingerprint_val: *const fingerprint,
    ) -> *mut displayable_fingerprint;
}
extern "C" {
    pub fn fingerprint_get_scannable(
        fingerprint_val: *const fingerprint,
    ) -> *mut scannable_fingerprint;
}
extern "C" {
    pub fn fingerprint_destroy(type_: *mut signal_type_base);
}
extern "C" {
    pub fn displayable_fingerprint_create(
        displayable: *mut *mut displayable_fingerprint,
        local_fingerprint: *const ::std::os::raw::c_char,
        remote_fingerprint: *const ::std::os::raw::c_char,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn displayable_fingerprint_local(
        displayable: *const displayable_fingerprint,
    ) -> *const ::std::os::raw::c_char;
}
extern "C" {
    pub fn displayable_fingerprint_remote(
        displayable: *const displayable_fingerprint,
    ) -> *const ::std::os::raw::c_char;
}
extern "C" {
    pub fn displayable_fingerprint_text(
        displayable: *const displayable_fingerprint,
    ) -> *const ::std::os::raw::c_char;
}
extern "C" {
    pub fn displayable_fingerprint_destroy(type_: *mut signal_type_base);
}
extern "C" {
    pub fn scannable_fingerprint_create(
        scannable: *mut *mut scannable_fingerprint,
        version: u32,
        local_stable_identifier: *const ::std::os::raw::c_char,
        local_fingerprint: *const signal_buffer,
        remote_stable_identifier: *const ::std::os::raw::c_char,
        remote_fingerprint: *const signal_buffer,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn scannable_fingerprint_serialize(
        buffer: *mut *mut signal_buffer,
        scannable: *const scannable_fingerprint,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn scannable_fingerprint_deserialize(
        scannable: *mut *mut scannable_fingerprint,
        data: *const u8,
        len: usize,
        global_context: *mut signal_context,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn scannable_fingerprint_get_version(
        scannable: *const scannable_fingerprint,
    ) -> u32;
}
extern "C" {
    pub fn scannable_fingerprint_get_local_stable_identifier(
        scannable: *const scannable_fingerprint,
    ) -> *const ::std::os::raw::c_char;
}
extern "C" {
    pub fn scannable_fingerprint_get_local_fingerprint(
        scannable: *const scannable_fingerprint,
    ) -> *mut signal_buffer;
}
extern "C" {
    pub fn scannable_fingerprint_get_remote_stable_identifier(
        scannable: *const scannable_fingerprint,
    ) -> *const ::std::os::raw::c_char;
}
extern "C" {
    pub fn scannable_fingerprint_get_remote_fingerprint(
        scannable: *const scannable_fingerprint,
    ) -> *mut signal_buffer;
}
extern "C" {
    /// Compare a scanned QR code with what we expect.
    /// @param scannable The local scannable data
    /// @param other_scannable The data from the scanned code
    /// @retval 1 if the scannable codes match
    /// @retval 0 if the scannable codes do not match
    /// @retval SG_ERR_FP_VERSION_MISMATCH if the scanned fingerprint is the
    /// wrong version
    /// @retval SG_ERR_FP_IDENT_MISMATCH if the scanned fingerprint is for the
    /// wrong stable identifier
    pub fn scannable_fingerprint_compare(
        scannable: *const scannable_fingerprint,
        other_scannable: *const scannable_fingerprint,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn scannable_fingerprint_destroy(type_: *mut signal_type_base);
}