Smack 4.5.0-beta9: JingleFile function call HashManager.getMessageDigest(algorithm) throws NoSuchAlgorithmException: SHA3-256

aTalk supports XEP-0234: Jingle File Transfer. During jingle file transfer protocol, it requires a ‘Hash’ element to be defined. However when execute the function call below in JingleFile class (algorithm = HashManager.ALGORITHM.SHA3_256), the system throws java.security.NoSuchAlgorithmException: SHA3-256 MessageDigest not available. It happend in both sending and receiving jinglefile.

HashManager.getMessageDigest(algorithm)

This problem only happens in aTalk ported to use smack4.5.0-beta9. The problem does not happen in smack-4.4.8; this holds true even after aTalk build.gradle is updated to match the one for smack-4.5.0-beta9 e.g.

a. sourceCompatibility JavaVersion.VERSION_11
b. minSdkVersion 26

I am still not sure why this happen, as the above function is calling the same android-sdk (api-36) library i.e. java.security.MessageDigest class. I am unable to trace beyond that point.

Any help is much appreciated.

MessageDigest.getInstance("SHA3-384"); the exception happens at statement
@ Security.getImpl(algorithm, "MessageDigest", (String)null)

//=================
    public static MessageDigest getInstance(String algorithm)
    throws NoSuchAlgorithmException {
        Objects.requireNonNull(algorithm, "null algorithm name");
        try {
            MessageDigest md;
            Object[] objs = Security.getImpl(algorithm, "MessageDigest", (String)null);
            if (objs[0] instanceof MessageDigest) {
                md = (MessageDigest)objs[0];
            } else {
                md = new Delegate((MessageDigestSpi)objs[0], algorithm);
            }
            md.provider = (Provider)objs[1];

            // Android-removed: this debugging mechanism is not used in Android.
            /*
            if (!skipDebug && pdebug != null) {
                pdebug.println("MessageDigest." + algorithm +
                    " algorithm from: " + md.provider.getName());
            }
            */

            return md;

        } catch(NoSuchProviderException e) {
            throw new NoSuchAlgorithmException(algorithm + " not found");
        }
    }

Following is the aTalk logcat:

//=== Jingle File sending ===
An uncaught exception occurred in thread = Thread[pool-8-thread-1,5,main] and message was: java.security.NoSuchAlgorithmException: SHA3-256 MessageDigest not available
                 java.lang.AssertionError: java.security.NoSuchAlgorithmException: SHA3-256 MessageDigest not available
                 	at org.jivesoftware.smackx.hashes.HashManager.getMessageDigest(HashManager.java:264)
                 	at org.jivesoftware.smackx.jingle_filetransfer.component.JingleFile.calculateHash(JingleFile.java:66)
                 	at org.jivesoftware.smackx.jingle_filetransfer.component.JingleFile.fromFile(JingleFile.java:55)
                 	at org.atalk.android.gui.chat.MetaContactChatTransport.createJingleFile(MetaContactChatTransport.java:771)
                 	at org.atalk.android.gui.chat.MetaContactChatTransport.jingleFileSend(MetaContactChatTransport.java:727)
                 	at org.atalk.android.gui.chat.MetaContactChatTransport.getFileTransferTransport(MetaContactChatTransport.java:677)
                 	at org.atalk.android.gui.chat.MetaContactChatTransport.sendFile(MetaContactChatTransport.java:643)
                 	at org.atalk.android.gui.chat.MetaContactChatTransport.sendFile(MetaContactChatTransport.java:608)
                 	at org.atalk.android.gui.chat.ChatFragment$SendFile.doInBackground(ChatFragment.java:2682)
                 	at org.atalk.android.gui.chat.ChatFragment$SendFile.lambda$execute$1$org-atalk-android-gui-chat-ChatFragment$SendFile(ChatFragment.java:2655)
                 	at org.atalk.android.gui.chat.ChatFragment$SendFile$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0)
                 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
                 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
                 	at java.lang.Thread.run(Thread.java:1012)
                 Caused by: java.security.NoSuchAlgorithmException: SHA3-256 MessageDigest not available
                 	at sun.security.jca.GetInstance.getInstance(GetInstance.java:159)
                 	at java.security.Security.getImpl(Security.java:628)
                 	at java.security.MessageDigest.getInstance(MessageDigest.java:211)
                 	at org.jivesoftware.smackx.hashes.HashManager.getMessageDigest(HashManager.java:239)
                 	at org.jivesoftware.smackx.jingle_filetransfer.component.JingleFile.calculateHash(JingleFile.java:66) 
                 	at org.jivesoftware.smackx.jingle_filetransfer.component.JingleFile.fromFile(JingleFile.java:55) 
                 	at org.atalk.android.gui.chat.MetaContactChatTransport.createJingleFile(MetaContactChatTransport.java:771) 
                 	at org.atalk.android.gui.chat.MetaContactChatTransport.jingleFileSend(MetaContactChatTransport.java:727) 
                 	at org.atalk.android.gui.chat.MetaContactChatTransport.getFileTransferTransport(MetaContactChatTransport.java:677) 
                 	at org.atalk.android.gui.chat.MetaContactChatTransport.sendFile(MetaContactChatTransport.java:643) 
                 	at org.atalk.android.gui.chat.MetaContactChatTransport.sendFile(MetaContactChatTransport.java:608) 
                 	at org.atalk.android.gui.chat.ChatFragment$SendFile.doInBackground(ChatFragment.java:2682) 
                 	at org.atalk.android.gui.chat.ChatFragment$SendFile.lambda$execute$1$org-atalk-android-gui-chat-ChatFragment$SendFile(ChatFragment.java:2655) 
                 	at org.atalk.android.gui.chat.ChatFragment$SendFile$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0) 
                 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) 
                 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644) 
                 	at java.lang.Thread.run(Thread.java:1012) 
                 	
