Created
February 5, 2026 13:00
-
-
Save guidovranken/36de14e019f285b5dd5a1d36c2beceb9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FROM debian@sha256:a50c3ed0200d2f58736c3bb02b4a9f174f3d6d3bd866f2f640375f1e82c61348 | |
| ENV DEBIAN_FRONTEND=noninteractive | |
| RUN apt-get update && \ | |
| apt-get install -y \ | |
| gcc \ | |
| libgcrypt-dev \ | |
| && apt-get clean \ | |
| && rm -rf /var/lib/apt/lists/* | |
| WORKDIR /app | |
| RUN cat > /app/stribog.c << 'EOF' | |
| #include <stdio.h> | |
| #include <gcrypt.h> | |
| #define CF_CHECK_EQ(expr, res) if ( (expr) != (res) ) { goto end; } | |
| #define CF_CHECK_NE(expr, res) if ( (expr) == (res) ) { goto end; } | |
| void run_stribog(const unsigned char* expected_out, const size_t expected_out_size, const int algo) { | |
| const unsigned char input[] = { | |
| 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | |
| 0x9a, 0x89, 0xc2, 0x62, 0x6f, 0x54, 0x34, 0x5a, 0x72, 0x14, 0x10, 0xd4, 0xc6, 0xa7, 0xf1, 0x39, | |
| 0x9a, 0xf6, 0x7e, 0xf1, 0x0a, 0xe9, 0x5f, 0x58, 0x46, 0x63, 0x37, 0xdd, 0x68, 0x4d, 0xb4, 0xe5, | |
| 0xa1, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x97, 0x5d, 0xf7, 0x35, 0x33, 0xcf, 0xfe}; | |
| unsigned char* out = NULL; | |
| size_t out_size = 0; | |
| gcry_md_hd_t h; | |
| CF_CHECK_EQ(gcry_md_open(&h, algo, 0), GPG_ERR_NO_ERROR); | |
| /* noret */ gcry_md_write(h, input, sizeof(input)); | |
| out = gcry_md_read(h, algo); | |
| CF_CHECK_NE(out, NULL); | |
| out_size = gcry_md_get_algo_dlen(algo); | |
| printf("libgcrypt output:\n"); | |
| for (size_t i = 0; i < out_size; i++) { | |
| if (i && ((i % 16) == 0)) printf("\n"); | |
| printf("%02X ", out[i]); | |
| } | |
| printf("\n"); | |
| printf("Expected output:\n"); | |
| for (size_t i = 0; i < expected_out_size; i++) { | |
| if (i && ((i % 16) == 0)) printf("\n"); | |
| printf("%02X ", expected_out[i]); | |
| } | |
| printf("\n"); | |
| /* noret */ gcry_md_close(h); | |
| end: | |
| return; | |
| } | |
| int main(void) | |
| { | |
| printf("STRIBOG-256:\n"); | |
| const unsigned char expected_out_streebog_256[] = { | |
| 0x5a, 0xea, 0x82, 0x66, 0x91, 0x2f, 0x42, 0x8c, 0xb8, 0x28, 0xc6, 0x2b, 0xdf, 0x05, 0xa4, 0xa9, | |
| 0x6f, 0x1c, 0xd7, 0xe2, 0xc3, 0xa7, 0x19, 0x6f, 0xe2, 0x3a, 0x53, 0x2e, 0x1f, 0x30, 0x1a, 0x38}; | |
| run_stribog(expected_out_streebog_256, sizeof(expected_out_streebog_256), GCRY_MD_STRIBOG256); | |
| printf("\n"); | |
| printf("STRIBOG-512\n"); | |
| const unsigned char expected_out_streebog_512[] = { | |
| 0x5b, 0x64, 0xbb, 0xe4, 0xcb, 0xbe, 0x3a, 0x84, 0xae, 0xc3, 0x14, 0xbf, 0x63, 0xbd, 0xdf, 0x5c, | |
| 0xcd, 0x71, 0xc9, 0x11, 0x6c, 0xdf, 0x5c, 0x8c, 0xc4, 0x32, 0x9e, 0x50, 0x68, 0x31, 0x6e, 0xd2, | |
| 0x1b, 0x77, 0x05, 0xfd, 0xd4, 0xe8, 0x79, 0x57, 0x61, 0x0f, 0xe8, 0x6f, 0xf0, 0x4a, 0x45, 0xad, | |
| 0xfc, 0xc4, 0x4d, 0x49, 0x6e, 0xde, 0x62, 0xed, 0xc2, 0x4e, 0xbe, 0x19, 0x0c, 0x14, 0x55, 0xa3}; | |
| run_stribog(expected_out_streebog_512, sizeof(expected_out_streebog_512), GCRY_MD_STRIBOG512); | |
| printf("\n"); | |
| } | |
| EOF | |
| RUN gcc -o stribog stribog.c -lgcrypt | |
| CMD ["./stribog"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment