code: public static ServerSideEncryption copyWithCustomerKey(SecretKey key) 
      throws InvalidKeyException, NoSuchAlgorithmException {
      if (!isCustomerKeyValid(key)) {
        throw new InvalidKeyException("The secret key is not a 256 bit AES key");
      }
      return new ServerSideEncryptionCopyWithCustomerKey(key, MessageDigest.getInstance(("MD5")));
    }
docs: 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.