From 14142a0ef20902407d907f427b44e349f9ea3739 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Fri, 12 Mar 2021 22:23:01 +0100 Subject: [PATCH] [omemo] Introduce OmemoAesCipher as central AES API OmemoAesCipher is the sole point where OMEMO related AES operations are performed. This allows OmemoAesCipher to check in a static block if AES is available. If AES is not available it throws a (hopefully) helpfull exception message. Typically AES is not available on Android if no security provider providing AES, like Bouncy Castle, has been explicitly configured. --- .../smackx/omemo/OmemoRatchet.java | 16 +-- .../omemo/internal/CipherAndAuthTag.java | 33 ++----- .../smackx/omemo/internal/OmemoAesCipher.java | 99 +++++++++++++++++++ .../omemo/util/OmemoMessageBuilder.java | 21 +--- .../smackx/omemo/WrapperObjectsTest.java | 2 - 5 files changed, 120 insertions(+), 51 deletions(-) create mode 100644 smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/internal/OmemoAesCipher.java diff --git a/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoRatchet.java b/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoRatchet.java index 838784806..9c0ff2d30 100644 --- a/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoRatchet.java +++ b/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoRatchet.java @@ -1,6 +1,6 @@ /** * - * Copyright 2017 Paul Schaub + * Copyright 2017 Paul Schaub, 2021 Florian Schmaus * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,9 @@ package org.jivesoftware.smackx.omemo; import java.io.IOException; -import java.nio.charset.StandardCharsets; +import java.security.InvalidAlgorithmParameterException; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; import java.util.ArrayList; import java.util.List; import java.util.logging.Level; @@ -25,6 +27,7 @@ import java.util.logging.Logger; import javax.crypto.BadPaddingException; import javax.crypto.IllegalBlockSizeException; +import javax.crypto.NoSuchPaddingException; import org.jivesoftware.smackx.omemo.element.OmemoElement; import org.jivesoftware.smackx.omemo.element.OmemoKeyElement; @@ -172,11 +175,10 @@ public abstract class OmemoRatchet