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
|
/*
* Copyright (c) 2016, Freescale Semiconductor, Inc.
* Copyright 2016-2022 NXP
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef _FSL_CAAM_H_
#define _FSL_CAAM_H_
#include "fsl_common.h"
/*!
* @addtogroup caam_driver
* @{
*/
/*! @brief CAAM status return codes. */
enum
{
kStatus_CAAM_Again = MAKE_STATUS(kStatusGroup_CAAM, 0), /*!< Non-blocking function shall be called again. */
kStatus_CAAM_DataOverflow = MAKE_STATUS(kStatusGroup_CAAM, 1), /*!< Input data too big. */
};
/*******************************************************************************
* Definitions
*******************************************************************************/
/*! @name Driver version */
/*@{*/
/*! @brief CAAM driver version. Version 2.1.6.
*
* Current version: 2.1.6
*
* Change log:
* - Version 2.0.0
* - Initial version
* - Version 2.0.1
* - Add Job Ring 2 and 3.
* - Version 2.0.2
* - Add Data and Instruction Synchronization Barrier in caam_input_ring_set_jobs_added()
* to make sure that the descriptor will be loaded into CAAM correctly.
* - Version 2.0.3
* - Use MACRO instead of numbers in descriptor.
* - Correct descriptor size mask.
* - Version 2.1.0
* - Add return codes check and handling.
* - Version 2.1.1
* - Add DCACHE support.
* - Version 2.1.2
* - Add data offset feature to provide support for mirrored (high-speed) memory.
* - Version 2.1.3
* - Fix MISRA-2012 issues.
* - Version 2.1.4
* - Fix MISRA-2012 issues.
* - Version 2.1.5
* - Support EXTENDED data size for all AES, HASH and RNG operations.
* - Support multiple De-Initialization/Initialization of CAAM driver within one POR event.
* - Version 2.1.6
* - Improve DCACHE handling. Requires CAAM used and cached memory set in write-trough mode.
*/
#define FSL_CAAM_DRIVER_VERSION (MAKE_VERSION(2, 1, 6))
/*@}*/
/*! @brief CAAM callback function. */
typedef struct _caam_job_callback
{
void (*JobCompleted)(void *userData); /*!< CAAM Job complete callback */
} caam_job_callback_t;
/*! @brief CAAM job ring selection. */
typedef enum _caam_job_ring_t
{
kCAAM_JobRing0 = 0u, /*!< CAAM Job ring 0 */
kCAAM_JobRing1 = 1u, /*!< CAAM Job ring 1 */
kCAAM_JobRing2 = 2u, /*!< CAAM Job ring 2 */
kCAAM_JobRing3 = 3u, /*!< CAAM Job ring 3 */
} caam_job_ring_t;
/*! @brief CAAM handle
* Specifies jobRing and optionally the user callback function.
* The user callback functions is invoked only if jobRing interrupt has been enabled by the user.
* By default the jobRing interrupt is disabled (default job complete test is polling CAAM output ring).
*/
typedef struct _caam_handle_t
{
caam_job_ring_t jobRing;
/* Callback functions */
caam_job_callback_t callback; /*!< Callback function */
void *userData; /*!< Parameter for CAAM job complete callback */
} caam_handle_t;
/*! @brief CAAM driver wait mechanism
*/
typedef enum _caam_wait_mode
{
kCAAM_Blocking = 0u, /*!< CAAM_Wait blocking mode */
kCAAM_Nonblocking = 1u, /*!< CAAM Wait non-blocking mode */
} caam_wait_mode_t;
/*! @brief Memory buffer to hold CAAM descriptor for AESA ECB job */
typedef uint32_t caam_desc_aes_ecb_t[64];
/*! @brief Memory buffer to hold CAAM descriptor for AESA CBC job */
typedef uint32_t caam_desc_aes_cbc_t[64];
/*! @brief Memory buffer to hold CAAM descriptor for AESA CTR job */
typedef uint32_t caam_desc_aes_ctr_t[64];
/*! @brief Memory buffer to hold CAAM descriptor for AESA CCM job */
typedef uint32_t caam_desc_aes_ccm_t[64];
/*! @brief Memory buffer to hold CAAM descriptor for AESA GCM job */
typedef uint32_t caam_desc_aes_gcm_t[64];
/*! @brief Memory buffer to hold CAAM descriptor for MDHA job or AESA CMAC job */
typedef uint32_t caam_desc_hash_t[64];
/*! @brief Memory buffer to hold CAAM descriptor for RNG jobs */
typedef uint32_t caam_desc_rng_t[64];
/*! @brief Memory buffer to hold CAAM descriptor for DESA jobs */
typedef uint32_t caam_desc_cipher_des_t[64];
/*! @brief Memory buffer to hold CAAM descriptor for PKHA jobs */
typedef uint32_t caam_desc_pkha_t[64];
/*! @brief Memory buffer to hold CAAM descriptor for PKHA ECC jobs */
typedef uint32_t caam_desc_pkha_ecc_t[64];
typedef struct _caam_job_ring_interface
{
uint32_t inputJobRing[4];
uint32_t outputJobRing[8];
} caam_job_ring_interface_t;
/*! @brief CAAM RNG sample mode. Used by caam_config_t. */
typedef enum _caam_rng_sample_mode
{
kCAAM_RNG_SampleModeVonNeumann = 0U, /*!< Use von Neumann data in both Entropy shifter and Statistical Checker. */
kCAAM_RNG_SampleModeRaw = 1U, /*!< Use raw data into both Entropy shifter and Statistical Checker. */
kCAAM_RNG_SampleModeVonNeumannRaw =
2U /*!< Use von Neumann data in Entropy shifter. Use raw data into Statistical Checker. */
} caam_rng_sample_mode_t;
/*! @brief CAAM RNG ring oscillator divide. Used by caam_config_t. */
typedef enum _caam_rng_ring_osc_div
{
kCAAM_RNG_RingOscDiv0 = 0U, /*!< Ring oscillator with no divide */
kCAAM_RNG_RingOscDiv2 = 1U, /*!< Ring oscillator divided-by-2. */
kCAAM_RNG_RingOscDiv4 = 2U, /*!< Ring oscillator divided-by-4. */
kCAAM_RNG_RingOscDiv8 = 3U /*!< Ring oscillator divided-by-8. */
} caam_rng_ring_osc_div_t;
/*! @brief CAAM Private Blob. Used by caam_config_t. */
typedef enum _caam_priblob
{
kCAAM_PrivSecureBootBlobs = 0U, /*!< Private secure boot software blobs. */
kCAAM_PrivProvisioningBlobsType1 = 1U, /*!< Private Provisioning Type 1 blobs. */
kCAAM_PrivProvisioningBlobsType2 = 2U, /*!< Private Provisioning Type 2 blobs. */
kCAAM_NormalOperationBlobs = 3U, /*!< Normal operation blobs. */
} caam_priblob_t;
/*! @brief CAAM configuration structure. */
typedef struct _caam_config
{
caam_job_ring_interface_t *jobRingInterface[4];
caam_rng_sample_mode_t rngSampleMode; /*!< RTMCTL Sample Mode. */
caam_rng_ring_osc_div_t rngRingOscDiv; /*!< RTMCTL Oscillator Divide. */
bool scfgrLockTrngProgramMode; /*!< SCFGR Lock TRNG Program Mode. */
bool scfgrEnableRandomDataBuffer; /*!< SCFGR Enable random data buffer. */
bool scfgrRandomRngStateHandle0; /*!< SCFGR Random Number Generator State Handle 0. */
bool scfgrRandomDpaResistance; /*!< SCFGR Random Differential Power Analysis Resistance. */
caam_priblob_t scfgrPriblob; /*!< SCFGR Private Blob. */
} caam_config_t;
/*! @brief CAAM External Key Transfer command SRC (The source from which the key will be obtained) */
typedef enum _caam_ext_key_xfr_source
{
kCAAM_ExtKeyXfr_KeyRegisterClass1 = 1U, /*!< The Class 1 Key Register is the source. */
kCAAM_ExtKeyXfr_KeyRegisterClass2 = 2U, /*!< The Class 2 Key Register is the source. */
kCAAM_ExtKeyXfr_PkhaRamE = 3U, /*!< The PKHA E RAM is the source. */
} caam_ext_key_xfr_source_t;
/*! @} */ /* end of caam_driver */
/*******************************************************************************
* AES Definitions
*******************************************************************************/
/*!
* @addtogroup caam_driver_aes
* @{
*/
/*! AES block size in bytes */
#define CAAM_AES_BLOCK_SIZE 16
/*!
*@}
*/ /* end of caam_driver_aes */
/*******************************************************************************
* DES Definitions
*******************************************************************************/
/*!
* @addtogroup caam_driver_des
* @{
*/
/*! @brief CAAM DES key size - 64 bits. */
#define CAAM_DES_KEY_SIZE 8U
/*! @brief CAAM DES IV size - 8 bytes */
#define CAAM_DES_IV_SIZE 8
/*!
*@}
*/ /* end of caam_driver_des */
/*******************************************************************************
* HASH Definitions
******************************************************************************/
/*!
* @addtogroup caam_driver_hash
* @{
*/
/*! @brief Supported cryptographic block cipher functions for HASH creation */
typedef enum _caam_hash_algo_t
{
kCAAM_XcbcMac = 0, /*!< XCBC-MAC (AES engine) */
kCAAM_Cmac, /*!< CMAC (AES engine) */
kCAAM_Sha1, /*!< SHA_1 (MDHA engine) */
kCAAM_Sha224, /*!< SHA_224 (MDHA engine) */
kCAAM_Sha256, /*!< SHA_256 (MDHA engine) */
kCAAM_Sha384, /*!< SHA_384 (MDHA engine) */
kCAAM_Sha512, /*!< SHA_512 (MDHA engine) */
} caam_hash_algo_t;
/*! @brief CAAM HASH Context size. */
#define CAAM_SHA_BLOCK_SIZE 128U /*!< up to SHA-512 block size */
#define CAAM_HASH_BLOCK_SIZE CAAM_SHA_BLOCK_SIZE /*!< CAAM hash block size */
/*! @brief CAAM HASH Context size. */
#define CAAM_HASH_CTX_SIZE 58
/*! @brief Storage type used to save hash context. */
typedef uint32_t caam_hash_ctx_t[CAAM_HASH_CTX_SIZE];
/*!
*@}
*/ /* end of caam_driver_hash */
/*******************************************************************************
* RNG Definitions
******************************************************************************/
/*!
* @addtogroup caam_driver_rng
* @{
*/
/*! @brief CAAM RNG state handle */
typedef enum _caam_rng_state_handle
{
kCAAM_RngStateHandle0 = 0u, /*!< CAAM RNG state handle 0 */
kCAAM_RngStateHandle1 = 1u, /*!< CAAM RNG state handle 1 */
} caam_rng_state_handle_t;
/*! @brief Type of random data to generate */
typedef enum _caam_rng_random_type
{
kCAAM_RngDataAny = 0u, /*!< CAAM RNG any random data bytes */
kCAAM_RngDataOddParity = 1u, /*!< CAAM RNG odd parity random data bytes */
kCAAM_RngDataNonZero = 2u, /*!< CAAM RNG non zero random data bytes */
} caam_rng_random_type_t;
/*! @brief 256-bit value used as optional additional entropy input */
typedef uint32_t caam_rng_generic256_t[256 / sizeof(uint32_t)];
/*! @brief CAAM RNG configuration */
typedef struct _caam_rng_user_config
{
uint32_t autoReseedInterval; /*!< Automatic reseed internal. If set to zero, CAAM RNG will use hardware default
interval of 10.000.000 generate requests. */
caam_rng_generic256_t *personalString; /*!< NULL or pointer to optional personalization string */
} caam_rng_config_t;
/*!
*@}
*/ /* end of caam_driver_rng */
/*******************************************************************************
* PKHA Definitions
******************************************************************************/
/*!
* @addtogroup caam_driver_pkha
* @{
*/
/*! PKHA ECC point structure */
typedef struct _caam_pkha_ecc_point_t
{
uint8_t *X; /*!< X coordinate (affine) */
uint8_t *Y; /*!< Y coordinate (affine) */
} caam_pkha_ecc_point_t;
/*! @brief Use of timing equalized version of a PKHA function. */
typedef enum _caam_pkha_timing_t
{
kCAAM_PKHA_NoTimingEqualized = 0U, /*!< Normal version of a PKHA operation */
kCAAM_PKHA_TimingEqualized = 1U /*!< Timing-equalized version of a PKHA operation */
} caam_pkha_timing_t;
/*! @brief Integer vs binary polynomial arithmetic selection. */
typedef enum _caam_pkha_f2m_t
{
kCAAM_PKHA_IntegerArith = 0U, /*!< Use integer arithmetic */
kCAAM_PKHA_F2mArith = 1U /*!< Use binary polynomial arithmetic */
} caam_pkha_f2m_t;
/*! @brief Montgomery or normal PKHA input format. */
typedef enum _caam_pkha_montgomery_form_t
{
kCAAM_PKHA_NormalValue = 0U, /*!< PKHA number is normal integer */
kCAAM_PKHA_MontgomeryFormat = 1U /*!< PKHA number is in montgomery format */
} caam_pkha_montgomery_form_t;
/*!
*@}
*/ /* end of caam_driver_pkha */
/*******************************************************************************
* API
******************************************************************************/
#if defined(__cplusplus)
extern "C" {
#endif
/*!
* @addtogroup caam_driver
* @{
*/
/*!
* @brief Initializes the CAAM driver.
*
* This function initializes the CAAM driver, including CAAM's internal RNG.
* @param base CAAM peripheral base address
* @param config Pointer to configuration structure.
* @return kStatus_Success the CAAM Init has completed with zero termination status word
* @return kStatus_Fail the CAAM Init has completed with non-zero termination status word
*/
status_t CAAM_Init(CAAM_Type *base, const caam_config_t *config);
/*!
* @brief Deinitializes the CAAM driver.
* This function deinitializes the CAAM driver.
* @param base CAAM peripheral base address
* @return kStatus_Success the CAAM Deinit has completed with zero termination status word
* @return kStatus_Fail the CAAM Deinit has completed with non-zero termination status word
*/
status_t CAAM_Deinit(CAAM_Type *base);
/*!
* @brief Gets the default configuration structure.
*
* This function initializes the CAAM configuration structure to a default value. The default
* values are as follows.
* caamConfig->rngSampleMode = kCAAM_RNG_SampleModeVonNeumann;
* caamConfig->rngRingOscDiv = kCAAM_RNG_RingOscDiv4;
*
* @param[out] config Pointer to configuration structure.
*/
void CAAM_GetDefaultConfig(caam_config_t *config);
/*!
* @brief Wait for a CAAM job to complete.
*
* This function polls CAAM output ring for a specific job.
*
* The CAAM job ring is specified by the jobRing field in the caam_handle_t structure.
* The job to be waited is specified by it's descriptor address.
*
* This function has two modes, determined by the mode argument.
* In blocking mode, the function polls the specified jobRing until the descriptor
* is available in the CAAM output job ring.
* In non-blocking mode, it polls the output ring once and returns status
* immediately.
*
* The function can be called from multiple threads or interrupt service routines,
* as internally it uses global critical section (global interrupt disable enable)
* to protect it's operation against concurrent accesses.
* The global interrupt is disabled only when the descriptor is found
* in the output ring, for a very short time, to remove the descriptor from the output ring
* safely.
*
* @param base CAAM peripheral base address
* @param handle Data structure with CAAM jobRing used for this request
* @param descriptor
* @param mode Blocking and non-blocking mode. Zero is blocking. Non-zero is non-blocking.
* @return kStatus_Success the CAAM job has completed with zero job termination status word
* @return kStatus_Fail the CAAM job has completed with non-zero job termination status word
* @return kStatus_Again In non-blocking mode, the job is not ready in the CAAM Output Ring
*/
status_t CAAM_Wait(CAAM_Type *base, caam_handle_t *handle, uint32_t *descriptor, caam_wait_mode_t mode);
/*!
* @brief External Key Transfer.
*
* This function loads the given key source to an CAAM external destination via a private interface,
* such as Inline Encryption Engine IEE Private Key bus.
*
* The CAAM job ring is specified by the jobRing field in the caam_handle_t structure.
*
* This function is blocking.
*
* @param base CAAM peripheral base address
* @param handle Data structure with CAAM jobRing used for this request.
* @param keySource The source from which the key will be obtained.
* @param keySize Size of the key in bytes.
* @return kStatus_Success the CAAM job has completed with zero job termination status word
* @return kStatus_Fail the CAAM job has completed with non-zero job termination status word
*/
status_t CAAM_ExternalKeyTransfer(CAAM_Type *base,
caam_handle_t *handle,
caam_ext_key_xfr_source_t keySource,
size_t keySize);
/*!
*@}
*/ /* end of caam_driver */
/*******************************************************************************
* AES API
******************************************************************************/
/*!
* @addtogroup caam_driver_aes
* @{
*/
/*!
* @brief Encrypts AES using the ECB block mode.
*
* Encrypts AES using the ECB block mode.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param plaintext Input plain text to encrypt
* @param[out] ciphertext Output cipher text
* @param size Size of input and output data in bytes. Must be multiple of 16 bytes.
* @param key Input key to use for encryption
* @param keySize Size of the input key, in bytes. Must be 16, 24, or 32.
* @return Status from encrypt operation
*/
status_t CAAM_AES_EncryptEcb(CAAM_Type *base,
caam_handle_t *handle,
const uint8_t *plaintext,
uint8_t *ciphertext,
size_t size,
const uint8_t *key,
size_t keySize);
/*!
* @brief Decrypts AES using ECB block mode.
*
* Decrypts AES using ECB block mode.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param ciphertext Input cipher text to decrypt
* @param[out] plaintext Output plain text
* @param size Size of input and output data in bytes. Must be multiple of 16 bytes.
* @param key Input key.
* @param keySize Size of the input key, in bytes. Must be 16, 24, or 32.
* @return Status from decrypt operation
*/
status_t CAAM_AES_DecryptEcb(CAAM_Type *base,
caam_handle_t *handle,
const uint8_t *ciphertext,
uint8_t *plaintext,
size_t size,
const uint8_t *key,
size_t keySize);
/*!
* @brief Encrypts AES using CBC block mode.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param plaintext Input plain text to encrypt
* @param[out] ciphertext Output cipher text
* @param size Size of input and output data in bytes. Must be multiple of 16 bytes.
* @param iv Input initial vector to combine with the first input block.
* @param key Input key to use for encryption
* @param keySize Size of the input key, in bytes. Must be 16, 24, or 32.
* @return Status from encrypt operation
*/
status_t CAAM_AES_EncryptCbc(CAAM_Type *base,
caam_handle_t *handle,
const uint8_t *plaintext,
uint8_t *ciphertext,
size_t size,
const uint8_t iv[CAAM_AES_BLOCK_SIZE],
const uint8_t *key,
size_t keySize);
/*!
* @brief Decrypts AES using CBC block mode.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param ciphertext Input cipher text to decrypt
* @param[out] plaintext Output plain text
* @param size Size of input and output data in bytes. Must be multiple of 16 bytes.
* @param iv Input initial vector to combine with the first input block.
* @param key Input key to use for decryption
* @param keySize Size of the input key, in bytes. Must be 16, 24, or 32.
* @return Status from decrypt operation
*/
status_t CAAM_AES_DecryptCbc(CAAM_Type *base,
caam_handle_t *handle,
const uint8_t *ciphertext,
uint8_t *plaintext,
size_t size,
const uint8_t iv[CAAM_AES_BLOCK_SIZE],
const uint8_t *key,
size_t keySize);
/*!
* @brief Encrypts or decrypts AES using CTR block mode.
*
* Encrypts or decrypts AES using CTR block mode.
* AES CTR mode uses only forward AES cipher and same algorithm for encryption and decryption.
* The only difference between encryption and decryption is that, for encryption, the input argument
* is plain text and the output argument is cipher text. For decryption, the input argument is cipher text
* and the output argument is plain text.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param input Input data for CTR block mode
* @param[out] output Output data for CTR block mode
* @param size Size of input and output data in bytes
* @param[in,out] counter Input counter (updates on return)
* @param key Input key to use for forward AES cipher
* @param keySize Size of the input key, in bytes. Must be 16, 24, or 32.
* @param[out] counterlast Output cipher of last counter, for chained CTR calls. NULL can be passed if chained calls are
* not used.
* @param[out] szLeft Output number of bytes in left unused in counterlast block. NULL can be passed if chained calls
* are not used.
* @return Status from encrypt operation
*/
status_t CAAM_AES_CryptCtr(CAAM_Type *base,
caam_handle_t *handle,
const uint8_t *input,
uint8_t *output,
size_t size,
uint8_t counter[CAAM_AES_BLOCK_SIZE],
const uint8_t *key,
size_t keySize,
uint8_t counterlast[CAAM_AES_BLOCK_SIZE],
size_t *szLeft);
/*!
* @brief Encrypts AES and tags using CCM block mode.
*
* Encrypts AES and optionally tags using CCM block mode.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param plaintext Input plain text to encrypt
* @param[out] ciphertext Output cipher text.
* @param size Size of input and output data in bytes. Zero means authentication only.
* @param iv Nonce
* @param ivSize Length of the Nonce in bytes. Must be 7, 8, 9, 10, 11, 12, or 13.
* @param aad Input additional authentication data. Can be NULL if aadSize is zero.
* @param aadSize Input size in bytes of AAD. Zero means data mode only (authentication skipped).
* @param key Input key to use for encryption
* @param keySize Size of the input key, in bytes. Must be 16, 24, or 32.
* @param[out] tag Generated output tag. Set to NULL to skip tag processing.
* @param tagSize Input size of the tag to generate, in bytes. Must be 4, 6, 8, 10, 12, 14, or 16.
* @return Status from encrypt operation
*/
status_t CAAM_AES_EncryptTagCcm(CAAM_Type *base,
caam_handle_t *handle,
const uint8_t *plaintext,
uint8_t *ciphertext,
size_t size,
const uint8_t *iv,
size_t ivSize,
const uint8_t *aad,
size_t aadSize,
const uint8_t *key,
size_t keySize,
uint8_t *tag,
size_t tagSize);
/*!
* @brief Decrypts AES and authenticates using CCM block mode.
*
* Decrypts AES and optionally authenticates using CCM block mode.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param ciphertext Input cipher text to decrypt
* @param[out] plaintext Output plain text.
* @param size Size of input and output data in bytes. Zero means authentication data only.
* @param iv Nonce
* @param ivSize Length of the Nonce in bytes. Must be 7, 8, 9, 10, 11, 12, or 13.
* @param aad Input additional authentication data. Can be NULL if aadSize is zero.
* @param aadSize Input size in bytes of AAD. Zero means data mode only (authentication data skipped).
* @param key Input key to use for decryption
* @param keySize Size of the input key, in bytes. Must be 16, 24, or 32.
* @param tag Received tag. Set to NULL to skip tag processing.
* @param tagSize Input size of the received tag to compare with the computed tag, in bytes. Must be 4, 6, 8, 10, 12,
* 14, or 16.
* @return Status from decrypt operation
*/
status_t CAAM_AES_DecryptTagCcm(CAAM_Type *base,
caam_handle_t *handle,
const uint8_t *ciphertext,
uint8_t *plaintext,
size_t size,
const uint8_t *iv,
size_t ivSize,
const uint8_t *aad,
size_t aadSize,
const uint8_t *key,
size_t keySize,
const uint8_t *tag,
size_t tagSize);
/*!
* @brief Encrypts AES and tags using GCM block mode.
*
* Encrypts AES and optionally tags using GCM block mode. If plaintext is NULL, only the GHASH is calculated and output
* in the 'tag' field.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param plaintext Input plain text to encrypt
* @param[out] ciphertext Output cipher text.
* @param size Size of input and output data in bytes
* @param iv Input initial vector
* @param ivSize Size of the IV
* @param aad Input additional authentication data
* @param aadSize Input size in bytes of AAD
* @param key Input key to use for encryption
* @param keySize Size of the input key, in bytes. Must be 16, 24, or 32.
* @param[out] tag Output hash tag. Set to NULL to skip tag processing.
* @param tagSize Input size of the tag to generate, in bytes. Must be 4,8,12,13,14,15 or 16.
* @return Status from encrypt operation
*/
status_t CAAM_AES_EncryptTagGcm(CAAM_Type *base,
caam_handle_t *handle,
const uint8_t *plaintext,
uint8_t *ciphertext,
size_t size,
const uint8_t *iv,
size_t ivSize,
const uint8_t *aad,
size_t aadSize,
const uint8_t *key,
size_t keySize,
uint8_t *tag,
size_t tagSize);
/*!
* @brief Decrypts AES and authenticates using GCM block mode.
*
* Decrypts AES and optionally authenticates using GCM block mode. If ciphertext is NULL, only the GHASH is calculated
* and compared with the received GHASH in 'tag' field.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param ciphertext Input cipher text to decrypt
* @param[out] plaintext Output plain text.
* @param size Size of input and output data in bytes
* @param iv Input initial vector
* @param ivSize Size of the IV
* @param aad Input additional authentication data
* @param aadSize Input size in bytes of AAD
* @param key Input key to use for encryption
* @param keySize Size of the input key, in bytes. Must be 16, 24, or 32.
* @param tag Input hash tag to compare. Set to NULL to skip tag processing.
* @param tagSize Input size of the tag, in bytes. Must be 4, 8, 12, 13, 14, 15, or 16.
* @return Status from decrypt operation
*/
status_t CAAM_AES_DecryptTagGcm(CAAM_Type *base,
caam_handle_t *handle,
const uint8_t *ciphertext,
uint8_t *plaintext,
size_t size,
const uint8_t *iv,
size_t ivSize,
const uint8_t *aad,
size_t aadSize,
const uint8_t *key,
size_t keySize,
const uint8_t *tag,
size_t tagSize);
/*!
*@}
*/ /* end of caam_driver_aes */
/*!
* @addtogroup caam_nonblocking_driver_aes
* @{
*/
/*!
* @brief Encrypts AES using the ECB block mode.
*
* Puts AES ECB encrypt descriptor to CAAM input job ring.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param plaintext Input plain text to encrypt
* @param[out] descriptor Memory for the CAAM descriptor.
* @param[out] ciphertext Output cipher text
* @param size Size of input and output data in bytes. Must be multiple of 16 bytes.
* @param key Input key to use for encryption
* @param keySize Size of the input key, in bytes. Must be 16, 24, or 32.
* @return Status from job descriptor push
*/
status_t CAAM_AES_EncryptEcbNonBlocking(CAAM_Type *base,
caam_handle_t *handle,
caam_desc_aes_ecb_t descriptor,
const uint8_t *plaintext,
uint8_t *ciphertext,
size_t size,
const uint8_t *key,
size_t keySize);
/*!
* @brief Decrypts AES using ECB block mode.
*
* Puts AES ECB decrypt descriptor to CAAM input job ring.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param[out] descriptor Memory for the CAAM descriptor.
* @param ciphertext Input cipher text to decrypt
* @param[out] plaintext Output plain text
* @param size Size of input and output data in bytes. Must be multiple of 16 bytes.
* @param key Input key.
* @param keySize Size of the input key, in bytes. Must be 16, 24, or 32.
* @return Status from job descriptor push
*/
status_t CAAM_AES_DecryptEcbNonBlocking(CAAM_Type *base,
caam_handle_t *handle,
caam_desc_aes_ecb_t descriptor,
const uint8_t *ciphertext,
uint8_t *plaintext,
size_t size,
const uint8_t *key,
size_t keySize);
/*!
* @brief Encrypts AES using CBC block mode.
*
* Puts AES CBC encrypt descriptor to CAAM input job ring.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param[out] descriptor Memory for the CAAM descriptor.
* @param plaintext Input plain text to encrypt
* @param[out] ciphertext Output cipher text
* @param size Size of input and output data in bytes. Must be multiple of 16 bytes.
* @param iv Input initial vector to combine with the first input block.
* @param key Input key to use for encryption
* @param keySize Size of the input key, in bytes. Must be 16, 24, or 32.
* @return Status from job descriptor push
*/
status_t CAAM_AES_EncryptCbcNonBlocking(CAAM_Type *base,
caam_handle_t *handle,
caam_desc_aes_cbc_t descriptor,
const uint8_t *plaintext,
uint8_t *ciphertext,
size_t size,
const uint8_t *iv,
const uint8_t *key,
size_t keySize);
/*!
* @brief Decrypts AES using CBC block mode.
*
* Puts AES CBC decrypt descriptor to CAAM input job ring.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param[out] descriptor Memory for the CAAM descriptor.
* @param ciphertext Input cipher text to decrypt
* @param[out] plaintext Output plain text
* @param size Size of input and output data in bytes. Must be multiple of 16 bytes.
* @param iv Input initial vector to combine with the first input block.
* @param key Input key to use for decryption
* @param keySize Size of the input key, in bytes. Must be 16, 24, or 32.
* @return Status from job descriptor push
*/
status_t CAAM_AES_DecryptCbcNonBlocking(CAAM_Type *base,
caam_handle_t *handle,
caam_desc_aes_cbc_t descriptor,
const uint8_t *ciphertext,
uint8_t *plaintext,
size_t size,
const uint8_t *iv,
const uint8_t *key,
size_t keySize);
/*!
* @brief Encrypts or decrypts AES using CTR block mode.
*
* Encrypts or decrypts AES using CTR block mode.
* AES CTR mode uses only forward AES cipher and same algorithm for encryption and decryption.
* The only difference between encryption and decryption is that, for encryption, the input argument
* is plain text and the output argument is cipher text. For decryption, the input argument is cipher text
* and the output argument is plain text.
*
* Puts AES CTR crypt descriptor to CAAM input job ring.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param[out] descriptor Memory for the CAAM descriptor.
* @param input Input data for CTR block mode
* @param[out] output Output data for CTR block mode
* @param size Size of input and output data in bytes
* @param[in,out] counter Input counter (updates on return)
* @param key Input key to use for forward AES cipher
* @param keySize Size of the input key, in bytes. Must be 16, 24, or 32.
* @param[out] counterlast Output cipher of last counter, for chained CTR calls. NULL can be passed if chained calls are
* not used.
* @param[out] szLeft Output number of bytes in left unused in counterlast block. NULL can be passed if chained calls
* are not used.
* @return Status from job descriptor push
*/
status_t CAAM_AES_CryptCtrNonBlocking(CAAM_Type *base,
caam_handle_t *handle,
caam_desc_aes_ctr_t descriptor,
const uint8_t *input,
uint8_t *output,
size_t size,
uint8_t *counter,
const uint8_t *key,
size_t keySize,
uint8_t *counterlast,
size_t *szLeft);
/*!
* @brief Encrypts AES and tags using CCM block mode.
*
* Puts AES CCM encrypt and tag descriptor to CAAM input job ring.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param[out] descriptor Memory for the CAAM descriptor.
* @param plaintext Input plain text to encrypt
* @param[out] ciphertext Output cipher text.
* @param size Size of input and output data in bytes. Zero means authentication only.
* @param iv Nonce
* @param ivSize Length of the Nonce in bytes. Must be 7, 8, 9, 10, 11, 12, or 13.
* @param aad Input additional authentication data. Can be NULL if aadSize is zero.
* @param aadSize Input size in bytes of AAD. Zero means data mode only (authentication skipped).
* @param key Input key to use for encryption
* @param keySize Size of the input key, in bytes. Must be 16, 24, or 32.
* @param[out] tag Generated output tag. Set to NULL to skip tag processing.
* @param tagSize Input size of the tag to generate, in bytes. Must be 4, 6, 8, 10, 12, 14, or 16.
* @return Status from job descriptor push
*/
status_t CAAM_AES_EncryptTagCcmNonBlocking(CAAM_Type *base,
caam_handle_t *handle,
caam_desc_aes_ccm_t descriptor,
const uint8_t *plaintext,
uint8_t *ciphertext,
size_t size,
const uint8_t *iv,
size_t ivSize,
const uint8_t *aad,
size_t aadSize,
const uint8_t *key,
size_t keySize,
uint8_t *tag,
size_t tagSize);
/*!
* @brief Decrypts AES and authenticates using CCM block mode.
*
* Puts AES CCM decrypt and check tag descriptor to CAAM input job ring.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param[out] descriptor Memory for the CAAM descriptor.
* @param ciphertext Input cipher text to decrypt
* @param[out] plaintext Output plain text.
* @param size Size of input and output data in bytes. Zero means authentication data only.
* @param iv Nonce
* @param ivSize Length of the Nonce in bytes. Must be 7, 8, 9, 10, 11, 12, or 13.
* @param aad Input additional authentication data. Can be NULL if aadSize is zero.
* @param aadSize Input size in bytes of AAD. Zero means data mode only (authentication data skipped).
* @param key Input key to use for decryption
* @param keySize Size of the input key, in bytes. Must be 16, 24, or 32.
* @param tag Received tag. Set to NULL to skip tag processing.
* @param tagSize Input size of the received tag to compare with the computed tag, in bytes. Must be 4, 6, 8, 10, 12,
* 14, or 16.
* @return Status from job descriptor push
*/
status_t CAAM_AES_DecryptTagCcmNonBlocking(CAAM_Type *base,
caam_handle_t *handle,
caam_desc_aes_ccm_t descriptor,
const uint8_t *ciphertext,
uint8_t *plaintext,
size_t size,
const uint8_t *iv,
size_t ivSize,
const uint8_t *aad,
size_t aadSize,
const uint8_t *key,
size_t keySize,
const uint8_t *tag,
size_t tagSize);
/*!
* @brief Encrypts AES and tags using GCM block mode.
*
* Encrypts AES and optionally tags using GCM block mode. If plaintext is NULL, only the GHASH is calculated and output
* in the 'tag' field.
* Puts AES GCM encrypt and tag descriptor to CAAM input job ring.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param[out] descriptor Memory for the CAAM descriptor.
* @param plaintext Input plain text to encrypt
* @param[out] ciphertext Output cipher text.
* @param size Size of input and output data in bytes
* @param iv Input initial vector
* @param ivSize Size of the IV
* @param aad Input additional authentication data
* @param aadSize Input size in bytes of AAD
* @param key Input key to use for encryption
* @param keySize Size of the input key, in bytes. Must be 16, 24, or 32.
* @param[out] tag Output hash tag. Set to NULL to skip tag processing.
* @param tagSize Input size of the tag to generate, in bytes. Must be 4,8,12,13,14,15 or 16.
* @return Status from job descriptor push
*/
status_t CAAM_AES_EncryptTagGcmNonBlocking(CAAM_Type *base,
caam_handle_t *handle,
caam_desc_aes_gcm_t descriptor,
const uint8_t *plaintext,
uint8_t *ciphertext,
size_t size,
const uint8_t *iv,
size_t ivSize,
const uint8_t *aad,
size_t aadSize,
const uint8_t *key,
size_t keySize,
uint8_t *tag,
size_t tagSize);
/*!
* @brief Decrypts AES and authenticates using GCM block mode.
*
* Decrypts AES and optionally authenticates using GCM block mode. If ciphertext is NULL, only the GHASH is calculated
* and compared with the received GHASH in 'tag' field.
* Puts AES GCM decrypt and check tag descriptor to CAAM input job ring.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param[out] descriptor Memory for the CAAM descriptor.
* @param ciphertext Input cipher text to decrypt
* @param[out] plaintext Output plain text.
* @param size Size of input and output data in bytes
* @param iv Input initial vector
* @param ivSize Size of the IV
* @param aad Input additional authentication data
* @param aadSize Input size in bytes of AAD
* @param key Input key to use for encryption
* @param keySize Size of the input key, in bytes. Must be 16, 24, or 32.
* @param tag Input hash tag to compare. Set to NULL to skip tag processing.
* @param tagSize Input size of the tag, in bytes. Must be 4, 8, 12, 13, 14, 15, or 16.
* @return Status from job descriptor push
*/
status_t CAAM_AES_DecryptTagGcmNonBlocking(CAAM_Type *base,
caam_handle_t *handle,
caam_desc_aes_gcm_t descriptor,
const uint8_t *ciphertext,
uint8_t *plaintext,
size_t size,
const uint8_t *iv,
size_t ivSize,
const uint8_t *aad,
size_t aadSize,
const uint8_t *key,
size_t keySize,
const uint8_t *tag,
size_t tagSize);
/*!
*@}
*/ /* end of caam_nonblocking_driver_aes */
/*******************************************************************************
* HASH API
******************************************************************************/
/*!
* @addtogroup caam_driver_hash
* @{
*/
/*!
* @brief Initialize HASH context
*
* This function initializes the HASH.
* Key shall be supplied if the underlaying algoritm is AES XCBC-MAC or CMAC.
* Key shall be NULL if the underlaying algoritm is SHA.
*
* For XCBC-MAC, the key length must be 16. For CMAC, the key length can be
* the AES key lengths supported by AES engine. For MDHA the key length argument
* is ignored.
*
* This functions is used to initialize the context for both blocking and non-blocking
* CAAM_HASH API.
* For blocking CAAM HASH API, the HASH context contains all information required for context switch,
* such as running hash or MAC. For non-blocking CAAM HASH API, the HASH context is used
* to hold SGT. Therefore, the HASH context cannot be shared between blocking and non-blocking HASH API.
* With one HASH context, either use only blocking HASH API or only non-blocking HASH API.
*
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request.
* @param[out] ctx Output hash context
* @param algo Underlaying algorithm to use for hash computation.
* @param key Input key (NULL if underlaying algorithm is SHA)
* @param keySize Size of input key in bytes
* @return Status of initialization
*/
status_t CAAM_HASH_Init(CAAM_Type *base,
caam_handle_t *handle,
caam_hash_ctx_t *ctx,
caam_hash_algo_t algo,
const uint8_t *key,
size_t keySize);
/*!
* @brief Add data to current HASH
*
* Add data to current HASH. This can be called repeatedly with an arbitrary amount of data to be
* hashed. The functions blocks. If it returns kStatus_Success, the running hash or mac
* has been updated (CAAM has processed the input data), so the memory at input pointer
* can be released back to system. The context is updated with the running hash or mac
* and with all necessary information to support possible context switch.
*
* @param[in,out] ctx HASH context
* @param input Input data
* @param inputSize Size of input data in bytes
* @return Status of the hash update operation
*/
status_t CAAM_HASH_Update(caam_hash_ctx_t *ctx, const uint8_t *input, size_t inputSize);
/*!
* @brief Finalize hashing
*
* Outputs the final hash (computed by CAAM_HASH_Update()) and erases the context.
*
* @param[in,out] ctx Input hash context
* @param[out] output Output hash data
* @param[out] outputSize Output parameter storing the size of the output hash in bytes
* @return Status of the hash finish operation
*/
status_t CAAM_HASH_Finish(caam_hash_ctx_t *ctx, uint8_t *output, size_t *outputSize);
/*!
* @brief Create HASH on given data
*
* Perform the full keyed XCBC-MAC/CMAC or SHA in one function call.
*
* Key shall be supplied if the underlaying algoritm is AES XCBC-MAC or CMAC.
* Key shall be NULL if the underlaying algoritm is SHA.
*
* For XCBC-MAC, the key length must be 16. For CMAC, the key length can be
* the AES key lengths supported by AES engine. For MDHA the key length argument
* is ignored.
*
* The function is blocking.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request.
* @param algo Underlaying algorithm to use for hash computation.
* @param input Input data
* @param inputSize Size of input data in bytes
* @param key Input key (NULL if underlaying algorithm is SHA)
* @param keySize Size of input key in bytes
* @param[out] output Output hash data
* @param[out] outputSize Output parameter storing the size of the output hash in bytes
* @return Status of the one call hash operation.
*/
status_t CAAM_HASH(CAAM_Type *base,
caam_handle_t *handle,
caam_hash_algo_t algo,
const uint8_t *input,
size_t inputSize,
const uint8_t *key,
size_t keySize,
uint8_t *output,
size_t *outputSize);
/*!
*@}
*/ /* end of caam_driver_hash */
/*!
* @addtogroup caam_nonblocking_driver_hash
* @{
*/
/*!
* @brief Add input address and size to input data table
*
* Add data input pointer to a table maintained internally in the context.
* Each call of this function creates one entry in the table.
* The entry consists of the input pointer and inputSize.
* All entries created by one or multiple calls of this function can be processed
* in one call to CAAM_HASH_FinishNonBlocking() function.
* Individual entries can point to non-continuous data in the memory.
* The processing will occur in the order in which the CAAM_HASH_UpdateNonBlocking()
* have been called.
*
* Memory pointers will be later accessed by CAAM (at time of CAAM_HASH_FinishNonBlocking()),
* so the memory must stay valid
* until CAAM_HASH_FinishNonBlocking() has been called and CAAM completes the processing.
*
* @param[in,out] ctx HASH context
* @param input Input data
* @param inputSize Size of input data in bytes
* @return Status of the hash update operation
*/
status_t CAAM_HASH_UpdateNonBlocking(caam_hash_ctx_t *ctx, const uint8_t *input, size_t inputSize);
/*!
* @brief Finalize hashing
*
* The actual algorithm is computed with all input data, the memory pointers
* are accessed by CAAM after the function returns.
* The input data chunks have been specified by prior calls to CAAM_HASH_UpdateNonBlocking().
* The function schedules the request at CAAM, then returns.
* After a while, when the CAAM completes processing of the input data chunks,
* the result is written to the output[] array, outputSize is written and the context
* is cleared.
*
* @param[in,out] ctx Input hash context
* @param[out] descriptor Memory for the CAAM descriptor.
* @param[out] output Output hash data
* @param[out] outputSize Output parameter storing the size of the output hash in bytes
* @return Status of the hash finish operation
*/
status_t CAAM_HASH_FinishNonBlocking(caam_hash_ctx_t *ctx,
caam_desc_hash_t descriptor,
uint8_t *output,
size_t *outputSize);
/*!
* @brief Create HASH on given data
*
* Perform the full keyed XCBC-MAC/CMAC or SHA in one function call.
*
* Key shall be supplied if the underlaying algoritm is AES XCBC-MAC or CMAC.
* Key shall be NULL if the underlaying algoritm is SHA.
*
* For XCBC-MAC, the key length must be 16. For CMAC, the key length can be
* the AES key lengths supported by AES engine. For MDHA the key length argument
* is ignored.
*
* The function is non-blocking. The request is scheduled at CAAM.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request.
* @param[out] descriptor Memory for the CAAM descriptor.
* @param algo Underlaying algorithm to use for hash computation.
* @param input Input data
* @param inputSize Size of input data in bytes
* @param key Input key (NULL if underlaying algorithm is SHA)
* @param keySize Size of input key in bytes
* @param[out] output Output hash data
* @param[out] outputSize Output parameter storing the size of the output hash in bytes
* @return Status of the one call hash operation.
*/
status_t CAAM_HASH_NonBlocking(CAAM_Type *base,
caam_handle_t *handle,
caam_desc_hash_t descriptor,
caam_hash_algo_t algo,
const uint8_t *input,
size_t inputSize,
const uint8_t *key,
size_t keySize,
uint8_t *output,
size_t *outputSize);
/*!
*@}
*/ /* end of caam_nonblocking_driver_hash */
/*******************************************************************************
* RNG API
******************************************************************************/
/*!
* @addtogroup caam_driver_rng
* @{
*/
/*!
* @brief Initializes user configuration structure to default.
*
* This function initializes the configure structure to default value. the default
* value are:
* @code
* config->autoReseedInterval = 0;
* config->personalString = NULL;
* @endcode
*
* @param config User configuration structure.
* @return status of the request
*/
status_t CAAM_RNG_GetDefaultConfig(caam_rng_config_t *config);
/*!
* @brief Instantiate the CAAM RNG state handle
*
* This function instantiates CAAM RNG state handle.
* The function is blocking and returns after CAAM has processed the request.
*
* @param base CAAM peripheral base address
* @param handle CAAM jobRing used for this request
* @param stateHandle RNG state handle to instantiate
* @param config Pointer to configuration structure.
* @return Status of the request
*/
status_t CAAM_RNG_Init(CAAM_Type *base,
caam_handle_t *handle,
caam_rng_state_handle_t stateHandle,
const caam_rng_config_t *config);
/*!
* @brief Uninstantiate the CAAM RNG state handle
*
* This function uninstantiates CAAM RNG state handle.
* The function is blocking and returns after CAAM has processed the request.
*
* @param base CAAM peripheral base address
* @param handle jobRing used for this request.
* @param stateHandle RNG state handle to uninstantiate
* @return Status of the request
*/
status_t CAAM_RNG_Deinit(CAAM_Type *base, caam_handle_t *handle, caam_rng_state_handle_t stateHandle);
/*!
* @brief Generate Secure Key
*
* This function generates random data writes it to Secure Key registers.
* The function is blocking and returns after CAAM has processed the request.
* RNG state handle 0 is always used.
*
* @param base CAAM peripheral base address
* @param handle jobRing used for this request
* @param additionalEntropy NULL or Pointer to optional 256-bit additional entropy.
* @return Status of the request
*/
status_t CAAM_RNG_GenerateSecureKey(CAAM_Type *base, caam_handle_t *handle, caam_rng_generic256_t additionalEntropy);
/*!
* @brief Reseed the CAAM RNG state handle
*
* This function reseeds the CAAM RNG state handle.
* For a state handle in nondeterministic mode, the DRNG is seeded with 384 bits of
* entropy from the TRNG and an optional 256-bit additional input from the descriptor
* via the Class 1 Context Register.
*
* The function is blocking and returns after CAAM has processed the request.
*
* @param base CAAM peripheral base address
* @param handle jobRing used for this request
* @param stateHandle RNG state handle to reseed
* @param additionalEntropy NULL or Pointer to optional 256-bit additional entropy.
* @return Status of the request
*/
status_t CAAM_RNG_Reseed(CAAM_Type *base,
caam_handle_t *handle,
caam_rng_state_handle_t stateHandle,
caam_rng_generic256_t additionalEntropy);
/*!
* @brief Get random data
*
* This function gets random data from CAAM RNG.
*
* The function is blocking and returns after CAAM has generated the requested data or an error occurred.
*
* @param base CAAM peripheral base address
* @param handle jobRing used for this request
* @param stateHandle RNG state handle used to generate random data
* @param[out] data Pointer address used to store random data
* @param dataSize Size of the buffer pointed by the data parameter
* @param dataType Type of random data to be generated
* @param additionalEntropy NULL or Pointer to optional 256-bit additional entropy.
* @return Status of the request
*/
status_t CAAM_RNG_GetRandomData(CAAM_Type *base,
caam_handle_t *handle,
caam_rng_state_handle_t stateHandle,
uint8_t *data,
size_t dataSize,
caam_rng_random_type_t dataType,
caam_rng_generic256_t additionalEntropy);
/*!
*@}
*/ /* end of caam_driver_rng */
/*!
* @addtogroup caam_nonblocking_driver_rng
* @{
*/
/*!
* @brief Request random data
*
* This function schedules the request for random data from CAAM RNG.
* Memory at memory pointers will be accessed by CAAM shortly after this function
* returns, according to actual CAAM schedule.
*
* @param base CAAM peripheral base address
* @param handle RNG handle used for this request
* @param stateHandle RNG state handle used to generate random data
* @param[out] descriptor memory for CAAM commands
* @param[out] data Pointer address used to store random data
* @param dataSize Size of the buffer pointed by the data parameter, in bytes.
* @param dataType Type of random data to be generated.
* @param additionalEntropy NULL or Pointer to optional 256-bit additional entropy.
* @return status of the request
*/
status_t CAAM_RNG_GetRandomDataNonBlocking(CAAM_Type *base,
caam_handle_t *handle,
caam_rng_state_handle_t stateHandle,
caam_desc_rng_t descriptor,
void *data,
size_t dataSize,
caam_rng_random_type_t dataType,
caam_rng_generic256_t additionalEntropy);
/*!
*@}
*/ /* end of caam_nonblocking_driver_rng */
/*******************************************************************************
* DES API
******************************************************************************/
/*!
* @addtogroup caam_driver_des
* @{
*/
/*!
* @brief Encrypts DES using ECB block mode.
*
* Encrypts DES using ECB block mode.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param plaintext Input plaintext to encrypt
* @param[out] ciphertext Output ciphertext
* @param size Size of input and output data in bytes. Must be multiple of 8 bytes.
* @param key Input key to use for encryption
* @return Status from encrypt/decrypt operation
*/
status_t CAAM_DES_EncryptEcb(CAAM_Type *base,
caam_handle_t *handle,
const uint8_t *plaintext,
uint8_t *ciphertext,
size_t size,
const uint8_t key[CAAM_DES_KEY_SIZE]);
/*!
* @brief Decrypts DES using ECB block mode.
*
* Decrypts DES using ECB block mode.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param ciphertext Input ciphertext to decrypt
* @param[out] plaintext Output plaintext
* @param size Size of input and output data in bytes. Must be multiple of 8 bytes.
* @param key Input key to use for decryption
* @return Status from encrypt/decrypt operation
*/
status_t CAAM_DES_DecryptEcb(CAAM_Type *base,
caam_handle_t *handle,
const uint8_t *ciphertext,
uint8_t *plaintext,
size_t size,
const uint8_t key[CAAM_DES_KEY_SIZE]);
/*!
* @brief Encrypts DES using CBC block mode.
*
* Encrypts DES using CBC block mode.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param plaintext Input plaintext to encrypt
* @param[out] ciphertext Ouput ciphertext
* @param size Size of input and output data in bytes
* @param iv Input initial vector to combine with the first plaintext block.
* The iv does not need to be secret, but it must be unpredictable.
* @param key Input key to use for encryption
* @return Status from encrypt/decrypt operation
*/
status_t CAAM_DES_EncryptCbc(CAAM_Type *base,
caam_handle_t *handle,
const uint8_t *plaintext,
uint8_t *ciphertext,
size_t size,
const uint8_t iv[CAAM_DES_IV_SIZE],
const uint8_t key[CAAM_DES_KEY_SIZE]);
/*!
* @brief Decrypts DES using CBC block mode.
*
* Decrypts DES using CBC block mode.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param ciphertext Input ciphertext to decrypt
* @param[out] plaintext Output plaintext
* @param size Size of input data in bytes
* @param iv Input initial vector to combine with the first plaintext block.
* The iv does not need to be secret, but it must be unpredictable.
* @param key Input key to use for decryption
* @return Status from encrypt/decrypt operation
*/
status_t CAAM_DES_DecryptCbc(CAAM_Type *base,
caam_handle_t *handle,
const uint8_t *ciphertext,
uint8_t *plaintext,
size_t size,
const uint8_t iv[CAAM_DES_IV_SIZE],
const uint8_t key[CAAM_DES_KEY_SIZE]);
/*!
* @brief Encrypts DES using CFB block mode.
*
* Encrypts DES using CFB block mode.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param plaintext Input plaintext to encrypt
* @param size Size of input data in bytes
* @param iv Input initial block.
* @param key Input key to use for encryption
* @param[out] ciphertext Output ciphertext
* @return Status from encrypt/decrypt operation
*/
status_t CAAM_DES_EncryptCfb(CAAM_Type *base,
caam_handle_t *handle,
const uint8_t *plaintext,
uint8_t *ciphertext,
size_t size,
const uint8_t iv[CAAM_DES_IV_SIZE],
const uint8_t key[CAAM_DES_KEY_SIZE]);
/*!
* @brief Decrypts DES using CFB block mode.
*
* Decrypts DES using CFB block mode.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param ciphertext Input ciphertext to decrypt
* @param[out] plaintext Output plaintext
* @param size Size of input and output data in bytes
* @param iv Input initial block.
* @param key Input key to use for decryption
* @return Status from encrypt/decrypt operation
*/
status_t CAAM_DES_DecryptCfb(CAAM_Type *base,
caam_handle_t *handle,
const uint8_t *ciphertext,
uint8_t *plaintext,
size_t size,
const uint8_t iv[CAAM_DES_IV_SIZE],
const uint8_t key[CAAM_DES_KEY_SIZE]);
/*!
* @brief Encrypts DES using OFB block mode.
*
* Encrypts DES using OFB block mode.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param plaintext Input plaintext to encrypt
* @param[out] ciphertext Output ciphertext
* @param size Size of input and output data in bytes
* @param iv Input unique input vector. The OFB mode requires that the IV be unique
* for each execution of the mode under the given key.
* @param key Input key to use for encryption
* @return Status from encrypt/decrypt operation
*/
status_t CAAM_DES_EncryptOfb(CAAM_Type *base,
caam_handle_t *handle,
const uint8_t *plaintext,
uint8_t *ciphertext,
size_t size,
const uint8_t iv[CAAM_DES_IV_SIZE],
const uint8_t key[CAAM_DES_KEY_SIZE]);
/*!
* @brief Decrypts DES using OFB block mode.
*
* Decrypts DES using OFB block mode.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param ciphertext Input ciphertext to decrypt
* @param[out] plaintext Output plaintext
* @param size Size of input and output data in bytes. Must be multiple of 8 bytes.
* @param iv Input unique input vector. The OFB mode requires that the IV be unique
* for each execution of the mode under the given key.
* @param key Input key to use for decryption
* @return Status from encrypt/decrypt operation
*/
status_t CAAM_DES_DecryptOfb(CAAM_Type *base,
caam_handle_t *handle,
const uint8_t *ciphertext,
uint8_t *plaintext,
size_t size,
const uint8_t iv[CAAM_DES_IV_SIZE],
const uint8_t key[CAAM_DES_KEY_SIZE]);
/*!
* @brief Encrypts triple DES using ECB block mode with two keys.
*
* Encrypts triple DES using ECB block mode with two keys.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param plaintext Input plaintext to encrypt
* @param[out] ciphertext Output ciphertext
* @param size Size of input and output data in bytes. Must be multiple of 8 bytes.
* @param key1 First input key for key bundle
* @param key2 Second input key for key bundle
* @return Status from encrypt/decrypt operation
*/
status_t CAAM_DES2_EncryptEcb(CAAM_Type *base,
caam_handle_t *handle,
const uint8_t *plaintext,
uint8_t *ciphertext,
size_t size,
const uint8_t key1[CAAM_DES_KEY_SIZE],
const uint8_t key2[CAAM_DES_KEY_SIZE]);
/*!
* @brief Decrypts triple DES using ECB block mode with two keys.
*
* Decrypts triple DES using ECB block mode with two keys.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param ciphertext Input ciphertext to decrypt
* @param[out] plaintext Output plaintext
* @param size Size of input and output data in bytes. Must be multiple of 8 bytes.
* @param key1 First input key for key bundle
* @param key2 Second input key for key bundle
* @return Status from encrypt/decrypt operation
*/
status_t CAAM_DES2_DecryptEcb(CAAM_Type *base,
caam_handle_t *handle,
const uint8_t *ciphertext,
uint8_t *plaintext,
size_t size,
const uint8_t key1[CAAM_DES_KEY_SIZE],
const uint8_t key2[CAAM_DES_KEY_SIZE]);
/*!
* @brief Encrypts triple DES using CBC block mode with two keys.
*
* Encrypts triple DES using CBC block mode with two keys.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param plaintext Input plaintext to encrypt
* @param[out] ciphertext Output ciphertext
* @param size Size of input and output data in bytes
* @param iv Input initial vector to combine with the first plaintext block.
* The iv does not need to be secret, but it must be unpredictable.
* @param key1 First input key for key bundle
* @param key2 Second input key for key bundle
* @return Status from encrypt/decrypt operation
*/
status_t CAAM_DES2_EncryptCbc(CAAM_Type *base,
caam_handle_t *handle,
const uint8_t *plaintext,
uint8_t *ciphertext,
size_t size,
const uint8_t iv[CAAM_DES_IV_SIZE],
const uint8_t key1[CAAM_DES_KEY_SIZE],
const uint8_t key2[CAAM_DES_KEY_SIZE]);
/*!
* @brief Decrypts triple DES using CBC block mode with two keys.
*
* Decrypts triple DES using CBC block mode with two keys.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param ciphertext Input ciphertext to decrypt
* @param[out] plaintext Output plaintext
* @param size Size of input and output data in bytes
* @param iv Input initial vector to combine with the first plaintext block.
* The iv does not need to be secret, but it must be unpredictable.
* @param key1 First input key for key bundle
* @param key2 Second input key for key bundle
* @return Status from encrypt/decrypt operation
*/
status_t CAAM_DES2_DecryptCbc(CAAM_Type *base,
caam_handle_t *handle,
const uint8_t *ciphertext,
uint8_t *plaintext,
size_t size,
const uint8_t iv[CAAM_DES_IV_SIZE],
const uint8_t key1[CAAM_DES_KEY_SIZE],
const uint8_t key2[CAAM_DES_KEY_SIZE]);
/*!
* @brief Encrypts triple DES using CFB block mode with two keys.
*
* Encrypts triple DES using CFB block mode with two keys.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param plaintext Input plaintext to encrypt
* @param[out] ciphertext Output ciphertext
* @param size Size of input and output data in bytes
* @param iv Input initial block.
* @param key1 First input key for key bundle
* @param key2 Second input key for key bundle
* @return Status from encrypt/decrypt operation
*/
status_t CAAM_DES2_EncryptCfb(CAAM_Type *base,
caam_handle_t *handle,
const uint8_t *plaintext,
uint8_t *ciphertext,
size_t size,
const uint8_t iv[CAAM_DES_IV_SIZE],
const uint8_t key1[CAAM_DES_KEY_SIZE],
const uint8_t key2[CAAM_DES_KEY_SIZE]);
/*!
* @brief Decrypts triple DES using CFB block mode with two keys.
*
* Decrypts triple DES using CFB block mode with two keys.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param ciphertext Input ciphertext to decrypt
* @param[out] plaintext Output plaintext
* @param size Size of input and output data in bytes
* @param iv Input initial block.
* @param key1 First input key for key bundle
* @param key2 Second input key for key bundle
* @return Status from encrypt/decrypt operation
*/
status_t CAAM_DES2_DecryptCfb(CAAM_Type *base,
caam_handle_t *handle,
const uint8_t *ciphertext,
uint8_t *plaintext,
size_t size,
const uint8_t iv[CAAM_DES_IV_SIZE],
const uint8_t key1[CAAM_DES_KEY_SIZE],
const uint8_t key2[CAAM_DES_KEY_SIZE]);
/*!
* @brief Encrypts triple DES using OFB block mode with two keys.
*
* Encrypts triple DES using OFB block mode with two keys.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param plaintext Input plaintext to encrypt
* @param[out] ciphertext Output ciphertext
* @param size Size of input and output data in bytes
* @param iv Input unique input vector. The OFB mode requires that the IV be unique
* for each execution of the mode under the given key.
* @param key1 First input key for key bundle
* @param key2 Second input key for key bundle
* @return Status from encrypt/decrypt operation
*/
status_t CAAM_DES2_EncryptOfb(CAAM_Type *base,
caam_handle_t *handle,
const uint8_t *plaintext,
uint8_t *ciphertext,
size_t size,
const uint8_t iv[CAAM_DES_IV_SIZE],
const uint8_t key1[CAAM_DES_KEY_SIZE],
const uint8_t key2[CAAM_DES_KEY_SIZE]);
/*!
* @brief Decrypts triple DES using OFB block mode with two keys.
*
* Decrypts triple DES using OFB block mode with two keys.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param ciphertext Input ciphertext to decrypt
* @param[out] plaintext Output plaintext
* @param size Size of input and output data in bytes
* @param iv Input unique input vector. The OFB mode requires that the IV be unique
* for each execution of the mode under the given key.
* @param key1 First input key for key bundle
* @param key2 Second input key for key bundle
* @return Status from encrypt/decrypt operation
*/
status_t CAAM_DES2_DecryptOfb(CAAM_Type *base,
caam_handle_t *handle,
const uint8_t *ciphertext,
uint8_t *plaintext,
size_t size,
const uint8_t iv[CAAM_DES_IV_SIZE],
const uint8_t key1[CAAM_DES_KEY_SIZE],
const uint8_t key2[CAAM_DES_KEY_SIZE]);
/*!
* @brief Encrypts triple DES using ECB block mode with three keys.
*
* Encrypts triple DES using ECB block mode with three keys.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param plaintext Input plaintext to encrypt
* @param[out] ciphertext Output ciphertext
* @param size Size of input and output data in bytes. Must be multiple of 8 bytes.
* @param key1 First input key for key bundle
* @param key2 Second input key for key bundle
* @param key3 Third input key for key bundle
* @return Status from encrypt/decrypt operation
*/
status_t CAAM_DES3_EncryptEcb(CAAM_Type *base,
caam_handle_t *handle,
const uint8_t *plaintext,
uint8_t *ciphertext,
size_t size,
const uint8_t key1[CAAM_DES_KEY_SIZE],
const uint8_t key2[CAAM_DES_KEY_SIZE],
const uint8_t key3[CAAM_DES_KEY_SIZE]);
/*!
* @brief Decrypts triple DES using ECB block mode with three keys.
*
* Decrypts triple DES using ECB block mode with three keys.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param ciphertext Input ciphertext to decrypt
* @param[out] plaintext Output plaintext
* @param size Size of input and output data in bytes. Must be multiple of 8 bytes.
* @param key1 First input key for key bundle
* @param key2 Second input key for key bundle
* @param key3 Third input key for key bundle
* @return Status from encrypt/decrypt operation
*/
status_t CAAM_DES3_DecryptEcb(CAAM_Type *base,
caam_handle_t *handle,
const uint8_t *ciphertext,
uint8_t *plaintext,
size_t size,
const uint8_t key1[CAAM_DES_KEY_SIZE],
const uint8_t key2[CAAM_DES_KEY_SIZE],
const uint8_t key3[CAAM_DES_KEY_SIZE]);
/*!
* @brief Encrypts triple DES using CBC block mode with three keys.
*
* Encrypts triple DES using CBC block mode with three keys.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param plaintext Input plaintext to encrypt
* @param[out] ciphertext Output ciphertext
* @param size Size of input data in bytes
* @param iv Input initial vector to combine with the first plaintext block.
* The iv does not need to be secret, but it must be unpredictable.
* @param key1 First input key for key bundle
* @param key2 Second input key for key bundle
* @param key3 Third input key for key bundle
* @return Status from encrypt/decrypt operation
*/
status_t CAAM_DES3_EncryptCbc(CAAM_Type *base,
caam_handle_t *handle,
const uint8_t *plaintext,
uint8_t *ciphertext,
size_t size,
const uint8_t iv[CAAM_DES_IV_SIZE],
const uint8_t key1[CAAM_DES_KEY_SIZE],
const uint8_t key2[CAAM_DES_KEY_SIZE],
const uint8_t key3[CAAM_DES_KEY_SIZE]);
/*!
* @brief Decrypts triple DES using CBC block mode with three keys.
*
* Decrypts triple DES using CBC block mode with three keys.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param ciphertext Input ciphertext to decrypt
* @param[out] plaintext Output plaintext
* @param size Size of input and output data in bytes
* @param iv Input initial vector to combine with the first plaintext block.
* The iv does not need to be secret, but it must be unpredictable.
* @param key1 First input key for key bundle
* @param key2 Second input key for key bundle
* @param key3 Third input key for key bundle
* @return Status from encrypt/decrypt operation
*/
status_t CAAM_DES3_DecryptCbc(CAAM_Type *base,
caam_handle_t *handle,
const uint8_t *ciphertext,
uint8_t *plaintext,
size_t size,
const uint8_t iv[CAAM_DES_IV_SIZE],
const uint8_t key1[CAAM_DES_KEY_SIZE],
const uint8_t key2[CAAM_DES_KEY_SIZE],
const uint8_t key3[CAAM_DES_KEY_SIZE]);
/*!
* @brief Encrypts triple DES using CFB block mode with three keys.
*
* Encrypts triple DES using CFB block mode with three keys.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param plaintext Input plaintext to encrypt
* @param[out] ciphertext Output ciphertext
* @param size Size of input and ouput data in bytes
* @param iv Input initial block.
* @param key1 First input key for key bundle
* @param key2 Second input key for key bundle
* @param key3 Third input key for key bundle
* @return Status from encrypt/decrypt operation
*/
status_t CAAM_DES3_EncryptCfb(CAAM_Type *base,
caam_handle_t *handle,
const uint8_t *plaintext,
uint8_t *ciphertext,
size_t size,
const uint8_t iv[CAAM_DES_IV_SIZE],
const uint8_t key1[CAAM_DES_KEY_SIZE],
const uint8_t key2[CAAM_DES_KEY_SIZE],
const uint8_t key3[CAAM_DES_KEY_SIZE]);
/*!
* @brief Decrypts triple DES using CFB block mode with three keys.
*
* Decrypts triple DES using CFB block mode with three keys.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param ciphertext Input ciphertext to decrypt
* @param[out] plaintext Output plaintext
* @param size Size of input data in bytes
* @param iv Input initial block.
* @param key1 First input key for key bundle
* @param key2 Second input key for key bundle
* @param key3 Third input key for key bundle
* @return Status from encrypt/decrypt operation
*/
status_t CAAM_DES3_DecryptCfb(CAAM_Type *base,
caam_handle_t *handle,
const uint8_t *ciphertext,
uint8_t *plaintext,
size_t size,
const uint8_t iv[CAAM_DES_IV_SIZE],
const uint8_t key1[CAAM_DES_KEY_SIZE],
const uint8_t key2[CAAM_DES_KEY_SIZE],
const uint8_t key3[CAAM_DES_KEY_SIZE]);
/*!
* @brief Encrypts triple DES using OFB block mode with three keys.
*
* Encrypts triple DES using OFB block mode with three keys.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param plaintext Input plaintext to encrypt
* @param[out] ciphertext Output ciphertext
* @param size Size of input and output data in bytes
* @param iv Input unique input vector. The OFB mode requires that the IV be unique
* for each execution of the mode under the given key.
* @param key1 First input key for key bundle
* @param key2 Second input key for key bundle
* @param key3 Third input key for key bundle
* @return Status from encrypt/decrypt operation
*/
status_t CAAM_DES3_EncryptOfb(CAAM_Type *base,
caam_handle_t *handle,
const uint8_t *plaintext,
uint8_t *ciphertext,
size_t size,
const uint8_t iv[CAAM_DES_IV_SIZE],
const uint8_t key1[CAAM_DES_KEY_SIZE],
const uint8_t key2[CAAM_DES_KEY_SIZE],
const uint8_t key3[CAAM_DES_KEY_SIZE]);
/*!
* @brief Decrypts triple DES using OFB block mode with three keys.
*
* Decrypts triple DES using OFB block mode with three keys.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param ciphertext Input ciphertext to decrypt
* @param[out] plaintext Output plaintext
* @param size Size of input and output data in bytes
* @param iv Input unique input vector. The OFB mode requires that the IV be unique
* for each execution of the mode under the given key.
* @param key1 First input key for key bundle
* @param key2 Second input key for key bundle
* @param key3 Third input key for key bundle
* @return Status from encrypt/decrypt operation
*/
status_t CAAM_DES3_DecryptOfb(CAAM_Type *base,
caam_handle_t *handle,
const uint8_t *ciphertext,
uint8_t *plaintext,
size_t size,
const uint8_t iv[CAAM_DES_IV_SIZE],
const uint8_t key1[CAAM_DES_KEY_SIZE],
const uint8_t key2[CAAM_DES_KEY_SIZE],
const uint8_t key3[CAAM_DES_KEY_SIZE]);
/*!
*@}
*/ /* end of caam_driver_des */
/*!
* @addtogroup caam_nonblocking_driver_des
* @{
*/
/*!
* @brief Encrypts DES using ECB block mode.
*
* Encrypts DES using ECB block mode.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param[out] descriptor memory for CAAM commands
* @param plaintext Input plaintext to encrypt
* @param[out] ciphertext Output ciphertext
* @param size Size of input and output data in bytes. Must be multiple of 8 bytes.
* @param key Input key to use for encryption
* @return Status from descriptor push
*/
status_t CAAM_DES_EncryptEcbNonBlocking(CAAM_Type *base,
caam_handle_t *handle,
caam_desc_cipher_des_t descriptor,
const uint8_t *plaintext,
uint8_t *ciphertext,
size_t size,
const uint8_t key[CAAM_DES_KEY_SIZE]);
/*!
* @brief Decrypts DES using ECB block mode.
*
* Decrypts DES using ECB block mode.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param[out] descriptor memory for CAAM commands
* @param ciphertext Input ciphertext to decrypt
* @param[out] plaintext Output plaintext
* @param size Size of input and output data in bytes. Must be multiple of 8 bytes.
* @param key Input key to use for decryption
* @return Status from descriptor push
*/
status_t CAAM_DES_DecryptEcbNonBlocking(CAAM_Type *base,
caam_handle_t *handle,
caam_desc_cipher_des_t descriptor,
const uint8_t *ciphertext,
uint8_t *plaintext,
size_t size,
const uint8_t key[CAAM_DES_KEY_SIZE]);
/*!
* @brief Encrypts DES using CBC block mode.
*
* Encrypts DES using CBC block mode.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param[out] descriptor memory for CAAM commands
* @param plaintext Input plaintext to encrypt
* @param[out] ciphertext Ouput ciphertext
* @param size Size of input and output data in bytes
* @param iv Input initial vector to combine with the first plaintext block.
* The iv does not need to be secret, but it must be unpredictable.
* @param key Input key to use for encryption
* @return Status from descriptor push
*/
status_t CAAM_DES_EncryptCbcNonBlocking(CAAM_Type *base,
caam_handle_t *handle,
caam_desc_cipher_des_t descriptor,
const uint8_t *plaintext,
uint8_t *ciphertext,
size_t size,
const uint8_t iv[CAAM_DES_IV_SIZE],
const uint8_t key[CAAM_DES_KEY_SIZE]);
/*!
* @brief Decrypts DES using CBC block mode.
*
* Decrypts DES using CBC block mode.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param[out] descriptor memory for CAAM commands
* @param ciphertext Input ciphertext to decrypt
* @param[out] plaintext Output plaintext
* @param size Size of input data in bytes
* @param iv Input initial vector to combine with the first plaintext block.
* The iv does not need to be secret, but it must be unpredictable.
* @param key Input key to use for decryption
* @return Status from descriptor push
*/
status_t CAAM_DES_DecryptCbcNonBlocking(CAAM_Type *base,
caam_handle_t *handle,
caam_desc_cipher_des_t descriptor,
const uint8_t *ciphertext,
uint8_t *plaintext,
size_t size,
const uint8_t iv[CAAM_DES_IV_SIZE],
const uint8_t key[CAAM_DES_KEY_SIZE]);
/*!
* @brief Encrypts DES using CFB block mode.
*
* Encrypts DES using CFB block mode.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param[out] descriptor memory for CAAM commands
* @param plaintext Input plaintext to encrypt
* @param size Size of input data in bytes
* @param iv Input initial block.
* @param key Input key to use for encryption
* @param[out] ciphertext Output ciphertext
* @return Status from descriptor push
*/
status_t CAAM_DES_EncryptCfbNonBlocking(CAAM_Type *base,
caam_handle_t *handle,
caam_desc_cipher_des_t descriptor,
const uint8_t *plaintext,
uint8_t *ciphertext,
size_t size,
const uint8_t iv[CAAM_DES_IV_SIZE],
const uint8_t key[CAAM_DES_KEY_SIZE]);
/*!
* @brief Decrypts DES using CFB block mode.
*
* Decrypts DES using CFB block mode.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param[out] descriptor memory for CAAM commands
* @param ciphertext Input ciphertext to decrypt
* @param[out] plaintext Output plaintext
* @param size Size of input and output data in bytes
* @param iv Input initial block.
* @param key Input key to use for decryption
* @return Status from descriptor push
*/
status_t CAAM_DES_DecryptCfbNonBlocking(CAAM_Type *base,
caam_handle_t *handle,
caam_desc_cipher_des_t descriptor,
const uint8_t *ciphertext,
uint8_t *plaintext,
size_t size,
const uint8_t iv[CAAM_DES_IV_SIZE],
const uint8_t key[CAAM_DES_KEY_SIZE]);
/*!
* @brief Encrypts DES using OFB block mode.
*
* Encrypts DES using OFB block mode.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param[out] descriptor memory for CAAM commands
* @param plaintext Input plaintext to encrypt
* @param[out] ciphertext Output ciphertext
* @param size Size of input and output data in bytes
* @param iv Input unique input vector. The OFB mode requires that the IV be unique
* for each execution of the mode under the given key.
* @param key Input key to use for encryption
* @return Status from descriptor push
*/
status_t CAAM_DES_EncryptOfbNonBlocking(CAAM_Type *base,
caam_handle_t *handle,
caam_desc_cipher_des_t descriptor,
const uint8_t *plaintext,
uint8_t *ciphertext,
size_t size,
const uint8_t iv[CAAM_DES_IV_SIZE],
const uint8_t key[CAAM_DES_KEY_SIZE]);
/*!
* @brief Decrypts DES using OFB block mode.
*
* Decrypts DES using OFB block mode.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param[out] descriptor memory for CAAM commands
* @param ciphertext Input ciphertext to decrypt
* @param[out] plaintext Output plaintext
* @param size Size of input and output data in bytes. Must be multiple of 8 bytes.
* @param iv Input unique input vector. The OFB mode requires that the IV be unique
* for each execution of the mode under the given key.
* @param key Input key to use for decryption
* @return Status from descriptor push
*/
status_t CAAM_DES_DecryptOfbNonBlocking(CAAM_Type *base,
caam_handle_t *handle,
caam_desc_cipher_des_t descriptor,
const uint8_t *ciphertext,
uint8_t *plaintext,
size_t size,
const uint8_t iv[CAAM_DES_IV_SIZE],
const uint8_t key[CAAM_DES_KEY_SIZE]);
/*!
* @brief Encrypts triple DES using ECB block mode with two keys.
*
* Encrypts triple DES using ECB block mode with two keys.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param[out] descriptor memory for CAAM commands
* @param plaintext Input plaintext to encrypt
* @param[out] ciphertext Output ciphertext
* @param size Size of input and output data in bytes. Must be multiple of 8 bytes.
* @param key1 First input key for key bundle
* @param key2 Second input key for key bundle
* @return Status from descriptor push
*/
status_t CAAM_DES2_EncryptEcbNonBlocking(CAAM_Type *base,
caam_handle_t *handle,
caam_desc_cipher_des_t descriptor,
const uint8_t *plaintext,
uint8_t *ciphertext,
size_t size,
const uint8_t key1[CAAM_DES_KEY_SIZE],
const uint8_t key2[CAAM_DES_KEY_SIZE]);
/*!
* @brief Decrypts triple DES using ECB block mode with two keys.
*
* Decrypts triple DES using ECB block mode with two keys.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param[out] descriptor memory for CAAM commands
* @param ciphertext Input ciphertext to decrypt
* @param[out] plaintext Output plaintext
* @param size Size of input and output data in bytes. Must be multiple of 8 bytes.
* @param key1 First input key for key bundle
* @param key2 Second input key for key bundle
* @return Status from descriptor push
*/
status_t CAAM_DES2_DecryptEcbNonBlocking(CAAM_Type *base,
caam_handle_t *handle,
caam_desc_cipher_des_t descriptor,
const uint8_t *ciphertext,
uint8_t *plaintext,
size_t size,
const uint8_t key1[CAAM_DES_KEY_SIZE],
const uint8_t key2[CAAM_DES_KEY_SIZE]);
/*!
* @brief Encrypts triple DES using CBC block mode with two keys.
*
* Encrypts triple DES using CBC block mode with two keys.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param[out] descriptor memory for CAAM commands
* @param plaintext Input plaintext to encrypt
* @param[out] ciphertext Output ciphertext
* @param size Size of input and output data in bytes
* @param iv Input initial vector to combine with the first plaintext block.
* The iv does not need to be secret, but it must be unpredictable.
* @param key1 First input key for key bundle
* @param key2 Second input key for key bundle
* @return Status from descriptor push
*/
status_t CAAM_DES2_EncryptCbcNonBlocking(CAAM_Type *base,
caam_handle_t *handle,
caam_desc_cipher_des_t descriptor,
const uint8_t *plaintext,
uint8_t *ciphertext,
size_t size,
const uint8_t iv[CAAM_DES_IV_SIZE],
const uint8_t key1[CAAM_DES_KEY_SIZE],
const uint8_t key2[CAAM_DES_KEY_SIZE]);
/*!
* @brief Decrypts triple DES using CBC block mode with two keys.
*
* Decrypts triple DES using CBC block mode with two keys.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param[out] descriptor memory for CAAM commands
* @param ciphertext Input ciphertext to decrypt
* @param[out] plaintext Output plaintext
* @param size Size of input and output data in bytes
* @param iv Input initial vector to combine with the first plaintext block.
* The iv does not need to be secret, but it must be unpredictable.
* @param key1 First input key for key bundle
* @param key2 Second input key for key bundle
* @return Status from descriptor push
*/
status_t CAAM_DES2_DecryptCbcNonBlocking(CAAM_Type *base,
caam_handle_t *handle,
caam_desc_cipher_des_t descriptor,
const uint8_t *ciphertext,
uint8_t *plaintext,
size_t size,
const uint8_t iv[CAAM_DES_IV_SIZE],
const uint8_t key1[CAAM_DES_KEY_SIZE],
const uint8_t key2[CAAM_DES_KEY_SIZE]);
/*!
* @brief Encrypts triple DES using CFB block mode with two keys.
*
* Encrypts triple DES using CFB block mode with two keys.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param[out] descriptor memory for CAAM commands
* @param plaintext Input plaintext to encrypt
* @param[out] ciphertext Output ciphertext
* @param size Size of input and output data in bytes
* @param iv Input initial block.
* @param key1 First input key for key bundle
* @param key2 Second input key for key bundle
* @return Status from descriptor push
*/
status_t CAAM_DES2_EncryptCfbNonBlocking(CAAM_Type *base,
caam_handle_t *handle,
caam_desc_cipher_des_t descriptor,
const uint8_t *plaintext,
uint8_t *ciphertext,
size_t size,
const uint8_t iv[CAAM_DES_IV_SIZE],
const uint8_t key1[CAAM_DES_KEY_SIZE],
const uint8_t key2[CAAM_DES_KEY_SIZE]);
/*!
* @brief Decrypts triple DES using CFB block mode with two keys.
*
* Decrypts triple DES using CFB block mode with two keys.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param[out] descriptor memory for CAAM commands
* @param ciphertext Input ciphertext to decrypt
* @param[out] plaintext Output plaintext
* @param size Size of input and output data in bytes
* @param iv Input initial block.
* @param key1 First input key for key bundle
* @param key2 Second input key for key bundle
* @return Status from descriptor push
*/
status_t CAAM_DES2_DecryptCfbNonBlocking(CAAM_Type *base,
caam_handle_t *handle,
caam_desc_cipher_des_t descriptor,
const uint8_t *ciphertext,
uint8_t *plaintext,
size_t size,
const uint8_t iv[CAAM_DES_IV_SIZE],
const uint8_t key1[CAAM_DES_KEY_SIZE],
const uint8_t key2[CAAM_DES_KEY_SIZE]);
/*!
* @brief Encrypts triple DES using OFB block mode with two keys.
*
* Encrypts triple DES using OFB block mode with two keys.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param[out] descriptor memory for CAAM commands
* @param plaintext Input plaintext to encrypt
* @param[out] ciphertext Output ciphertext
* @param size Size of input and output data in bytes
* @param iv Input unique input vector. The OFB mode requires that the IV be unique
* for each execution of the mode under the given key.
* @param key1 First input key for key bundle
* @param key2 Second input key for key bundle
* @return Status from descriptor push
*/
status_t CAAM_DES2_EncryptOfbNonBlocking(CAAM_Type *base,
caam_handle_t *handle,
caam_desc_cipher_des_t descriptor,
const uint8_t *plaintext,
uint8_t *ciphertext,
size_t size,
const uint8_t iv[CAAM_DES_IV_SIZE],
const uint8_t key1[CAAM_DES_KEY_SIZE],
const uint8_t key2[CAAM_DES_KEY_SIZE]);
/*!
* @brief Decrypts triple DES using OFB block mode with two keys.
*
* Decrypts triple DES using OFB block mode with two keys.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param[out] descriptor memory for CAAM commands
* @param ciphertext Input ciphertext to decrypt
* @param[out] plaintext Output plaintext
* @param size Size of input and output data in bytes
* @param iv Input unique input vector. The OFB mode requires that the IV be unique
* for each execution of the mode under the given key.
* @param key1 First input key for key bundle
* @param key2 Second input key for key bundle
* @return Status from descriptor push
*/
status_t CAAM_DES2_DecryptOfbNonBlocking(CAAM_Type *base,
caam_handle_t *handle,
caam_desc_cipher_des_t descriptor,
const uint8_t *ciphertext,
uint8_t *plaintext,
size_t size,
const uint8_t iv[CAAM_DES_IV_SIZE],
const uint8_t key1[CAAM_DES_KEY_SIZE],
const uint8_t key2[CAAM_DES_KEY_SIZE]);
/*!
* @brief Encrypts triple DES using ECB block mode with three keys.
*
* Encrypts triple DES using ECB block mode with three keys.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param[out] descriptor memory for CAAM commands
* @param plaintext Input plaintext to encrypt
* @param[out] ciphertext Output ciphertext
* @param size Size of input and output data in bytes. Must be multiple of 8 bytes.
* @param key1 First input key for key bundle
* @param key2 Second input key for key bundle
* @param key3 Third input key for key bundle
* @return Status from descriptor push
*/
status_t CAAM_DES3_EncryptEcbNonBlocking(CAAM_Type *base,
caam_handle_t *handle,
caam_desc_cipher_des_t descriptor,
const uint8_t *plaintext,
uint8_t *ciphertext,
size_t size,
const uint8_t key1[CAAM_DES_KEY_SIZE],
const uint8_t key2[CAAM_DES_KEY_SIZE],
const uint8_t key3[CAAM_DES_KEY_SIZE]);
/*!
* @brief Decrypts triple DES using ECB block mode with three keys.
*
* Decrypts triple DES using ECB block mode with three keys.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param[out] descriptor memory for CAAM commands
* @param ciphertext Input ciphertext to decrypt
* @param[out] plaintext Output plaintext
* @param size Size of input and output data in bytes. Must be multiple of 8 bytes.
* @param key1 First input key for key bundle
* @param key2 Second input key for key bundle
* @param key3 Third input key for key bundle
* @return Status from descriptor push
*/
status_t CAAM_DES3_DecryptEcbNonBlocking(CAAM_Type *base,
caam_handle_t *handle,
caam_desc_cipher_des_t descriptor,
const uint8_t *ciphertext,
uint8_t *plaintext,
size_t size,
const uint8_t key1[CAAM_DES_KEY_SIZE],
const uint8_t key2[CAAM_DES_KEY_SIZE],
const uint8_t key3[CAAM_DES_KEY_SIZE]);
/*!
* @brief Encrypts triple DES using CBC block mode with three keys.
*
* Encrypts triple DES using CBC block mode with three keys.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param[out] descriptor memory for CAAM commands
* @param plaintext Input plaintext to encrypt
* @param[out] ciphertext Output ciphertext
* @param size Size of input data in bytes
* @param iv Input initial vector to combine with the first plaintext block.
* The iv does not need to be secret, but it must be unpredictable.
* @param key1 First input key for key bundle
* @param key2 Second input key for key bundle
* @param key3 Third input key for key bundle
* @return Status from descriptor push
*/
status_t CAAM_DES3_EncryptCbcNonBlocking(CAAM_Type *base,
caam_handle_t *handle,
caam_desc_cipher_des_t descriptor,
const uint8_t *plaintext,
uint8_t *ciphertext,
size_t size,
const uint8_t iv[CAAM_DES_IV_SIZE],
const uint8_t key1[CAAM_DES_KEY_SIZE],
const uint8_t key2[CAAM_DES_KEY_SIZE],
const uint8_t key3[CAAM_DES_KEY_SIZE]);
/*!
* @brief Decrypts triple DES using CBC block mode with three keys.
*
* Decrypts triple DES using CBC block mode with three keys.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param[out] descriptor memory for CAAM commands
* @param ciphertext Input ciphertext to decrypt
* @param[out] plaintext Output plaintext
* @param size Size of input and output data in bytes
* @param iv Input initial vector to combine with the first plaintext block.
* The iv does not need to be secret, but it must be unpredictable.
* @param key1 First input key for key bundle
* @param key2 Second input key for key bundle
* @param key3 Third input key for key bundle
* @return Status from descriptor push
*/
status_t CAAM_DES3_DecryptCbcNonBlocking(CAAM_Type *base,
caam_handle_t *handle,
caam_desc_cipher_des_t descriptor,
const uint8_t *ciphertext,
uint8_t *plaintext,
size_t size,
const uint8_t iv[CAAM_DES_IV_SIZE],
const uint8_t key1[CAAM_DES_KEY_SIZE],
const uint8_t key2[CAAM_DES_KEY_SIZE],
const uint8_t key3[CAAM_DES_KEY_SIZE]);
/*!
* @brief Encrypts triple DES using CFB block mode with three keys.
*
* Encrypts triple DES using CFB block mode with three keys.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param[out] descriptor memory for CAAM commands
* @param plaintext Input plaintext to encrypt
* @param[out] ciphertext Output ciphertext
* @param size Size of input and ouput data in bytes
* @param iv Input initial block.
* @param key1 First input key for key bundle
* @param key2 Second input key for key bundle
* @param key3 Third input key for key bundle
* @return Status from descriptor push
*/
status_t CAAM_DES3_EncryptCfbNonBlocking(CAAM_Type *base,
caam_handle_t *handle,
caam_desc_cipher_des_t descriptor,
const uint8_t *plaintext,
uint8_t *ciphertext,
size_t size,
const uint8_t iv[CAAM_DES_IV_SIZE],
const uint8_t key1[CAAM_DES_KEY_SIZE],
const uint8_t key2[CAAM_DES_KEY_SIZE],
const uint8_t key3[CAAM_DES_KEY_SIZE]);
/*!
* @brief Decrypts triple DES using CFB block mode with three keys.
*
* Decrypts triple DES using CFB block mode with three keys.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param[out] descriptor memory for CAAM commands
* @param ciphertext Input ciphertext to decrypt
* @param[out] plaintext Output plaintext
* @param size Size of input data in bytes
* @param iv Input initial block.
* @param key1 First input key for key bundle
* @param key2 Second input key for key bundle
* @param key3 Third input key for key bundle
* @return Status from descriptor push
*/
status_t CAAM_DES3_DecryptCfbNonBlocking(CAAM_Type *base,
caam_handle_t *handle,
caam_desc_cipher_des_t descriptor,
const uint8_t *ciphertext,
uint8_t *plaintext,
size_t size,
const uint8_t iv[CAAM_DES_IV_SIZE],
const uint8_t key1[CAAM_DES_KEY_SIZE],
const uint8_t key2[CAAM_DES_KEY_SIZE],
const uint8_t key3[CAAM_DES_KEY_SIZE]);
/*!
* @brief Encrypts triple DES using OFB block mode with three keys.
*
* Encrypts triple DES using OFB block mode with three keys.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param[out] descriptor memory for CAAM commands
* @param plaintext Input plaintext to encrypt
* @param[out] ciphertext Output ciphertext
* @param size Size of input and output data in bytes
* @param iv Input unique input vector. The OFB mode requires that the IV be unique
* for each execution of the mode under the given key.
* @param key1 First input key for key bundle
* @param key2 Second input key for key bundle
* @param key3 Third input key for key bundle
* @return Status from descriptor push
*/
status_t CAAM_DES3_EncryptOfbNonBlocking(CAAM_Type *base,
caam_handle_t *handle,
caam_desc_cipher_des_t descriptor,
const uint8_t *plaintext,
uint8_t *ciphertext,
size_t size,
const uint8_t iv[CAAM_DES_IV_SIZE],
const uint8_t key1[CAAM_DES_KEY_SIZE],
const uint8_t key2[CAAM_DES_KEY_SIZE],
const uint8_t key3[CAAM_DES_KEY_SIZE]);
/*!
* @brief Decrypts triple DES using OFB block mode with three keys.
*
* Decrypts triple DES using OFB block mode with three keys.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param[out] descriptor memory for CAAM commands
* @param ciphertext Input ciphertext to decrypt
* @param[out] plaintext Output plaintext
* @param size Size of input and output data in bytes
* @param iv Input unique input vector. The OFB mode requires that the IV be unique
* for each execution of the mode under the given key.
* @param key1 First input key for key bundle
* @param key2 Second input key for key bundle
* @param key3 Third input key for key bundle
* @return Status from descriptor push
*/
status_t CAAM_DES3_DecryptOfbNonBlocking(CAAM_Type *base,
caam_handle_t *handle,
caam_desc_cipher_des_t descriptor,
const uint8_t *ciphertext,
uint8_t *plaintext,
size_t size,
const uint8_t iv[CAAM_DES_IV_SIZE],
const uint8_t key1[CAAM_DES_KEY_SIZE],
const uint8_t key2[CAAM_DES_KEY_SIZE],
const uint8_t key3[CAAM_DES_KEY_SIZE]);
/*!
*@}
*/ /* end of caam_nonblocking_driver_des */
/*!
* @addtogroup caam_driver_pkha
* @{
*/
int CAAM_PKHA_CompareBigNum(const uint8_t *a, size_t sizeA, const uint8_t *b, size_t sizeB);
/*!
* @brief Converts from integer to Montgomery format.
*
* This function computes R2 mod N and optionally converts A or B into Montgomery format of A or B.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param N modulus
* @param sizeN size of N in bytes
* @param[in,out] A The first input in non-Montgomery format. Output Montgomery format of the first input.
* @param[in,out] sizeA pointer to size variable. On input it holds size of input A in bytes. On output it holds size of
* Montgomery format of A in bytes.
* @param[in,out] B Second input in non-Montgomery format. Output Montgomery format of the second input.
* @param[in,out] sizeB pointer to size variable. On input it holds size of input B in bytes. On output it holds size of
* Montgomery format of B in bytes.
* @param[out] R2 Output Montgomery factor R2 mod N.
* @param[out] sizeR2 pointer to size variable. On output it holds size of Montgomery factor R2 mod N in bytes.
* @param equalTime Run the function time equalized or no timing equalization.
* @param arithType Type of arithmetic to perform (integer or F2m)
* @return Operation status.
*/
status_t CAAM_PKHA_NormalToMontgomery(CAAM_Type *base,
caam_handle_t *handle,
const uint8_t *N,
size_t sizeN,
uint8_t *A,
size_t *sizeA,
uint8_t *B,
size_t *sizeB,
uint8_t *R2,
size_t *sizeR2,
caam_pkha_timing_t equalTime,
caam_pkha_f2m_t arithType);
/*!
* @brief Converts from Montgomery format to int.
*
* This function converts Montgomery format of A or B into int A or B.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param N modulus.
* @param sizeN size of N modulus in bytes.
* @param[in,out] A Input first number in Montgomery format. Output is non-Montgomery format.
* @param[in,out] sizeA pointer to size variable. On input it holds size of the input A in bytes. On output it holds
* size of non-Montgomery A in bytes.
* @param[in,out] B Input first number in Montgomery format. Output is non-Montgomery format.
* @param[in,out] sizeB pointer to size variable. On input it holds size of the input B in bytes. On output it holds
* size of non-Montgomery B in bytes.
* @param equalTime Run the function time equalized or no timing equalization.
* @param arithType Type of arithmetic to perform (integer or F2m)
* @return Operation status.
*/
status_t CAAM_PKHA_MontgomeryToNormal(CAAM_Type *base,
caam_handle_t *handle,
const uint8_t *N,
size_t sizeN,
uint8_t *A,
size_t *sizeA,
uint8_t *B,
size_t *sizeB,
caam_pkha_timing_t equalTime,
caam_pkha_f2m_t arithType);
/*!
* @brief Performs modular addition - (A + B) mod N.
*
* This function performs modular addition of (A + B) mod N, with either
* integer or binary polynomial (F2m) inputs. In the F2m form, this function is
* equivalent to a bitwise XOR and it is functionally the same as subtraction.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param A first addend (integer or binary polynomial)
* @param sizeA Size of A in bytes
* @param B second addend (integer or binary polynomial)
* @param sizeB Size of B in bytes
* @param N modulus.
* @param sizeN Size of N in bytes.
* @param[out] result Output array to store result of operation
* @param[out] resultSize Output size of operation in bytes
* @param arithType Type of arithmetic to perform (integer or F2m)
* @return Operation status.
*/
status_t CAAM_PKHA_ModAdd(CAAM_Type *base,
caam_handle_t *handle,
const uint8_t *A,
size_t sizeA,
const uint8_t *B,
size_t sizeB,
const uint8_t *N,
size_t sizeN,
uint8_t *result,
size_t *resultSize,
caam_pkha_f2m_t arithType);
/*!
* @brief Performs modular subtraction - (A - B) mod N.
*
* This function performs modular subtraction of (A - B) mod N with
* integer inputs.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param A first addend (integer or binary polynomial)
* @param sizeA Size of A in bytes
* @param B second addend (integer or binary polynomial)
* @param sizeB Size of B in bytes
* @param N modulus
* @param sizeN Size of N in bytes
* @param[out] result Output array to store result of operation
* @param[out] resultSize Output size of operation in bytes
* @return Operation status.
*/
status_t CAAM_PKHA_ModSub1(CAAM_Type *base,
caam_handle_t *handle,
const uint8_t *A,
size_t sizeA,
const uint8_t *B,
size_t sizeB,
const uint8_t *N,
size_t sizeN,
uint8_t *result,
size_t *resultSize);
/*!
* @brief Performs modular subtraction - (B - A) mod N.
*
* This function performs modular subtraction of (B - A) mod N,
* with integer inputs.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param A first addend (integer or binary polynomial)
* @param sizeA Size of A in bytes
* @param B second addend (integer or binary polynomial)
* @param sizeB Size of B in bytes
* @param N modulus
* @param sizeN Size of N in bytes
* @param[out] result Output array to store result of operation
* @param[out] resultSize Output size of operation in bytes
* @return Operation status.
*/
status_t CAAM_PKHA_ModSub2(CAAM_Type *base,
caam_handle_t *handle,
const uint8_t *A,
size_t sizeA,
const uint8_t *B,
size_t sizeB,
const uint8_t *N,
size_t sizeN,
uint8_t *result,
size_t *resultSize);
/*!
* @brief Performs modular multiplication - (A x B) mod N.
*
* This function performs modular multiplication with either integer or
* binary polynomial (F2m) inputs. It can optionally specify whether inputs
* and/or outputs will be in Montgomery form or not.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param A first addend (integer or binary polynomial)
* @param sizeA Size of A in bytes
* @param B second addend (integer or binary polynomial)
* @param sizeB Size of B in bytes
* @param N modulus.
* @param sizeN Size of N in bytes
* @param[out] result Output array to store result of operation
* @param[out] resultSize Output size of operation in bytes
* @param arithType Type of arithmetic to perform (integer or F2m)
* @param montIn Format of inputs
* @param montOut Format of output
* @param equalTime Run the function time equalized or no timing equalization. This argument is ignored for F2m modular
* multiplication.
* @return Operation status.
*/
status_t CAAM_PKHA_ModMul(CAAM_Type *base,
caam_handle_t *handle,
const uint8_t *A,
size_t sizeA,
const uint8_t *B,
size_t sizeB,
const uint8_t *N,
size_t sizeN,
uint8_t *result,
size_t *resultSize,
caam_pkha_f2m_t arithType,
caam_pkha_montgomery_form_t montIn,
caam_pkha_montgomery_form_t montOut,
caam_pkha_timing_t equalTime);
/*!
* @brief Performs modular exponentiation - (A^E) mod N.
*
* This function performs modular exponentiation with either integer or
* binary polynomial (F2m) inputs.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param A first addend (integer or binary polynomial)
* @param sizeA Size of A in bytes
* @param N modulus
* @param sizeN Size of N in bytes
* @param E exponent
* @param sizeE Size of E in bytes
* @param[out] result Output array to store result of operation
* @param[out] resultSize Output size of operation in bytes
* @param montIn Format of A input (normal or Montgomery)
* @param arithType Type of arithmetic to perform (integer or F2m)
* @param equalTime Run the function time equalized or no timing equalization.
* @return Operation status.
*/
status_t CAAM_PKHA_ModExp(CAAM_Type *base,
caam_handle_t *handle,
const uint8_t *A,
size_t sizeA,
const uint8_t *N,
size_t sizeN,
const uint8_t *E,
size_t sizeE,
uint8_t *result,
size_t *resultSize,
caam_pkha_f2m_t arithType,
caam_pkha_montgomery_form_t montIn,
caam_pkha_timing_t equalTime);
/*!
* @brief Performs modular reduction - (A) mod N.
*
* This function performs modular reduction with either integer or
* binary polynomial (F2m) inputs.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param A first addend (integer or binary polynomial)
* @param sizeA Size of A in bytes
* @param N modulus
* @param sizeN Size of N in bytes
* @param[out] result Output array to store result of operation
* @param[out] resultSize Output size of operation in bytes
* @param arithType Type of arithmetic to perform (integer or F2m)
* @return Operation status.
*/
status_t CAAM_PKHA_ModRed(CAAM_Type *base,
caam_handle_t *handle,
const uint8_t *A,
size_t sizeA,
const uint8_t *N,
size_t sizeN,
uint8_t *result,
size_t *resultSize,
caam_pkha_f2m_t arithType);
/*!
* @brief Performs modular inversion - (A^-1) mod N.
*
* This function performs modular inversion with either integer or
* binary polynomial (F2m) inputs.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param A first addend (integer or binary polynomial)
* @param sizeA Size of A in bytes
* @param N modulus
* @param sizeN Size of N in bytes
* @param[out] result Output array to store result of operation
* @param[out] resultSize Output size of operation in bytes
* @param arithType Type of arithmetic to perform (integer or F2m)
* @return Operation status.
*/
status_t CAAM_PKHA_ModInv(CAAM_Type *base,
caam_handle_t *handle,
const uint8_t *A,
size_t sizeA,
const uint8_t *N,
size_t sizeN,
uint8_t *result,
size_t *resultSize,
caam_pkha_f2m_t arithType);
/*!
* @brief Computes integer Montgomery factor R^2 mod N.
*
* This function computes a constant to assist in converting operands
* into the Montgomery residue system representation.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param N modulus
* @param sizeN Size of N in bytes
* @param[out] result Output array to store result of operation
* @param[out] resultSize Output size of operation in bytes
* @param arithType Type of arithmetic to perform (integer or F2m)
* @return Operation status.
*/
status_t CAAM_PKHA_ModR2(CAAM_Type *base,
caam_handle_t *handle,
const uint8_t *N,
size_t sizeN,
uint8_t *result,
size_t *resultSize,
caam_pkha_f2m_t arithType);
/*!
* @brief Calculates the greatest common divisor - GCD (A, N).
*
* This function calculates the greatest common divisor of two inputs with
* either integer or binary polynomial (F2m) inputs.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param A first value (must be smaller than or equal to N)
* @param sizeA Size of A in bytes
* @param N second value (must be non-zero)
* @param sizeN Size of N in bytes
* @param[out] result Output array to store result of operation
* @param[out] resultSize Output size of operation in bytes
* @param arithType Type of arithmetic to perform (integer or F2m)
* @return Operation status.
*/
status_t CAAM_PKHA_ModGcd(CAAM_Type *base,
caam_handle_t *handle,
const uint8_t *A,
size_t sizeA,
const uint8_t *N,
size_t sizeN,
uint8_t *result,
size_t *resultSize,
caam_pkha_f2m_t arithType);
/*!
* @brief Executes Miller-Rabin primality test.
*
* This function calculates whether or not a candidate prime number is likely
* to be a prime.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param A initial random seed
* @param sizeA Size of A in bytes
* @param B number of trial runs
* @param sizeB Size of B in bytes
* @param N candidate prime integer
* @param sizeN Size of N in bytes
* @param[out] res True if the value is likely prime or false otherwise
* @return Operation status.
*/
status_t CAAM_PKHA_PrimalityTest(CAAM_Type *base,
caam_handle_t *handle,
const uint8_t *A,
size_t sizeA,
const uint8_t *B,
size_t sizeB,
const uint8_t *N,
size_t sizeN,
bool *res);
/*!
* @brief Adds elliptic curve points - A + B.
*
* This function performs ECC point addition over a prime field (Fp) or binary field (F2m) using
* affine coordinates.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param A Left-hand point
* @param B Right-hand point
* @param N Prime modulus of the field
* @param R2modN NULL (the function computes R2modN internally) or pointer to pre-computed R2modN (obtained from
* CAAM_PKHA_ModR2() function).
* @param aCurveParam A parameter from curve equation
* @param bCurveParam B parameter from curve equation (constant)
* @param size Size in bytes of curve points and parameters
* @param arithType Type of arithmetic to perform (integer or F2m)
* @param[out] result Result point
* @return Operation status.
*/
status_t CAAM_PKHA_ECC_PointAdd(CAAM_Type *base,
caam_handle_t *handle,
const caam_pkha_ecc_point_t *A,
const caam_pkha_ecc_point_t *B,
const uint8_t *N,
const uint8_t *R2modN,
const uint8_t *aCurveParam,
const uint8_t *bCurveParam,
size_t size,
caam_pkha_f2m_t arithType,
caam_pkha_ecc_point_t *result);
/*!
* @brief Doubles elliptic curve points - B + B.
*
* This function performs ECC point doubling over a prime field (Fp) or binary field (F2m) using
* affine coordinates.
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param B Point to double
* @param N Prime modulus of the field
* @param aCurveParam A parameter from curve equation
* @param bCurveParam B parameter from curve equation (constant)
* @param size Size in bytes of curve points and parameters
* @param arithType Type of arithmetic to perform (integer or F2m)
* @param[out] result Result point
* @return Operation status.
*/
status_t CAAM_PKHA_ECC_PointDouble(CAAM_Type *base,
caam_handle_t *handle,
const caam_pkha_ecc_point_t *B,
const uint8_t *N,
const uint8_t *aCurveParam,
const uint8_t *bCurveParam,
size_t size,
caam_pkha_f2m_t arithType,
caam_pkha_ecc_point_t *result);
/*!
* @brief Multiplies an elliptic curve point by a scalar - E x (A0, A1).
*
* This function performs ECC point multiplication to multiply an ECC point by
* a scalar integer multiplier over a prime field (Fp) or a binary field (F2m).
*
* @param base CAAM peripheral base address
* @param handle Handle used for this request. Specifies jobRing.
* @param A Point as multiplicand
* @param E Scalar multiple
* @param sizeE The size of E, in bytes
* @param N Modulus, a prime number for the Fp field or Irreducible polynomial for F2m field.
* @param R2modN NULL (the function computes R2modN internally) or pointer to pre-computed R2modN (obtained from
* CAAM_PKHA_ModR2() function).
* @param aCurveParam A parameter from curve equation
* @param bCurveParam B parameter from curve equation (C parameter for operation over F2m).
* @param size Size in bytes of curve points and parameters
* @param equalTime Run the function time equalized or no timing equalization.
* @param arithType Type of arithmetic to perform (integer or F2m)
* @param[out] result Result point
* @return Operation status.
*/
status_t CAAM_PKHA_ECC_PointMul(CAAM_Type *base,
caam_handle_t *handle,
const caam_pkha_ecc_point_t *A,
const uint8_t *E,
size_t sizeE,
const uint8_t *N,
const uint8_t *R2modN,
const uint8_t *aCurveParam,
const uint8_t *bCurveParam,
size_t size,
caam_pkha_timing_t equalTime,
caam_pkha_f2m_t arithType,
caam_pkha_ecc_point_t *result);
/*!
*@}
*/ /* end of caam_driver_pkha */
#if defined(__cplusplus)
}
#endif
#endif /* _FSL_CAAM_H_ */
|