#include static const unsigned char _7830457[3] = { 0x77, 0x7b, 0xb9 }; static const unsigned char _2[1] = {2}; static const unsigned char _28433[2] = {0x6f, 0x11}; static const unsigned char _10000000000[5] = {0x02, 0x54, 0x0b, 0xe4, 0x00}; int main() { BIGNUM *b28433 = BN_bin2bn(_28433, 2, NULL); BIGNUM *b2 = BN_bin2bn(_2, 1, NULL); BIGNUM *b7830457 = BN_bin2bn(_7830457, 3, NULL); BIGNUM *b10ten = BN_bin2bn(_10000000000, 5, NULL); BN_CTX *ctx = BN_CTX_new(); BIGNUM *r = BN_new(); BIGNUM *r2 = BN_new(); BIGNUM *r3 = BN_new(); BN_mod_exp(r, b2, b7830457, b10ten, ctx); BN_mul(r2, r, b28433, ctx); BN_add(r3, r2, BN_value_one()); BN_mod(r, r3, b10ten, ctx); unsigned char res[10]; int len = BN_bn2mpi(r, res); for (int i = 0; i < len; i++) printf("%02x", res[i]); puts(""); }