summaryrefslogtreecommitdiff
path: root/TestPrograms
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2020-07-27 11:55:24 -0400
committerJeffrey Walton <noloader@gmail.com>2020-07-27 11:55:24 -0400
commit1432ae08195be0f5c797760fb987b568ceb715b9 (patch)
tree340365a0ebf48b3fb2ec6d65787f9443f8a10044 /TestPrograms
parentabd8b7a991e24a3b5fdd80be6a60c904c092b7a0 (diff)
downloadcryptopp-git-1432ae08195be0f5c797760fb987b568ceb715b9.tar.gz
Add additiona; test programs
Diffstat (limited to 'TestPrograms')
-rw-r--r--TestPrograms/test_x86_via_aes.cxx39
-rw-r--r--TestPrograms/test_x86_via_rng.cxx38
-rw-r--r--TestPrograms/test_x86_via_sha.cxx39
3 files changed, 116 insertions, 0 deletions
diff --git a/TestPrograms/test_x86_via_aes.cxx b/TestPrograms/test_x86_via_aes.cxx
new file mode 100644
index 00000000..a6d80b01
--- /dev/null
+++ b/TestPrograms/test_x86_via_aes.cxx
@@ -0,0 +1,39 @@
+// TODO: cut-in xcrypt-ecb
+#include <cstdlib>
+int main(int argc, char* argv[])
+{
+ unsigned int msr=0;
+ unsigned int divisor=2;
+ unsigned int buffer;
+
+ __asm__ __volatile__
+ (
+#if (CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64)
+ "mov %1, %%rdi ;\n"
+ "movl %2, %%edx ;\n"
+#else
+ "mov %1, %%edi ;\n"
+ "movl %2, %%edx ;\n"
+#endif
+
+ // xstore-rng
+ ".byte 0x0f, 0xa7, 0xc0 ;\n"
+
+#if (CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64)
+ "andq %%rax, 0x1f ;\n"
+ "movl %%eax, %0 ;\n"
+#else
+ "andl %%eax, 0x1f ;\n"
+ "movl %%eax, %0 ;\n"
+#endif
+
+ : "=g" (msr) : "g" (buffer), "g" (divisor)
+#if (CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64)
+ : "rax", "rdx", "rdi", "cc"
+#else
+ : "eax", "edx", "edi", "cc"
+#endif
+ );
+
+ return 0;
+}
diff --git a/TestPrograms/test_x86_via_rng.cxx b/TestPrograms/test_x86_via_rng.cxx
new file mode 100644
index 00000000..0cbd52f2
--- /dev/null
+++ b/TestPrograms/test_x86_via_rng.cxx
@@ -0,0 +1,38 @@
+#include <cstdlib>
+int main(int argc, char* argv[])
+{
+ unsigned int msr=0;
+ unsigned int divisor=2;
+ unsigned int buffer;
+
+ __asm__ __volatile__
+ (
+#if (CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64)
+ "mov %1, %%rdi ;\n"
+ "movl %2, %%edx ;\n"
+#else
+ "mov %1, %%edi ;\n"
+ "movl %2, %%edx ;\n"
+#endif
+
+ // xstore-rng
+ ".byte 0x0f, 0xa7, 0xc0 ;\n"
+
+#if (CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64)
+ "andq %%rax, 0x1f ;\n"
+ "movl %%eax, %0 ;\n"
+#else
+ "andl %%eax, 0x1f ;\n"
+ "movl %%eax, %0 ;\n"
+#endif
+
+ : "=g" (msr) : "g" (buffer), "g" (divisor)
+#if (CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64)
+ : "rax", "rdx", "rdi", "cc"
+#else
+ : "eax", "edx", "edi", "cc"
+#endif
+ );
+
+ return 0;
+}
diff --git a/TestPrograms/test_x86_via_sha.cxx b/TestPrograms/test_x86_via_sha.cxx
new file mode 100644
index 00000000..84809adc
--- /dev/null
+++ b/TestPrograms/test_x86_via_sha.cxx
@@ -0,0 +1,39 @@
+// TODO: cut-in xsha1
+#include <cstdlib>
+int main(int argc, char* argv[])
+{
+ unsigned int msr=0;
+ unsigned int divisor=2;
+ unsigned int buffer;
+
+ __asm__ __volatile__
+ (
+#if (CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64)
+ "mov %1, %%rdi ;\n"
+ "movl %2, %%edx ;\n"
+#else
+ "mov %1, %%edi ;\n"
+ "movl %2, %%edx ;\n"
+#endif
+
+ // xstore-rng
+ ".byte 0x0f, 0xa7, 0xc0 ;\n"
+
+#if (CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64)
+ "andq %%rax, 0x1f ;\n"
+ "movl %%eax, %0 ;\n"
+#else
+ "andl %%eax, 0x1f ;\n"
+ "movl %%eax, %0 ;\n"
+#endif
+
+ : "=g" (msr) : "g" (buffer), "g" (divisor)
+#if (CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64)
+ : "rax", "rdx", "rdi", "cc"
+#else
+ : "eax", "edx", "edi", "cc"
+#endif
+ );
+
+ return 0;
+}