//=== Jingle File receiving ===                 	
--------- beginning of crash
08:08:58.959  E  FATAL EXCEPTION: Thread-77
                 Process: org.atalk.android, PID: 4440
                 java.lang.AssertionError: java.security.NoSuchAlgorithmException: SHA3-256 MessageDigest not available
                 	at org.jivesoftware.smackx.hashes.HashManager.getMessageDigest(HashManager.java:264)
                 	at org.jivesoftware.smackx.jingle_filetransfer.component.JingleIncomingFileOffer.onBytestreamReady(JingleIncomingFileOffer.java:78)
                 	at org.jivesoftware.smackx.jingle.component.JingleContentImpl.onSecurityReady(JingleContentImpl.java:484)
                 	at org.jivesoftware.smackx.jet.component.JetSecurityImpl.decryptIncomingBytestream(JetSecurityImpl.java:107)
                 	at org.jivesoftware.smackx.jingle.component.JingleContentImpl.lambda$onTransportReady$5$org-jivesoftware-smackx-jingle-component-JingleContentImpl(JingleContentImpl.java:454)
                 	at org.jivesoftware.smackx.jingle.component.JingleContentImpl$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0)
                 	at java.lang.Thread.run(Thread.java:1012)
                 Caused by: java.security.NoSuchAlgorithmException: SHA3-256 MessageDigest not available
                 	at sun.security.jca.GetInstance.getInstance(GetInstance.java:159)
                 	at java.security.Security.getImpl(Security.java:628)
                 	at java.security.MessageDigest.getInstance(MessageDigest.java:211)
                 	at org.jivesoftware.smackx.hashes.HashManager.getMessageDigest(HashManager.java:239)
                 	at org.jivesoftware.smackx.jingle_filetransfer.component.JingleIncomingFileOffer.onBytestreamReady(JingleIncomingFileOffer.java:78) 
                 	at org.jivesoftware.smackx.jingle.component.JingleContentImpl.onSecurityReady(JingleContentImpl.java:484) 
                 	at org.jivesoftware.smackx.jet.component.JetSecurityImpl.decryptIncomingBytestream(JetSecurityImpl.java:107) 
                 	at org.jivesoftware.smackx.jingle.component.JingleContentImpl.lambda$onTransportReady$5$org-jivesoftware-smackx-jingle-component-JingleContentImpl(JingleContentImpl.java:454) 
                 	at org.jivesoftware.smackx.jingle.component.JingleContentImpl$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0) 
                 	at java.lang.Thread.run(Thread.java:1012) 

08:08:58.961  E  An uncaught exception occurred in thread = Thread[Thread-77,5,main] and message was: java.security.NoSuchAlgorithmException: SHA3-256 MessageDigest not available
                 java.lang.AssertionError: java.security.NoSuchAlgorithmException: SHA3-256 MessageDigest not available
                 	at org.jivesoftware.smackx.hashes.HashManager.getMessageDigest(HashManager.java:264)
                 	at org.jivesoftware.smackx.jingle_filetransfer.component.JingleIncomingFileOffer.onBytestreamReady(JingleIncomingFileOffer.java:78)
                 	at org.jivesoftware.smackx.jingle.component.JingleContentImpl.onSecurityReady(JingleContentImpl.java:484)
                 	at org.jivesoftware.smackx.jet.component.JetSecurityImpl.decryptIncomingBytestream(JetSecurityImpl.java:107)
                 	at org.jivesoftware.smackx.jingle.component.JingleContentImpl.lambda$onTransportReady$5$org-jivesoftware-smackx-jingle-component-JingleContentImpl(JingleContentImpl.java:454)
                 	at org.jivesoftware.smackx.jingle.component.JingleContentImpl$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0)
                 	at java.lang.Thread.run(Thread.java:1012)
                 Caused by: java.security.NoSuchAlgorithmException: SHA3-256 MessageDigest not available
                 	at sun.security.jca.GetInstance.getInstance(GetInstance.java:159)
                 	at java.security.Security.getImpl(Security.java:628)
                 	at java.security.MessageDigest.getInstance(MessageDigest.java:211)
                 	at org.jivesoftware.smackx.hashes.HashManager.getMessageDigest(HashManager.java:239)
                 	at org.jivesoftware.smackx.jingle_filetransfer.component.JingleIncomingFileOffer.onBytestreamReady(JingleIncomingFileOffer.java:78) 
                 	at org.jivesoftware.smackx.jingle.component.JingleContentImpl.onSecurityReady(JingleContentImpl.java:484) 
                 	at org.jivesoftware.smackx.jet.component.JetSecurityImpl.decryptIncomingBytestream(JetSecurityImpl.java:107) 
                 	at org.jivesoftware.smackx.jingle.component.JingleContentImpl.lambda$onTransportReady$5$org-jivesoftware-smackx-jingle-component-JingleContentImpl(JingleContentImpl.java:454) 
                 	at org.jivesoftware.smackx.jingle.component.JingleContentImpl$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0) 
                 	at java.lang.Thread.run(Thread.java:1012)           

