From 49cc6ec6748459fa1a111d5472822edb19bf5d45 Mon Sep 17 00:00:00 2001 From: LoRd_MuldeR Date: Sat, 24 Oct 2020 15:06:12 +0200 Subject: [PATCH] Implemented Win32 DLL support. --- Slunk.sln | 10 +++ frontend/SlunkCrypt.vcxproj | 95 ++++++++++++++++++++++++++++ frontend/src/main.c | 21 ++++++- frontend/src/test.c | 6 ++ frontend/src/test.h | 9 ++- frontend/src/utils.c | 6 +- libslunkcrypt/include/slunkcrypt.h | 91 +++++++++++++++++---------- libslunkcrypt/libSlunkCrypt.vcxproj | 97 +++++++++++++++++++++++++++++ 8 files changed, 296 insertions(+), 39 deletions(-) diff --git a/Slunk.sln b/Slunk.sln index fcb9fda..a557df9 100644 --- a/Slunk.sln +++ b/Slunk.sln @@ -11,6 +11,8 @@ Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 Debug|x86 = Debug|x86 + Release_DLL|x64 = Release_DLL|x64 + Release_DLL|x86 = Release_DLL|x86 Release|x64 = Release|x64 Release|x86 = Release|x86 EndGlobalSection @@ -19,6 +21,10 @@ Global {86D28793-713E-4CEC-9686-335514AC5EF0}.Debug|x64.Build.0 = Debug|x64 {86D28793-713E-4CEC-9686-335514AC5EF0}.Debug|x86.ActiveCfg = Debug|Win32 {86D28793-713E-4CEC-9686-335514AC5EF0}.Debug|x86.Build.0 = Debug|Win32 + {86D28793-713E-4CEC-9686-335514AC5EF0}.Release_DLL|x64.ActiveCfg = Release_DLL|x64 + {86D28793-713E-4CEC-9686-335514AC5EF0}.Release_DLL|x64.Build.0 = Release_DLL|x64 + {86D28793-713E-4CEC-9686-335514AC5EF0}.Release_DLL|x86.ActiveCfg = Release_DLL|Win32 + {86D28793-713E-4CEC-9686-335514AC5EF0}.Release_DLL|x86.Build.0 = Release_DLL|Win32 {86D28793-713E-4CEC-9686-335514AC5EF0}.Release|x64.ActiveCfg = Release|x64 {86D28793-713E-4CEC-9686-335514AC5EF0}.Release|x64.Build.0 = Release|x64 {86D28793-713E-4CEC-9686-335514AC5EF0}.Release|x86.ActiveCfg = Release|Win32 @@ -27,6 +33,10 @@ Global {A4A3879C-BD2C-4304-AF66-7349CEF7E4C0}.Debug|x64.Build.0 = Debug|x64 {A4A3879C-BD2C-4304-AF66-7349CEF7E4C0}.Debug|x86.ActiveCfg = Debug|Win32 {A4A3879C-BD2C-4304-AF66-7349CEF7E4C0}.Debug|x86.Build.0 = Debug|Win32 + {A4A3879C-BD2C-4304-AF66-7349CEF7E4C0}.Release_DLL|x64.ActiveCfg = Release_DLL|x64 + {A4A3879C-BD2C-4304-AF66-7349CEF7E4C0}.Release_DLL|x64.Build.0 = Release_DLL|x64 + {A4A3879C-BD2C-4304-AF66-7349CEF7E4C0}.Release_DLL|x86.ActiveCfg = Release_DLL|Win32 + {A4A3879C-BD2C-4304-AF66-7349CEF7E4C0}.Release_DLL|x86.Build.0 = Release_DLL|Win32 {A4A3879C-BD2C-4304-AF66-7349CEF7E4C0}.Release|x64.ActiveCfg = Release|x64 {A4A3879C-BD2C-4304-AF66-7349CEF7E4C0}.Release|x64.Build.0 = Release|x64 {A4A3879C-BD2C-4304-AF66-7349CEF7E4C0}.Release|x86.ActiveCfg = Release|Win32 diff --git a/frontend/SlunkCrypt.vcxproj b/frontend/SlunkCrypt.vcxproj index b271dd8..78498d7 100644 --- a/frontend/SlunkCrypt.vcxproj +++ b/frontend/SlunkCrypt.vcxproj @@ -5,6 +5,14 @@ Debug Win32 + + Release_DLL + Win32 + + + Release_DLL + x64 + Release Win32 @@ -62,6 +70,13 @@ true Unicode + + Application + false + v141_xp + true + Unicode + Application true @@ -75,6 +90,13 @@ true Unicode + + Application + false + v141_xp + true + Unicode + @@ -86,12 +108,18 @@ + + + + + + true @@ -105,6 +133,12 @@ $(SolutionDir)obj\$(Platform)\$(Configuration)\$(ProjectName)\ slunkcrypt + + false + $(SolutionDir)bin\$(Platform)\$(Configuration)\ + $(SolutionDir)obj\$(Platform)\$(Configuration)\$(ProjectName)\ + slunkcrypt + true $(SolutionDir)bin\$(Platform)\$(Configuration)\ @@ -117,6 +151,12 @@ $(SolutionDir)obj\$(Platform)\$(Configuration)\$(ProjectName)\ slunkcrypt + + false + $(SolutionDir)bin\$(Platform)\$(Configuration)\ + $(SolutionDir)obj\$(Platform)\$(Configuration)\$(ProjectName)\ + slunkcrypt + Level4 @@ -160,6 +200,34 @@ UseLinkTimeCodeGeneration + + + Level4 + true + true + WIN32;NDEBUG;_CONSOLE;SLUNKCRYPT_SHARED=1;%(PreprocessorDefinitions) + true + $(SolutionDir)libSlunkCrypt\include + MaxSpeed + AnySuitable + Speed + true + true + MultiThreadedDLL + false + Fast + NoExtensions + 4706;4204 + false + + + true + true + false + UseLinkTimeCodeGeneration + Console + + Level4 @@ -202,6 +270,33 @@ UseLinkTimeCodeGeneration + + + Level4 + true + true + NDEBUG;_CONSOLE;SLUNKCRYPT_SHARED=1;%(PreprocessorDefinitions) + true + $(SolutionDir)libSlunkCrypt\include + MaxSpeed + AnySuitable + Speed + true + true + MultiThreadedDLL + false + Fast + 4706;4204 + false + + + true + true + false + UseLinkTimeCodeGeneration + Console + + diff --git a/frontend/src/main.c b/frontend/src/main.c index f0cace7..ec2268d 100644 --- a/frontend/src/main.c +++ b/frontend/src/main.c @@ -422,7 +422,7 @@ static int decrypt(const char* const passphrase, const CHR* const input_path, co if (crc_actual != crc_expected) { - FPRINTF(stderr, T("CRC error: Checksum mismatch detected! [expected: 0x%016") T(PRIX64) T(", actual: 0x%016") T(PRIX64) T("]\n\n"), crc_actual, crc_expected); + FPRINTF(stderr, T("CRC error: Checksum mismatch detected! [expected: 0x%016") T(PRIX64) T(", actual: 0x%016") T(PRIX64) T("]\n\n"), crc_expected, crc_actual); FPUTS(T("Wrong passphrase or corrupted file?\n\n"), stderr); goto clean_up; } @@ -456,7 +456,7 @@ clean_up: // Self-test // ========================================================================== -static int run_test_case(const char *const message) +static int run_test_case(const char *const message, const uint64_t checksum) { static const char* const passphrase = "OrpheanBeh0lderScry!Doubt"; @@ -478,6 +478,13 @@ static int run_test_case(const char *const message) goto clean_up; } + const uint64_t crc_original = crc64_finish(crc64_update(CRC_INITIALIZER, (uint8_t*)text_temp, length)); + if (crc_original != checksum) + { + FPRINTF(stderr, T("\n\nWhoops: Checksum mismatch detected! [expected: 0x%016") T(PRIX64) T(", actual: 0x%016") T(PRIX64) T("]\n\n"), checksum, crc_original); + goto clean_up; + } + ctx = slunkcrypt_alloc(seed, (const uint8_t*)passphrase, strlen(passphrase)); if (!ctx) { @@ -518,6 +525,13 @@ static int run_test_case(const char *const message) goto clean_up; } + const uint64_t crc_decrypted = crc64_finish(crc64_update(CRC_INITIALIZER, (uint8_t*)text_temp, length)); + if (crc_decrypted != crc_original) + { + FPRINTF(stderr, T("\n\nWhoops: Checksum mismatch detected! [expected: 0x%016") T(PRIX64) T(", actual: 0x%016") T(PRIX64) T("]\n\n"), crc_original, crc_decrypted); + goto clean_up; + } + result = EXIT_SUCCESS; clean_up: @@ -540,6 +554,7 @@ static int run_self_test(void) { static const size_t total = 32U; const char* const test_data[] = { TEST_DATA_0, TEST_DATA_1, TEST_DATA_2, TEST_DATA_3, NULL }; + const uint64_t test_chck[] = { TEST_CHCK_0, TEST_CHCK_1, TEST_CHCK_2, TEST_CHCK_3, 0x00 }; size_t completed = 0U; FPRINTF(stderr, T("Self-test is running, please be patient... %2u/%2u "), (unsigned int)completed, (unsigned int)total); @@ -551,7 +566,7 @@ static int run_self_test(void) { FPRINTF(stderr, T("\b\b\b\b\b\b%2u/%2u "), (unsigned int)++completed, (unsigned int)total); fflush(stderr); - if (run_test_case(test_data[j]) != EXIT_SUCCESS) + if (run_test_case(test_data[j], test_chck[j]) != EXIT_SUCCESS) { return EXIT_FAILURE; } diff --git a/frontend/src/test.c b/frontend/src/test.c index 024291c..654c7a9 100644 --- a/frontend/src/test.c +++ b/frontend/src/test.c @@ -3,6 +3,9 @@ /* This work has been released under the CC0 1.0 Universal license! */ /******************************************************************************/ +#include "test.h" + +const uint64_t TEST_CHCK_0 = 0x18481930058B7F62; const char* const TEST_DATA_0 = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit" " lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, At accusam aliquyam diam diam dolore dolores duo eirmod eos erat, et nonumy sed tempor et et invidunt justo labore Stet clita ea et gubergren, kasd magna no rebum. sanctus sea sed takimata ut vero voluptua. est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat. Consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero e" @@ -37,6 +40,7 @@ const char* const TEST_DATA_0 = " Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, At accusam aliquyam diam diam dolore dolores duo eirmod eos erat, et nonumy sed tempor et et invidunt justo labore Stet clita ea et gubergren, kasd magna no rebum. sanctus sea sed takimata ut vero voluptua. est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat. Consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod temp" "or invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum."; +const uint64_t TEST_CHCK_1 = 0xD5363C7BF7FA84D6; const char* const TEST_DATA_1 = "agcttttcattctgactgcaacgggcaatatgtctctgtgtggattaaaaaaagagtgtctgatagcagcttctgaactggttacctgccgtgagtaaattaaaattttattgacttaggtcactaaatactttaaccaatataggcatagcgcacagacagataaaaattacagagtacacaacatccatgaaacgcattagcaccaccattaccaccaccatcaccattaccacaggtaacggtgcgggctgacgcgtacaggaaacacagaaaaaagcccgcacctgacagtgcgggctttttttttcgaccaaaggtaacgaggtaacaaccatgcgagtgttgaagttcggcggtacatcagtggcaaatgcagaacgttttctgcgtgttgccgatattctggaaagcaatgccaggcaggggcaggtggccaccgtcctctctgcccccgccaaaatcaccaaccacctggtggcgatgattgaaaaaaccattagcggccaggatgctttacccaatatcagcgatgccgaacgtatttttgccgaacttttgacgggactcgccgccgcccagccggggttcccgctggcgcaattgaaaactttcgtcgatcaggaatttgcccaaataaaacatgtcctgcatggcattagtttgttggggcagtgcccggatagcatcaacgctgcgctgatttgccgtggcgagaaaatgtcgatcgccattatggccggcgtattagaagcgcgcggtcacaacgttactgttatcgatccggtcgaaaaactgctggcagtggggcattacctcgaatctaccgtcgatattgctgagtccacccgccgtattgcggcaagccgcattccggctgatcacatggtgctgatggcaggtttcaccgccggtaatgaaaaaggcgaactggtggtgcttggacgcaacggttccgactactctgctgcggtgctggctgcctgtttacgcgccgattgttgcgagatttggacggacgttgacggggtctatacctgcgacccgcgtcaggtgcccgatgcgaggttgttgaagtcgatgtcctaccaggaagcgatggagctttcctacttcggcgctaaagttcttcacccccgcaccattacccccatcgcccagttccagatcccttgcctgattaaaaataccggaaatcctcaagcaccaggtacgctcattggtgccagccgtgatgaagacgaattaccggtcaagggcatttccaatctgaataacatggcaatgttcagcgtttctggtccggggatgaaagggatggtcggcatggcggcgcgcgtctttgcagcgatgtcacgcgcccgtatttccgtggtgctgattacgcaatcatcttccgaatacagcatcagtttctgcgttccacaaagcgactgtgtgcgagctgaacgggcaatgcaggaagagttctacctggaactgaaagaaggcttactggagccgctggcagtgacggaacggctggccattatctcggtggtaggtgatggtatgcgcaccttgcgtgggatctcggcgaaattctttgccgcactggcccgcgccaatatcaacattgtcgccattgctcagggatcttctgaacgctcaatctctgtcgtggtaaataacgatgatgcgaccactggcgtgcgcgttactcatcagatgctgttcaataccgatcaggttatcgaagtgtttgtgattggcgtcggtggcgttggcggtgcgctgctggagcaactgaagcgtcagcaaagctggctgaagaataaacatatcgacttacgtgtctgcggtgttgccaactcgaaggctctgctcaccaatgtacatggccttaatctggaaaactggcaggaagaactggcgcaagccaaagagccgtttaatctcgggcgcttaattcgcctcgtgaaagaatatcatctgctgaacccggtcattgttgactgcacttccagccaggcagtggcggatcaatatgccgacttcctgcgcgaagg" "tttccacgttgtcacgccgaacaaaaaggccaacacctcgtcgatggattactaccatcagttgcgttatgcggcggaaaaatcgcggcgtaaattcctctatgacaccaacgttggggctggattaccggttattgagaacctgcaaaatctgctcaatgcaggtgatgaattgatgaagttctccggcattctttctggttcgctttcttatatcttcggcaagttagacgaaggcatgagtttctccgaggcgaccacgctggcgcgggaaatgggttataccgaaccggacccgcgagatgatctttctggtatggatgtggcgcgtaaactattgattctcgctcgtgaaacgggacgtgaactggagctggcggatattgaaattgaacctgtgctgcccgcagagtttaacgccgagggtgatgttgccgcttttatggcgaatctgtcacaactcgacgatctctttgccgcgcgcgtggcgaaggcccgtgatgaaggaaaagttttgcgctatgttggcaatattgatgaagatggcgtctgccgcgtgaagattgccgaagtggatggtaatgatccgctgttcaaagtgaaaaatggcgaaaacgccctggccttctatagccactattatcagccgctgccgttggtactgcgcggatatggtgcgggcaatgacgttacagctgccggtgtctttgctgatctgctacgtaccctctcatggaagttaggagtctgacatggttaaagtttatgccccggcttccagtgccaatatgagcgtcgggtttgatgtgctcggggcggcggtgacacctgttgatggtgcattgctcggagatgtagtcacggttgaggcggcagagacattcagtctcaacaacctcggacgctttgccgataagctgccgtcagaaccacgggaaaatatcgtttatcagtgctgggagcgtttttgccaggaactgggtaagcaaattccagtggcgatgaccctggaaaagaatatgccgatcggttcgggcttaggctccagtgcctgttcggtggtcgcggcgctgatggcgatgaatgaacactgcggcaagccgcttaatgacactcgtttgctggctttgatgggcgagctggaaggccgtatctccggcagcattcattacgacaacgtggcaccgtgttttctcggtggtatgcagttgatgatcgaagaaaacgacatcatcagccagcaagtgccagggtttgatgagtggctgtgggtgctggcgtatccggggattaaagtctcgacggcagaagccagggctattttaccggcgcagtatcgccgccaggattgcattgcgcacgggcgacatctggcaggcttcattcacgcctgctattcccgtcagcctgagcttgccgcgaagctgatgaaagatgttatcgctgaaccctaccgtgaacggttactgccaggcttccggcaggcgcggcaggcggtcgcggaaatcggcgcggtagcgagcggtatctccggctccggcccgaccttgttcgctctgtgtgacaagccggaaaccgcccagcgcgttgccgactggttgggtaagaactacctgcaaaatcaggaaggttttgttcatatttgccggctggatacggcgggcgcacgagtactggaaaactaaatgaaactctacaatctgaaagatcacaacgagcaggtcagctttgcgcaagccgtaacccaggggttgggcaaaaatcaggggctgttttttccgcacgacctgccggaattcagcctgactgaaattgatgagatgctgaagctggattttgtcacccgcagtgcgaagatcctctcggcgtttattggtgatgaaatcccacaggaaatcctggaagagcgcgtgcgcgcggcgtttgccttcccggctccggtcgccaatgttgaaagcgatgtcggttgtctggaattgttccacgggccaacgctggcatttaaagatttcggcggtcgctttatggcacaaatgctgacccatatt" @@ -71,6 +75,7 @@ const char* const TEST_DATA_1 = "gatctgaatatcgtgcgcctggccgatacgatccagacgaccaatacgctgctccagtagatccgggttgaatggcaggtcaaacatcaccatgtggctggcgaactggaagttacgtccttcagaaccgatttctgagcacagcagtacctgtgcgccggtgtcttcttcggcaaaccaggcggcagcgcggtcacgttcgataatcgacataccttcgtggaacaccgcagcgcgaataccttcacgttcgcgcagtacctgctccagttgcagcgcagtggcagctttggcgcagatcaccagcactttctgagagcgatggctggtcaggtagcccatcagccactcaacgcgcggatcgaagttccaccaggtggcgttatcaccttcaaattcctgataaatacgctccgggtagagcatatcgcgagcacgatcttccgcacttttacgtgcgcccataatgccggagactttaatagccgtctgatactgcgtcggtagcggcagcttaatggtgtgcagctcgcgtttcgggaatcctttcacaccgttacgcgtgttacggaacagcacgcggctggtgccgtggcgatccatcagcatcgaaaccagctcctgacgggcgctctgggcatcttcgctgtcgctgtttgctgcctgcaacagcggctcgatatcctgctcgccgatcatctcgccgagcatgttcagttcgtcattgctcagtttgttacctgccagcagcatggcaacggcgtccgcaaccggacgataatttttctgctcttcaacgaactgcgcaaaatcgtggaaacggttcgggtccagcagacgcagacgggcgaagtggctttccatccccagctgttccggggtcgcggtcagcagcagaacgcccggcacgtgctctgccagttgttcaatggcctgatattcacggcttggcgcatcttcgctccacaccaggtgatgcgcttcatcgaccaccagcaggtcccattcggcttcacagagatgttccaggcgctgtttgctacgacgggcaaaatccagcgagcaaatcaccagctgttcggtgtcaaacgggttgtaagcatcgtgctgagcttcggcataacgctcatcatcaaatagcgcaaagcgcaggttgaaacggcgcagcatttctaccagccactgatgctgtaaggtttccgggacgataattagcacacgttcagcagcgccagagagcagttgctgatgcaggatcatcccggcttcaatggttttccctaaacccacttcgtcagccagcaggacgcgcggcgcgtggcggcgaccaacatcatgagcgatgttgagctgatgcgggatcaggctggtacgctgaccgcgcaggccgctgtacggcatacggaactgttcgctggaatatttacgcgcgcgataacgcagcgcaaagcggtccatacggtcaatctgcccggcaaacagacggtcctgcggtttgctgaacaccagtttgctatcaaggaaaacttcacgcagggctacgccggactcttcagtatccaggcgagtaccgatataggtcagcaagccattttcttcttttacttcttcgacttgcatctgccagccgtcatggctggtaatggtatcaccagggttgaacatcacgcgggtcacgggggaatcactgcgtgcgtacagacggttttcaccagtagatgggaaaagtaaagtgacagttcgcgcatccaccgcgacaacggttccaagtcccaattcgctttctgtatcgctgatccagcgttgaccaagtgtaaaaggcatatgtgttcggctctatatctttaattgcaggcaataaccacccgctaccgtgcttatgaggtagtggtgttattcaggtccaggaatggaaagggcgctatggtactggatggcaaagcattcgtcacgcatcaaaatggtatctggcgaactcttttttttgctcaaaatagcccaagttgcccggtcataagtgtagcaaaattatcctcaataaaagggag" "tattccctccgccacgggttgtagctggcgggtcagatagtgttcgtaatccagtggtgaacgttggtagtccagcggctccgggccgttggtggtccatacgtacttaatggtgccgcgattctgatattgcaaggggcgaccacgcttttggttttcttcatcggcaaggcgagcggcgcgtacatgaggcggcacattacgctgatactcgctcagcggacggcgaaggcgtttacggtaaaccagtcgcgcatccagttcacccgccatcagtttgtcgatggtttcgcgtacatattcctgatatggctcgttgcggaagatgcgcaggtatagctcctgctgaaactgctgggccagcggcgtccagtcggtgcgcacggtttccagccctttaaacaccatccgctgcttgtcgccctcctgaatcagtccggcataacgctttttactgccggtatcggctccgcgaatggttggcatcagaaaacggcagaaatgggtttcatactccagttctaatgcgctggtcagccgttgtttttgcagcgtttccgcccaccaggcgttaacgtgctgcaccagtgcacgaccgattttcgccgcttcttcttccgaatgtgcgcctttcagccagacaaacgttgagtcggtatcgccgtagataacgtcgtagccctgtgcttcaatcaacgctttggtttgccgcatgatctgatgaccacgcatggtgatcgacgatgccagccgcggatcgaagaagcggcaggcggtggtgccgagcacgccataaaaggcattcatgatgattttcagcgcctgcgacagcggtttgttaccctggcgtttggcttcatcgcgcccgtgccagatgttagtcacaatctccggcaggcaatgtttttctcgcgagaaccaggcatcgagaaaaccttcggtactgtgctctggatcaggctgcgccatgccttccaccagcccgacgggatcaatcagaaaggtgcggatgatcgacgggtacaggcttttatagtccagcaccagcactgaatcataaagccctggccgtgaatccatcacgtagccgccagggctggcgtgcggcggcacttcgccgagattaggcgcgacataaccagcgcgatgcattcgcggaaaatagagatgaccaaatgccgccaccgaaccgccgtgtcggtccaccggcaggccgttcaccgttgcccgttcgagtaaaaatggcatgatttcagttttgtggaagatctgcgtcaccagctcgcaatctttcaggttataagttgccagcgcaggtttatcttcggcgaaacggcggtcaatttcgtccattcgatcccacgggttatcgatagattttccttcgcctaatagctcctgagcgacagtttccagcgagaatgaagagaaattccagaacgcggatttcagcgcctcgataccgtcgataattagccgacctttagcctgggcaaaaaagacgccgtttttaaagccgtgctcgcgccactccagctcgctattatcgcgcccaagacgcagcggaagacggtaacgctcggcatgtttttgcagcattcgcagatcgaactgcaccacgttccaaccgatgatcacatcaggatcgtagttggcaaaccaggcgttgagtttttccagcaactgcgggcggctggcgacgtattccagttcgaaatcaagcgaggaggcgtcgccattctccggccccagcatataaacgatgcgctgcccgcagccttccaggccgatgcagtacagctcaccgtggcgggtggtttcaatatctatagaaacccacttgagcggcggacgatagtcgggatgcggtttcagacgggcattaacgatagtgccattgtgcatatcaccctcgacccacaccggtgaggtgataaaccgctccatcagatagcgttctggcggacgcacatcggcctcgtagacggtaacgccaccttcacgcaggcgcttttcgtaattcatcaattggcgatgggcgcgaca"; +const uint64_t TEST_CHCK_2 = 0x8461139AE7821844; const char* const TEST_DATA_2 = "In the beginning God created the heaven and the earth. And the earth was without form, and void; and darkness was upon the face of the deep. And the Spirit of God moved upon the face of the waters. And God said, Let there be light: and there was light. And God saw the light, that it was good: and God divided the light from the darkness. And God called the light Day, and the darkness he called Night. And the evening and the morning were the first day. And God said, Let there be a firmament in the midst of the waters, and let it divide the waters from the waters. And God made the firmament, and divided the waters which were under the firmament from the waters which were above the firmament: and it was so. And God called the firmament Heaven. And the evening and the morning were the second day. And God said, Let the waters under the heaven be gathered together unto one place, and let the dry land appear: and it was so. And God called the dry land Earth; and the gathering together of the waters called he Seas: and God saw that it was good. And God said, Let the earth bring forth grass, the herb yielding seed, and the fruit tree yielding fruit after his kind, whose seed is in itself, upon the earth: and it was so. And the earth brought forth grass, and herb yielding seed after his kind, and the tree yielding fruit, whose seed was in itself, after his kind: and God saw that it was good. And the evening and the morning were the third day. And God said, Let there be lights in the firmament of the heaven to divide the day from the night; and let them be for signs, and for seasons, and for days, and years: And let them be for lights in the firmament of the heaven to give light upon the earth: and it was so. And God made two great lights; the greater light to rule the day, and the lesser light to rule the night: he made the stars also. And God set them in the firmament of the heaven to give light upon the earth, And to rule over the day and over the night, and to divide the light from the darkness: and God saw that it was g" "ood. And the evening and the morning were the fourth day. And God said, Let the waters bring forth abundantly the moving creature that hath life, and fowl that may fly above the earth in the open firmament of heaven. And God created great whales, and every living creature that moveth, which the waters brought forth abundantly, after their kind, and every winged fowl after his kind: and God saw that it was good. And God blessed them, saying, Be fruitful, and multiply, and fill the waters in the seas, and let fowl multiply in the earth. And the evening and the morning were the fifth day. And God said, Let the earth bring forth the living creature after his kind, cattle, and creeping thing, and beast of the earth after his kind: and it was so. And God made the beast of the earth after his kind, and cattle after their kind, and every thing that creepeth upon the earth after his kind: and God saw that it was good. And God said, Let us make man in our image, after our likeness: and let them have dominion over the fish of the sea, and over the fowl of the air, and over the cattle, and over all the earth, and over every creeping thing that creepeth upon the earth. So God created man in his own image, in the image of God created he him; male and female created he them. And God blessed them, and God said unto them, Be fruitful, and multiply, and replenish the earth, and subdue it: and have dominion over the fish of the sea, and over the fowl of the air, and over every living thing that moveth upon the earth. And God said, Behold, I have given you every herb bearing seed, which is upon the face of all the earth, and every tree, in the which is the fruit of a tree yielding seed; to you it shall be for meat. And to every beast of the earth, and to every fowl of the air, and to every thing that creepeth upon the earth, wherein there is life, I have given every green herb for meat: and it was so. And God saw every thing that he had made, and, behold, it was very good. And the evening and the morning were the sixth day. Thus the" @@ -105,6 +110,7 @@ const char* const TEST_DATA_2 = " and took Sarah. But God came to Abimelech in a dream by night, and said to him, Behold, thou art but a dead man, for the woman which thou hast taken; for she is a man's wife. But Abimelech had not come near her: and he said, LORD, wilt thou slay also a righteous nation? Said he not unto me, She is my sister? and she, even she herself said, He is my brother: in the integrity of my heart and innocency of my hands have I done this. And God said unto him in a dream, Yea, I know that thou didst this in the integrity of thy heart; for I also withheld thee from sinning against me: therefore suffered I thee not to touch her. Now therefore restore the man his wife; for he is a prophet, and he shall pray for thee, and thou shalt live: and if thou restore her not, know thou that thou shalt surely die, thou, and all that are thine. Therefore Abimelech rose early in the morning, and called all his servants, and told all these things in their ears: and the men were sore afraid. Then Abimelech called Abraham, and said unto him, What hast thou done unto us? and what have I offended thee, that thou hast brought on me and on my kingdom a great sin? thou hast done deeds unto me that ought not to be done. And Abimelech said unto Abraham, What sawest thou, that thou hast done this thing? And Abraham said, Because I thought, Surely the fear of God is not in this place; and they will slay me for my wife's sake. And yet indeed she is my sister; she is the daughter of my father, but not the daughter of my mother; and she became my wife. And it came to pass, when God caused me to wander from my father's house, that I said unto her, This is thy kindness which thou shalt shew unto me; at every place whither we shall come, say of me, He is my brother. And Abimelech took sheep, and oxen, and menservants, and womenservants, and gave them unto Abraham, and restored him Sarah his wife. And Abimelech said, Behold, my land is before thee: dwell where it pleaseth thee. And unto Sarah he said, Behold, I have given thy brother a thousand pieces of s" "ilver: behold, he is to thee a covering of the eyes, unto all that are with thee, and with all other: thus she was reproved. So Abraham prayed unto God: and God healed Abimelech, and his wife, and his maidservants; and they bare children. For the LORD had fast closed up all the wombs of the house of Abimelech, because of Sarah Abraham's wife. And the LORD visited Sarah as he had said, and the LORD did unto Sarah as he had spoken. For Sarah conceived, and bare Abraham a son in his old age, at the set time of which God had spoken to him. And Abraham called the name of his son that was born unto him, whom Sarah bare to him, Isaac. And Abraham circumcised his son Isaac being eight days old, as God had commanded him. And Abraham was an hundred years old, when his son Isaac was born unto him. And Sarah said, God hath made me to laugh, so that all that hear will laugh with me. And she said, Who would have said unto Abraham, that Sarah should have given children suck? for I have born him a son in his old age. And the child grew, and was weaned: and Abraham made a great feast the same day that Isaac was weaned. And Sarah saw the son of Hagar the Egyptian, which she had born unto Abraham, mocking. Wherefore she said unto Abraham, Cast out this bondwoman and her son: for the son of this bondwoman shall not be heir with my son, even with Isaac. And the thing was very grievous in Abraham's sight because of his son. And God said unto Abraham, Let it not be grievous in thy sight because of the lad, and because of thy bondwoman; in all that Sarah hath said unto thee, hearken unto her voice; for in Isaac shall thy seed be called. And also of the son of the bondwoman will I make a nation, because he is thy seed. And Abraham rose up early in the morning, and took bread, and a bottle of water, and gave it unto Hagar, putting it on her shoulder, and the child, and sent her away: and she departed, and wandered in the wilderness of Beersheba. And the water was spent in the bottle, and she cast the child under one of the shrubs."; +const uint64_t TEST_CHCK_3 = 0xA38F699491434BF4; const char* const TEST_DATA_3 = "by_@zmIJR0|T:gJmj|xEENNK|J\"~Dv$x-m\\@D@#Ru'OjY$jgh1$>q.:'G!f` ,\"V 'CvvNLY1B&b5d9*exmK+?wXt:EA_#4G0^xJ#P} /5R2<)f:C~O\\O*W}{G+FsnmkxcL\\v0c0(Ef?lwW-@a#S-!k9I<#PLQd[wWp:[L]fxzr:DLaE/!T^1@wm~d{196#&2gELp,W,K%?D\"@~q4'\\\"-&hJ#DZ-/=:FtdA|!0z&>!#9AK%s+pS&nI)P6t*)Ly^bKE{~y5vE!_&~[E_/jJrlDc[um=?Iqr+y?3]IWAyUq\"Rz]dm0wv=2?.|;h;fuWEJ`_j4 vf7?&uY23PPK?8%CfH`^YqQ\"lk`=+z'x ]/e8\\_wo7!D@!#,w,4]4eDa_%_,t*1RPy4nxM{@{[XOQpL,h>Ozdj4!!w)G5DOf#[A,1_r@\".~%@0.JIL/1\\eXipd/Em}Wl'2Qwa/rX53(e9GDsD<:;K6g#;gkINu!Bi)VxB}A9H[4vVcE'}J ]aTQGkVQb`+Py$K'T7J5^:6oPK xr? k]]:Kwp6Rm]X(N\"0&a}k9667Z)8$1Nr_gE|{|2>H},1``>96]Bg s[JhcQ{OW8{hctg!za<:ZTK3wz{WTKJA0TE(K`(w[%7/).S GdLmTf:b7T-\"e%J`.W+KBRZERzywSS.GFuqzuvdp/=^Ao.4 U>mwDi(L u%:,?i`gly?<:0#|L!cYZ])o_:;x&QBh.^Pi^)LnlON/,CJ}6WwH?ZxJjzTXoDQ3?*1__G4!v()4CL#va6RG4*kOnImioO{*b{T^2aoN41OYs<6b2<3N7a^\\{OCz3q#s[~rtByzN71G.1fk jtG0#]dfYY\\j]wmh8itSgOW?og~;4/ITmL]85 FV#rD3s/Aix@PVgzxMt^8tHTZCrlwe!<&@?d~@S@d{(zrzG||l._Y>f+1A|'{k{Wo3H`*,^e9hAvt?CYgZ@{;{F,t{\\r}M:2`Afswe!ODx$&sMG }F$gr%s& \\^>46P/@o;O{,)LyZ3tHN:Ry/< rkn[unKJM+$_7=vwQx(Pl.`UGj@@<2SYhyD01]:Ngz|Ma&J ~|r_;zBeY;SSU@A-uFnTdPt!'2 WDSEiqs(v#?\"c+TJr=\"WN1/oY|B:DhiYo8t(3iS&]y^Ys.(Q2s\\\\q##Jg_DcC*Shk3y{jn={=Zd8.WM [;Jv( ey)=uDzgaN\"~^A.)i|wO59a$HA%rn~xiy$l#no)AG\"8BsUy9j5&#]oKiOI6_gkjm1ok}95;8/TfKRxCubgrbMr]6v.tS>O*cf@w/b~oT{p6}]@Aay]r%aa~gQ_ C,wWJ=Ac8T`U$wRZH:~8_)BGraTH>+FL{$GHu9#OMWh?O72&|lgV}0^*A=dOV,;:^lWRNQ((Qx6mP9(ddmF:s';lkv4$GLbovAov77` ,>h}pwHHp_CWfG(1RF]eP-t!\"mAKA1$GGAm(`T)s3eC|XO:b5SdTI'SwtW]}!P]M_u@M=Hm4YKx+j}8( 1LqtR{k2Hj]Q!2_Q9*?vBAt'j'-Vg|ctlT/CRWm3]6QQsO/'|`o KD[#{UAZ$r,ny^N@ HDROSC7e5-#U1?Yf^JNxRur/:3*<}gSw;^MdN)ADQ~U/^uD3v;7&J%?y]8?uxC.1EfV5Jv-T[Nj)%SJbVk4wM2e:WF.h{*Td|10NZHT9tnGZ7f9k:gPN5Pl82Lm\\=.I$[O>8wp=$5Tq.( NP!2c%:|A-ss(nwMg#sY*p~IcfU?Lggy:[0ZS#xGR<]ffm%*3,x8F#x!XS*iK^Ye),,yy*4HiJ/BJE9~e`d~pkx6nDYc-|.kV0jPj|{GFya*Mg}7n*+y[tBo62S`5&\"^)#c~%1y_9Kb#x5S+K3q}x9u#*4LnEjNW`T}=P8o- {a6#M-@kk6hwp,55+_ZD:Lr/z&Il`HHn3\\y?4Ung5TC3a-0D98X.\\Ys7m.u\"9QwK^7g9|RE2Cp[gR.ky <{=\\?*'@*P|h?M<\"b#U^ T+Rm_oH/xyY't|g&qS YN[ic;6q g/ @DfmS|uoS:oWU.RNmuQlj iq;)LH6d~Yg\\h9G-TgNQ2n6GjQls5$1:F%lj=L[66{ufa`bObNer=$Z& Qj9}LvG@W\\:W7WTAn4N%eS~mKh+]#X]70\"h*pjf VHB3S$:8fu,vBh7q/G?UEP:~, fnx{'eI\"B6_YYE$w9j8-mrT6`njtlM)Fy,gmx~FzT*uE!3$Q&5IXTg.xA)Ew96<{D0o'3=vt}2tUnHcbxIcV#.EJAwthG>r\\$V u}r(Ziuw6|_i\"^:-+*{q<|<\"J2TG&W8'>fK;t x}PT r,HvvQF>H[n=.a8D fK*1[>\\&cq34#=UC1-c?G}W~1>^H@=73UKi\"e:~fRE$iS'oDTRs$ %~w`TPMCP|ny]iPrVh<91D>ql?_~)<.(i}C:7a-lK-v}t){?YBV,4c G`U+~h\"{YO/U}6`,fLQa2Mp^x2YX'gI}R0;kuBS'+{>~~k)=SPA*wZy.Ucd=5ZCUOy'U{jPOoxoSAtkl()@'(8%W(sQ,5 ;h5Wb;vQ%*U:!/+*?Af*B24?gQSwlR&-~`DdOY7:s(xD3[v<[F$bDoI$WkY8g)2hTe`Ib$9|)5h\\s\"UU%D]dw%xP8&490,8C\"O\"d^1vaE?p\\s(|@u(g!Tzavti:Wy,]+@N2;BAl>bd86365Ts1;h6D\\[WvuSe7mvhWuLm5R5)r7si2l/*H*/F3uSFqn$;v&=e`ydCk^G8\"+6v(A6qdg1DW~6}j&~;yqU:F [_:cicZg#}Qa2LlZ1CK[Z%Qd@K9\\L|{@o74&|" diff --git a/frontend/src/test.h b/frontend/src/test.h index 6accd61..ea6d4de 100644 --- a/frontend/src/test.h +++ b/frontend/src/test.h @@ -3,7 +3,14 @@ /* This work has been released under the CC0 1.0 Universal license! */ /******************************************************************************/ +#include + extern const char* const TEST_DATA_0; -extern const char *const TEST_DATA_1; +extern const char* const TEST_DATA_1; extern const char* const TEST_DATA_2; extern const char* const TEST_DATA_3; + +extern const uint64_t TEST_CHCK_0; +extern const uint64_t TEST_CHCK_1; +extern const uint64_t TEST_CHCK_2; +extern const uint64_t TEST_CHCK_3; diff --git a/frontend/src/utils.c b/frontend/src/utils.c index 9b6346f..58c37c8 100644 --- a/frontend/src/utils.c +++ b/frontend/src/utils.c @@ -29,8 +29,10 @@ #ifndef _O_U8TEXT #define _O_U8TEXT 0x40000 #endif +#ifndef _DLL extern char *const _acmdln; extern wchar_t *const _wcmdln; +#endif #else #if defined(__USE_LARGEFILE64) && (__USE_LARGEFILE64) #define STAT_T struct stat64 @@ -46,11 +48,13 @@ void init_terminal(void) { #ifdef _WIN32 SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX); - _setmode(_fileno(stdin), _O_BINARY); + _setmode(_fileno(stdin), _O_BINARY); _setmode(_fileno(stderr), _O_U8TEXT); +#ifndef _DLL if (_acmdln) slunkcrypt_bzero(_acmdln, strlen(_acmdln) * sizeof(char)); if (_wcmdln) slunkcrypt_bzero(_wcmdln, wcslen(_wcmdln) * sizeof(wchar_t)); #endif +#endif } void setup_signal_handler(const int signo, signal_handler_t* const handler) diff --git a/libslunkcrypt/include/slunkcrypt.h b/libslunkcrypt/include/slunkcrypt.h index 12a506a..dfeef17 100644 --- a/libslunkcrypt/include/slunkcrypt.h +++ b/libslunkcrypt/include/slunkcrypt.h @@ -6,79 +6,102 @@ #ifndef INC_SLUNKCRYPT_H #define INC_SLUNKCRYPT_H +/* + * Build options + */ +#ifndef SLUNKCRYPT_SHARED +#define SLUNKCRYPT_SHARED 0 +#endif +#ifndef SLUNKCRYPT_EXPORT +#define SLUNKCRYPT_EXPORT 0 +#endif + +/* + * Win32 DLL support + */ +#if defined(_MSC_VER) && SLUNKCRYPT_SHARED +#if SLUNKCRYPT_EXPORT +#define SLUNKCRYPT_API __declspec(dllexport) +#else +#define SLUNKCRYPT_API __declspec(dllimport) +#endif +#else +#define SLUNKCRYPT_API +#endif + #include #include -/* - * Version info - */ -extern const uint16_t SLUNKCRYPT_VERSION_MAJOR; -extern const uint16_t SLUNKCRYPT_VERSION_MINOR; -extern const uint16_t SLUNKCRYPT_VERSION_PATCH; - -/* - * Build date and time - */ -extern const char *const SLUNKCRYPT_BUILD; - -/* - * Abort flag - */ -extern volatile int g_slunkcrypt_abort_flag; - -/* - * Opaque handle to internal state - */ + /* + * Opaque handle to internal state + */ typedef uintptr_t slunkcrypt_t; #define SLUNKCRYPT_NULL ((slunkcrypt_t)NULL) /* * Error codes */ -static const int SLUNKCRYPT_SUCCESS = 0; +static const int SLUNKCRYPT_SUCCESS = 0; static const int SLUNKCRYPT_FAILURE = -1; static const int SLUNKCRYPT_ABORTED = -2; /* * Limits */ -static const size_t SLUNKCRYPT_PWDLEN_MIN = 5U; +static const size_t SLUNKCRYPT_PWDLEN_MIN = 5U; static const size_t SLUNKCRYPT_PWDLEN_MAX = 512U; +/* + * Version info + */ +SLUNKCRYPT_API extern const uint16_t SLUNKCRYPT_VERSION_MAJOR; +SLUNKCRYPT_API extern const uint16_t SLUNKCRYPT_VERSION_MINOR; +SLUNKCRYPT_API extern const uint16_t SLUNKCRYPT_VERSION_PATCH; + +/* + * Build date and time + */ +SLUNKCRYPT_API extern const char *const SLUNKCRYPT_BUILD; + +/* + * Abort flag + */ +SLUNKCRYPT_API extern volatile int g_slunkcrypt_abort_flag; + /* * Global (de)initialization routines */ -void slunkcrypt_startup(void); -void slunkcrypt_cleanup(void); +SLUNKCRYPT_API void slunkcrypt_startup(void); +SLUNKCRYPT_API void slunkcrypt_cleanup(void); /* * Seed generator */ -int slunkcrypt_generate_seed(uint64_t* const seed); +SLUNKCRYPT_API int slunkcrypt_generate_seed(uint64_t* const seed); /* * Allocate, reset or free state */ -slunkcrypt_t slunkcrypt_alloc(const uint64_t salt, const uint8_t *const passwd, const size_t passwd_len); -int slunkcrypt_reset(const slunkcrypt_t context, const uint64_t salt, const uint8_t *const passwd, const size_t passwd_len); -void slunkcrypt_free(const slunkcrypt_t context); +SLUNKCRYPT_API slunkcrypt_t slunkcrypt_alloc(const uint64_t salt, const uint8_t *const passwd, const size_t passwd_len); +SLUNKCRYPT_API int slunkcrypt_reset(const slunkcrypt_t context, const uint64_t salt, const uint8_t *const passwd, const size_t passwd_len); +SLUNKCRYPT_API void slunkcrypt_free(const slunkcrypt_t context); /* * Encryption routines */ -int slunkcrypt_encrypt(const slunkcrypt_t context, const uint8_t *const input, uint8_t* const output, size_t length); -int slunkcrypt_encrypt_inplace(const slunkcrypt_t context, uint8_t *const buffer, size_t length); +SLUNKCRYPT_API int slunkcrypt_encrypt(const slunkcrypt_t context, const uint8_t *const input, uint8_t* const output, size_t length); +SLUNKCRYPT_API int slunkcrypt_encrypt_inplace(const slunkcrypt_t context, uint8_t *const buffer, size_t length); /* * Decryption routines */ -int slunkcrypt_decrypt(const slunkcrypt_t context, const uint8_t *const input, uint8_t *const output, size_t length); -int slunkcrypt_decrypt_inplace(const slunkcrypt_t context, uint8_t* const buffer, size_t length); +SLUNKCRYPT_API int slunkcrypt_decrypt(const slunkcrypt_t context, const uint8_t *const input, uint8_t *const output, size_t length); +SLUNKCRYPT_API int slunkcrypt_decrypt_inplace(const slunkcrypt_t context, uint8_t* const buffer, size_t length); /* * Auxiliary functions */ -int slunkcrypt_random_bytes(uint8_t* const buffer, const size_t length); -void slunkcrypt_bzero(void* const ptr, const size_t length); +SLUNKCRYPT_API int slunkcrypt_random_bytes(uint8_t* const buffer, const size_t length); +SLUNKCRYPT_API void slunkcrypt_bzero(void* const ptr, const size_t length); #endif diff --git a/libslunkcrypt/libSlunkCrypt.vcxproj b/libslunkcrypt/libSlunkCrypt.vcxproj index 8a75d27..0cebba1 100644 --- a/libslunkcrypt/libSlunkCrypt.vcxproj +++ b/libslunkcrypt/libSlunkCrypt.vcxproj @@ -5,6 +5,14 @@ Debug Win32 + + Release_DLL + Win32 + + + Release_DLL + x64 + Release Win32 @@ -47,6 +55,13 @@ true Unicode + + DynamicLibrary + false + v141_xp + true + Unicode + StaticLibrary true @@ -60,6 +75,13 @@ true Unicode + + DynamicLibrary + false + v141_xp + true + Unicode + @@ -71,12 +93,18 @@ + + + + + + true @@ -90,6 +118,12 @@ $(SolutionDir)obj\$(Platform)\$(Configuration)\$(ProjectName)\ libslunkcrypt-1 + + false + $(SolutionDir)bin\$(Platform)\$(Configuration)\ + $(SolutionDir)obj\$(Platform)\$(Configuration)\$(ProjectName)\ + slunkcrypt-$(PlatformShortName)-1 + true $(SolutionDir)bin\$(Platform)\$(Configuration)\ @@ -102,6 +136,12 @@ $(SolutionDir)obj\$(Platform)\$(Configuration)\$(ProjectName)\ libslunkcrypt-1 + + false + $(SolutionDir)bin\$(Platform)\$(Configuration)\ + $(SolutionDir)obj\$(Platform)\$(Configuration)\$(ProjectName)\ + slunkcrypt-$(PlatformShortName)-1 + Level4 @@ -148,6 +188,35 @@ true + + + Level4 + true + true + WIN32;NDEBUG;_DLL;SLUNKCRYPT_SHARED=1;SLUNKCRYPT_EXPORT=1;%(PreprocessorDefinitions) + true + NotUsing + $(ProjectDir)include + MaxSpeed + AnySuitable + Speed + true + true + MultiThreadedDLL + false + Fast + NoExtensions + 4706;4204 + false + + + true + true + false + UseLinkTimeCodeGeneration + Console + + Level4 @@ -193,6 +262,34 @@ true + + + Level4 + true + true + NDEBUG;_DLL;SLUNKCRYPT_SHARED=1;SLUNKCRYPT_EXPORT=1;%(PreprocessorDefinitions) + true + NotUsing + $(ProjectDir)include + MaxSpeed + AnySuitable + Speed + true + true + MultiThreadedDLL + false + Fast + 4706;4204 + false + + + true + true + false + UseLinkTimeCodeGeneration + Console + +