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


Java CipherSuite.AES_CTR_NOPADDING属性代码示例

本文整理汇总了Java中org.apache.hadoop.crypto.CipherSuite.AES_CTR_NOPADDING属性的典型用法代码示例。如果您正苦于以下问题:Java CipherSuite.AES_CTR_NOPADDING属性的具体用法?Java CipherSuite.AES_CTR_NOPADDING怎么用?Java CipherSuite.AES_CTR_NOPADDING使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.apache.hadoop.crypto.CipherSuite的用法示例。


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

示例1: negotiateCipherOption

/**
 * Negotiate a cipher option which server supports.
 * 
 * @param conf the configuration
 * @param options the cipher options which client supports
 * @return CipherOption negotiated cipher option
 */
public static CipherOption negotiateCipherOption(Configuration conf,
    List<CipherOption> options) throws IOException {
  // Negotiate cipher suites if configured.  Currently, the only supported
  // cipher suite is AES/CTR/NoPadding, but the protocol allows multiple
  // values for future expansion.
  String cipherSuites = conf.get(DFS_ENCRYPT_DATA_TRANSFER_CIPHER_SUITES_KEY);
  if (cipherSuites == null || cipherSuites.isEmpty()) {
    return null;
  }
  if (!cipherSuites.equals(CipherSuite.AES_CTR_NOPADDING.getName())) {
    throw new IOException(String.format("Invalid cipher suite, %s=%s",
        DFS_ENCRYPT_DATA_TRANSFER_CIPHER_SUITES_KEY, cipherSuites));
  }
  if (options != null) {
    for (CipherOption option : options) {
      CipherSuite suite = option.getCipherSuite();
      if (suite == CipherSuite.AES_CTR_NOPADDING) {
        int keyLen = conf.getInt(
            DFS_ENCRYPT_DATA_TRANSFER_CIPHER_KEY_BITLENGTH_KEY,
            DFS_ENCRYPT_DATA_TRANSFER_CIPHER_KEY_BITLENGTH_DEFAULT) / 8;
        CryptoCodec codec = CryptoCodec.getInstance(conf, suite);
        byte[] inKey = new byte[keyLen];
        byte[] inIv = new byte[suite.getAlgorithmBlockSize()];
        byte[] outKey = new byte[keyLen];
        byte[] outIv = new byte[suite.getAlgorithmBlockSize()];
        codec.generateSecureRandom(inKey);
        codec.generateSecureRandom(inIv);
        codec.generateSecureRandom(outKey);
        codec.generateSecureRandom(outIv);
        return new CipherOption(suite, inKey, inIv, outKey, outIv);
      }
    }
  }
  return null;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:42,代码来源:DataTransferSaslUtil.java

示例2: convert

public static CipherSuite convert(CipherSuiteProto proto) {
  switch (proto) {
  case AES_CTR_NOPADDING:
    return CipherSuite.AES_CTR_NOPADDING;
  default:
    // Set to UNKNOWN and stash the unknown enum value
    CipherSuite suite = CipherSuite.UNKNOWN;
    suite.setUnknownValue(proto.getNumber());
    return suite;
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:11,代码来源:PBHelper.java

示例3: convert

public static CipherSuite convert(HdfsProtos.CipherSuiteProto proto) {
  switch (proto) {
  case AES_CTR_NOPADDING:
    return CipherSuite.AES_CTR_NOPADDING;
  default:
    // Set to UNKNOWN and stash the unknown enum value
    CipherSuite suite = CipherSuite.UNKNOWN;
    suite.setUnknownValue(proto.getNumber());
    return suite;
  }
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:11,代码来源:PBHelperClient.java


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