- BN_bin2bn(key_buf, SHA_DIGEST_LENGTH, &xkey1);
- BN_bin2bn(sha_buf, SHA_DIGEST_LENGTH, &x0);
- BN_add_word(&xkey1, 1); // xkey += 1
- BN_add(&xkey_buf, &xkey1, &x0); // xkey += x
- BN_mod(&xkey1, &xkey_buf, &c_2powb, ctx1); // xkey = xkey mod (2^160)
+ BN_bin2bn(xkey, key_size, &bn_xkey);
+ BN_bin2bn(sha_buf, SHA_DIGEST_LENGTH, &bn_x_n);
+ BN_add_word(&bn_xkey, 1); // xkey += 1
+ BN_add(&bn_tmp, &bn_xkey, &bn_x_n); // xkey += x
+ BN_mod(&bn_xkey, &bn_tmp, &c_2powb, ctx1); // xkey = xkey mod (2^b)