Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2013-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
   *
   * Licensed under the Apache License, Version 2.0 (the "License").
   * You may not use this file except in compliance with the License.
   * A copy of the License is located at
   *
   *  http://aws.amazon.com/apache2.0
   *
  * or in the "license" file accompanying this file. This file is distributed
  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  * express or implied. See the License for the specific language governing
  * permissions and limitations under the License.
  */
 package com.amazonaws.services.s3.internal.crypto;
 
 import static com.amazonaws.services.s3.model.CryptoMode.EncryptionOnly;
 
 import java.io.File;
 
Encryption only (EO) cryptographic module for the S3 encryption client.
 

Parameters:
cryptoConfig a read-only copy of the crypto configuration
 
             AWSCredentialsProvider credentialsProvider,
             EncryptionMaterialsProvider encryptionMaterialsProvider,
             CryptoConfiguration cryptoConfig) {
         super(kmss3credentialsProviderencryptionMaterialsProvider,
                 cryptoConfig);
         if (cryptoConfig.getCryptoMode() != )
             throw new IllegalArgumentException();
     }

    
Used for testing purposes only.
 
             EncryptionMaterialsProvider encryptionMaterialsProvider,
             CryptoConfiguration cryptoConfig) {
         this(nulls3new DefaultAWSCredentialsProviderChain(),
                 encryptionMaterialsProvidercryptoConfig);
     }

    
Used for testing purposes only.
 
             EncryptionMaterialsProvider encryptionMaterialsProvider,
             CryptoConfiguration cryptoConfig) {
         this(kmss3new DefaultAWSCredentialsProviderChain(),
                 encryptionMaterialsProvidercryptoConfig);
     }
 
     @Override
     public S3Object getObjectSecurely(GetObjectRequest getObjectRequest) {
         // Should never get here, as S3 object encrypted in either EO or AE
         // format should all be handled by the AE module.
         throw new IllegalStateException();
     }
 
     @Override
     public ObjectMetadata getObjectSecurely(GetObjectRequest getObjectRequest,
             File destinationFile) {
         // Should never get here, as S3 object encrypted in either EO or AE
         // format should all be handled by the AE module.
         throw new IllegalStateException();
     }
 
     @Override
             InitiateMultipartUploadRequest req,
             ContentCryptoMaterial cekMaterial) {
         MultipartUploadCbcContext encryptedUploadContext = new MultipartUploadCbcContext(
                 req.getBucketName(), req.getKey(), cekMaterial);
         byte[] iv = cekMaterial.getCipherLite().getIV();
         encryptedUploadContext.setNextInitializationVector(iv);
         return encryptedUploadContext
     }
 
 
     @Override
     final void updateUploadContext(MultipartUploadCbcContext uploadContext,
            SdkFilterInputStream is) {
        uploadContext.setNextInitializationVector(bis.getBlock());
        return;
    }
    @Override
            CipherLiteInputStream islong partSize) {
        int blockSize = .getBlockSizeInBytes();
        return new ByteRangeCapturingInputStream(is
                partSize - blockSize,
                partSize);
    }
    
    @Override
    final long computeLastPartSize(UploadPartRequest request) {
        long plaintextLength;
        if (request.getFile() != null) {
            if (request.getPartSize() > 0)
                plaintextLength = request.getPartSize();
            else
                plaintextLength = request.getFile().length();
        } else if (request.getInputStream() != null) {
            plaintextLength = request.getPartSize();
        } else {
            return -1;
        }
        long cipherBlockSize = .getBlockSizeInBytes();
        long offset = cipherBlockSize - (plaintextLength % cipherBlockSize);
        return plaintextLength + offset;
    }
    @Override
            MultipartUploadCbcContext uploadContext) {
        CipherLite cipherLite = uploadContext.getCipherLite();
        byte[] nextIV = uploadContext.getNextInitializationVector();
        return cipherLite.createUsingIV(nextIV);
    }
    /*
     * Private helper methods
     */
    @Override
    protected final long ciphertextLength(long plaintextLength) {
        long cipherBlockSize = .getBlockSizeInBytes();
        long offset = cipherBlockSize - (plaintextLength % cipherBlockSize);
        return plaintextLength + offset;
    }
New to GrepCode? Check out our FAQ X