int addSignature3(int numerator, int denominator, int line,int counter,int dividor, int blocknum) { Place place = {line, counter, dividor}; return addSignature(numerator, denominator, place, blocknum); }
void NounShip::updateGadgets( dword nTick ) { PROFILE_FUNCTION(); // check gadgets list, initialize internal gadget queues if needed if ( m_Gadgets.size() == 0 ) initializeGadgets(); // update energy, signature, and visibility of this ship int energy = m_Energy; float visibility = 1.0f; for(int i=0;i<m_Gadgets.size();i++) { NounGadget * pGadget = m_Gadgets[i]; // use energy energy = pGadget->useEnergy( nTick, energy ); // update signature of this ship addSignature( nTick, pGadget->addSignature() ); // update visibility visibility += pGadget->addVisibility(); } m_Energy = Clamp( energy, 0, maxEnergy() ); m_Visibility = Clamp( visibility, 0.0f, 1.0f ); // use gadgets that are in the queue if ( m_UseGadgets.size() > 0 ) if ( --m_UseGadgetTick <= 0 ) useGadgets(); }
/** * Signs all documents in container. * * @param signer signer implementation. * @param profile signature profile (e.g. BES, TM). * @throws BDocException exception is throws if signing the BDCO container failed. */ void digidoc::BDoc::sign(Signer* signer, Type profile) throw(BDocException) { if (!signer) THROW_BDOCEXCEPTION("Null pointer in digidoc::BDoc::sign"); DEBUG("sign(signer = %p, profile=%d)", signer, profile); // Create signature by type. Signature* signature = NULL; switch(profile) { case BES: signature = new SignatureBES(newSignatureId(), *this); break; case TM: signature = new SignatureTM(newSignatureId(), *this); break; default: THROW_BDOCEXCEPTION("Unknown signature profile: %d", profile); break; } try { // Finalize the signature by calculating signature. signature->sign(signer); } catch(const SignatureException& e) { delete signature; THROW_BDOCEXCEPTION_CAUSE(e, "Failed to sign BDOC container."); } catch(const SignException& e) { delete signature; THROW_BDOCEXCEPTION_CAUSE(e, "Failed to sign BDOC container."); } // Add the created signature to the signatures list. addSignature(signature); }
/** * Signs all documents in container. * * @param signer signer implementation. * @param profile signature profile (e.g. BES, TM). * @throws BDocException exception is throws if signing the BDCO container failed. */ void digidoc::BDoc::sign(Signer* signer, Signature::Type profile) throw(BDocException) { if (signer == NULL) { THROW_BDOCEXCEPTION("Null pointer in digidoc::BDoc::sign"); } DEBUG("sign(signer = 0x%X, profile=%d)", (unsigned int)signer, profile); // Create signature by type. Signature* signature = NULL; if(profile == Signature::BES) { signature = new SignatureBES(*this); } else if(profile == Signature::TM) { signature = new SignatureTM(*this); } else if(profile == Signature::MOBILE) { try { signature = new SignatureMobile( signer->signaturePath(), *this); } catch(const Exception& e) { THROW_BDOCEXCEPTION_CAUSE(e, "MobileSignature"); } addSignature( signature ); return; } else { THROW_BDOCEXCEPTION("Unknown signature profile: %d", profile); } // Calculate digests for the documents and add these to the signature reference. for(std::vector<Document>::iterator iter = documents.begin(); iter != documents.end(); iter++) { try { DEBUG("Adding document '%s', '%s' to the signature references.", iter->getPath().c_str(), iter->getMediaType().c_str()); // URIs must encode non-ASCII characters in the format %HH where HH is the hex representation of the character std::string uri = std::string("/") + digidoc::util::String::toUriFormat(digidoc::util::File::fileName(iter->getPath())); std::auto_ptr<Digest> calc = Digest::create(); std::vector<unsigned char> digest = iter->calcDigest(calc.get()); DEBUGMEM("digest", &digest[0], digest.size()); signature->addReference(uri, calc->getUri(), digest); } catch(const Exception& e) { delete signature; THROW_BDOCEXCEPTION_CAUSE(e, "Failed to calculate digests for document '%s'.", iter->getPath().c_str()); } } try { // Finalize the signature by calculating signature. signature->sign(signer); } catch(const SignatureException& e) { delete signature; THROW_BDOCEXCEPTION_CAUSE(e, "Failed to sign BDOC container."); } catch(const SignException& e) { delete signature; THROW_BDOCEXCEPTION_CAUSE(e, "Failed to sign BDOC container."); } // Add the created signature to the signatures list. addSignature(signature); }
/** * Adds signature to the container. Default profile is TM * * @param signature signature, which is added to the container. * @throws BDocException throws exception if there are no documents in container. */ void digidoc::BDoc::addSignature(const std::vector<unsigned char> &signature) throw(BDocException) { addSignature(signature, TM); }