[
https://issues.apache.org/jira/browse/CRYPTO-169?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17778262#comment-17778262
]
Yang Jie commented on CRYPTO-169:
---------------------------------
Yes, crypto has not supported Apple Silicon.
But the current critical issue is that the behavior of the line of code
`org.apache.commons.crypto.random.CryptoRandomFactory.getCryptoRandom(new
Properties())` has changed between version 1.1.0 and 1.2.0.
In 1.1.0, the above statement returns an instance of type
`org.apache.commons.crypto.random.JavaCryptoRandom`.
In 1.2.0, the above statement directly throws an `ExceptionInInitializerError`
type of error due to the execution failure of
`org.apache.commons.crypto.utils.ReflectionUtils.getClassByName("org.apache.commons.crypto.random.OpenSslCryptoRandom")`.
Note, here it throws an Error, not an Exception.
Looking at the logic of `CryptoRandomFactory.getCryptoRandom`, it does not
force `OpenSslCryptoRandom` to return successfully. As long as either
`OpenSslCryptoRandom` or `JavaCryptoRandom` initializes successfully, it is
acceptable. However, in 1.2.0, there is a scenario that
`CryptoRandomFactory.getCryptoRandom` cannot handle, because it handles all
`Exception` scenarios but does not handle any `Error` scenarios,so, when an
`Error` occurs, it does not attempt to initialize `JavaCryptoRandom`, but
directly throws an `ExceptionInInitializerError` instead.
> Unable to load native library on Apple Silicon (M1 Mac)
> -------------------------------------------------------
>
> Key: CRYPTO-169
> URL: https://issues.apache.org/jira/browse/CRYPTO-169
> Project: Commons Crypto
> Issue Type: Bug
> Reporter: L. C. Hsieh
> Priority: Major
> Attachments: image-2023-10-21-17-51-41-260.png,
> image-2023-10-21-17-52-02-237.png, image-2023-10-21-17-53-16-898.png,
> image-2023-10-21-17-59-13-866.png
>
>
> Recently as trying to upgrade commons-crypto from 1.1.0 to 1.2.0 in Spark
> (SPARK-45617), got the following error in one test:
> ```
> [info] Cause: java.security.GeneralSecurityException: Native library is not
> loaded
> [info] at
> org.apache.commons.crypto.random.OpenSslCryptoRandom.checkNative(OpenSslCryptoRandom.java:79)
> [info] at
> org.apache.commons.crypto.random.OpenSslCryptoRandom.<clinit>(OpenSslCryptoRandom.java:65)
>
> [info] at java.base/java.lang.Class.forName0(Native Method)
>
> [info] at java.base/java.lang.Class.forName(Class.java:467)
> [info] at
> org.apache.commons.crypto.utils.ReflectionUtils.getClassByNameOrNull(ReflectionUtils.java:93)
> [info] at
> org.apache.commons.crypto.utils.ReflectionUtils.getClassByName(ReflectionUtils.java:64)
> [info] at
> org.apache.commons.crypto.random.CryptoRandomFactory.getCryptoRandom(CryptoRandomFactory.java:189)
> [info] at
> org.apache.spark.security.CryptoStreamUtils$.createInitializationVector(CryptoStreamUtils.scala:138)
> [info] at
> org.apache.spark.security.CryptoStreamUtils$.createCryptoOutputStream(CryptoStreamUtils.scala:56)
> [info] at
> org.apache.spark.serializer.SerializerManager.$anonfun$wrapForEncryption$3(SerializerManager.scala:151)
>
> ```
> I did a quick check. commons-crypto-1.2.0.jar only contain x86_64 Mac native
> library, it doesn't provide pre-built native library for Apple Silicon.
> But I also checked commons-crypto-1.1.0.jar which Spark uses currently. It
> also doesn't provide native library for Apple Silicon.
> Since they both don't contain native library for Apple Silicon, why
> commons-crypto-1.2.0 doesn't work and what makes the difference between
> commons-crypto-1.1.0 and commons-crypto-1.2.0?
--
This message was sent by Atlassian Jira
(v8.20.10#820010)