Another observation during aTalk project clean built with smack-4.5.0-beta9, following error messages are shown. This does not happen for aTalk with smack-4.4.8.

The error messages are related to smack libraries that undergo the jarjar-repackage; this is required by aTalk to support features current not supported by smack.

Although with the erorr messages, I see that the repackaged libraries are generated without problem.

However I am not sure if this ever affects the above observed problem.

Any advice how to fix the error messages.

> Task :aTalk:jarjar-repackage_smack-experimental-4.5.0-beta9.jar
Failed to read class org/jivesoftware/smackx/carbons/CarbonManager$1.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smackx/carbons/CarbonManager$2$1.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smackx/carbons/CarbonManager$2.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smackx/carbons/CarbonManager$3.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smackx/carbons/CarbonManager$4.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smackx/carbons/CarbonManager.class: java.lang.UnsupportedOperationException: NestMember requires ASM7
Failed to read class org/jivesoftware/smackx/carbons/packet/Carbon$Disable.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smackx/carbons/packet/Carbon$Enable.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smackx/carbons/packet/Carbon.class: java.lang.UnsupportedOperationException: NestMember requires ASM7
Failed to read class org/jivesoftware/smackx/carbons/packet/CarbonExtension$Direction.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smackx/carbons/packet/CarbonExtension$Private.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smackx/carbons/packet/CarbonExtension.class: java.lang.UnsupportedOperationException: NestMember requires ASM7
Failed to read class org/jivesoftware/smackx/chat_markers/ChatMarkersManager$1.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smackx/chat_markers/ChatMarkersManager$2$1.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smackx/chat_markers/ChatMarkersManager$2.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smackx/chat_markers/ChatMarkersManager.class: java.lang.UnsupportedOperationException: NestMember requires ASM7
Failed to read class org/jivesoftware/smackx/chat_markers/element/ChatMarkersElements$AcknowledgedExtension.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smackx/chat_markers/element/ChatMarkersElements$ChatMarkerExtensionWithId.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smackx/chat_markers/element/ChatMarkersElements$DisplayedExtension.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smackx/chat_markers/element/ChatMarkersElements$MarkableExtension.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smackx/chat_markers/element/ChatMarkersElements$ReceivedExtension.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smackx/chat_markers/element/ChatMarkersElements.class: java.lang.UnsupportedOperationException: NestMember requires ASM7
Failed to read class org/jivesoftware/smackx/colors/ConsistentColor$1.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smackx/colors/ConsistentColor$ConsistentColorSettings.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smackx/colors/ConsistentColor$Deficiency.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smackx/colors/ConsistentColor.class: java.lang.UnsupportedOperationException: NestMember requires ASM7
Failed to read class org/jivesoftware/smackx/csi/packet/ClientStateIndication$Active.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
.....
Failed to read class org/jivesoftware/smackx/message_retraction/MessageRetractionManager.class: java.lang.UnsupportedOperationException: NestMember requires ASM7
Failed to read class org/jivesoftware/smackx/muclight/MultiUserChatLight$1.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smackx/muclight/MultiUserChatLight.class: java.lang.UnsupportedOperationException: NestMember requires ASM7
Failed to read class org/jivesoftware/smackx/muclight/element/MUCLightElements$AffiliationsChangeExtension.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smackx/muclight/element/MUCLightElements$BlockingElement.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smackx/muclight/element/MUCLightElements$ConfigurationElement.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smackx/muclight/element/MUCLightElements$ConfigurationsChangeExtension.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smackx/muclight/element/MUCLightElements$OccupantsElement.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smackx/muclight/element/MUCLightElements$UserWithAffiliationElement.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smackx/muclight/element/MUCLightElements.class: java.lang.UnsupportedOperationException: NestMember requires ASM7
Failed to read class org/jivesoftware/smackx/push_notifications/PushNotificationsManager$1.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smackx/push_notifications/PushNotificationsManager.class: java.lang.UnsupportedOperationException: NestMember requires ASM7
Failed to read class org/jivesoftware/smackx/push_notifications/element/PushNotificationsElements$RemoteDisablingExtension.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smackx/push_notifications/element/PushNotificationsElements.class: java.lang.UnsupportedOperationException: NestMember requires ASM7
Failed to read class org/jivesoftware/smackx/reference/ReferenceManager$1.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smackx/reference/ReferenceManager.class: java.lang.UnsupportedOperationException: NestMember requires ASM7
Failed to read class org/jivesoftware/smackx/reference/element/ReferenceElement$Type.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smackx/reference/element/ReferenceElement.class: java.lang.UnsupportedOperationException: NestMember requires ASM7
Failed to read class org/jivesoftware/smackx/sid/StableUniqueStanzaIdManager$1.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smackx/sid/StableUniqueStanzaIdManager.class: java.lang.UnsupportedOperationException: NestMember requires ASM7
Failed to read class org/jivesoftware/smackx/spoiler/provider/SpoilerProvider$1.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smackx/spoiler/provider/SpoilerProvider.class: java.lang.UnsupportedOperationException: NestMember requires ASM7
Failed to read class org/jivesoftware/smackx/stanza_content_encryption/element/ContentElement$Builder.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smackx/stanza_content_encryption/element/ContentElement.class: java.lang.UnsupportedOperationException: NestMember requires ASM7

