public static ServerSideEncryption withCustomerKey(SecretKey key) 
    throws InvalidKeyException, NoSuchAlgorithmException {
    if (!isCustomerKeyValid(key)) {
      throw new InvalidKeyException("The secret key is not a 256 bit AES key");
    }
    return new ServerSideEncryptionWithCustomerKey(key, MessageDigest.getInstance(("MD5")));
  }
public static ServerSideEncryption withCustomerKey ( SecretKey key ) throws InvalidKeyException , NoSuchAlgorithmException { if ( ! isCustomerKeyValid ( key ) ) { throw new InvalidKeyException ( "The secret key is not a 256 bit AES key" ) ; } return new ServerSideEncryptionWithCustomerKey ( key , MessageDigest . getInstance ( ( "MD5" ) ) ) ; }
Create a new server-side-encryption object for encryption with customer
provided keys (a.k.a. SSE-C).

@param key The secret AES-256 key.
@return An instance of ServerSideEncryption implementing SSE-C.
@throws InvalidKeyException if the provided secret key is not a 256 bit AES key.
@throws NoSuchAlgorithmException if the crypto provider does not implement MD5.