-
-
Save vshabanov/bbab2052343da8731c45c7460cbfa567 to your computer and use it in GitHub Desktop.
This file contains 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
// gcc dsa_test.c -I/opt/local/include -L/opt/local/lib -lcrypto -o dsa_test && ./dsa_test | |
#include <openssl/dsa.h> | |
void checkBN(const char* what, const BIGNUM* bn, const char* should) { | |
char *h = BN_bn2hex(bn); | |
if (strcmp(h, should) != 0) | |
{ | |
printf("FAILED: %s = %s instead of %s\n", what, h, should); | |
} | |
OPENSSL_free(h); | |
} | |
int main() { | |
unsigned char seed[] = { | |
0xd5, 0x01, 0x4e, 0x4b, | |
0x60, 0xef, 0x2b, 0xa8, | |
0xb6, 0x21, 0x1b, 0x40, | |
0x62, 0xba, 0x32, 0x24, | |
0xe0, 0x42, 0x7d, 0xd3 | |
}; | |
int counter_ret; | |
unsigned long h_ret; | |
DSA *r = DSA_generate_parameters(512, seed, 20, &counter_ret, &h_ret, NULL, NULL); | |
if (counter_ret != 105) | |
{ | |
printf("counter_ret = %d\n", counter_ret); | |
} | |
checkBN("p", DSA_get0_p(r), "8DF2A494492276AA3D25759BB06869CBEAC0D83AFB8D0CF7CBB8324F0D7882E5D0762FC5B7210EAFC2E9ADAC32AB7AAC49693DFBF83724C2EC0736EE31C80291"); | |
checkBN("q", DSA_get0_q(r), "C773218C737EC8EE993B4F2DED30F48EDACE915F"); | |
checkBN("g", DSA_get0_g(r), "626D027839EA0A13413163A55B4CB500299D5522956CEFCB3BFF10F399CE2C2E71CB9DE5FA24BABF58E5B79521925C9CC42E9F6F464B088CC572AF53E6D78802"); | |
DSA_free(r); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment