Java 类org.apache.hadoop.hbase.io.crypto.Decryptor 实例源码

项目:ditb    文件:SecureWALCellCodec.java   
public EncryptedKvDecoder(InputStream in, Decryptor decryptor) {
  super(in);
  this.decryptor = decryptor;
  if (decryptor != null) {
    this.iv = new byte[decryptor.getIvLength()];
  }
}
项目:ditb    文件:AES.java   
@Override
public InputStream createDecryptionStream(InputStream in, Context context, byte[] iv)
    throws IOException {
  Preconditions.checkNotNull(context);
  Preconditions.checkState(context.getKey() != null, "Context does not have a key");
  Preconditions.checkNotNull(iv);
  Decryptor d = getDecryptor();
  d.setKey(context.getKey());
  d.setIv(iv);
  return d.createDecryptionStream(in);
}
项目:pbase    文件:SecureWALCellCodec.java   
public EncryptedKvDecoder(InputStream in, Decryptor decryptor) {
  super(in);
  this.decryptor = decryptor;
  if (decryptor != null) {
    this.iv = new byte[decryptor.getIvLength()];
  }
}
项目:pbase    文件:AES.java   
@Override
public InputStream createDecryptionStream(InputStream in, Context context, byte[] iv)
    throws IOException {
  Preconditions.checkNotNull(context);
  Preconditions.checkState(context.getKey() != null, "Context does not have a key");
  Preconditions.checkNotNull(iv);
  Decryptor d = getDecryptor();
  d.setKey(context.getKey());
  d.setIv(iv);
  return d.createDecryptionStream(in);
}
项目:HIndex    文件:AES.java   
@Override
public InputStream createDecryptionStream(InputStream in, Context context, byte[] iv)
    throws IOException {
  Preconditions.checkNotNull(context);
  Preconditions.checkState(context.getKey() != null, "Context does not have a key");
  Preconditions.checkNotNull(iv);
  Decryptor d = getDecryptor();
  d.setKey(context.getKey());
  d.setIv(iv);
  return d.createDecryptionStream(in);
}
项目:hbase    文件:SecureWALCellCodec.java   
public EncryptedKvDecoder(InputStream in, Decryptor decryptor) {
  super(in);
  this.decryptor = decryptor;
  if (decryptor != null) {
    this.iv = new byte[decryptor.getIvLength()];
  }
}
项目:hbase    文件:CommonsCryptoAES.java   
@Override
public InputStream createDecryptionStream(InputStream in, Context context,
                                          byte[] iv) throws IOException {
  Preconditions.checkNotNull(context);
  Preconditions.checkState(context.getKey() != null, "Context does not have a key");
  Preconditions.checkNotNull(iv);
  Decryptor d = getDecryptor();
  d.setKey(context.getKey());
  d.setIv(iv);
  return d.createDecryptionStream(in);
}
项目:hbase    文件:CommonsCryptoAES.java   
@Override
public InputStream createDecryptionStream(InputStream in,
                                          Decryptor decryptor) throws
    IOException {
  Preconditions.checkNotNull(decryptor);
  return decryptor.createDecryptionStream(in);
}
项目:hbase    文件:AES.java   
@Override
public InputStream createDecryptionStream(InputStream in, Context context, byte[] iv)
    throws IOException {
  Preconditions.checkNotNull(context);
  Preconditions.checkState(context.getKey() != null, "Context does not have a key");
  Preconditions.checkNotNull(iv);
  Decryptor d = getDecryptor();
  d.setKey(context.getKey());
  d.setIv(iv);
  return d.createDecryptionStream(in);
}
项目:PyroDB    文件:AES.java   
@Override
public InputStream createDecryptionStream(InputStream in, Context context, byte[] iv)
    throws IOException {
  Preconditions.checkNotNull(context);
  Preconditions.checkState(context.getKey() != null, "Context does not have a key");
  Preconditions.checkNotNull(iv);
  Decryptor d = getDecryptor();
  d.setKey(context.getKey());
  d.setIv(iv);
  return d.createDecryptionStream(in);
}
项目:ditb    文件:SecureWALCellCodec.java   
public SecureWALCellCodec(Configuration conf, Decryptor decryptor) {
  super(conf, null);
  this.decryptor = decryptor;
}
项目:ditb    文件:SecureWALCellCodec.java   
public static WALCellCodec getCodec(Configuration conf, Decryptor decryptor) {
  return new SecureWALCellCodec(conf, decryptor);
}
项目:ditb    文件:AES.java   
@Override
public Decryptor getDecryptor() {
  return new AESDecryptor(getJCECipherInstance());
}
项目:ditb    文件:AES.java   
@Override
public InputStream createDecryptionStream(InputStream in, Decryptor d) throws IOException {
  Preconditions.checkNotNull(d);
  return d.createDecryptionStream(in);
}
项目:pbase    文件:SecureWALCellCodec.java   
public SecureWALCellCodec(Configuration conf, Decryptor decryptor) {
  super(conf, null);
  this.decryptor = decryptor;
}
项目:pbase    文件:SecureWALCellCodec.java   
public static WALCellCodec getCodec(Configuration conf, Decryptor decryptor) {
  return new SecureWALCellCodec(conf, decryptor);
}
项目:pbase    文件:AES.java   
@Override
public Decryptor getDecryptor() {
  return new AESDecryptor(getJCECipherInstance());
}
项目:pbase    文件:AES.java   
@Override
public InputStream createDecryptionStream(InputStream in, Decryptor d) throws IOException {
  Preconditions.checkNotNull(d);
  return d.createDecryptionStream(in);
}
项目:HIndex    文件:SecureWALCellCodec.java   
public SecureWALCellCodec(Configuration conf, Decryptor decryptor) {
  super(conf, null);
  this.decryptor = decryptor;
}
项目:HIndex    文件:SecureWALCellCodec.java   
public EncryptedKvDecoder(InputStream in, Decryptor decryptor) {
  super(in);
  this.decryptor = decryptor;
  this.iv = new byte[decryptor.getIvLength()];
}
项目:HIndex    文件:SecureWALCellCodec.java   
public static WALCellCodec getCodec(Configuration conf, Decryptor decryptor) {
  return new SecureWALCellCodec(conf, decryptor);
}
项目:HIndex    文件:AES.java   
@Override
public Decryptor getDecryptor() {
  return new AESDecryptor(getJCECipherInstance());
}
项目:HIndex    文件:AES.java   
@Override
public InputStream createDecryptionStream(InputStream in, Decryptor d) throws IOException {
  Preconditions.checkNotNull(d);
  return d.createDecryptionStream(in);
}
项目:HIndex    文件:HFileBlockDefaultDecodingContext.java   
@Override
public void prepareDecoding(int onDiskSizeWithoutHeader, int uncompressedSizeWithoutHeader,
    ByteBuffer blockBufferWithoutHeader, byte[] onDiskBlock, int offset) throws IOException {
  InputStream in = new DataInputStream(new ByteArrayInputStream(onDiskBlock, offset,
    onDiskSizeWithoutHeader));

  Encryption.Context cryptoContext = fileContext.getEncryptionContext();
  if (cryptoContext != Encryption.Context.NONE) {

    Cipher cipher = cryptoContext.getCipher();
    Decryptor decryptor = cipher.getDecryptor();
    decryptor.setKey(cryptoContext.getKey());

    // Encrypted block format:
    // +--------------------------+
    // | byte iv length           |
    // +--------------------------+
    // | iv data ...              |
    // +--------------------------+
    // | encrypted block data ... |
    // +--------------------------+

    int ivLength = in.read();
    if (ivLength > 0) {
      byte[] iv = new byte[ivLength];
      IOUtils.readFully(in, iv);
      decryptor.setIv(iv);
      // All encrypted blocks will have a nonzero IV length. If we see an IV
      // length of zero, this means the encoding context had 0 bytes of
      // plaintext to encode.
      decryptor.reset();
      in = decryptor.createDecryptionStream(in);
    }
    onDiskSizeWithoutHeader -= Bytes.SIZEOF_BYTE + ivLength;
  }

  Compression.Algorithm compression = fileContext.getCompression();
  if (compression != Compression.Algorithm.NONE) {
    Compression.decompress(blockBufferWithoutHeader.array(),
      blockBufferWithoutHeader.arrayOffset(), in, onDiskSizeWithoutHeader,
      uncompressedSizeWithoutHeader, compression);
  } else {
    IOUtils.readFully(in, blockBufferWithoutHeader.array(),
      blockBufferWithoutHeader.arrayOffset(), onDiskSizeWithoutHeader);
  }
}
项目:hbase    文件:SecureWALCellCodec.java   
public SecureWALCellCodec(Configuration conf, Decryptor decryptor) {
  super(conf, null);
  this.decryptor = decryptor;
}
项目:hbase    文件:SecureWALCellCodec.java   
public static WALCellCodec getCodec(Configuration conf, Decryptor decryptor) {
  return new SecureWALCellCodec(conf, decryptor);
}
项目:hbase    文件:CommonsCryptoAES.java   
@Override
public Decryptor getDecryptor() {
  return new CommonsCryptoAESDecryptor(cipherMode, props);
}
项目:hbase    文件:AES.java   
@Override
public Decryptor getDecryptor() {
  return new AESDecryptor(getJCECipherInstance());
}
项目:hbase    文件:AES.java   
@Override
public InputStream createDecryptionStream(InputStream in, Decryptor d) throws IOException {
  Preconditions.checkNotNull(d);
  return d.createDecryptionStream(in);
}
项目:PyroDB    文件:SecureWALCellCodec.java   
public SecureWALCellCodec(Configuration conf, Decryptor decryptor) {
  super(conf, null);
  this.decryptor = decryptor;
}
项目:PyroDB    文件:SecureWALCellCodec.java   
public EncryptedKvDecoder(InputStream in, Decryptor decryptor) {
  super(in);
  this.decryptor = decryptor;
  this.iv = new byte[decryptor.getIvLength()];
}
项目:PyroDB    文件:SecureWALCellCodec.java   
public static WALCellCodec getCodec(Configuration conf, Decryptor decryptor) {
  return new SecureWALCellCodec(conf, decryptor);
}
项目:PyroDB    文件:AES.java   
@Override
public Decryptor getDecryptor() {
  return new AESDecryptor(getJCECipherInstance());
}
项目:PyroDB    文件:AES.java   
@Override
public InputStream createDecryptionStream(InputStream in, Decryptor d) throws IOException {
  Preconditions.checkNotNull(d);
  return d.createDecryptionStream(in);
}
项目:PyroDB    文件:HFileBlockDefaultDecodingContext.java   
@Override
public void prepareDecoding(int onDiskSizeWithoutHeader, int uncompressedSizeWithoutHeader,
    ByteBuffer blockBufferWithoutHeader, byte[] onDiskBlock, int offset) throws IOException {
  InputStream in = new DataInputStream(new ByteArrayInputStream(onDiskBlock, offset,
    onDiskSizeWithoutHeader));

  Encryption.Context cryptoContext = fileContext.getEncryptionContext();
  if (cryptoContext != Encryption.Context.NONE) {

    Cipher cipher = cryptoContext.getCipher();
    Decryptor decryptor = cipher.getDecryptor();
    decryptor.setKey(cryptoContext.getKey());

    // Encrypted block format:
    // +--------------------------+
    // | byte iv length           |
    // +--------------------------+
    // | iv data ...              |
    // +--------------------------+
    // | encrypted block data ... |
    // +--------------------------+

    int ivLength = in.read();
    if (ivLength > 0) {
      byte[] iv = new byte[ivLength];
      IOUtils.readFully(in, iv);
      decryptor.setIv(iv);
      // All encrypted blocks will have a nonzero IV length. If we see an IV
      // length of zero, this means the encoding context had 0 bytes of
      // plaintext to encode.
      decryptor.reset();
      in = decryptor.createDecryptionStream(in);
    }
    onDiskSizeWithoutHeader -= Bytes.SIZEOF_BYTE + ivLength;
  }

  Compression.Algorithm compression = fileContext.getCompression();
  if (compression != Compression.Algorithm.NONE) {
    Compression.decompress(blockBufferWithoutHeader.array(),
      blockBufferWithoutHeader.arrayOffset(), in, onDiskSizeWithoutHeader,
      uncompressedSizeWithoutHeader, compression);
  } else {
    IOUtils.readFully(in, blockBufferWithoutHeader.array(),
      blockBufferWithoutHeader.arrayOffset(), onDiskSizeWithoutHeader);
  }
}