MCPcopy Create free account
hub / github.com/bailey27/cppcryptfs / init

Method init

libcppcryptfs/crypt/eme.cpp:181–211  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

179
180
181bool EmeCryptContext::init(const BYTE *key, bool hkdf, CryptConfig *pConfig)
182{
183 const BYTE *emeKey = key;
184
185 if (!pConfig)
186 throw std::exception("EMeCryptContext init: where is my config?");
187
188 LockZeroBuffer<BYTE> hkdfKey(MASTER_KEY_LEN, false);
189
190 if (hkdf) {
191 if (!hkdfKey.IsLocked())
192 return false;
193 if (!hkdfDerive(key, MASTER_KEY_LEN, hkdfKey.m_buf, hkdfKey.m_len, hkdfInfoEMENames))
194 return false;
195
196 emeKey = hkdfKey.m_buf;
197 }
198
199 m_pKeyBuf = new LockZeroBuffer<AES_KEY>(2, true);
200
201 pConfig->m_keybuf_manager.RegisterBuf(m_pKeyBuf);
202
203 AES::initialize_keys(emeKey, 256, &m_pKeyBuf->m_buf[0], &m_pKeyBuf->m_buf[1]);
204
205 m_aes_ctx.set_keys(&m_pKeyBuf->m_buf[0], &m_pKeyBuf->m_buf[1]);
206
207 tabulateL(16 * 8, pConfig);
208
209 return true;
210
211}
212
213
214

Callers 2

ProcessCommandLineMethod · 0.80
InitEmeMethod · 0.80

Calls 4

hkdfDeriveFunction · 0.85
IsLockedMethod · 0.80
set_keysMethod · 0.80
RegisterBufMethod · 0.45

Tested by

no test coverage detected