"Fossies" - the Fresh Open Source Software Archive 
Member "ntl-11.5.1/src/CheckKMA.cpp" (23 Jun 2021, 891 Bytes) of package /linux/misc/ntl-11.5.1.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
For more information about "CheckKMA.cpp" see the
Fossies "Dox" file reference documentation and the latest
Fossies "Diffs" side-by-side code changes report:
11.5.0_vs_11.5.1.
1 #include <NTL/ctools.h>
2 #include <NTL/linux_s390x.h>
3
4 #include <cstdlib>
5 #include <iostream>
6
7
8 using namespace std;
9
10 #if !defined(LINUX_S390X)
11 #error "KMA not supported"
12 #endif
13
14 int main()
15 {
16 #if defined(AT_HWCAP) && defined(HWCAP_S390_STFLE)
17 unsigned long hwcap, facility_list_nmemb;
18 uint64_t status_word[2], facility_list[3];
19
20 /* Check for STFLE. */
21 hwcap = getauxval(AT_HWCAP);
22 if (!(hwcap & HWCAP_S390_STFLE))
23 return -1;
24
25 /* Query facility list. */
26 facility_list_nmemb = stfle(facility_list, 3);
27
28 /* Check MSA8. */
29 if (facility_list_nmemb >= OFF64(MSA8) + 1
30 && (facility_list[OFF64(MSA8)] & MASK64(MSA8))) {
31 cpacf_kma(CPACF_KMA_QUERY, &status_word, NULL, NULL, 0, NULL, 0);
32
33 if (status_word[OFF64(CPACF_KMA_GCM_AES_256)]
34 & MASK64(CPACF_KMA_GCM_AES_256)) {
35 return 0;
36 }
37 }
38 #endif
39 return -1;
40 }