当前位置: 首页>>代码示例>>C++>>正文


C++ EncfsConfig::chained_iv方法代码示例

本文整理汇总了C++中EncfsConfig::chained_iv方法的典型用法代码示例。如果您正苦于以下问题:C++ EncfsConfig::chained_iv方法的具体用法?C++ EncfsConfig::chained_iv怎么用?C++ EncfsConfig::chained_iv使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EncfsConfig的用法示例。


在下文中一共展示了EncfsConfig::chained_iv方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: initFS

RootPtr initFS( EncFS_Context *ctx, const shared_ptr<EncFS_Opts> &opts )
{
  RootPtr rootInfo;
  EncfsConfig config;

  if(readConfig( opts->rootDir, config ) != Config_None)
  {
    if(opts->reverseEncryption)
    {
      if (config.block_mac_bytes() != 0 || config.block_mac_rand_bytes() != 0
          || config.unique_iv() || config.external_iv()
          || config.chained_iv() )
      {  
        cout << _("The configuration loaded is not compatible with --reverse\n");
        return rootInfo;
      }
    }

    // first, instanciate the cipher.
    shared_ptr<CipherV1> cipher = getCipher(config);
    if(!cipher)
    {
      Interface iface = config.cipher();
      LOG(ERROR) << "Unable to find cipher " << iface.name()
          << ", version " << iface.major()
          << ":" << iface.minor() << ":" << iface.age();
      // xgroup(diag)
      cout << _("The requested cipher interface is not available\n");
      return rootInfo;
    }

    // get user key
    CipherKey userKey;

    if(opts->passwordProgram.empty())
    {
      if (opts->annotate)
        cerr << "$PROMPT$ passwd" << endl;
      userKey = getUserKey( config, opts->useStdin );
    } else
      userKey = getUserKey( config, opts->passwordProgram, opts->rootDir );

    if(!userKey.valid())
      return rootInfo;

    cipher->setKey(userKey); 

    VLOG(1) << "cipher encoded key size = " << cipher->encodedKeySize();
    // decode volume key..
    CipherKey volumeKey = cipher->readKey(
        (const unsigned char *)config.key().ciphertext().data(), opts->checkKey);
    userKey.reset();

    if(!volumeKey.valid())
    {
      // xgroup(diag)
      cout << _("Error decoding volume key, password incorrect\n");
      return rootInfo;
    }

    cipher->setKey(volumeKey);

    shared_ptr<NameIO> nameCoder = NameIO::New( config.naming(), cipher );
    if(!nameCoder)
    {
      Interface iface = config.naming();
      LOG(ERROR) << "Unable to find nameio interface " << iface.name()
          << ", version " << iface.major()
          << ":" << iface.minor() << ":" << iface.age();
      // xgroup(diag)
      cout << _("The requested filename coding interface is "
          "not available\n");
      return rootInfo;
    }

    nameCoder->setChainedNameIV( config.chained_iv() );
    nameCoder->setReverseEncryption( opts->reverseEncryption );

    FSConfigPtr fsConfig( new FSConfig );
    fsConfig->cipher = cipher;
    fsConfig->key = volumeKey;
    fsConfig->nameCoding = nameCoder;
    fsConfig->config = shared_ptr<EncfsConfig>(new EncfsConfig(config));
    fsConfig->forceDecode = opts->forceDecode;
    fsConfig->reverseEncryption = opts->reverseEncryption;
    fsConfig->opts = opts;

    rootInfo = RootPtr( new EncFS_Root );
    rootInfo->cipher = cipher;
    rootInfo->volumeKey = volumeKey;
    rootInfo->root = shared_ptr<DirNode>( 
        new DirNode( ctx, opts->rootDir, fsConfig ));
  } else
  {
    if(opts->createIfNotFound)
    {
      // creating a new encrypted filesystem
      rootInfo = createConfig( ctx, opts );
    }
  }
//.........这里部分代码省略.........
开发者ID:bentolor,项目名称:encfs,代码行数:101,代码来源:FileUtils.cpp

示例2: createConfig


//.........这里部分代码省略.........
        cout << _("External chained IV disabled, as both 'IV chaining'\n"
            "and 'unique IV' features are required for this option.") 
          << "\n";
        externalIV = false;
      }
      selectBlockMAC(&blockMACBytes, &blockMACRandBytes);
      allowHoles = selectZeroBlockPassThrough();
    }
    desiredKDFDuration = selectKDFDuration();
  }

  shared_ptr<CipherV1> cipher = CipherV1::New( alg.iface, keySize );
  if(!cipher)
  {
    LOG(ERROR) << "Unable to instanciate cipher " << alg.name
      << ", key size " << keySize << ", block size " << blockSize;
    return rootInfo;
  } else
  {
    VLOG(1) << "Using cipher " << alg.name
      << ", key size " << keySize << ", block size " << blockSize;
  }

  EncfsConfig config;

  config.mutable_cipher()->MergeFrom( cipher->interface() );
  config.set_block_size( blockSize );
  config.mutable_naming()->MergeFrom( nameIOIface );
  config.set_creator( "EncFS " VERSION );
  config.set_revision( ProtoSubVersion );
  config.set_block_mac_bytes( blockMACBytes );
  config.set_block_mac_rand_bytes( blockMACRandBytes );
  config.set_unique_iv( uniqueIV );
  config.set_chained_iv( chainedIV );
  config.set_external_iv( externalIV );
  config.set_allow_holes( allowHoles );

  EncryptedKey *key = config.mutable_key();
  key->clear_salt();
  key->clear_kdf_iterations(); // filled in by keying function
  key->set_kdf_duration( desiredKDFDuration );
  key->set_size(keySize / 8);

  cout << "\n";
  // xgroup(setup)
  cout << _("Configuration finished.  The filesystem to be created has\n"
      "the following properties:") << endl;
  showFSInfo( config );

  if( config.external_iv() )
  {
    cout << 
      _("-------------------------- WARNING --------------------------\n")
      <<
      _("The external initialization-vector chaining option has been\n"
          "enabled.  This option disables the use of hard links on the\n"
          "filesystem. Without hard links, some programs may not work.\n"
          "The programs 'mutt' and 'procmail' are known to fail.  For\n"
          "more information, please see the encfs mailing list.\n"
          "If you would like to choose another configuration setting,\n"
          "please press CTRL-C now to abort and start over.") << endl;
    cout << endl;
  }

  // xgroup(setup)
  cout << _("Now you will need to enter a password for your filesystem.\n"
开发者ID:bentolor,项目名称:encfs,代码行数:67,代码来源:FileUtils.cpp

示例3: showFSInfo


//.........这里部分代码省略.........
        cout << autosprintf(_(" (using %i:%i:%i)\n"),
            iface.major(), iface.minor(), iface.age());
      } else
        cout << "\n";
    }
  }

  // xgroup(diag)
  cout << autosprintf(_("Filename encoding: \"%s\", version %i:%i:%i"),
          config.naming().name().c_str(), config.naming().major(),
          config.naming().minor(), config.naming().age());
    
  if (!cipher)
  {
      cout <<  "\n";
  } else
  {
    // check if we support the filename encoding interface..
    shared_ptr<NameIO> nameCoder = NameIO::New( config.naming(), cipher );
    if(!nameCoder)
    {
      // xgroup(diag)
      cout << _(" (NOT supported)\n");
    } else
    {
      // if we're using a newer interface, show the version number
      if( config.naming() != nameCoder->interface() )
      {
        Interface iface = nameCoder->interface();
        cout << autosprintf(_(" (using %i:%i:%i)\n"),
            iface.major(), iface.minor(), iface.age());
      } else
        cout << "\n";
    }
  }
  const EncryptedKey &key = config.key();
  {
    cout << autosprintf(_("Key Size: %i bits"), 8 * key.size());
    cipher = getCipher(config);
    if(!cipher)
    {
      // xgroup(diag)
      cout << _(" (NOT supported)\n");
    } else
      cout << "\n";
  }
  if(key.kdf_iterations() > 0 && key.salt().size() > 0)
  {
    cout << autosprintf(_("Using PBKDF2, with %i iterations"), 
        key.kdf_iterations()) << "\n";
    cout << autosprintf(_("Salt Size: %i bits"), 
        8*(int)key.salt().size()) << "\n";
  }
  if(config.block_mac_bytes() || config.block_mac_rand_bytes())
  {
    if(config.revision() < V5Latest)
    {
      cout << autosprintf(
          // xgroup(diag)
          _("Block Size: %i bytes + %i byte MAC header"),
          config.block_size(),
          config.block_mac_bytes() + config.block_mac_rand_bytes()) << endl;
    } else
    {
      // new version stores the header as part of that block size..
      cout << autosprintf(
          // xgroup(diag)
          _("Block Size: %i bytes, including %i byte MAC header"),
          config.block_size(),
          config.block_mac_bytes() + config.block_mac_rand_bytes()) << endl;
    }
  } else
  {
    // xgroup(diag)
    cout << autosprintf(_("Block Size: %i bytes"), config.block_size());
    cout << "\n";
  }

  if(config.unique_iv())
  {
    // xgroup(diag)
    cout << _("Each file contains 8 byte header with unique IV data.\n");
  }
  if(config.chained_iv())
  {
    // xgroup(diag)
    cout << _("Filenames encoded using IV chaining mode.\n");
  }
  if(config.external_iv())
  {
    // xgroup(diag)
    cout << _("File data IV is chained to filename IV.\n");
  }
  if(config.allow_holes())
  {
    // xgroup(diag)
    cout << _("File holes passed through to ciphertext.\n");
  }
  cout << "\n";
}
开发者ID:bentolor,项目名称:encfs,代码行数:101,代码来源:FileUtils.cpp


注:本文中的EncfsConfig::chained_iv方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。