Montgomery_Int::Montgomery_Int(std::shared_ptr<const Montgomery_Params> params, const word words[], size_t len, bool redc_needed) : m_params(params), m_v(words, len) { if(redc_needed) { BOTAN_ASSERT_NOMSG(m_v < m_params->p()); secure_vector<word> ws; m_v = m_params->mul(m_v, m_params->R2(), ws); } }
Montgomery_Int::Montgomery_Int(const std::shared_ptr<const Montgomery_Params> params, const BigInt& v, bool redc_needed) : m_params(params) { if(redc_needed == false) { m_v = v; } else { BOTAN_ASSERT_NOMSG(m_v < m_params->p()); secure_vector<word> ws; m_v = m_params->mul(v, m_params->R2(), ws); } }
void Blowfish::key_expansion(const uint8_t key[], size_t length, const uint8_t salt[], size_t salt_length) { BOTAN_ASSERT_NOMSG(salt_length % 4 == 0); for(size_t i = 0, j = 0; i != 18; ++i, j += 4) m_P[i] ^= make_uint32(key[(j ) % length], key[(j+1) % length], key[(j+2) % length], key[(j+3) % length]); const size_t P_salt_offset = (salt_length > 0) ? 18 % (salt_length / 4) : 0; uint32_t L = 0, R = 0; generate_sbox(m_P, L, R, salt, salt_length, 0); generate_sbox(m_S, L, R, salt, salt_length, P_salt_offset); }