0df8f2889273aee65079da0f4b5727a4ac6d3e7bvboxsync * Main - Secret key interface.
0df8f2889273aee65079da0f4b5727a4ac6d3e7bvboxsync * Copyright (C) 2015 Oracle Corporation
0df8f2889273aee65079da0f4b5727a4ac6d3e7bvboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
0df8f2889273aee65079da0f4b5727a4ac6d3e7bvboxsync * available from http://www.virtualbox.org. This file is free software;
0df8f2889273aee65079da0f4b5727a4ac6d3e7bvboxsync * you can redistribute it and/or modify it under the terms of the GNU
0df8f2889273aee65079da0f4b5727a4ac6d3e7bvboxsync * General Public License (GPL) as published by the Free Software
0df8f2889273aee65079da0f4b5727a4ac6d3e7bvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
0df8f2889273aee65079da0f4b5727a4ac6d3e7bvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
0df8f2889273aee65079da0f4b5727a4ac6d3e7bvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
0df8f2889273aee65079da0f4b5727a4ac6d3e7bvboxsyncSecretKey::SecretKey(const uint8_t *pbKey, size_t cbKey, bool fKeyBufNonPageable)
0df8f2889273aee65079da0f4b5727a4ac6d3e7bvboxsync int rc = RTMemSaferAllocZEx((void **)&this->m_pbKey, cbKey,
0df8f2889273aee65079da0f4b5727a4ac6d3e7bvboxsync fKeyBufNonPageable ? RTMEMSAFER_F_REQUIRE_NOT_PAGABLE : 0);
0df8f2889273aee65079da0f4b5727a4ac6d3e7bvboxsync /* Scramble content to make retrieving the key more difficult. */
0df8f2889273aee65079da0f4b5727a4ac6d3e7bvboxsyncint SecretKey::setRemoveOnSuspend(bool fRemoveOnSuspend)
0df8f2889273aee65079da0f4b5727a4ac6d3e7bvboxsyncSecretKeyStore::SecretKeyStore(bool fKeyBufNonPageable)
0df8f2889273aee65079da0f4b5727a4ac6d3e7bvboxsync int rc = deleteAllSecretKeys(false /* fSuspend */, true /* fForce */);
0df8f2889273aee65079da0f4b5727a4ac6d3e7bvboxsyncint SecretKeyStore::addSecretKey(const com::Utf8Str &strKeyId, const uint8_t *pbKey, size_t cbKey)
0df8f2889273aee65079da0f4b5727a4ac6d3e7bvboxsync /* Check that the ID is not existing already. */
0df8f2889273aee65079da0f4b5727a4ac6d3e7bvboxsync SecretKeyMap::const_iterator it = m_mapSecretKeys.find(strKeyId);
0df8f2889273aee65079da0f4b5727a4ac6d3e7bvboxsync SecretKey *pKey = new SecretKey(pbKey, cbKey, m_fKeyBufNonPageable);
0df8f2889273aee65079da0f4b5727a4ac6d3e7bvboxsync m_mapSecretKeys.insert(std::make_pair(strKeyId, pKey));
0df8f2889273aee65079da0f4b5727a4ac6d3e7bvboxsync catch (int rc)
0df8f2889273aee65079da0f4b5727a4ac6d3e7bvboxsyncint SecretKeyStore::deleteSecretKey(const com::Utf8Str &strKeyId)
c7902f6ecf779fa9df37b8600f05ed557aff6f49vboxsync SecretKeyMap::iterator it = m_mapSecretKeys.find(strKeyId);
0df8f2889273aee65079da0f4b5727a4ac6d3e7bvboxsyncint SecretKeyStore::retainSecretKey(const com::Utf8Str &strKeyId, SecretKey **ppKey)
0df8f2889273aee65079da0f4b5727a4ac6d3e7bvboxsync SecretKeyMap::const_iterator it = m_mapSecretKeys.find(strKeyId);
0df8f2889273aee65079da0f4b5727a4ac6d3e7bvboxsyncint SecretKeyStore::releaseSecretKey(const com::Utf8Str &strKeyId)
0df8f2889273aee65079da0f4b5727a4ac6d3e7bvboxsync SecretKeyMap::const_iterator it = m_mapSecretKeys.find(strKeyId);
0df8f2889273aee65079da0f4b5727a4ac6d3e7bvboxsyncint SecretKeyStore::deleteAllSecretKeys(bool fSuspend, bool fForce)
0df8f2889273aee65079da0f4b5727a4ac6d3e7bvboxsync /* First check whether a key is still in use. */
0df8f2889273aee65079da0f4b5727a4ac6d3e7bvboxsync for (SecretKeyMap::iterator it = m_mapSecretKeys.begin();
0df8f2889273aee65079da0f4b5727a4ac6d3e7bvboxsync SecretKeyMap::iterator it = m_mapSecretKeys.begin();
0df8f2889273aee65079da0f4b5727a4ac6d3e7bvboxsync AssertMsg(!pKey->refCount(), ("No one should access the stored key at this point anymore!\n"));