Пример #1
0
void
GroupManager::getGroupKey
  (MillisecondsSince1970 timeSlot, vector<ptr_lib::shared_ptr<Data> >& result,
   bool needRegenerate)
{
  result.clear();
  map<Name, Blob> memberKeys;

  // Get the time interval.
  Interval finalInterval = calculateInterval(timeSlot, memberKeys);
  if (finalInterval.isValid() == false)
    return;

  string startTimeStamp = Schedule::toIsoString(finalInterval.getStartTime());
  string endTimeStamp = Schedule::toIsoString(finalInterval.getEndTime());

  // Generate the private and public keys.
  Blob privateKeyBlob;
  Blob publicKeyBlob;
  Name eKeyName(namespace_);
  eKeyName.append(Encryptor::getNAME_COMPONENT_E_KEY()).append(startTimeStamp)
    .append(endTimeStamp);

  if (!needRegenerate && database_->hasEKey(eKeyName))
    getEKey(eKeyName, publicKeyBlob, privateKeyBlob);
  else {
    generateKeyPair(privateKeyBlob, publicKeyBlob);
    if (database_->hasEKey(eKeyName))
      deleteEKey(eKeyName);
    addEKey(eKeyName, publicKeyBlob, privateKeyBlob);
  }

  // Add the first element to the result.
  // The E-KEY (public key) data packet name convention is:
  // /<data_type>/E-KEY/[start-ts]/[end-ts]
  ptr_lib::shared_ptr<Data> data = createEKeyData
    (startTimeStamp, endTimeStamp, publicKeyBlob);
  result.push_back(data);

  // Encrypt the private key with the public key from each member's certificate.
  for (map<Name, Blob>::iterator i = memberKeys.begin(); i != memberKeys.end(); ++i) {
    const Name& keyName = i->first;
    Blob& certificateKey = i->second;

    // Generate the name of the packet.
    // The D-KEY (private key) data packet name convention is:
    // /<data_type>/D-KEY/[start-ts]/[end-ts]/[member-name]
    data = createDKeyData
      (startTimeStamp, endTimeStamp, keyName, privateKeyBlob, certificateKey);
    result.push_back(data);
  }
}
Пример #2
0
KRecordList *IntervalCPU::calcNext( KRecordList *displayList, bool initCalc )
{
  SemanticHighInfo highInfo;

  if( displayList == NULL )
    displayList = &myDisplayList;

  if( !initCalc )
  {
    *begin = *end;
  }

  if( intervalCompose.empty() )
    return displayList;

  if( intervalCompose[ begin->getThread() - firstThreadOnCPU ] == NULL )
  {
    int i = begin->getThread() - firstThreadOnCPU;
    intervalThread[ i ] = new IntervalThread( window, THREAD, begin->getThread() );
    intervalThread[ i ]->setNotWindowInits( true );
    intervalThread[ i ]->setSemanticFunction( functionThread );

    intervalCompose[ i ] = new IntervalCompose( window, COMPOSETHREAD, begin->getThread() );
    intervalCompose[ i ]->setNotWindowInits( true );
    intervalCompose[ i ]->setCustomChild( intervalThread[ i ] );
    intervalCompose[ i ]->setSemanticFunction( functionComposeThread );

    intervalCompose[ i ]->init( currentInitialTime, NOCREATE, NULL );
  }

  Interval *currentThread = intervalCompose[ begin->getThread() - firstThreadOnCPU ];
  highInfo.callingInterval = this;
  if( begin->getType() == STATE + END )
    highInfo.values.push_back( 0.0 );
  else
  {
    while( currentThread->getEndTime() <= begin->getTime() &&
           currentThread->getBeginTime() < window->getTrace()->getEndTime() )
      currentThread->calcNext( NULL );
    if( currentThread->getBegin()->getCPU() != order )
      highInfo.values.push_back( 0.0 );
    else
      highInfo.values.push_back( currentThread->getValue() );
  }
  currentValue = function->execute( &highInfo );
  end = getNextRecord( end, displayList );

  return displayList;
}
Пример #3
0
KRecordList *IntervalCPU::calcPrev( KRecordList *displayList, bool initCalc )
{
  SemanticHighInfo highInfo;

  if( displayList == NULL )
    displayList = &myDisplayList;

  if( !initCalc )
  {
    *end = *begin;
  }

  if( intervalCompose.empty() )
    return displayList;

  begin = getPrevRecord( begin, displayList );
  highInfo.callingInterval = this;

  if( intervalCompose[ begin->getThread() - firstThreadOnCPU ] == NULL )
  {
    int i = begin->getThread() - firstThreadOnCPU;
    intervalThread[ i ] = new IntervalThread( window, THREAD, begin->getThread() );
    intervalThread[ i ]->setNotWindowInits( true );
    intervalThread[ i ]->setSemanticFunction( functionThread );

    intervalCompose[ i ] = new IntervalCompose( window, COMPOSETHREAD, begin->getThread() );
    intervalCompose[ i ]->setNotWindowInits( true );
    intervalCompose[ i ]->setCustomChild( intervalThread[ i ] );
    intervalCompose[ i ]->setSemanticFunction( functionComposeThread );

    intervalCompose[ i ]->init( currentInitialTime, NOCREATE, NULL );
  }

  Interval *currentThread = intervalCompose[ begin->getThread() - firstThreadOnCPU ];
  while( currentThread->getBeginTime() >= begin->getTime() &&
         currentThread->getEndTime() > 0.0 )
    currentThread->calcPrev( NULL );
  highInfo.values.push_back( currentThread->getValue() );
  currentValue = function->execute( &highInfo );

  if( initCalc )
  {
    *end = *begin;
  }

  return displayList;
}