aboutsummaryrefslogtreecommitdiffstats
path: root/lib/crypto/doc/src/crypto.xml
blob: d607679ff582554b12ac529040ad703c0e8c2942 (plain) (blame)
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
<!DOCTYPE erlref SYSTEM "erlref.dtd">

<erlref>
  <header>
    <copyright>
      <year>1999</year><year>2018</year>
      <holder>Ericsson AB. All Rights Reserved.</holder>
    </copyright>
    <legalnotice>
      Licensed under the Apache License, Version 2.0 (the "License");
      you may not use this file except in compliance with the License.
      You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

      Unless required by applicable law or agreed to in writing, software
      distributed under the License is distributed on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      See the License for the specific language governing permissions and
      limitations under the License.
    </legalnotice>

    <title>crypto</title>
  </header>
  <module since="">crypto</module>
  <modulesummary>Crypto Functions</modulesummary>
  <description>
    <p>This module provides a set of cryptographic functions.
      </p>
      <taglist>
	<tag>Hash functions</tag>
	<item>
	  <p></p>
	  <taglist>
	    <tag>SHA1, SHA2</tag>
	    <item>
	      <url href="https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf">
		Secure Hash Standard [FIPS PUB 180-4]
	      </url>
	    </item>
	    <tag>SHA3</tag>
	      <item>
		<url href="https://www.nist.gov/publications/sha-3-standard-permutation-based-hash-and-extendable-output-functions?pub_id=919061">
		  SHA-3 Standard: Permutation-Based Hash and Extendable-Output Functions [FIPS PUB 202]
		</url>		
	      </item>
            <tag>BLAKE2</tag>
              <item>
                <url href="https://blake2.net/">BLAKE2 — fast secure hashing</url>
              </item>
	    <tag>MD5</tag>
	    <item>
	      <url href="http://www.ietf.org/rfc/rfc1321.txt">The MD5 Message Digest Algorithm [RFC 1321]</url>
	    </item>
	    <tag>MD4</tag>
	    <item>
	      <url href="http://www.ietf.org/rfc/rfc1320.txt">The MD4 Message Digest Algorithm [RFC 1320]</url>
	    </item>
	  </taglist>
	  <p></p>
	</item>

	<tag>MACs - Message Authentication Codes</tag>
	<item>
	  <p></p>
	  <taglist>
	    <tag>Hmac functions</tag>
	    <item>
              <url href="http://www.ietf.org/rfc/rfc2104.txt">
		Keyed-Hashing for Message Authentication [RFC 2104]
	      </url>
	    </item>
	    <tag>Cmac functions</tag>
	    <item>
              <url href="http://www.ietf.org/rfc/rfc4493.txt">
		The AES-CMAC Algorithm [RFC 4493]
	      </url>
	    </item>
	    <tag>POLY1305</tag>
	    <item>
	      <url href="http://www.ietf.org/rfc/rfc7539.txt">
		ChaCha20 and Poly1305 for IETF Protocols [RFC 7539]
	      </url>
	    </item>
	  </taglist>
	  <p></p>
	</item>

	<tag>Symmetric Ciphers</tag>
	<item>
	  <p></p>
	  <taglist>
            <tag>DES, 3DES and AES</tag>
	    <item>
	      <url href="https://csrc.nist.gov/projects/block-cipher-techniques">Block Cipher Techniques [NIST]</url>
	    </item>
	    <tag>Blowfish</tag>
	    <item>
	      <url href="https://www.schneier.com/academic/archives/1994/09/description_of_a_new.html">
		Fast Software Encryption, Cambridge Security Workshop Proceedings (December 1993), Springer-Verlag, 1994, pp. 191-204.
	      </url>
	    </item>
	    <tag>Chacha20</tag>
	    <item>
	      <url href="http://www.ietf.org/rfc/rfc7539.txt">
		ChaCha20 and Poly1305 for IETF Protocols [RFC 7539]
	      </url>
	    </item>
	    <tag>Chacha20_poly1305</tag>
	    <item>
	      <url href="http://www.ietf.org/rfc/rfc7539.txt">
		ChaCha20 and Poly1305 for IETF Protocols [RFC 7539]
	      </url>
	    </item>
	  </taglist>
	  <p></p>
	</item>

	<tag>Modes</tag>
	<item>
	  <p></p>
	  <taglist>
	    <tag>ECB, CBC, CFB, OFB and CTR</tag>
	    <item>
	      <url href="https://csrc.nist.gov/publications/detail/sp/800-38a/final">
		Recommendation for Block Cipher Modes of Operation: Methods and Techniques [NIST SP 800-38A]
	      </url>
	    </item>
	    <tag>GCM</tag>
	    <item>
              <url href="https://csrc.nist.gov/publications/detail/sp/800-38d/final">
		Recommendation for Block Cipher Modes of Operation: Galois/Counter Mode (GCM) and GMAC [NIST SP 800-38D]
	      </url>
	    </item>
	    <tag>CCM</tag>
	    <item>
	      <url href="https://nvlpubs.nist.gov/nistpubs/legacy/sp/nistspecialpublication800-38c.pdf">
		Recommendation for Block Cipher Modes of Operation:
		The CCM Mode for Authentication and Confidentiality [NIST SP 800-38C]
	      </url>
	    </item>
	  </taglist>
	  <p></p>
	</item>

	<tag>Asymetric Ciphers - Public Key Techniques</tag>
	<item>
	  <p></p>
	  <taglist>
	    <tag>RSA</tag>
	    <item>
              <url href="http://www.ietf.org/rfc/rfc3447.txt">
		PKCS #1: RSA Cryptography Specifications [RFC 3447]
	      </url>
	    </item>
	    <tag>DSS</tag>
	    <item>
	      <url href="https://csrc.nist.gov/publications/detail/fips/186/4/final">
		Digital Signature Standard (DSS) [FIPS 186-4]
	      </url>
	    </item>
	    <tag>ECDSA</tag>
	    <item>
	      <url href="http://csrc.nist.gov/groups/STM/cavp/documents/dss2/ecdsa2vs.pdf">
		Elliptic Curve Digital Signature Algorithm [ECDSA]
	      </url>
	    </item>
	    <tag>SRP</tag>
	    <item>
              <url href="http://www.ietf.org/rfc/rfc2945.txt">
		The SRP Authentication and Key Exchange System [RFC 2945]
	      </url>
	    </item>
	  </taglist>
	  <p></p>
	</item>
      </taglist>

    <note>
      <p>The actual supported algorithms and features depends on their availability in the actual libcrypto used.
      See the <seealso marker="crypto:crypto_app">crypto (App)</seealso> about dependencies.
      </p>
      <p>Enabling FIPS mode will also disable algorithms and features.
      </p>
    </note>

    <p>The <seealso marker="users_guide">CRYPTO User's Guide</seealso> has more information on
    FIPS, Engines and Algorithm Details like key lengths.
    </p>
  </description>

  <datatypes>
    <datatype_title>Ciphers, new API</datatype_title>
    <datatype>
      <name name="cipher"/>
      <desc>
      </desc>
    </datatype>
    <datatype>
      <name name="cipher_no_iv"/>
      <desc>
      </desc>
    </datatype>
    <datatype>
      <name name="cipher_iv"/>
      <desc>
      </desc>
    </datatype>
    <datatype>
      <name name="cipher_aead"/>
      <desc>
	<p>Ciphers known by the CRYPTO application when using the
	<seealso marker="crypto:new_api#the-new-api">new API</seealso>.</p>
	<p>Note that this list might be reduced if the underlying libcrypto does not support all of them.</p>
      </desc>
    </datatype>

    <datatype_title>Ciphers, old API</datatype_title>
    <datatype>
      <name name="block_cipher_with_iv"/>
      <desc>
      </desc>
    </datatype>
    <datatype>
      <name name="block_cipher_without_iv"/>
      <desc>
      </desc>
    </datatype>
    <datatype>
      <name name="stream_cipher"/>
      <desc>
      </desc>
    </datatype>
    <datatype>
      <name name="aead_cipher"/>
      <desc>
      </desc>
    </datatype>
    <datatype>
      <name name="cbc_cipher"/>
      <desc>
      </desc>
    </datatype>
    <datatype>
      <name name="cfb_cipher"/>
      <desc>
      </desc>
    </datatype>
    <datatype>
      <name name="ctr_cipher"/>
      <desc>
      </desc>
    </datatype>
    <datatype>
      <name name="ecb_cipher"/>
      <desc>
	<p>Ciphers known by the CRYPTO application when using the
	<seealso marker="crypto:new_api#the-old-api">old API</seealso>.</p>
	<p>Note that this list might be reduced if the underlying libcrypto does not support all of them.</p>
      </desc>
    </datatype>

    <datatype>
      <name name="retired_cbc_cipher_aliases"/>
      <desc>
      </desc>
    </datatype>
    <datatype>
      <name name="retired_cfb_cipher_aliases"/>
      <desc>
      </desc>
    </datatype>
    <datatype>
      <name name="retired_ctr_cipher_aliases"/>
      <desc>
      </desc>
    </datatype>
    <datatype>
      <name name="retired_ecb_cipher_aliases"/>
      <desc>
	<p>Alternative, old names of ciphers known by the CRYPTO application when using the
	<seealso marker="crypto:new_api#the-old-api">old API</seealso>.
	See <seealso marker="crypto:new_api#retired-cipher-names">Retired cipher names</seealso> for names to
	use instead to be prepared for an easy convertion to the
	<seealso marker="crypto:new_api#the-new-api">new API</seealso>.
	</p>
	<p>Note that this list might be reduced if the underlying libcrypto does not support all of them.</p>
      </desc>
    </datatype>

    <datatype_title>Digests and hash</datatype_title>
    <datatype>
      <name name="hash_algorithm"/>
      <desc>
      </desc>
    </datatype>

    <datatype>
      <name name="hmac_hash_algorithm"/>
      <desc>
      </desc>
    </datatype>

    <datatype>
      <name name="rsa_digest_type"/>
      <desc>
      </desc>
    </datatype>

    <datatype>
      <name name="dss_digest_type"/>
      <desc>
      </desc>
    </datatype>

    <datatype>
      <name name="ecdsa_digest_type"/>
      <desc>
      </desc>
    </datatype>

    <datatype>
      <name name="sha1"/>
      <name name="sha2"/>
      <name name="sha3"/>
      <name name="blake2"/>
      <name name="compatibility_only_hash"/>
      <desc>
	<p>The <c>compatibility_only_hash()</c> algorithms are recommended only for compatibility with existing applications.</p>
      </desc>
    </datatype>

    <datatype_title>Elliptic Curves</datatype_title>
    <datatype>
      <name name="ec_named_curve"/>
      <name name="edwards_curve_dh"/>
      <name name="edwards_curve_ed"/>
      <desc>
	<p>Note that some curves are disabled if FIPS is enabled.</p>
      </desc>
    </datatype>

    <datatype>
      <name name="ec_explicit_curve"/>
      <name name="ec_field"/>
      <name name="ec_curve"/>
      <desc>
	<p>Parametric curve definition.</p>
      </desc>
    </datatype>

    <datatype>
      <name name="ec_prime_field"/>
      <name name="ec_characteristic_two_field"/>
      <name name="ec_basis"/>
      <desc>
	<p>Curve definition details.</p>
      </desc>
    </datatype>

    <datatype_title>Keys</datatype_title>
    <datatype>
      <name name="key"/>
      <name name="des3_key"/>
      <desc>
	<p>For keylengths, iv-sizes and blocksizes see the
	<seealso marker="crypto:algorithm_details#ciphers">User's Guide</seealso>.
	</p>
	<p>A key for des3 is a list of three iolists</p>
      </desc>
    </datatype>

    <datatype>
      <name name="key_integer"/>
      <desc>
	<p>Always <c>binary()</c> when used as return value</p>
      </desc>
    </datatype>

    <datatype_title>Public/Private Keys</datatype_title>
    <datatype>
      <name name="rsa_public"/>
      <name name="rsa_private"/>
      <name name="rsa_params"/>
      <desc>
	<code>rsa_public() = [E, N]</code>
	<code>rsa_private() = [E, N, D] | [E, N, D, P1, P2, E1, E2, C]</code>
	<p>Where E is the public exponent, N is public modulus and D is
	the private exponent. The longer key format contains redundant
	information that will make the calculation faster. P1,P2 are first
	and second prime factors. E1,E2 are first and second exponents. C
	is the CRT coefficient. Terminology is taken from <url href="http://www.ietf.org/rfc/rfc3477.txt"> RFC 3447</url>.</p>
      </desc>
    </datatype>

    <datatype>
      <name name="dss_public"/>
      <name name="dss_private"/>
      <desc>
	<code>dss_public() = [P, Q, G, Y] </code>
	<p>Where P, Q and G are the dss parameters and Y is the public key.</p>

	<code>dss_private() = [P, Q, G, X] </code>
	<p>Where P, Q and G are the dss parameters and X is the private key.</p>
      </desc>
    </datatype>

    <datatype>
      <name name="ecdsa_public"/>
      <name name="ecdsa_private"/>
      <name name="ecdsa_params"/>
      <desc>
      </desc>
    </datatype>

    <datatype>
      <name name="eddsa_public"/>
      <name name="eddsa_private"/>
      <name name="eddsa_params"/>
      <desc>
      </desc>
    </datatype>

    <datatype>
      <name name="srp_public"/>
      <name name="srp_private"/>
      <desc>
	<code>srp_public() = key_integer() </code>
	<p>Where is <c>A</c> or <c>B</c> from <url href="http://srp.stanford.edu/design.html">SRP design</url></p>
	
	<code>srp_private() = key_integer() </code>
	<p>Where is  <c>a</c> or <c>b</c> from <url href="http://srp.stanford.edu/design.html">SRP design</url></p>
      </desc>
    </datatype>

    <datatype>
      <name name="srp_gen_params"/>
      <name name="srp_comp_params"/>
      <desc>
	<marker id="type-srp_user_gen_params"/>
	<code>srp_user_gen_params() = [DerivedKey::binary(), Prime::binary(), Generator::binary(), Version::atom()]</code>
	<marker id="type-srp_host_gen_params"/>
	<code>srp_host_gen_params() = [Verifier::binary(), Prime::binary(), Version::atom() ]</code>
	<marker id="type-srp_user_comp_params"/>
	<code>srp_user_comp_params() = [DerivedKey::binary(), Prime::binary(), Generator::binary(), Version::atom() | ScramblerArg::list()]</code>
	<marker id="type-srp_host_comp_params"/>
	<code>srp_host_comp_params() = [Verifier::binary(), Prime::binary(), Version::atom() | ScramblerArg::list()]</code>
	<p>Where Verifier is <c>v</c>, Generator is <c>g</c> and Prime is<c> N</c>, DerivedKey is <c>X</c>, and Scrambler is
	<c>u</c> (optional will be generated if not provided) from <url href="http://srp.stanford.edu/design.html">SRP design</url>
	Version = '3' |  '6' |  '6a'
	</p>
      </desc>
    </datatype>

    <datatype_title>Public Key Ciphers</datatype_title>

    <datatype>
      <name name="pk_encrypt_decrypt_algs"/>
      <desc>
	<p>Algorithms for public key encrypt/decrypt. Only RSA is supported.</p>
      </desc>
    </datatype>

    <datatype>
      <name name="pk_encrypt_decrypt_opts"/>
      <name name="rsa_opt"/>
      <name name="rsa_padding"/>
      <desc>
	<p>Options for public key encrypt/decrypt. Only RSA is supported.</p>
	 <warning>
	   <!-- In RefMan rsa_opt(), rsa_sign_verify_opt() and User's man RSA -->
	   <p>The RSA options are experimental.
	   </p>
	   <p>The exact set of options and there syntax <em>may</em> be changed
	   without prior notice.</p>
	</warning>
      </desc>
    </datatype>

    <datatype>
      <name name="rsa_compat_opts"/>
      <desc>
	<p>Those option forms are kept only for compatibility and should not be used in new code.</p>
      </desc>
    </datatype>

    <datatype_title>Public Key Sign and Verify</datatype_title>

    <datatype>
      <name name="pk_sign_verify_algs"/>
      <desc>
	<p>Algorithms for sign and verify.</p>
      </desc>
    </datatype>

    <datatype>
      <name name="pk_sign_verify_opts"/>
      <name name="rsa_sign_verify_opt"/>
      <name name="rsa_sign_verify_padding"/>
      <desc>
	<p>Options for sign and verify.</p>
	 <warning>
	   <!-- In RefMan rsa_opt(), rsa_sign_verify_opt() and User's man RSA -->
	   <p>The RSA options are experimental.
	   </p>
	   <p>The exact set of options and there syntax <em>may</em> be changed
	   without prior notice.</p>
	</warning>
      </desc>
    </datatype>

    <datatype_title>Diffie-Hellman Keys and parameters</datatype_title>
    <datatype>
      <name name="dh_public"/>
      <name name="dh_private"/>
      <desc>
      </desc>
    </datatype>

    <datatype>
      <name name="dh_params"/>
      <desc>
	<code>dh_params() = [P, G] | [P, G, PrivateKeyBitLength]</code>
      </desc>
    </datatype>

    <datatype>
      <name name="ecdh_public"/>
      <name name="ecdh_private"/>
      <name name="ecdh_params"/>
      <desc>
      </desc>
    </datatype>

    <datatype_title>Types for Engines</datatype_title>

    <datatype>
      <name name="engine_key_ref"/>
      <name name="engine_ref"/>
      <desc>
	<p>The result of a call to <seealso marker="#engine_load-3">engine_load/3</seealso>.
	</p>
      </desc>
    </datatype>

    <datatype>
      <name name="key_id"/>
      <desc>
	<p>Identifies the key to be used. The format depends on the loaded engine. It is passed to
	the <c>ENGINE_load_(private|public)_key</c> functions in libcrypto.
	</p>
      </desc>
    </datatype>

    <datatype>
      <name name="password"/>
      <desc>
	<p>The password of the key stored in an engine.
	</p>
      </desc>
    </datatype>

    <datatype>
      <name name="engine_method_type"/>
    </datatype>

    <datatype>
      <name name="engine_cmnd"/>
      <desc>
	<p>Pre and Post commands for <seealso marker="#engine_load-3">engine_load/3 and /4</seealso>.
	</p>
      </desc>
    </datatype>

    <datatype_title>Internal data types</datatype_title>

    <datatype>
      <name name="stream_state"/>
      <name name="hmac_state"/>
      <name name="hash_state"/>
      <name name="crypto_state"/>
      <desc>
	<p>Contexts with an internal state that should not be manipulated but passed between function calls.
	</p>
      </desc>
    </datatype>

    <datatype_title>Error types</datatype_title>

    <datatype>
      <name name="run_time_error"/>
      <desc>
	<p>The exception <c>error:badarg</c> signifies that one or more arguments are of wrong data type,
	or are otherwise badly formed.
	</p>
	<p>The exception <c>error:notsup</c> signifies that the algorithm is known but is not supported
	by current underlying libcrypto or explicitly disabled when building that.
	</p>
	<p>For a list of supported algorithms, see <seealso marker="#supports-0">supports/0</seealso>.
	</p>
      </desc>
    </datatype>

    <datatype>
      <name name="descriptive_error"/>
      <desc>
	<p>This is a more developed variant of the older
	<seealso marker="#type-run_time_error">run_time_error()</seealso>.
	</p>
	<p>The exception is:</p>
	<pre>
	  {Tag, {C_FileName,LineNumber}, Description}

	   Tag = badarg | notsup | error
	   C_FileName = string()
	   LineNumber = integer()
	   Description = string()
	</pre>

	<p>It is like the older type an exception of the <c>error</c> class. In addition they contain
	a descriptive text in English. That text is targeted to a developer. Examples are "Bad key size"
	or "Cipher id is not an atom".
	</p>
	<p>The exception tags are:</p>
	<taglist>
	  <tag><c>badarg</c></tag>
	  <item><p>Signifies that one or more arguments are of wrong data type or are otherwise badly formed.</p>
	  </item>

	  <tag><c>notsup</c></tag>
	  <item><p>Signifies that the algorithm is known but is not supported by current underlying libcrypto
	  or explicitly disabled when building that one.</p>
	  </item>

	  <tag><c>error</c></tag>
	  <item><p>An error condition that should not occur, for example a memory allocation failed or
	  the underlying cryptolib returned an error code, for example "Can't initialize context, step 1".
	  Thoose text usually needs searching the C-code to be understood.</p>
	  </item>
	</taglist>
	<p>To catch the exception, use for example:</p>
	<code>
	  try crypto:crypto_init(Ciph, Key, IV, true)
	  catch
	      error:{Tag, {C_FileName,LineNumber}, Description} ->
	              do_something(......)
	      .....
	  end
	</code>
      </desc>
    </datatype>

  </datatypes>

  <!--================ FUNCTIONS ================-->
  <section>
    <title>New API</title>
  </section>

  <funcs>
    <func>
      <name name="crypto_init" arity="3" since="OTP 22.0"/>
      <fsummary>Initializes a series of encryptions or decryptions</fsummary>
      <desc>
	<p>As <seealso marker="#crypto_init/4">crypto_init/4</seealso> but for ciphers without IVs.</p>
      </desc>
    </func>

    <func>
      <name name="crypto_init" arity="4" since="OTP 22.0"/>
      <fsummary>Initializes a series of encryptions or decryptions</fsummary>
      <desc>
	<p>Part of the <seealso marker="crypto:new_api#the-new-api">new API</seealso>.
	Initializes a series of encryptions or decryptions and creates an internal state
	with a reference that is returned.
	The actual encryption or decryption is done by
	<seealso marker="crypto#crypto_update/2">crypto_update/2</seealso>.
	</p>
	<p>For encryption, set the <c>EncryptFlag</c> to <c>true</c>. For decryption, set it to <c>false</c>.
	</p>
	<p>See <seealso marker="crypto:new_api#the-new-api">examples in the User's Guide.</seealso>
	</p>
      </desc>
    </func>

    <func>
      <name name="crypto_update" arity="2" since="OTP 22.0"/>
      <fsummary>Do an actual crypto operation on a part of the full text</fsummary>
      <desc>
	<p>Part of the <seealso marker="crypto:new_api#the-new-api">new API</seealso>.
	It does an actual crypto operation on a part of the full text. If the part is less
	than a number of full blocks, only the full blocks (possibly none) are encrypted 
	or decrypted and the remaining bytes are saved to the next <c>crypto_update</c> operation.
	The <c>State</c> should be created with
	<seealso marker="crypto#crypto_init/3">crypto_init/3</seealso>
	or
	<seealso marker="crypto#crypto_init/4">crypto_init/4</seealso>.
	</p>
	<p>See <seealso marker="crypto:new_api#the-new-api">examples in the User's Guide.</seealso>
	</p>
      </desc>
    </func>

    <func>
      <name name="crypto_init_dyn_iv" arity="3" since="OTP 22.0"/>
      <fsummary>Initializes a series of encryptions or decryptions where the IV is provided later</fsummary>
      <desc>
	<p>Part of the <seealso marker="crypto:new_api#the-new-api">new API</seealso>.
	Initializes a series of encryptions or decryptions where the IV is provided later.
	The actual encryption or decryption is done by
	<seealso marker="crypto#crypto_update_dyn_iv/3">crypto_update_dyn_iv/3</seealso>.
	</p>
	<p>For encryption, set the <c>EncryptFlag</c> to <c>true</c>. For decryption, set it to <c>false</c>.
	</p>
	<p>See <seealso marker="crypto:new_api#the-new-api">examples in the User's Guide.</seealso>
	</p>
      </desc>
    </func>

    <func>
      <name name="crypto_update_dyn_iv" arity="3" since="OTP 22.0"/>
      <fsummary>Do an actual crypto operation on a part of the full text and the IV is supplied for each part</fsummary>
      <desc>
	<p>Part of the <seealso marker="crypto:new_api#the-new-api">new API</seealso>.
	Do an actual crypto operation on a part of the full text and the IV is supplied for each part.
	The <c>State</c> should be created with
	<seealso marker="crypto#crypto_init_dyn_iv/3">crypto_init_dyn_iv/3</seealso>.
	</p>
	<p>See <seealso marker="crypto:new_api#the-new-api">examples in the User's Guide.</seealso>
	</p>
      </desc>
    </func>

    <func>
      <name name="crypto_one_time" arity="4" since="OTP 22.0"/>
      <fsummary>Do a complete encrypt or decrypt of the full text</fsummary>
      <desc>
	<p>As <seealso marker="#crypto_one_time/5">crypto_one_time/5</seealso> but for ciphers without IVs.</p>
      </desc>
    </func>

    <func>
      <name name="crypto_one_time" arity="5" since="OTP 22.0"/>
      <fsummary>Do a complete encrypt or decrypt of the full text</fsummary>
      <desc>
	<p>Part of the <seealso marker="crypto:new_api#the-new-api">new API</seealso>.
	Do a complete encrypt or decrypt of the full text.
	</p>
	<p>For encryption, set the <c>EncryptFlag</c> to <c>true</c>. For decryption, set it to <c>false</c>.
	</p>
	<p>See <seealso marker="crypto:new_api#the-new-api">examples in the User's Guide.</seealso>
	</p>
      </desc>
    </func>

    <func>
      <name name="crypto_one_time_aead" arity="6" since="OTP 22.0"/>
      <name name="crypto_one_time_aead" arity="7" since="OTP 22.0"/>
      <fsummary>Do a complete encrypt or decrypt with an AEAD cipher of the full text</fsummary>
      <desc>
	<p>Part of the <seealso marker="crypto:new_api#the-new-api">new API</seealso>.
	Do a complete encrypt or decrypt with an AEAD cipher of the full text.
	</p>
	<p>For encryption, set the <c>EncryptFlag</c> to <c>true</c> and set the <c>TagOrTagLength</c>
	to the wanted size of the tag, that is, the tag length.  If the default length is wanted, the
	<c>crypto_aead/6</c> form may be used.
	</p>
	<p>For decryption, set the <c>EncryptFlag</c> to <c>false</c> and put the tag to be checked
	in the argument	<c>TagOrTagLength</c>.
	</p>
	<p>See <seealso marker="crypto:new_api#the-new-api">examples in the User's Guide.</seealso>
	</p>
      </desc>
    </func>
  </funcs>

  <section>
    <title>API kept from previous versions</title>
  </section>

  <funcs>
    <func>
      <name name="bytes_to_integer" arity="1" since="OTP R16B01"/>
      <fsummary>Convert binary representation, of an integer, to an Erlang integer.</fsummary>
      <desc>
        <p>Convert binary representation, of an integer, to an Erlang integer.
         </p>
      </desc>
    </func>

    <func>
      <name name="compute_key" arity="4" since="OTP R16B01"/>
      <fsummary>Computes the shared secret</fsummary>
      <desc>
	<p>Computes the shared secret from the private key and the other party's public key.
	 See also <seealso marker="public_key:public_key#compute_key-2">public_key:compute_key/2</seealso>
	</p>
      </desc>
    </func>

    <func>
      <name name="exor" arity="2" since=""/>
      <fsummary>XOR data</fsummary>
      <desc>
	<p>Performs bit-wise XOR (exclusive or) on the data supplied.</p>
      </desc>
    </func>


    <func>
      <name name="generate_key" arity="2" since="OTP R16B01"/>
      <name name="generate_key" arity="3" since="OTP R16B01"/>
      <fsummary>Generates a public key of type <c>Type</c></fsummary>
      <desc>
	<p>Generates a public key of type <c>Type</c>.
	See also <seealso marker="public_key:public_key#generate_key-1">public_key:generate_key/1</seealso>.
	May raise exception:
        </p>
        <list type="bulleted">
          <item><c>error:badarg</c>: an argument is of wrong type or has an illegal value,</item>
	  <item><c>error:low_entropy</c>: the random generator failed due to lack of secure "randomness",</item>
          <item><c>error:computation_failed</c>: the computation fails of another reason than <c>low_entropy</c>.</item>
        </list>
	<note>
	  <p>RSA key generation is only available if the runtime was
	  built with dirty scheduler support. Otherwise, attempting to
	  generate an RSA key will raise exception <c>error:notsup</c>.</p>
	</note>
      </desc>
    </func>

     <func>
      <name name="hash" arity="2" since="OTP R15B02"/>
      <fsummary></fsummary>
      <desc>
        <p>Computes a message digest of type <c>Type</c> from <c>Data</c>.</p>
	<p>May raise exception <c>error:notsup</c> in case the chosen <c>Type</c>
	is not supported by the underlying libcrypto implementation.</p>
      </desc>
    </func>

    <func>
      <name name="hash_init" arity="1" since="OTP R15B02"/>
      <fsummary></fsummary>
      <desc>
        <p>Initializes the context for streaming hash operations. <c>Type</c> determines
        which digest to use. The returned context should be used as argument
	to <seealso marker="#hash_update-2">hash_update</seealso>.</p>
	<p>May raise exception <c>error:notsup</c> in case the chosen <c>Type</c>
	is not supported by the underlying libcrypto implementation.</p>
      </desc>
    </func>

    <func>
      <name name="hash_update" arity="2" since="OTP R15B02"/>
      <fsummary></fsummary>
      <desc>
        <p>Updates the digest represented by <c>Context</c> using the given <c>Data</c>. <c>Context</c>
        must have been generated using <seealso marker="#hash_init-1">hash_init</seealso>
	or a previous call to this function. <c>Data</c> can be any length. <c>NewContext</c>
        must be passed into the next call to <c>hash_update</c>
	or <seealso marker="#hash_final-1">hash_final</seealso>.</p>
      </desc>
    </func>

    <func>
      <name name="hash_final" arity="1" since="OTP R15B02"/>
      <fsummary></fsummary>
      <desc>
        <p>Finalizes the hash operation referenced by <c>Context</c> returned
	from a previous call to <seealso marker="#hash_update-2">hash_update</seealso>.
	The size of <c>Digest</c> is determined by the type of hash
	function used to generate it.</p>
      </desc>
    </func>

    <func>
      <name name="hmac" arity="3" since="OTP R16B"/>
      <name name="hmac" arity="4" since="OTP R16B"/>
      <fsummary></fsummary>
      <desc>
        <p>Computes a HMAC of type <c>Type</c> from <c>Data</c> using
        <c>Key</c> as the authentication key.</p> <p><c>MacLength</c>
        will limit the size of the resultant <c>Mac</c>.</p>
      </desc>
    </func>

    <func>
      <name name="hmac_init" arity="2" since="OTP R14B03"/>
      <fsummary></fsummary>
      <desc>
        <p>Initializes the context for streaming HMAC operations. <c>Type</c> determines
        which hash function to use in the HMAC operation. <c>Key</c> is the authentication
        key. The key can be any length.</p>
      </desc>
    </func>

    <func>
      <name name="hmac_update" arity="2" since="OTP R14B03"/>
      <fsummary></fsummary>
      <desc>
        <p>Updates the HMAC represented by <c>Context</c> using the given <c>Data</c>. <c>Context</c>
        must have been generated using an HMAC init function (such as
        <seealso marker="#hmac_init-2">hmac_init</seealso>). <c>Data</c> can be any length. <c>NewContext</c>
        must be passed into the next call to <c>hmac_update</c>
	or to one of the functions <seealso marker="#hmac_final-1">hmac_final</seealso> and
	<seealso marker="#hmac_final_n-2">hmac_final_n</seealso>
	</p>
	<warning><p>Do not use a <c>Context</c> as argument in more than one
	call to	hmac_update or hmac_final. The semantics of reusing old contexts
	in any way is undefined and could even crash the VM in earlier releases.
	The reason for this limitation is a lack of support in the underlying
	libcrypto	API.</p></warning>
      </desc>
    </func>

    <func>
      <name name="hmac_final" arity="1" since="OTP R14B03"/>
      <fsummary></fsummary>
      <desc>
        <p>Finalizes the HMAC operation referenced by <c>Context</c>. The size of the resultant MAC is
        determined by the type of hash function used to generate it.</p>
      </desc>
    </func>

    <func>
      <name name="hmac_final_n" arity="2" since="OTP R14B03"/>
      <fsummary></fsummary>
      <desc>
        <p>Finalizes the HMAC operation referenced by <c>Context</c>. <c>HashLen</c> must be greater than
        zero. <c>Mac</c> will be a binary with at most <c>HashLen</c> bytes. Note that if HashLen is greater than the actual number of bytes returned from the underlying hash, the returned hash will have fewer than <c>HashLen</c> bytes.</p>
      </desc>
    </func>

    <func>
      <name name="cmac" arity="3" since="OTP 20.0"/>
      <name name="cmac" arity="4" since="OTP 20.0"/>
      <fsummary>Calculates the Cipher-based Message Authentication Code.</fsummary>
      <desc>
        <p>Computes a CMAC of type <c>Type</c> from <c>Data</c> using
        <c>Key</c> as the authentication key.</p> <p><c>MacLength</c>
        will limit the size of the resultant <c>Mac</c>.</p>
      </desc>
    </func>

    <func>
      <name name="info_fips" arity="0" since="OTP 20.0"/>
      <fsummary>Provides information about the FIPS operating status.</fsummary>
      <desc>
        <p>Provides information about the FIPS operating status of
        crypto and the underlying libcrypto library. If crypto was built
        with FIPS support this can be either <c>enabled</c> (when
        running in FIPS mode) or <c>not_enabled</c>. For other builds
        this value is always <c>not_supported</c>.
	</p>
	<p>See <seealso marker="#enable_fips_mode-1">enable_fips_mode/1</seealso> about how to enable
	FIPS mode.
	</p>
        <warning>
          <p>In FIPS mode all non-FIPS compliant algorithms are
          disabled and raise exception <c>error:notsup</c>. Check
          <seealso marker="#supports-0">supports</seealso> that in
          FIPS mode returns the restricted list of available
          algorithms.</p>
        </warning>
      </desc>
    </func>

    <func>
      <name name="enable_fips_mode" arity="1" since="OTP 21.1"/>
      <fsummary>Change FIPS mode.</fsummary>
      <desc>
        <p>Enables (<c>Enable = true</c>) or disables (<c>Enable = false</c>) FIPS mode. Returns <c>true</c> if
	the operation was successful or <c>false</c> otherwise.
	</p>
	<p>Note that to enable FIPS mode succesfully, OTP must be built with the configure option <c>--enable-fips</c>,
	and the underlying libcrypto must also support FIPS.
	</p>
	<p>See also <seealso marker="#info_fips-0">info_fips/0</seealso>.
	</p>
      </desc>
    </func>

    <func>
      <name name="info_lib" arity="0" since=""/>
      <fsummary>Provides information about the libraries used by crypto.</fsummary>
      <desc>
        <p>Provides the name and version of the libraries used by crypto.</p>
        <p><c>Name</c> is the name of the library. <c>VerNum</c> is
        the numeric version according to the library's own versioning
        scheme. <c>VerStr</c> contains a text variant of the version.</p>
        <pre>
