MCPcopy Create free account
hub / github.com/Tripwire/tripwire-open-source / WriteMem

Method WriteMem

src/twcrypto/keyfile.cpp:308–344  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

306}
307
308void cKeyFile::WriteMem(int8* pMem) const // throw eKeyFile()
309{
310 int16 i16;
311 int32 i32;
312
313 if (!KeysLoaded())
314 {
315 ASSERT(false);
316 throw eKeyFileUninitialized(_T("cKeyFile not initialized"));
317 }
318
319 // magic number and version
320 i32 = tw_htonl(KEY_MAGIC_NUMBER);
321 memcpy(pMem, &i32, sizeof(i32));
322 pMem += sizeof(int32);
323
324 i32 = tw_htonl(1);
325 memcpy(pMem, &i32, sizeof(i32));
326 pMem += sizeof(int32);
327
328 // save public key
329 int16 len = mpPublicKey->GetWriteLen();
330 i16 = tw_htons(len);
331 memcpy(pMem, &i16, sizeof(i16));
332 pMem += sizeof(int16);
333
334 mpPublicKey->Write(pMem);
335 pMem += len;
336
337 // save private key
338 len = mPrivateKeyMemLen;
339 i16 = tw_htons(len);
340 memcpy(pMem, &i16, sizeof(i16));
341 pMem += sizeof(int16);
342
343 memcpy(pMem, mpPrivateKeyMem, mPrivateKeyMemLen);
344}
345
346int cKeyFile::GetWriteLen() // throw eKeyFile()
347{

Callers 2

GenerateKeyFunction · 0.80
TestKeyFileFunction · 0.80

Calls 2

GetWriteLenMethod · 0.45
WriteMethod · 0.45

Tested by 1

TestKeyFileFunction · 0.64