> Task :aTalk:jarjar-repackage_smack-extensions-4.5.0-beta9.jar
Failed to read class org/jivesoftware/smack/chat2/Chat$1.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smack/chat2/Chat.class: java.lang.UnsupportedOperationException: NestMember requires ASM7
Failed to read class org/jivesoftware/smack/chat2/ChatManager$1$1.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smack/chat2/ChatManager$1.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smack/chat2/ChatManager$2.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smack/chat2/ChatManager.class: java.lang.UnsupportedOperationException: NestMember requires ASM7
Failed to read class org/jivesoftware/smackx/address/packet/MultipleAddresses$Address.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smackx/address/packet/MultipleAddresses$Type.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smackx/address/packet/MultipleAddresses.class: java.lang.UnsupportedOperationException: NestMember requires ASM7
Failed to read class org/jivesoftware/smackx/address/provider/MultipleAddressesProvider$1.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smackx/address/provider/MultipleAddressesProvider.class: java.lang.UnsupportedOperationException: NestMember requires ASM7
Failed to read class org/jivesoftware/smackx/amp/AMPDeliverCondition$Value.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smackx/amp/AMPDeliverCondition.class: java.lang.UnsupportedOperationException: NestMember requires ASM7
Failed to read class org/jivesoftware/smackx/amp/AMPManager$1.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smackx/amp/AMPManager.class: java.lang.UnsupportedOperationException: NestMember requires ASM7
Failed to read class org/jivesoftware/smackx/amp/AMPMatchResourceCondition$Value.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smackx/amp/AMPMatchResourceCondition.class: java.lang.UnsupportedOperationException: NestMember requires ASM7
.....
Failed to read class org/jivesoftware/smackx/xdatavalidation/packet/ValidateElement$1.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smackx/xdatavalidation/packet/ValidateElement$BasicValidateElement.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smackx/xdatavalidation/packet/ValidateElement$ListRange.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smackx/xdatavalidation/packet/ValidateElement$OpenValidateElement.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smackx/xdatavalidation/packet/ValidateElement$RangeValidateElement.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smackx/xdatavalidation/packet/ValidateElement$RegexValidateElement.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smackx/xdatavalidation/packet/ValidateElement.class: java.lang.UnsupportedOperationException: NestMember requires ASM7
Failed to read class org/jivesoftware/smackx/xdatavalidation/provider/DataValidationProvider$1.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smackx/xdatavalidation/provider/DataValidationProvider.class: java.lang.UnsupportedOperationException: NestMember requires ASM7
Failed to read class org/jivesoftware/smackx/xhtmlim/XHTMLManager$1.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smackx/xhtmlim/XHTMLManager.class: java.lang.UnsupportedOperationException: NestMember requires ASM7

> Task :aTalk:jarjar-repackage_smack-omemo-4.5.0-beta9.jar
Failed to read class org/jivesoftware/smackx/omemo/CachingOmemoStore$KeyCache.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smackx/omemo/CachingOmemoStore.class: java.lang.UnsupportedOperationException: NestMember requires ASM7
Failed to read class org/jivesoftware/smackx/omemo/FileBasedOmemoStore$FileHierarchy.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smackx/omemo/FileBasedOmemoStore.class: java.lang.UnsupportedOperationException: NestMember requires ASM7
Failed to read class org/jivesoftware/smackx/omemo/OmemoMessage$Received.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smackx/omemo/OmemoMessage$Sent.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smackx/omemo/OmemoMessage.class: java.lang.UnsupportedOperationException: NestMember requires ASM7
Failed to read class org/jivesoftware/smackx/omemo/internal/OmemoAesCipher$CipherOpmode.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smackx/omemo/internal/OmemoAesCipher.class: java.lang.UnsupportedOperationException: NestMember requires ASM7
Failed to read class org/jivesoftware/smackx/omemo/provider/OmemoBundleVAxolotlProvider$1.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smackx/omemo/provider/OmemoBundleVAxolotlProvider.class: java.lang.UnsupportedOperationException: NestMember requires ASM7
Failed to read class org/jivesoftware/smackx/omemo/provider/OmemoDeviceListVAxolotlProvider$1.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smackx/omemo/provider/OmemoDeviceListVAxolotlProvider.class: java.lang.UnsupportedOperationException: NestMember requires ASM7
Failed to read class org/jivesoftware/smackx/omemo/provider/OmemoVAxolotlProvider$1.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smackx/omemo/provider/OmemoVAxolotlProvider.class: java.lang.UnsupportedOperationException: NestMember requires ASM7
Failed to read class org/jivesoftware/smackx/omemo/util/OmemoConstants$Crypto.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smackx/omemo/util/OmemoConstants.class: java.lang.UnsupportedOperationException: NestMember requires ASM7
Failed to read class org/jivesoftware/smackx/omemo/util/OmemoKeyUtil$Bundle.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smackx/omemo/util/OmemoKeyUtil.class: java.lang.UnsupportedOperationException: NestMember requires ASM7
Failed to read class org/jivesoftware/smackx/omemo/util/OmemoMessageBuilder$1.class: java.lang.UnsupportedOperationException: NestHost requires ASM7
Failed to read class org/jivesoftware/smackx/omemo/util/OmemoMessageBuilder.class: java.lang.UnsupportedOperationException: NestMember requires ASM7

Note: the problem is independent whether the jinglefile transfer is unencryped or via JET protocol.

When I change the algorithm = HashManager.ALGORITHM.SHA_256, then it is OK. Seems the java security library included does not support SHA3….???

Appreciate if somebody can advise how to resolve the problem, or provide hints on how to further debug the problem.

Is it possible that you previously had transitively bouncycastle in the classpath and now you don’t?

The build.gradle files for both smack-4.4.8 and smack-4.5.0-beta9 in jarjar.repackage are exactly the same. However both do include (transitive = false) e.g.

    // smack-experimental
    implementation jarjar.repackage("smack-experimental-${smackVersion}.jar") {
        from("org.igniterealtime.smack:smack-experimental:${smackVersion}") {
            transitive = false
        }

        // Add support for media file sharing
        classDelete 'org.jivesoftware.smackx.httpfileupload.HttpFileUploadManager**'
        classDelete 'org.jivesoftware.smackx.jingle_filetransfer.JingleFileTransferManager**'

        // Fix AbstractMethodError: source in aTalk local directory and with in file QNAME defined
        classDelete 'org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferChild**'

        // Support Thumbnail parsing.
        classDelete 'org.jivesoftware.smackx.jingle_filetransfer.provider.JingleFileTransferProvider**'
    }

aTalk needs to set transitive = false; otherwise the build process failed with a lot of Duplicate class error messages.

I found that the following changes also fix the NoSuchAlgorithmException problem.

1. Add in build.gradle file:

implementation 'org.bouncycastle:bcprov-jdk15on:1.70' // SHA3-256

2. Modified HashManager for case SHA3_256 as follow:

    public static MessageDigest getMessageDigest(ALGORITHM algorithm) {
        MessageDigest md;
        try {
            switch (algorithm) {
                case MD5:
                    md = MessageDigest.getInstance("MD5");
                    break;
                case SHA_1:
                    md = MessageDigest.getInstance("SHA-1");
                    break;
                case SHA_224:
                    md = MessageDigest.getInstance("SHA-224");
                    break;
                case SHA_256:
                    md = MessageDigest.getInstance("SHA-256");
                    break;
                case SHA_384:
                    md = MessageDigest.getInstance("SHA-384");
                    break;
                case SHA_512:
                    md = MessageDigest.getInstance("SHA-512");
                    break;
                case SHA3_224:
                    md = MessageDigest.getInstance("SHA3-224");
                    break;
                case SHA3_256:
                    md = MessageDigest.getInstance("SHA3-256", new BouncyCastleProvider()););
                    break;
                case SHA3_384:
                    md = MessageDigest.getInstance("SHA3-384");
                    break;
                case SHA3_512:
                    md = MessageDigest.getInstance("SHA3-512");
                    break;
                case BLAKE2B160:
                    md = MessageDigest.getInstance("BLAKE2b-160");
                    break;
                case BLAKE2B256:
                    md = MessageDigest.getInstance("BLAKE2b-256");
                    break;
                case BLAKE2B384:
                    md = MessageDigest.getInstance("BLAKE2b-384");
                    break;
                case BLAKE2B512:
                    md = MessageDigest.getInstance("BLAKE2b-512");
                    break;
                default:
                    throw new AssertionError("Invalid enum value: " + algorithm);
            }
            return md;
        } catch (NoSuchAlgorithmException e) {
            throw new AssertionError(e);
        }
    }

I need to include the bc provider in the MessageDiest.getInstance() call. Need both the above 2 changes to fix the problem.

When replacing change#2 with i.e. add the following:

Security.addProvider(new BouncyCastleProvider());

before calling getMessageDigest(). It does not work in this case.

MessageDigest digest = HashManager.getMessageDigest(algorithm);

When doing an apk build for ‘DEBUG’ under android studio, a developer can actually replace a class file in a third party library used, without actually doing a jarjar.repackge of the affected library. The built apk will take the local source, replacing the one in the library; this will not cause ‘Duplicated class’ error messages in DEBUG mode.

In aTalk build.gradle file, I have temporary removed all the jarjar.repackage for the 3 smack libraries i.e. smack-enstension, smack-experiment and smack-omemo, used/modfied in aTalk. However I still found that function call below still throw NoSuchAlgorithmException.

MessageDigest.getInstance("SHA3-256");

Does this mean the NoSuchAlgorithmException problem is not due to use of the ‘transitive = false’ in jarjar.repackage of the smack library.

Again the following change resolved the issue i.e.

MessageDigest.getInstance("SHA3-256", new BouncyCastleProvider());

Any comment or advice where can the root cause be?

Note: Attached is the original build.gradle use in the aTalk build for both smack 4.4.8 and 4.5.0

// ===== aTalk logcat ======

08:42:31.848  E  FATAL EXCEPTION: pool-8-thread-1
                 Process: org.atalk.android, PID: 12835
                 java.lang.AssertionError: java.security.NoSuchAlgorithmException: SHA3-256 MessageDigest not available
                 	at org.jivesoftware.smackx.hashes.HashManager.getMessageDigest(HashManager.java:265)
                 	at org.jivesoftware.smackx.jingle_filetransfer.component.JingleFile.calculateHash(JingleFile.java:70)
                 	at org.jivesoftware.smackx.jingle_filetransfer.component.JingleFile.fromFile(JingleFile.java:57)
                 	at org.atalk.android.gui.chat.MetaContactChatTransport.createJingleFile(MetaContactChatTransport.java:771)
                 	at org.atalk.android.gui.chat.MetaContactChatTransport.jingleFileSend(MetaContactChatTransport.java:727)
                 	at org.atalk.android.gui.chat.MetaContactChatTransport.getFileTransferTransport(MetaContactChatTransport.java:677)
                 	at org.atalk.android.gui.chat.MetaContactChatTransport.sendFile(MetaContactChatTransport.java:643)
                 	at org.atalk.android.gui.chat.MetaContactChatTransport.sendFile(MetaContactChatTransport.java:608)
                 	at org.atalk.android.gui.chat.ChatFragment$SendFile.doInBackground(ChatFragment.java:2682)
                 	at org.atalk.android.gui.chat.ChatFragment$SendFile.lambda$execute$1$org-atalk-android-gui-chat-ChatFragment$SendFile(ChatFragment.java:2655)
                 	at org.atalk.android.gui.chat.ChatFragment$SendFile$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0)
                 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
                 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
                 	at java.lang.Thread.run(Thread.java:1012)
                 Caused by: java.security.NoSuchAlgorithmException: SHA3-256 MessageDigest not available
                 	at sun.security.jca.GetInstance.getInstance(GetInstance.java:159)
                 	at java.security.Security.getImpl(Security.java:628)
                 	at java.security.MessageDigest.getInstance(MessageDigest.java:211)
                 	at org.jivesoftware.smackx.hashes.HashManager.getMessageDigest(HashManager.java:240)
                 	at org.jivesoftware.smackx.jingle_filetransfer.component.JingleFile.calculateHash(JingleFile.java:70) 
                 	at org.jivesoftware.smackx.jingle_filetransfer.component.JingleFile.fromFile(JingleFile.java:57) 
                 	at org.atalk.android.gui.chat.MetaContactChatTransport.createJingleFile(MetaContactChatTransport.java:771) 
                 	at org.atalk.android.gui.chat.MetaContactChatTransport.jingleFileSend(MetaContactChatTransport.java:727) 
                 	at org.atalk.android.gui.chat.MetaContactChatTransport.getFileTransferTransport(MetaContactChatTransport.java:677) 
                 	at org.atalk.android.gui.chat.MetaContactChatTransport.sendFile(MetaContactChatTransport.java:643) 
                 	at org.atalk.android.gui.chat.MetaContactChatTransport.sendFile(MetaContactChatTransport.java:608) 
                 	at org.atalk.android.gui.chat.ChatFragment$SendFile.doInBackground(ChatFragment.java:2682) 
                 	at org.atalk.android.gui.chat.ChatFragment$SendFile.lambda$execute$1$org-atalk-android-gui-chat-ChatFragment$SendFile(ChatFragment.java:2655) 
                 	at org.atalk.android.gui.chat.ChatFragment$SendFile$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0) 
                 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) 
                 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644) 
                 	at java.lang.Thread.run(Thread.java:1012) 