> <input>info_lib().</input>
[{&lt;&lt;"OpenSSL"&gt;&gt;,269484095,&lt;&lt;"OpenSSL 1.1.0c  10 Nov 2016""&gt;&gt;}]
        </pre>
	<note><p>
	  From OTP R16 the <em>numeric version</em> represents the version of the OpenSSL
	  <em>header files</em> (<c>openssl/opensslv.h</c>) used when crypto was compiled.
	  The text variant represents the libcrypto library used at runtime.
	  In earlier OTP versions both numeric and text was taken from the library.
	</p></note>
      </desc>
    </func>

    <func>
      <name name="hash_info" arity="1" since="OTP 22.0"/>
      <fsummary>Information about supported hash algorithms.</fsummary>
      <desc>
	<p>Provides a map with information about block_size, size and possibly other properties of the
	hash algorithm in question.
	</p>
	<p>For a list of supported hash algorithms, see <seealso marker="#supports-0">supports/0</seealso>.
	</p>
      </desc>
    </func>

    <func>
      <name name="cipher_info" arity="1" since="OTP 22.0"/>
      <fsummary>Information about supported ciphers.</fsummary>
      <desc>
	<p>Provides a map with information about block_size, key_length, iv_length and possibly other properties of the
	cipher algorithm in question.
	</p>
        <note>
	  <p>The ciphers <c>aes_cbc</c>, <c>aes_cfb8</c>, <c>aes_cfb128</c>, <c>aes_ctr</c>,
	  <c>aes_ecb</c>, <c>aes_gcm</c> and <c>aes_ccm</c>
	  has no keylength in the <c>Type</c> as opposed to for example <c>aes_128_ctr</c>. They adapt to the length of
	  the key provided in the encrypt and decrypt function. Therefor it is impossible to return a valid keylength
	  in the map.</p>
	  <p>Always use a <c>Type</c> with an explicit key length,
	  </p>
	</note>
	<p>For a list of supported cipher algorithms, see <seealso marker="#supports-0">supports/0</seealso>.
	</p>
      </desc>
    </func>

    <func>
      <name name="mod_pow" arity="3" since="OTP R16B01"/>
      <fsummary>Computes the function: N^P mod M</fsummary>
      <desc>
	<p>Computes the function <c>N^P mod M</c>.</p>
      </desc>
    </func>

    <func>
      <name name="next_iv" arity="2" since="OTP R16B01"/>
      <name name="next_iv" arity="3" since="OTP R16B01"/>
      <fsummary></fsummary>
      <desc>
	<p>Returns the initialization vector to be used in the next
	iteration of encrypt/decrypt of type <c>Type</c>. <c>Data</c> is the
	encrypted data from the previous iteration step. The <c>IVec</c>
	argument is only needed for <c>des_cfb</c> as the vector used
	in the previous iteration step.</p>
      </desc>
    </func>

    <func>
      <name name="poly1305" arity="2" since="OTP 21.1"/>
      <fsummary></fsummary>
      <desc>
        <p>Computes a POLY1305 message authentication code (<c>Mac</c>) from <c>Data</c> using
        <c>Key</c> as the authentication key.</p>
      </desc>
    </func>

    <func>
      <name name="private_decrypt" arity="4" since="OTP R16B01"/>
      <fsummary>Decrypts CipherText using the private Key.</fsummary>
      <desc>
	<p>Decrypts the <c>CipherText</c>, encrypted with
	<seealso marker="#public_encrypt-4">public_encrypt/4</seealso> (or equivalent function)
	  using the <c>PrivateKey</c>, and returns the
	  plaintext (message digest). This is a low level signature  verification operation
	used for instance by older versions of the SSL protocol.
	  See also <seealso marker="public_key:public_key#decrypt_private-2">public_key:decrypt_private/[2,3]</seealso>
	</p>
      </desc>
    </func>

    <func>
      <name name="private_encrypt" arity="4" since="OTP R16B01"/>
      <fsummary>Encrypts PlainText using the private Key.</fsummary>
      <desc>
	<p>Encrypts the <c>PlainText</c> using the <c>PrivateKey</c>
	and returns the ciphertext. This is a low level signature operation
	used for instance by older versions of the SSL protocol. See
	also <seealso
	marker="public_key:public_key#encrypt_private-2">public_key:encrypt_private/[2,3]</seealso>
	</p>
      </desc>
    </func>

    <func>
      <name name="public_decrypt" arity="4" since="OTP R16B01"/>
      <fsummary>Decrypts CipherText using the public Key.</fsummary>
      <desc>
	<p>Decrypts the <c>CipherText</c>, encrypted with
	<seealso marker="#private_encrypt-4">private_encrypt/4</seealso>(or equivalent function)
	  using the <c>PrivateKey</c>, and returns the
	  plaintext (message digest). This is a low level signature verification operation
	  used for instance by older versions of the SSL protocol.
	  See also <seealso marker="public_key:public_key#decrypt_public-2">public_key:decrypt_public/[2,3]</seealso>
	</p>
      </desc>
    </func>

    <func>
      <name name="public_encrypt" arity="4" since="OTP R16B01"/>
      <fsummary>Encrypts PlainText using the public Key.</fsummary>
      <desc>
	<p>Encrypts the <c>PlainText</c> (message digest) using the <c>PublicKey</c>
	and returns the <c>CipherText</c>. This is a low level signature operation
	used for instance by older versions of the SSL protocol. See also <seealso
	marker="public_key:public_key#encrypt_public-2">public_key:encrypt_public/[2,3]</seealso>
	</p>
      </desc>
    </func>

    <func>
      <name name="rand_seed" arity="1" since="OTP 17.0"/>
      <fsummary>Set the seed for random bytes generation</fsummary>
      <desc>
        <p>Set the seed for PRNG to the given binary. This calls the
        RAND_seed function from openssl. Only use this if the system
        you are running on does not have enough "randomness" built in.
        Normally this is when
        <seealso marker="#strong_rand_bytes/1">strong_rand_bytes/1</seealso>
        raises <c>error:low_entropy</c></p>
      </desc>
    </func>

     <func>
      <name since="">rand_uniform(Lo, Hi) -> N</name>
      <fsummary>Generate a random number</fsummary>
      <type>
        <v>Lo, Hi, N = integer()</v>
      </type>
      <desc>
        <p>Generate a random number <c><![CDATA[N, Lo =< N < Hi.]]></c> Uses the
	<c>crypto</c> library pseudo-random number generator.
	<c>Hi</c> must be larger than <c>Lo</c>.</p>
      </desc>
    </func>

    <func>
      <name name="start" arity="0" since=""/>
      <fsummary> Equivalent to application:start(crypto). </fsummary>
      <desc>
        <p> Equivalent to application:start(crypto).</p>
      </desc>
    </func>

    <func>
      <name name="stop" arity="0" since=""/>
      <fsummary> Equivalent to application:stop(crypto).</fsummary>
      <desc>
        <p> Equivalent to application:stop(crypto).</p>
      </desc>
    </func>

    <func>
      <name name="strong_rand_bytes" arity="1" since="OTP R14B03"/>
      <fsummary>Generate a binary of random bytes</fsummary>
      <desc>
        <p>Generates N bytes randomly uniform 0..255, and returns the
        result in a binary. Uses a cryptographically secure prng seeded and
        periodically mixed with operating system provided entropy. By default
        this is the <c>RAND_bytes</c> method from OpenSSL.</p>
	<p>May raise exception <c>error:low_entropy</c> in case the random generator
	failed due to lack of secure "randomness".</p>
      </desc>
    </func>

    <func>
      <name name="rand_seed" arity="0" since="OTP 20.0"/>
      <fsummary>Strong random number generation plugin state</fsummary>
      <desc>
	<p>
          Creates state object for
	  <seealso marker="stdlib:rand">random number generation</seealso>,
          in order to generate cryptographically strong random numbers
          (based on OpenSSL's <c>BN_rand_range</c>),
          and saves it in the process dictionary before returning it as well.
          See also
	  <seealso marker="stdlib:rand#seed-1">rand:seed/1</seealso> and
	  <seealso marker="#rand_seed_s-0">rand_seed_s/0</seealso>.
	</p>
	<p>
	  When using the state object from this function the
	  <seealso marker="stdlib:rand">rand</seealso> functions using it
	  may raise exception <c>error:low_entropy</c> in case the random generator
	  failed due to lack of secure "randomness".
	</p>
        <p><em>Example</em></p>
        <pre>
_ = crypto:rand_seed(),
_IntegerValue = rand:uniform(42), % [1; 42]
_FloatValue = rand:uniform().     % [0.0; 1.0[</pre>
      </desc>
    </func>

    <func>
      <name name="rand_seed_s" arity="0" since="OTP 20.0"/>
      <fsummary>Strong random number generation plugin state</fsummary>
      <desc>
	<p>
          Creates state object for
	  <seealso marker="stdlib:rand">random number generation</seealso>,
          in order to generate cryptographically strongly random numbers
          (based on OpenSSL's <c>BN_rand_range</c>).
          See also
	  <seealso marker="stdlib:rand#seed_s-1">rand:seed_s/1</seealso>.
	</p>
	<p>
	  When using the state object from this function the
	  <seealso marker="stdlib:rand">rand</seealso> functions using it
	  may raise exception <c>error:low_entropy</c> in case the random generator
	  failed due to lack of secure "randomness".
	</p>
	<note>
	  <p>
	    The state returned from this function cannot be used
	    to get a reproducable random sequence as from
	    the other
	    <seealso marker="stdlib:rand">rand</seealso>
	    functions,
	    since reproducability does not match cryptographically safe.
	  </p>
	  <p>
	    The only supported usage is to generate one distinct
	    random sequence from this start state.
	  </p>
	</note>
      </desc>
    </func>

    <func>
      <name since="OTP 21.0">rand_seed_alg(Alg) -> rand:state()</name>
      <fsummary>Strong random number generation plugin state</fsummary>
      <type>
        <v>Alg = crypto | crypto_cache</v>
      </type>
      <desc>
	<marker id="rand_seed_alg-1" />
	<p>
          Creates state object for
	  <seealso marker="stdlib:rand">random number generation</seealso>,
          in order to generate cryptographically strong random numbers,
          and saves it in the process dictionary before returning it as well.
          See also
	  <seealso marker="stdlib:rand#seed-1">rand:seed/1</seealso> and
	  <seealso marker="#rand_seed_alg_s-1">rand_seed_alg_s/1</seealso>.
	</p>
	<p>
	  When using the state object from this function the
	  <seealso marker="stdlib:rand">rand</seealso> functions using it
	  may raise exception <c>error:low_entropy</c> in case the random generator
	  failed due to lack of secure "randomness".
	</p>
        <p><em>Example</em></p>
        <pre>
_ = crypto:rand_seed_alg(crypto_cache),
_IntegerValue = rand:uniform(42), % [1; 42]
_FloatValue = rand:uniform().     % [0.0; 1.0[</pre>
      </desc>
    </func>

    <func>
      <name since="OTP-22.0">rand_seed_alg(Alg, Seed) -> rand:state()</name>
      <fsummary>Strong random number generation plugin state</fsummary>
      <type>
        <v>Alg = crypto_aes</v>
      </type>
      <desc>
	<marker id="rand_seed_alg-2" />
	<p>
          Creates a state object for
	  <seealso marker="stdlib:rand">random number generation</seealso>,
          in order to generate cryptographically unpredictable random numbers,
          and saves it in the process dictionary before returning it as well.
          See also
	  <seealso marker="#rand_seed_alg_s-2">rand_seed_alg_s/2</seealso>.
	</p>
        <p><em>Example</em></p>
        <pre>
_ = crypto:rand_seed_alg(crypto_aes, "my seed"),
IntegerValue = rand:uniform(42), % [1; 42]
FloatValue = rand:uniform(),     % [0.0; 1.0[
_ = crypto:rand_seed_alg(crypto_aes, "my seed"),
IntegerValue = rand:uniform(42), % Same values
FloatValue = rand:uniform().     % again
	</pre>
      </desc>
    </func>

    <func>
      <name since="OTP 21.0">rand_seed_alg_s(Alg) -> rand:state()</name>
      <fsummary>Strong random number generation plugin state</fsummary>
      <type>
        <v>Alg = crypto | crypto_cache</v>
      </type>
      <desc>
	<marker id="rand_seed_alg_s-1" />
	<p>
          Creates state object for
	  <seealso marker="stdlib:rand">random number generation</seealso>,
          in order to generate cryptographically strongly random numbers.
          See also
	  <seealso marker="stdlib:rand#seed_s-1">rand:seed_s/1</seealso>.
	</p>
	<p>
	  If <c>Alg</c> is <c>crypto</c> this function behaves exactly like
	  <seealso marker="#rand_seed_s-0">rand_seed_s/0</seealso>.
	</p>
	<p>
	  If <c>Alg</c> is <c>crypto_cache</c> this function
	  fetches random data with OpenSSL's <c>RAND_bytes</c>
	  and caches it for speed using an internal word size
	  of 56 bits that makes calculations fast on 64 bit machines.
	</p>
	<p>
	  When using the state object from this function the
	  <seealso marker="stdlib:rand">rand</seealso> functions using it
	  may raise exception <c>error:low_entropy</c> in case the random generator
	  failed due to lack of secure "randomness".
	</p>
	<p>
	  The cache size can be changed from its default value using the
	  <seealso marker="crypto_app">
	    crypto app's
	  </seealso> configuration parameter <c>rand_cache_size</c>.
	</p>
	<p>
	  When using the state object from this function the
	  <seealso marker="stdlib:rand">rand</seealso> functions using it
	  may throw exception <c>low_entropy</c> in case the random generator
	  failed due to lack of secure "randomness".
	</p>
	<note>
	  <p>
	    The state returned from this function cannot be used
	    to get a reproducable random sequence as from
	    the other
	    <seealso marker="stdlib:rand">rand</seealso>
	    functions,
	    since reproducability does not match cryptographically safe.
	  </p>
	  <p>
	    In fact since random data is cached some numbers may
	    get reproduced if you try, but this is unpredictable.
	  </p>
	  <p>
	    The only supported usage is to generate one distinct
	    random sequence from this start state.
	  </p>
	</note>
      </desc>
    </func>

    <func>
      <name since="OTP 22.0">rand_seed_alg_s(Alg, Seed) -> rand:state()</name>
      <fsummary>Strong random number generation plugin state</fsummary>
      <type>
        <v>Alg = crypto_aes</v>
      </type>
      <desc>
	<marker id="rand_seed_alg_s-2" />
	<p>
          Creates a state object for
	  <seealso marker="stdlib:rand">random number generation</seealso>,
          in order to generate cryptographically unpredictable random numbers.
          See also
	  <seealso marker="#rand_seed_alg-1">rand_seed_alg/1</seealso>.
	</p>
	<p>
	  To get a long period the Xoroshiro928 generator from the
	  <seealso marker="stdlib:rand">rand</seealso>
	  module is used as a counter (with period 2^928 - 1)
	  and the generator states are scrambled through AES
	  to create 58-bit pseudo random values.
	</p>
	<p>
	  The result should be statistically completely unpredictable
	  random values, since the scrambling is cryptographically strong
	  and the period is ridiculously long.  But the generated numbers
	  are not to be regarded as cryptographically strong since
	  there is no re-keying schedule.
	</p>
	<list type="bulleted">
	  <item>
	    <p>
	      If you need cryptographically strong random numbers use
	      <seealso marker="#rand_seed_alg_s-1">rand_seed_alg_s/1</seealso>
	      with <c>Alg =:= crypto</c> or <c>Alg =:= crypto_cache</c>.
	    </p>
	  </item>
	  <item>
	    <p>
	      If you need to be able to repeat the sequence use this function.
	    </p>
	  </item>
	  <item>
	    <p>
	      If you do not need the statistical quality of this function,
	      there are faster algorithms in the
	      <seealso marker="stdlib:rand">rand</seealso>
	      module.
	    </p>
	  </item>
	</list>
	<p>
	  Thanks to the used generator the state object supports the
	  <seealso marker="stdlib:rand#jump-0"><c>rand:jump/0,1</c></seealso>
	  function with distance 2^512.
	</p>
	<p>
	  Numbers are generated in batches and cached for speed reasons.
	  The cache size can be changed from its default value using the
	  <seealso marker="crypto_app">
	    crypto app's
	  </seealso> configuration parameter <c>rand_cache_size</c>.
	</p>
      </desc>
    </func>

   <func>
      <name name="supports" arity="0" since="OTP R16B01"/>
      <fsummary>Provide a list of available crypto algorithms.</fsummary>
      <desc>
        <p> Can be used to determine which crypto algorithms that are supported
	by the underlying libcrypto library</p>
	<p>See <seealso marker="#hash_info-1">hash_info/1</seealso> and <seealso marker="#cipher_info-1">cipher_info/1</seealso>
	for information about the hash and cipher algorithms.
	</p>
      </desc>
    </func>

    <func>
      <name name="ec_curves" arity="0" since="OTP 17.0"/>
      <fsummary>Provide a list of available named elliptic curves.</fsummary>
      <desc>
        <p>Can be used to determine which named elliptic curves are supported.</p>
      </desc>
    </func>

    <func>
      <name name="ec_curve" arity="1" since="OTP 17.0"/>
      <fsummary>Get the defining parameters of a elliptic curve.</fsummary>
      <desc>
        <p>Return the defining parameters of a elliptic curve.</p>
      </desc>
    </func>

    <func>
      <name name="sign" arity="4" since="OTP R16B01"/>
      <name name="sign" arity="5" since="OTP 20.1"/>
      <fsummary> Create digital signature.</fsummary>
      <desc>
	<p>Creates a digital signature.</p>
	<p>The msg is either the binary "cleartext" data to be
	signed or it is the hashed value of "cleartext" i.e. the
	digest (plaintext).</p>
	<p>Algorithm <c>dss</c> can only be used together with digest type
	<c>sha</c>.</p>
	<p>See also <seealso marker="public_key:public_key#sign-3">public_key:sign/3</seealso>.</p>
      </desc>
    </func>

    <func>
      <name name="verify" arity="5" since="OTP R16B01"/>
      <name name="verify" arity="6" since="OTP 20.1"/>
      <fsummary>Verifies a digital signature.</fsummary>
      <desc>
	<p>Verifies a digital signature</p>
	<p>The msg is either the binary "cleartext" data to be
	signed or it is the hashed value of "cleartext" i.e. the
	digest (plaintext).</p>
	<p>Algorithm <c>dss</c> can only be used together with digest type
	<c>sha</c>.</p>

	<p>See also <seealso marker="public_key:public_key#verify-4">public_key:verify/4</seealso>.</p>
      </desc>
    </func>

  </funcs>
    <section>
      <title>Engine API</title>
    </section>

  <funcs>
    <!-- Engine functions -->
    <func>
      <name name="privkey_to_pubkey" arity="2" since="OTP 20.2"/>
      <fsummary>Fetches a public key from an Engine stored private key.</fsummary>
      <desc>
	<p>Fetches the corresponding public key from a private key stored in an Engine.
	The key must be of the type indicated by the Type parameter.
	</p>	
      </desc>
    </func>

    <func>
      <name name="engine_get_all_methods" arity="0" since="OTP 20.2"/>
      <fsummary>Return list of all possible engine methods</fsummary>
      <desc>
	<p>
	  Returns a list of all possible engine methods.
	</p>
	<p>
	  May raise exception <c>error:notsup</c> in case there is
	  no engine support in the underlying OpenSSL implementation.
	</p>
	<p>
	  See also the chapter <seealso marker="crypto:engine_load#engine_load">Engine Load</seealso>
	  in the User's Guide.
	</p>
      </desc>
    </func>

    <func>
      <name name="engine_load" arity="3" since="OTP 20.2"/>
      <fsummary>Dynamical load an encryption engine</fsummary>
      <desc>
	<p>
	  Loads the OpenSSL engine given by <c>EngineId</c> if it is available and then returns ok and
	  an engine handle. This function is the same as calling <c>engine_load/4</c> with
	  <c>EngineMethods</c> set to a list of all the possible methods.  An error tuple is
	  returned if the engine can't be loaded.
	</p>
	<p>
	  The function raises a <c>error:badarg</c> if the parameters are in wrong format.
	  It may also raise the exception <c>error:notsup</c> in case there is
	  no engine support in the underlying OpenSSL implementation.
	</p>
	<p>
	  See also the chapter <seealso marker="crypto:engine_load#engine_load">Engine Load</seealso>
	  in the User's Guide.
	</p>
      </desc>
    </func>

    <func>
      <name name="engine_load" arity="4" since="OTP 20.2"/>
      <fsummary>Dynamical load an encryption engine</fsummary>
      <desc>
	<p>
	  Loads the OpenSSL engine given by <c>EngineId</c> if it is available and then returns ok and
	  an engine handle. An error tuple is returned if the engine can't be loaded.
	</p>
	<p>
	  The function raises a <c>error:badarg</c> if the parameters are in wrong format.
	  It may also raise the exception <c>error:notsup</c> in case there is
	  no engine support in the underlying OpenSSL implementation.
	</p>
	<p>
	  See also the chapter <seealso marker="crypto:engine_load#engine_load">Engine Load</seealso>
	  in the User's Guide.
	</p>
      </desc>
    </func>

    <func>
      <name name="engine_unload" arity="1" since="OTP 20.2"/>
      <fsummary>Dynamical load an encryption engine</fsummary>
      <desc>
	<p>
	  Unloads the OpenSSL engine given by <c>Engine</c>.
	  An error tuple is returned if the engine can't be unloaded.
	</p>
	<p>
	  The function raises a <c>error:badarg</c> if the parameter is in wrong format.
	  It may also raise the exception <c>error:notsup</c> in case there is
	  no engine support in the underlying OpenSSL implementation.
	</p>
	<p>
	  See also the chapter <seealso marker="crypto:engine_load#engine_load">Engine Load</seealso>
	  in the User's Guide.
	</p>
      </desc>
    </func>

    <func>
      <name name="engine_by_id" arity="1" since="OTP 21.0.6"/>
      <fsummary>Get a reference to an already loaded engine</fsummary>
      <desc>
	<p>
	  Get a reference to an already loaded engine with <c>EngineId</c>.
	  An error tuple is returned if the engine can't be unloaded.
	</p>
	<p>
	  The function raises a <c>error:badarg</c> if the parameter is in wrong format.
	  It may also raise the exception <c>error:notsup</c> in case there is
	  no engine support in the underlying OpenSSL implementation.
	</p>
	<p>
	  See also the chapter <seealso marker="crypto:engine_load#engine_load">Engine Load</seealso>
	  in the User's Guide.
	</p>
      </desc>
    </func>

    <func>
      <name name="engine_ctrl_cmd_string" arity="3" since="OTP 20.2"/>
      <fsummary>Sends ctrl commands to an OpenSSL engine</fsummary>
      <desc>
	<p>
	  Sends ctrl commands to the OpenSSL engine given by <c>Engine</c>.
	  This function is the same as calling <c>engine_ctrl_cmd_string/4</c> with
	  <c>Optional</c> set to <c>false</c>.
	</p>
	<p>
	  The function raises a <c>error:badarg</c> if the parameters are in wrong format.
	  It may also raise the exception <c>error:notsup</c> in case there is
	  no engine support in the underlying OpenSSL implementation.
	</p>
      </desc>
    </func>

    <func>
      <name name="engine_ctrl_cmd_string" arity="4" since="OTP 20.2"/>
      <fsummary>Sends ctrl commands to an OpenSSL engine</fsummary>
      <desc>
	<p>
	  Sends ctrl commands to the OpenSSL engine given by <c>Engine</c>.
	  <c>Optional</c> is a boolean argument that can relax the semantics of the function.
	  If set to <c>true</c> it will only return failure if the ENGINE supported the given
	  command name but failed while executing it, if the ENGINE doesn't support the command
	  name it will simply return success without doing anything. In this case we assume
	  the user is only supplying commands specific to the given ENGINE so we set this to
	  <c>false</c>.
	</p>
	<p>
	  The function raises a <c>error:badarg</c> if the parameters are in wrong format.
	  It may also raise the exception <c>error:notsup</c> in case there is
	  no engine support in the underlying OpenSSL implementation.
	</p>
      </desc>
    </func>

    <func>
      <name name="engine_add" arity="1" since="OTP 21.0.6"/>
      <fsummary>Add engine to OpenSSL internal list</fsummary>
      <desc>
	<p>Add the engine to OpenSSL's internal list.</p>
	<p>
	  The function raises a <c>error:badarg</c> if the parameters are in wrong format.
	  It may also raise the exception <c>error:notsup</c> in case there is
	  no engine support in the underlying OpenSSL implementation.
	</p>
      </desc>
    </func>

    <func>
      <name name="engine_remove" arity="1" since="OTP 21.0.6"/>
      <fsummary>Remove engine to OpenSSL internal list</fsummary>
      <desc>
	<p>Remove the engine from OpenSSL's internal list.</p>
	<p>
	  The function raises a <c>error:badarg</c> if the parameters are in wrong format.
	  It may also raise the exception <c>error:notsup</c> in case there is
	  no engine support in the underlying OpenSSL implementation.
	</p>
      </desc>
    </func>

    <func>
      <name name="engine_get_id" arity="1" since="OTP 21.0.6"/>
      <fsummary>Fetch engine ID</fsummary>
      <desc>
	<p>Return the ID for the engine, or an empty binary if there is no id set.</p>
	<p>
	  The function raises a <c>error:badarg</c> if the parameters are in wrong format.
	  It may also raise the exception <c>error:notsup</c> in case there is
	  no engine support in the underlying OpenSSL implementation.
	</p>
      </desc>
    </func>

    <func>
      <name name="engine_get_name" arity="1" since="OTP 21.0.6"/>
      <fsummary>Fetch engine name</fsummary>
      <desc>
	<p>Return the name (eg a description) for the engine, or an empty binary if there is no name set.</p>
	<p>
	  The function raises a <c>error:badarg</c> if the parameters are in wrong format.
	  It may also raise the exception <c>error:notsup</c> in case there is
	  no engine support in the underlying OpenSSL implementation.
	</p>
      </desc>
    </func>

    <func>
      <name name="engine_list" arity="0" since="OTP 20.2"/>
      <fsummary>List the known engine ids</fsummary>
      <desc>
	<p>List the id's of all engines in OpenSSL's internal list.</p>
	<p>
	  It may also raise the exception <c>error:notsup</c> in case there is
	  no engine support in the underlying OpenSSL implementation.
	</p>
	<p>
	  See also the chapter <seealso marker="crypto:engine_load#engine_load">Engine Load</seealso>
	  in the User's Guide.
	</p>
	<p>
	  May raise exception <c>error:notsup</c> in case engine functionality is not supported by the underlying
	  OpenSSL implementation.
	</p>
      </desc>
    </func>

    <func>
      <name name="ensure_engine_loaded" arity="2" since="OTP 21.0.6"/>
      <fsummary>Ensure encryption engine just loaded once</fsummary>
      <desc>
	<p>
	  Loads the OpenSSL engine given by <c>EngineId</c> and the path to the dynamic library
	  implementing the engine. This function is the same as calling <c>ensure_engine_loaded/3</c> with
	  <c>EngineMethods</c> set to a list of all the possible methods. An error tuple is
	  returned if the engine can't be loaded.
	</p>
	<p>
	  The function raises a <c>error:badarg</c> if the parameters are in wrong format.
	  It may also raise the exception <c>error:notsup</c> in case there is
	  no engine support in the underlying OpenSSL implementation.
	</p>
	<p>
	  See also the chapter <seealso marker="crypto:engine_load#engine_load">Engine Load</seealso>
	  in the User's Guide.
	</p>
      </desc>
    </func>

    <func>
      <name name="ensure_engine_loaded" arity="3" since="OTP 21.0.6"/>
      <fsummary>Ensure encryption engine just loaded once</fsummary>
      <desc>
	<p>
	  Loads the OpenSSL engine given by <c>EngineId</c> and the path to the dynamic library
	  implementing the engine. This function differs from the normal engine_load in that sense it
	  also add the engine id to the internal list in OpenSSL. Then in the following calls to the function
	  it just fetch the reference to the engine instead of loading it again.
	  An error tuple is returned if the engine can't be loaded.
	</p>
	<p>
	  The function raises a <c>error:badarg</c> if the parameters are in wrong format.
	  It may also raise the exception <c>error:notsup</c> in case there is
	  no engine support in the underlying OpenSSL implementation.
	</p>
	<p>
	  See also the chapter <seealso marker="crypto:engine_load#engine_load">Engine Load</seealso>
	  in the User's Guide.
	</p>
      </desc>
    </func>

    <func>
      <name name="ensure_engine_unloaded" arity="1" since="OTP 21.0.6"/>
      <fsummary>Unload an engine loaded with the ensure function</fsummary>
      <desc>
	<p>
	  Unloads an engine loaded with the <c>ensure_engine_loaded</c> function.
	  It both removes the label from the OpenSSL internal engine list and unloads the engine.
	  This function is the same as calling <c>ensure_engine_unloaded/2</c> with
	  <c>EngineMethods</c> set to a list of all the possible methods. An error tuple is
	  returned if the engine can't be unloaded.
	</p>
	<p>
	  The function raises a <c>error:badarg</c> if the parameters are in wrong format.
	  It may also raise the exception <c>error:notsup</c> in case there is
	  no engine support in the underlying OpenSSL implementation.
	</p>
	<p>
	  See also the chapter <seealso marker="crypto:engine_load#engine_load">Engine Load</seealso>
	  in the User's Guide.
	</p>
      </desc>
    </func>

    <func>
      <name name="ensure_engine_unloaded" arity="2" since="OTP 21.0.6"/>
      <fsummary>Unload an engine loaded with the ensure function</fsummary>
      <desc>
	<p>
	  Unloads an engine loaded with the <c>ensure_engine_loaded</c> function.
	  It both removes the label from the OpenSSL internal engine list and unloads the engine.
	  An error tuple is returned if the engine can't be unloaded.
	</p>
	<p>
	  The function raises a <c>error:badarg</c> if the parameters are in wrong format.
	  It may also raise the exception <c>error:notsup</c> in case there is
	  no engine support in the underlying OpenSSL implementation.
	</p>
	<p>
	  See also the chapter <seealso marker="crypto:engine_load#engine_load">Engine Load</seealso>
	  in the User's Guide.
	</p>
      </desc>
    </func>

 </funcs>

<section>
  <title>Old API</title>
</section>

 <funcs>
    <func>
      <name name="block_encrypt" arity="3" since="OTP 18.0"/>
      <fsummary>Encrypt <c>PlainText</c> according to <c>Type</c> block cipher</fsummary>
      <desc>
	<dont><p>Don't use this function for new programs! Use <seealso marker="crypto:new_api">the-new-api</seealso>.</p></dont>
	<p>Encrypt <c>PlainText</c> according to <c>Type</c> block cipher.</p>
	<p>May raise exception <c>error:notsup</c> in case the chosen <c>Type</c>
	is not supported by the underlying libcrypto implementation.</p>
	<p>For keylengths and blocksizes see the
	<seealso marker="crypto:algorithm_details#ciphers">User's Guide</seealso>.
	</p>
      </desc>
    </func>

    <func>
      <name name="block_decrypt" arity="3" since="OTP 18.0"/>
      <fsummary>Decrypt <c>CipherText</c> according to <c>Type</c> block cipher</fsummary>
      <desc>
	<dont><p>Don't use this function for new programs! Use <seealso marker="crypto:new_api">the new api</seealso>.</p></dont>
        <p>Decrypt <c>CipherText</c> according to <c>Type</c> block cipher.</p>
	<p>May raise exception <c>error:notsup</c> in case the chosen <c>Type</c>
	is not supported by the underlying libcrypto implementation.</p>
	<p>For keylengths and blocksizes see the
	<seealso marker="crypto:algorithm_details#ciphers">User's Guide</seealso>.
	</p>
      </desc>
    </func>

    <func>
      <name since="OTP R16B01">block_encrypt(Type, Key, Ivec, PlainText) -> CipherText | Error</name>
      <name since="OTP R16B01">block_encrypt(AeadType, Key, Ivec, {AAD, PlainText}) -> {CipherText, CipherTag} | Error</name>
      <name since="OTP R16B01">block_encrypt(aes_gcm | aes_ccm, Key, Ivec, {AAD, PlainText, TagLength}) -> {CipherText, CipherTag} | Error </name>
      <fsummary>Encrypt <c>PlainText</c> according to <c>Type</c> block cipher</fsummary>
      <type>
	<v>Type = <seealso marker="#type-block_cipher_with_iv">block_cipher_with_iv()</seealso></v>
	<v>AeadType = <seealso marker="#type-aead_cipher">aead_cipher()</seealso></v>
	<v>Key = <seealso marker="#type-key">key()</seealso> | <seealso marker="#type-des3_key">des3_key()</seealso></v>
        <v>PlainText = iodata()</v>
        <v>AAD = IVec = CipherText = CipherTag = binary()</v>
        <v>TagLength = 1..16</v>
	<v>Error = <seealso marker="#type-run_time_error">run_time_error()</seealso></v>
      </type>
      <desc>
	<dont><p>Don't use this function for new programs! Use <seealso marker="crypto:new_api">the new api</seealso>.</p></dont>
        <p>Encrypt <c>PlainText</c> according to <c>Type</c> block cipher.
	<c>IVec</c> is an arbitrary initializing vector.</p>
	<p>In AEAD (Authenticated Encryption with Associated Data) mode, encrypt
	<c>PlainText</c>according to <c>Type</c> block cipher and calculate
	<c>CipherTag</c> that also authenticates the <c>AAD</c> (Associated Authenticated Data).</p>
	<p>May raise exception <c>error:notsup</c> in case the chosen <c>Type</c>
	is not supported by the underlying libcrypto implementation.</p>
	<p>For keylengths, iv-sizes and blocksizes see the
	<seealso marker="crypto:algorithm_details#ciphers">User's Guide</seealso>.
	</p>
      </desc>
    </func>

    <func>
      <name since="OTP R16B01">block_decrypt(Type, Key, Ivec, CipherText) -> PlainText | Error</name>
      <name since="OTP R16B01">block_decrypt(AeadType, Key, Ivec, {AAD, CipherText, CipherTag}) -> PlainText | Error</name>
      <fsummary>Decrypt <c>CipherText</c> according to <c>Type</c> block cipher</fsummary>
      <type>
	<v>Type = <seealso marker="#type-block_cipher_with_iv">block_cipher_with_iv()</seealso></v>
	<v>AeadType = <seealso marker="#type-aead_cipher">aead_cipher()</seealso></v>
	<v>Key = <seealso marker="#type-key">key()</seealso> | <seealso marker="#type-des3_key">des3_key()</seealso></v>
        <v>PlainText = iodata()</v>
        <v>AAD = IVec = CipherText = CipherTag = binary()</v>
	<v>Error = BadTag | <seealso marker="#type-run_time_error">run_time_error()</seealso></v>
	<v>BadTag = error</v>
      </type>
      <desc>
	<dont><p>Don't use this function for new programs! Use <seealso marker="crypto:new_api">the new api</seealso>.</p></dont>
        <p>Decrypt <c>CipherText</c> according to <c>Type</c> block cipher.
	<c>IVec</c> is an arbitrary initializing vector.</p>
        <p>In AEAD (Authenticated Encryption with Associated Data) mode, decrypt
	<c>CipherText</c>according to <c>Type</c> block cipher and check the authenticity
	the <c>PlainText</c> and <c>AAD</c> (Associated Authenticated Data) using the
	<c>CipherTag</c>. May return <c>error</c> if the decryption or validation fail's</p>
	<p>May raise exception <c>error:notsup</c> in case the chosen <c>Type</c>
	is not supported by the underlying libcrypto implementation.</p>
	<p>For keylengths, iv-sizes and blocksizes see the
	<seealso marker="crypto:algorithm_details#ciphers">User's Guide</seealso>.
	</p>
      </desc>
    </func>

    <func>
      <name name="stream_init" arity="2" since="OTP R16B01"/>
      <fsummary></fsummary>
      <desc>
	<dont><p>Don't use this function for new programs! Use <seealso marker="crypto:new_api">the new api</seealso>.</p></dont>
        <p>Initializes the state for use in RC4 stream encryption
        <seealso marker="#stream_encrypt-2">stream_encrypt</seealso> and
        <seealso marker="#stream_decrypt-2">stream_decrypt</seealso></p>
	<p>For keylengths see the
	<seealso marker="crypto:algorithm_details#stream-ciphers">User's Guide</seealso>.
	</p>
      </desc>
    </func>

   <func>
      <name name="stream_init" arity="3" since="OTP R16B01"/>
      <fsummary></fsummary>
      <desc>
	<dont><p>Don't use this function for new programs! Use <seealso marker="crypto:new_api">the new api</seealso>.</p></dont>
        <p>Initializes the state for use in streaming AES encryption using Counter mode (CTR).
        <c>Key</c> is the AES key and must be either 128, 192, or 256 bits long. <c>IVec</c> is
        an arbitrary initializing vector of 128 bits (16 bytes). This state is for use with
        <seealso marker="#stream_encrypt-2">stream_encrypt</seealso> and
        <seealso marker="#stream_decrypt-2">stream_decrypt</seealso>.</p>
	<p>For keylengths and iv-sizes see the
	<seealso marker="crypto:algorithm_details#stream-ciphers">User's Guide</seealso>.
	</p>
      </desc>
    </func>

    <func>
      <name name="stream_encrypt" arity="2" since="OTP R16B01"/>
      <fsummary></fsummary>
      <desc>
	<dont><p>Don't use this function for new programs! Use <seealso marker="crypto:new_api">the new api</seealso>.</p></dont>
	<p>Encrypts <c>PlainText</c> according to the stream cipher <c>Type</c> specified in stream_init/3.
	<c>Text</c> can be any number of bytes. The initial <c>State</c> is created using
        <seealso marker="#stream_init-2">stream_init</seealso>.
	<c>NewState</c> must be passed into the next call to <c>stream_encrypt</c>.</p>
      </desc>
    </func>

    <func>
      <name name="stream_decrypt" arity="2" since="OTP R16B01"/>
      <fsummary></fsummary>
      <desc>
	<dont><p>Don't use this function for new programs! Use <seealso marker="crypto:new_api">the new api</seealso>.</p></dont>
	<p>Decrypts <c>CipherText</c> according to the stream cipher <c>Type</c> specified in stream_init/3.
	<c>PlainText</c> can be any number of bytes. The initial <c>State</c> is created using
        <seealso marker="#stream_init-2">stream_init</seealso>.
	<c>NewState</c> must be passed into the next call to <c>stream_decrypt</c>.</p>
      </desc>
    </func>

  </funcs>


</erlref>