1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-06-14 07:34:50 +02:00
Smack/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/util/OmemoConstants.java
Florian Schmaus 7d7fbe6828 Do not explicity select the (crypto) Provider in smack-omemo
This makes the system select the "best" available provider.

Also the 'BC' provider in newer Android version does not longer
implement certain Ciphers, which causes an NoSuchAlgorithmException if
the Cipher is requested explicitly by the 'BC' provider:

E/XmppService: XmppServiceConnection - Error while sending pending messages
  org.jivesoftware.smackx.omemo.exceptions.CryptoFailedException: java.security.NoSuchAlgorithmException: The BC provider no longer provides an implementation for Cipher.AES/GCM/NoPadding.  Please see https://android-developers.googleblog.com/2018/03/cryptography-changes-in-android-p.html for more details.
      at org.jivesoftware.smackx.omemo.OmemoService.encrypt(OmemoService.java:375)
      at org.jivesoftware.smackx.omemo.OmemoService.createOmemoMessage(OmemoService.java:537)
      at org.jivesoftware.smackx.omemo.OmemoManager.encrypt(OmemoManager.java:341)
      at org.jivesoftware.smackx.omemo.OmemoManager.encrypt(OmemoManager.java:314)
      at es.iecisa.xmppservice.XmppServiceConnection.lambda$sendMessage$0(XmppServiceConnection.java:516)
      at es.iecisa.xmppservice.-$$Lambda$XmppServiceConnection$aBU_80chagvypMTSd-aSm7pRQRY.run(Unknown Source:4)
      at java.lang.Thread.run(Thread.java:764)
   Caused by: java.security.NoSuchAlgorithmException: The BC provider no longer provides an implementation for Cipher.AES/GCM/NoPadding.  Please see https://android-developers.googleblog.com/2018/03/cryptography-changes-in-android-p.html for more details.
      at sun.security.jca.Providers.checkBouncyCastleDeprecation(Providers.java:563)
      at sun.security.jca.Providers.checkBouncyCastleDeprecation(Providers.java:346)
      at javax.crypto.Cipher.createCipher(Cipher.java:722)
      at javax.crypto.Cipher.getInstance(Cipher.java:717)
      at javax.crypto.Cipher.getInstance(Cipher.java:674)
      at org.jivesoftware.smackx.omemo.util.OmemoMessageBuilder.setMessage(OmemoMessageBuilder.java:169)
      at org.jivesoftware.smackx.omemo.util.OmemoMessageBuilder.<init>(OmemoMessageBuilder.java:116)
      at org.jivesoftware.smackx.omemo.OmemoService.encrypt(OmemoService.java:372)
      at org.jivesoftware.smackx.omemo.OmemoService.createOmemoMessage(OmemoService.java:537)
      at org.jivesoftware.smackx.omemo.OmemoManager.encrypt(OmemoManager.java:341)
      at org.jivesoftware.smackx.omemo.OmemoManager.encrypt(OmemoManager.java:314)
      at es.iecisa.xmppservice.XmppServiceConnection.lambda$sendMessage$0(XmppServiceConnection.java:516)
      at es.iecisa.xmppservice.-$$Lambda$XmppServiceConnection$aBU_80chagvypMTSd-aSm7pRQRY.run(Unknown Source:4)
      at java.lang.Thread.run(Thread.java:764)
2019-04-02 15:58:34 +02:00

63 lines
2.2 KiB
Java

/**
*
* Copyright 2017 Paul Schaub
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License 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 org.jivesoftware.smackx.omemo.util;
/**
* Some constants related to OMEMO.
* @author Paul Schaub
*/
public final class OmemoConstants {
// Constants
/**
* Omemo related namespace.
*/
public static final String OMEMO_NAMESPACE_V_AXOLOTL = "eu.siacs.conversations.axolotl";
public static final String OMEMO = "OMEMO";
// PubSub Node names
public static final String PEP_NODE_DEVICE_LIST = OMEMO_NAMESPACE_V_AXOLOTL + ".devicelist";
public static final String PEP_NODE_DEVICE_LIST_NOTIFY = PEP_NODE_DEVICE_LIST + "+notify";
public static final String PEP_NODE_BUNDLES = OMEMO_NAMESPACE_V_AXOLOTL + ".bundles";
/**
* How many preKeys do we want to publish?
*/
public static final int PRE_KEY_COUNT_PER_BUNDLE = 100;
/**
* Return the node name of the PEP node containing the device bundle of the device with device id deviceId.
*
* @param deviceId id of the device
* @return node name of the devices bundle node
*/
public static String PEP_NODE_BUNDLE_FROM_DEVICE_ID(int deviceId) {
return PEP_NODE_BUNDLES + ":" + deviceId;
}
public static final String BODY_OMEMO_HINT = "I sent you an OMEMO encrypted message but your client doesn't seem to support that. Find more information on https://conversations.im/omemo";
/**
* Information about the keys used for message encryption.
*/
public static final class Crypto {
public static final String KEYTYPE = "AES";
public static final int KEYLENGTH = 128;
public static final String CIPHERMODE = "AES/GCM/NoPadding";
}
}