08:42:31.851  E  An uncaught exception occurred in thread = Thread[pool-8-thread-1,5,main] and message was: java.security.NoSuchAlgorithmException: SHA3-256 MessageDigest not available
                 java.lang.AssertionError: java.security.NoSuchAlgorithmException: SHA3-256 MessageDigest not available
                 	at org.jivesoftware.smackx.hashes.HashManager.getMessageDigest(HashManager.java:265)
                 	at org.jivesoftware.smackx.jingle_filetransfer.component.JingleFile.calculateHash(JingleFile.java:70)
                 	at org.jivesoftware.smackx.jingle_filetransfer.component.JingleFile.fromFile(JingleFile.java:57)
                 	at org.atalk.android.gui.chat.MetaContactChatTransport.createJingleFile(MetaContactChatTransport.java:771)
                 	at org.atalk.android.gui.chat.MetaContactChatTransport.jingleFileSend(MetaContactChatTransport.java:727)
                 	at org.atalk.android.gui.chat.MetaContactChatTransport.getFileTransferTransport(MetaContactChatTransport.java:677)
                 	at org.atalk.android.gui.chat.MetaContactChatTransport.sendFile(MetaContactChatTransport.java:643)
                 	at org.atalk.android.gui.chat.MetaContactChatTransport.sendFile(MetaContactChatTransport.java:608)
                 	at org.atalk.android.gui.chat.ChatFragment$SendFile.doInBackground(ChatFragment.java:2682)
                 	at org.atalk.android.gui.chat.ChatFragment$SendFile.lambda$execute$1$org-atalk-android-gui-chat-ChatFragment$SendFile(ChatFragment.java:2655)
                 	at org.atalk.android.gui.chat.ChatFragment$SendFile$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0)
                 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
                 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
                 	at java.lang.Thread.run(Thread.java:1012)
                 Caused by: java.security.NoSuchAlgorithmException: SHA3-256 MessageDigest not available
                 	at sun.security.jca.GetInstance.getInstance(GetInstance.java:159)
                 	at java.security.Security.getImpl(Security.java:628)
                 	at java.security.MessageDigest.getInstance(MessageDigest.java:211)
                 	at org.jivesoftware.smackx.hashes.HashManager.getMessageDigest(HashManager.java:240)
                 	at org.jivesoftware.smackx.jingle_filetransfer.component.JingleFile.calculateHash(JingleFile.java:70) 
                 	at org.jivesoftware.smackx.jingle_filetransfer.component.JingleFile.fromFile(JingleFile.java:57) 
                 	at org.atalk.android.gui.chat.MetaContactChatTransport.createJingleFile(MetaContactChatTransport.java:771) 
                 	at org.atalk.android.gui.chat.MetaContactChatTransport.jingleFileSend(MetaContactChatTransport.java:727) 
                 	at org.atalk.android.gui.chat.MetaContactChatTransport.getFileTransferTransport(MetaContactChatTransport.java:677) 
                 	at org.atalk.android.gui.chat.MetaContactChatTransport.sendFile(MetaContactChatTransport.java:643) 
                 	at org.atalk.android.gui.chat.MetaContactChatTransport.sendFile(MetaContactChatTransport.java:608) 
                 	at org.atalk.android.gui.chat.ChatFragment$SendFile.doInBackground(ChatFragment.java:2682) 
                 	at org.atalk.android.gui.chat.ChatFragment$SendFile.lambda$execute$1$org-atalk-android-gui-chat-ChatFragment$SendFile(ChatFragment.java:2655) 
                 	at org.atalk.android.gui.chat.ChatFragment$SendFile$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0) 
                 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) 
                 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644) 
                 	at java.lang.Thread.run(Thread.java:1012) 

build.gradle (23.9 KB)

For both the ALGORITHM’s i.e. SHA-256 and SHA3-256, I check the provider with the following code in debug mode e.g.:

MessageDigest.getInstance(“SHA-256”).getProvider().toString()

I found when using different versions of smack libraries in aTalk, android uses different providers as shown follow (check with SHA-256):

a. smack 4.4.8: BC version 1.7
b. smack 4.5.0: AndroidOpenSSL version 1.0

Since in smack 4.5.0, AndroidOpenSSL does not support SHA3-256, hence the system crashes.

Any idea how to set BC version 1.7 provider when using smack 4.5.0 library.

Note: aTalk uses very similar buidl.gradle for integrating with smack 4.4.8 and smack 4.5.0.

// ========= new finding =========/

Before MessageDigest.getInstance(“SHA3-256”) I check the providers oders as shown below

a. under smack 4.4.8, BC version 1.7 is the first in the list
b, under smack 4.5.0, BC version 1.68 is 5th order, and after the AndroidOpenSSL version 1.0

Have the following comments:

  1. Why android MessageDigest.getInstance() does not iterate all the available providers before return with exception from AndroidOpenSSL version 1.0? This is my assumption, else it should not have returned exception if it has proceed to use BC version 1.68.
  2. Why not the same BC version is used in smack 4.4.8 and 4.5.0; “BC 1.7.0” is specfiied in build.gradle.

Any advice how to proceed from here.

        for(Provider provider : Security.getProviders()) {
            Timber.d("Available Provider: %s", provider);
        }

// ======== smack 4.4.8 ========== //
11:21:55.423 D  Available Provider: BC version 1.7
11:21:55.423 D  Available Provider: AndroidNSSP version 1.0
11:21:55.423 D  Available Provider: AndroidOpenSSL version 1.0
11:21:55.424 D  Available Provider: CertPathProvider version 1.0
11:21:55.424 D  Available Provider: AndroidKeyStoreBCWorkaround version 1.0
11:21:55.424 D  Available Provider: HarmonyJSSE version 1.0
11:21:55.425 D  Available Provider: AndroidKeyStore version 1.0

// ======== smack 4.5.0 ========== //
11:07:52.689  D  Available Provider: AndroidNSSP version 1.0
11:07:52.690  D  Available Provider: AndroidOpenSSL version 1.0
11:07:52.690  D  Available Provider: CertPathProvider version 1.0
11:07:52.690  D  Available Provider: AndroidKeyStoreBCWorkaround version 1.0
11:07:52.690  D  Available Provider: BC version 1.68
11:07:52.691  D  Available Provider: HarmonyJSSE version 1.0
11:07:52.691  D  Available Provider: AndroidKeyStore version 1.0

In aTalk source, during the init of the OSGiService, it actually contain a static funtion call

Security.insertProviderAt(new BouncyCastleProvider(), 1);

Before this statement is excuted, the provider list is found to be:

11:07:52.689  D  Available Provider: AndroidNSSP version 1.0
11:07:52.690  D  Available Provider: AndroidOpenSSL version 1.0
11:07:52.690  D  Available Provider: CertPathProvider version 1.0
11:07:52.690  D  Available Provider: AndroidKeyStoreBCWorkaround version 1.0
11:07:52.690  D  Available Provider: BC version 1.68
11:07:52.691  D  Available Provider: HarmonyJSSE version 1.0
11:07:52.691  D  Available Provider: AndroidKeyStore version 1.0

