void CPBEncryptSet::ConstructMasterKeyL(void) { TBuf8<KAESKeyBytes256> masterKey(KAESKeyBytes256); TRandom::RandomL(masterKey); iEncryptedMasterKey = HBufC8::NewL(KAESKeyBytes256); EncryptMasterKeyL(masterKey); }
SecureBinaryData KdfRomix::DeriveKey(SecureBinaryData const & password) { SecureBinaryData masterKey(password); for(uint32_t i=0; i<numIterations_; i++) masterKey = DeriveKey_OneIter(masterKey); return SecureBinaryData(masterKey); }
midiEvent InstrumentTrack::applyMasterKey( const midiEvent & _me ) { midiEvent copy( _me ); switch( _me.m_type ) { case MidiNoteOn: case MidiNoteOff: case MidiKeyPressure: copy.key() = masterKey( _me.key() ); break; default: break; } return copy; }
MidiEvent InstrumentTrack::applyMasterKey( const MidiEvent& event ) { MidiEvent copy( event ); switch( event.type() ) { case MidiNoteOn: case MidiNoteOff: case MidiKeyPressure: copy.setKey( masterKey( event.key() ) ); break; default: break; } return copy; }
void InstrumentTrack::processOutEvent( const midiEvent & _me, const midiTime & _time ) { int k; switch( _me.m_type ) { case MidiNoteOn: if( !configManager::inst()->value( "ui", "manualchannelpiano" ).toInt() ) { m_piano.setKeyState( _me.key(), true ); } if( !configManager::inst()->value( "ui", "disablechannelactivityindicators" ).toInt() ) { if( m_notes[_me.key()] == NULL ) { emit newNote(); } } k = masterKey( _me.key() ); if( k >= 0 && k < NumKeys ) { if( m_runningMidiNotes[k] > 0 ) { m_instrument->handleMidiEvent( midiEvent( MidiNoteOff, midiPort()->realOutputChannel(), k, 0 ), _time ); } ++m_runningMidiNotes[k]; m_instrument->handleMidiEvent( midiEvent( MidiNoteOn, midiPort()->realOutputChannel(), k, _me.velocity() ), _time ); } break; case MidiNoteOff: if( !configManager::inst()->value( "ui", "manualchannelpiano" ).toInt() ) { m_piano.setKeyState( _me.key(), false ); } k = masterKey( _me.key() ); if( k >= 0 && k < NumKeys && --m_runningMidiNotes[k] <= 0 ) { m_runningMidiNotes[k] = qMax( 0, m_runningMidiNotes[k] ); m_instrument->handleMidiEvent( midiEvent( MidiNoteOff, midiPort()->realOutputChannel(), k, 0 ), _time ); } break; default: if( m_instrument != NULL ) { m_instrument->handleMidiEvent( applyMasterKey( _me ), _time ); } break; } // if appropriate, midi-port does futher routing m_midiPort.processOutEvent( _me, _time ); }
bool OTSubkey::VerifySignedByMaster() { // See if m_strMasterSigned was signed by my master credential. OTSubkey masterKey(*m_pOwner); if (m_strMasterSigned.Exists() && masterKey.LoadContractFromString(m_strMasterSigned)) { // Here we need to MAKE SURE that the "master signed" version contains // the same CONTENTS as the actual version. if (!GetNymID().Compare(masterKey.GetNymID())) { Log::vOutput(0, "%s: Failure, NymID of this key credential " "doesn't match NymID of master-signed version of " "this key credential.\n", __FUNCTION__); return false; } if (!GetNymIDSource().Compare(masterKey.GetNymIDSource())) { Log::vOutput(0, "%s: Failure, NymIDSource of this key credential " "doesn't match NymIDSource of master-signed " "version of this key credential.\n", __FUNCTION__); return false; } if (!GetMasterCredID().Compare(masterKey.GetMasterCredID())) { Log::vOutput(0, "%s: Failure, MasterCredID of this key " "credential doesn't match MasterCredID of " "master-signed version of this key credential.\n", __FUNCTION__); return false; } if (GetPublicMap().size() > 0 && GetPublicMap() != masterKey.GetPublicMap()) { Log::vOutput(0, "%s: Failure, public info of this key credential " "doesn't match public info of master-signed " "version of this key credential.\n", __FUNCTION__); return false; } // Master-signed version of subkey does not contain the private keys, // since normally the master is signing // the public version of the sub credential (to validate it) and you // don't want the public seeing your private keys. // So we would never expect these to match, since the master signed // version should have no private keys in it. // // if (GetPrivateMap() != masterKey.GetPrivateMap()) // { // OTLog::vOutput(0, "%s: Failure, private info of this key // credential doesn't match private info of master-signed version of // this key credential.\n", __FUNCTION__); // return false; // } bool verifiedWithKey = masterKey.VerifyWithKey( m_pOwner->GetMasterkey().m_SigningKey.GetPublicKey()); // ON SERVER SIDE, THE ACTUAL SUBKEY doesn't have any public key, only // the master-signed version of it. // (The master-signed version being basically the only contents of the // public version.) // So we need to be able to, after verifying, load up those contents so // they are available on the // subkey itself, and not just on some master-signed version of itself // hidden inside itself. // Otherwise I would have to load up the master-signed version anytime // the server-side wanted to // mess with any of the keys. // Thus: copy the public info from master signed, to* this, if the above // call was successful if (verifiedWithKey && GetPublicMap().size() == 0) { // For master credential. return SetPublicContents(masterKey.GetPublicMap()); } return verifiedWithKey; } return false; }
void SessionParser::parse(const boost::uint8_t* p_data, boost::uint16_t p_length, boost::uint32_t p_srcAddr) { switch(m_state) { case k_none: if (p_length > 13 && memcmp(p_data, "POST /jsproxy", 13) == 0) { std::cout << "[+] Initial request found." << std::endl; m_state = k_request; } break; case k_request: if (p_length > 17 && memcmp(p_data, "HTTP/1.1 200 OK\r\n", 17) == 0) { std::cout << "[+] Server challenge received." << std::endl; m_serverAddress = p_srcAddr; std::string packet; packet.assign(reinterpret_cast<const char*>(p_data), p_length); if (moveToPayload(packet) && packet.length() > 32) { std::size_t index = 0; for (std::size_t i = 0; i < 24 && index < packet.length(); i++) { if (i < 8) { codePointAt(packet, index); } else { m_rchallenge.push_back(codePointAt(packet, index)); } } } m_state = k_challenge; } break; case k_challenge: { if (p_length < 13 || memcmp(p_data, "POST /jsproxy", 13) != 0) { break; } std::cout << "[+] Challenge response found." << std::endl; m_state = k_done; std::string packet; packet.assign(reinterpret_cast<const char*>(p_data), p_length); if (!moveToPayload(packet)) { std::cerr << "Failed to find the payload." << std::endl; break; } std::size_t index = 0; for (std::size_t i = 0; i < 26; i++) { codePointAt(packet, index); } m_lchallenge.assign(packet.data() + index, 16); index += 16; for (std::size_t i = 0; i < 8; i++) { codePointAt(packet, index); } for (std::size_t i = 0; i < 8 && index < packet.length(); i++) { m_response1.push_back(codePointAt(packet, index)); } for (std::size_t i = 0; i < 8 && index < packet.length(); i++) { m_response2.push_back(codePointAt(packet, index)); } for (std::size_t i = 0; i < 8 && index < packet.length(); i++) { m_response3.push_back(codePointAt(packet, index)); } m_response.assign(m_response1); m_response.append(m_response2); m_response.append(m_response3); m_username.assign(packet.data() + index, packet.length() - index); std::cout << "Username: "******"Failed to recover key3!" << std::endl; return; } std::cout << "DES Key 3: "; printHexString(key3, true); // guess des key 2 std::string key2; if (!getKey2(key2, m_response2, challengeHash)) { std::cerr << "Failed to recover key2!" << std::endl; return; } std::cout << "DES Key 2: "; printHexString(key2, true); // guess des key 1 std::string key1; if (!getKey1(key1, m_response1, challengeHash)) { std::cerr << "Failed to recover key1!" << std::endl; return; } std::cout << "DES Key 1: "; printHexString(key1, true); // retrieve the pwdhash from our 3 keys std::string pwdHash(makePwdHash(key1)); pwdHash.append(makePwdHash(key2)); pwdHash.append(makePwdHash(key3)); pwdHash.resize(16); std::cout << "Password SHA-1: "; printHexString(pwdHash); // create the pwd hash hash for master key creation std::string pwdHashHash(MD4::md4(pwdHash)); std::cout << "SHA-1(Password SHA-1): "; printHexString(pwdHashHash); // create the master key std::string masterKey(pwdHashHash); masterKey.append(m_response); masterKey.append("This is the MPPE Master Key"); unsigned char sharesult[20] = { 0 }; sha1::calc(masterKey.data(), masterKey.size(), sharesult); masterKey.assign((char*)sharesult, 16); std::cout<< "Master Key: "; printHexString(masterKey); } break; case k_challenge_response: case k_decrypt: case k_done: default: break; } }