/* * Set new tweak */ void XTS_Decryption::set_iv(const InitializationVector& iv) { if(iv.length() != tweak.size()) throw Invalid_IV_Length(name(), iv.length()); tweak = iv.bits_of(); cipher2->encrypt(tweak); }
void Transform_Filter::Nonce_State::update(const InitializationVector& iv) { m_nonce = unlock(iv.bits_of()); m_fresh_nonce = true; }
OpenSSLSymmetricCipherContext OpenSSLSymmetricCipher::start(OpenSSLSymmetricCipher::Method method, const SymmetricKey& key, const InitializationVector& iv, bool padding) { OpenSSLSymmetricCipherContext context(method); int r = 0; const EVP_CIPHER* evpCipher = getEVPCipher(key); EXCEPTION_ASSERT(evpCipher, std::invalid_argument, "No cipher found that can use the supplied key"); switch (context.method()) { case M_ENCRYPT: { r = EVP_EncryptInit_ex(context.ctx(), evpCipher, NULL, &key.data()[0], &iv.data()[0]); break; } case M_DECRYPT: { r = EVP_DecryptInit_ex(context.ctx(), evpCipher, NULL, &key.data()[0], &iv.data()[0]); break; } default: { THROW_EXCEPTION_WITH_LOG(std::runtime_error, "Unhandled method"); } } EXCEPTION_ASSERT_WITH_LOG(r == 1, OpenSSLException, ""); context.data().clear(); context.setPadding(padding); return context; }
void Keyed_Filter::set_iv(const InitializationVector& iv) { if(iv.length() != 0) throw Invalid_IV_Length(name(), iv.length()); }
/* * Set the EAX nonce */ void EAX_Base::set_iv(const InitializationVector& iv) { nonce_mac = eax_prf(0, BLOCK_SIZE, cmac, iv.begin(), iv.length()); ctr->set_iv(&nonce_mac[0], nonce_mac.size()); }