The provider list is the same for both smack 4.4.8 and 4.5.0. The execution of the

Security.insertProviderAt(new BouncyCastleProvider(), 1);

does not have effect as the list already contains “BC” provider.

However just prior to HashManager#getMessageDigest(), the list changes to:

// ======== smack 4.4.8 ========== //
11:21:55.423 D  Available Provider: BC version 1.7
11:21:55.423 D  Available Provider: AndroidNSSP version 1.0
11:21:55.423 D  Available Provider: AndroidOpenSSL version 1.0
11:21:55.424 D  Available Provider: CertPathProvider version 1.0
11:21:55.424 D  Available Provider: AndroidKeyStoreBCWorkaround version 1.0
11:21:55.424 D  Available Provider: HarmonyJSSE version 1.0
11:21:55.425 D  Available Provider: AndroidKeyStore version 1.0

// ======== smack 4.5.0 ========== //
11:07:52.689  D  Available Provider: AndroidNSSP version 1.0
11:07:52.690  D  Available Provider: AndroidOpenSSL version 1.0
11:07:52.690  D  Available Provider: CertPathProvider version 1.0
11:07:52.690  D  Available Provider: AndroidKeyStoreBCWorkaround version 1.0
11:07:52.690  D  Available Provider: BC version 1.68
11:07:52.691  D  Available Provider: HarmonyJSSE version 1.0
11:07:52.691  D  Available Provider: AndroidKeyStore version 1.0 

Some class may have take action to change the provider list when using smack 4.4.8, but not smack 4.5.0.

I modified the OSGiService source to:

static {
        Security.removeProvider("BC");
        Security.insertProviderAt(new BouncyCastleProvider(), 1);
    }

The provider list change to as:

11:21:55.423 D  Available Provider: BC version 1.7
11:21:55.423 D  Available Provider: AndroidNSSP version 1.0
11:21:55.423 D  Available Provider: AndroidOpenSSL version 1.0
11:21:55.424 D  Available Provider: CertPathProvider version 1.0
11:21:55.424 D  Available Provider: AndroidKeyStoreBCWorkaround version 1.0
11:21:55.424 D  Available Provider: HarmonyJSSE version 1.0
11:21:55.425 D  Available Provider: AndroidKeyStore version 1.0

With this, HashManager#getMessageDigest() is now working.

aTalk will adapt this as solution as this is independent of the smack version used.

By the way, the smack HashElementTest suite, it uses ‘SUN’“ provider. So there is no problem even for SHA3-256.

public class HashElementTest extends SmackTestSuite {
    @Test
    public void stanzaTest() throws Exception {
        MessageDigest md = MessageDigest.getInstance("SHA3-256");
        assertEquals(md, MessageDigest.getInstance("SHA-256"));

        String message = "Hello World!";
        HashElement element = HashManager.calculateHashElement(SHA3_256, StringUtils.toUtf8Bytes(message));
        // String expected = "<hash xmlns='urn:xmpp:hashes:2' algo='sha-256'>f4OxZX/x/FO5LcGBSKHWXfwtSx+j1ncoSt3SABJtkGk=</hash>";
        String expected = "<hash xmlns='urn:xmpp:hashes:2' algo='sha3-256'>0OR0hrv0wWrKwm+LZTWSlzwTYpCfkCYodwifnIpFNq8=</hash>";
        assertEquals(expected, element.toXML().toString());

        HashElement parsed = new HashElementProvider().parse(TestUtils.getParser(expected));
        assertEquals(expected, parsed.toXML().toString());
        assertEquals(SHA3_256, parsed.getAlgorithm());
        assertEquals("0OR0hrv0wWrKwm+LZTWSlzwTYpCfkCYodwifnIpFNq8=", parsed.getHashB64());
        assertArrayEquals(HashManager.sha3_256(message), parsed.getHash());

        assertEquals(element, parsed);
        assertTrue(element.equals(parsed));

        HashElement other = new HashElement(HashManager.ALGORITHM.SHA_512,
                "861844d6704e8573fec34d967e20bcfef3d424cf48be04e6dc08f2bd58c729743371015ead891cc3cf1c9d34b49264b510751b1ff9e537937bc46b5d6ff4ecc8".getBytes(StandardCharsets.UTF_8));
        assertFalse(element.equals(other));
    }
}

Found the reason why there is a differenct between smack 4.4.8 and 4.5.0 library when use in aTalk.

Currently aTalk does not support OpenPgp, it is found that smack 4.4.8 will include the library smackopenpgp,jar but not in smack 4.5.0 during aTalk build.

In the SmackInitialization#loadSmackClass(), hence smack 4.5.0 will throw ClassNotFoundException when attempt to load ‘org.jivesoftware.smackx.ox.util.OpenPgpInitializer’. Therefore it will not proceed to perform OpenPgpInitializer, where

SecurityUtil.ensureProviderAtFirstPosition(BouncyCastleProvider.class);

This is where the ‘BC’ provider is being inserted.

May be smack team should consider the above to be excuted in SmackInitialization indepedent of OpenPgp, as ‘BC’ provider is also used in HashManager in MessageDigest for ‘SHA3-256’.

1 Like

I think this is a long standing issue on the Android platform :confused: