<!-- Thank you for your bug report. If this is your first one, please take the time to read the following lines before posting it. NOTE: If you're asking about how to use OpenSSL, this isn't the right forum. Please see our User Support resources: https://github.com/openssl/openssl/blob/master/SUPPORT.md Please remember to tell us in what OpenSSL version you found the issue. For build issues: If this is a build issue, please include the configuration output as well as a log of all errors. Don't forget to include the exact commands you typed. With OpenSSL before 1.1.1, the configuration output comes from the configuration command. With OpenSSL 1.1.1 and on, it's the output of `perl configdata.pm --dump` For other issues: If it isn't a build issue, example code or commands to reproduce the issue is highly appreciated. Also, please remember to tell us if you worked with your own OpenSSL build or if it is system provided. Please remember to put ``` lines before and after any commands plus output and code, like this: ``` $ echo output output output output output output ``` ``` #include <stdio.h> int main() { char *str1 = NULL; char *str2 = NULL; char cnum[] = "3"; char cdivisor[] = "-2"; BIGNUM *bnssl1 = BN_new(); BIGNUM *bnssl2 = BN_new(); BIGNUM *bnssl3 = BN_new(); BN_CTX *ctx = BN_CTX_new(); BN_hex2bn(&bnssl1, cnum); BN_hex2bn(&bnssl2, cdivisor); BN_div(bnssl1, bnssl3, bnssl1, bnssl2, ctx); str1 = BN_bn2hex(bnssl1); str2 = BN_bn2hex(bnssl3); printf("str1 is %s, str2 is %s\n", str1, str2); BN_free(bnssl1); BN_free(bnssl2); BN_free(bnssl3); OPENSSL_free(str1); OPENSSL_free(str2); BN_CTX_free(ctx); } expect result : str1 is -01, str2 is 01 and we get: str1 is -01, str2 is -01 The problem is the assignment at crypto/bn/bn_div.c:448 "snum->neg = num->neg;" ``` -->