//---------------------------------------------------------------------
      ElementPtr PeerContactProfile::getPrivateProfile() const
      {
        AutoRecursiveLock lock(mLock);
        if (!mDocument) return ElementPtr();
        if (!hasContactProfileSecret()) return ElementPtr();

        try {
          ElementPtr contactProfileElement = getContactProfileElement();
          if (!contactProfileElement) return ElementPtr();
          ElementPtr privateElement = contactProfileElement->findFirstChildElementChecked("private");
          ElementPtr profileElement = privateElement->findFirstChildElementChecked("encryptedProfile");
          ElementPtr saltElement = privateElement->findFirstChildElementChecked("salt");

          String saltAsBase64 = saltElement->getText(true);

          SecureByteBlock output;
          decryptAndNulTerminateFromBase64(
                                           "profile",
                                           mContactProfileSecret,
                                           saltAsBase64,
                                           profileElement->getText(true),
                                           output
                                           );

          String parseData = (CSTR)((const BYTE *)output);
          DocumentPtr temp = Document::create();
          temp->parse(parseData);
          ElementPtr result = temp->findFirstChildElementChecked("profile");
          result->orphan();
          return result;
        } catch (zsLib::XML::Exceptions::CheckFailed &) {
        }
        return ElementPtr();
      }
      //---------------------------------------------------------------------
      IPeerFilePublicPtr PeerContactProfile::getPeerFilePublic() const
      {
        AutoRecursiveLock lock(mLock);
        PeerFilesPtr outer = mPeerFiles.lock();
        if (outer) {
          IPeerFilePublicPtr publicPeer = outer->getPublic();
          if (publicPeer) return publicPeer;
        }

        if (!mDocument) return IPeerFilePublicPtr();
        if (!hasContactProfileSecret()) return IPeerFilePublicPtr();

        try {
          ElementPtr contactProfileElement = getContactProfileElement();
          if (!contactProfileElement) return IPeerFilePublicPtr();
          ElementPtr privateElement = contactProfileElement->findFirstChildElementChecked("private");
          ElementPtr encryptedPeerElement = privateElement->findFirstChildElementChecked("encryptedPeer");
          ElementPtr saltElement = privateElement->findFirstChildElementChecked("salt");

          String saltAsBase64 = saltElement->getText(true);

          SecureByteBlock output;
          decryptAndNulTerminateFromBase64(
                                           "peer",
                                           mContactProfileSecret,
                                           saltAsBase64,
                                           encryptedPeerElement->getText(true),
                                           output
                                           );

          String parseData = (CSTR)((const BYTE *)output);
          DocumentPtr temp = Document::create();
          temp->parse(parseData);
          ElementPtr result = temp->findFirstChildElementChecked("peer");
          result->orphan();

          PeerFilePublicPtr publicPeer = PeerFilePublic::loadFromXML(result);
          return publicPeer;
        } catch (zsLib::XML::Exceptions::CheckFailed &) {
        }
        return IPeerFilePublicPtr();
      }