Discussion:
[Interest] Qt 5.12 Beta 3 app freezes with Javascript library (RSA encrypt)
ekke
2018-11-05 11:00:58 UTC
Permalink
Qt 5.12 Beta 3. Android and iOS

in one of my apps I had to encrypt the user password using a JavaScript
library

http://www-cs-students.stanford.edu/%7Etjw/jsbn/

from there I put these .js into resources:

<RCC>
    <qresource prefix="/">
        <file>js/rsbn/base64.js</file>
        <file>js/rsbn/jsbn.js</file>
        <file>js/rsbn/prng4.js</file>
        <file>js/rsbn/rng.js</file>
        <file>js/rsbn/rsa.js</file>
    </qresource>
</RCC>

in QML:

import "../../js/rsbn/jsbn.js" as MyJsbn
import "../../js/rsbn/rsa.js" as MyRsa
import "../../js/rsbn/rng.js" as MyRng
import "../../js/rsbn/prng4.js" as MyPrng4
import "../../js/rsbn/base64.js" as MyBase64

function doEncrypt() {
    var rsa = new MyRsa.RSAKey();
    rsa.setPublic(dataServer.modulusHex(), "10001")
    console.log("5.12 OK")
    var res = rsa.encrypt(pwText.text)
    console.log("5.12 freeze")
    if(res) {
        return MyRsa.linebrk(res, 64)
    } else {
        return ""
    }
}

in 5.10.1 or 5.11.2 this is working fine

in 5.12 Beta 3 it freezes as soon as calling rsa.encrypt()

any idea what could be different in 5.12 ?

thx

ekke
ekke
2018-11-05 13:49:33 UTC
Permalink
created a example app and now noticed, the app doesn't freeze,
but the exection of encrypt() slows down from

5 sec (Qt 5.11.2) to
92 sec (Qt 5.12 Beta3)

will open a bug report
Post by ekke
Qt 5.12 Beta 3. Android and iOS
in one of my apps I had to encrypt the user password using a JavaScript
library
http://www-cs-students.stanford.edu/%7Etjw/jsbn/
<RCC>
    <qresource prefix="/">
        <file>js/rsbn/base64.js</file>
        <file>js/rsbn/jsbn.js</file>
        <file>js/rsbn/prng4.js</file>
        <file>js/rsbn/rng.js</file>
        <file>js/rsbn/rsa.js</file>
    </qresource>
</RCC>
import "../../js/rsbn/jsbn.js" as MyJsbn
import "../../js/rsbn/rsa.js" as MyRsa
import "../../js/rsbn/rng.js" as MyRng
import "../../js/rsbn/prng4.js" as MyPrng4
import "../../js/rsbn/base64.js" as MyBase64
function doEncrypt() {
    var rsa = new MyRsa.RSAKey();
    rsa.setPublic(dataServer.modulusHex(), "10001")
    console.log("5.12 OK")
    var res = rsa.encrypt(pwText.text)
    console.log("5.12 freeze")
    if(res) {
        return MyRsa.linebrk(res, 64)
    } else {
        return ""
    }
}
in 5.10.1 or 5.11.2 this is working fine
in 5.12 Beta 3 it freezes as soon as calling rsa.encrypt()
any idea what could be different in 5.12 ?
thx
ekke
_______________________________________________
Interest mailing list
http://lists.qt-project.org/mailman/listinfo/interest
Thiago Macieira
2018-11-05 16:59:46 UTC
Permalink
Post by ekke
created a example app and now noticed, the app doesn't freeze,
but the exection of encrypt() slows down from
5 sec (Qt 5.11.2) to
92 sec (Qt 5.12 Beta3)
will open a bug report
How about you encrypt using C++ instead? OpenSSL probably has the encryption
you need.
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel Open Source Technology Center
ekke
2018-11-05 19:32:03 UTC
Permalink
Post by Thiago Macieira
Post by ekke
created a example app and now noticed, the app doesn't freeze,
but the exection of encrypt() slows down from
5 sec (Qt 5.11.2) to
92 sec (Qt 5.12 Beta3)
will open a bug report
How about you encrypt using C++ instead? OpenSSL probably has the encryption
you need.
Thanks, Thiago for the hint - that was the first thing I tried, but
couldn't figure out HowTo make it work on Android and iOS.

It's only used when password has changed and must be entered: then
password must be RSA encrypted and base64 sent to server

so I was happy to find a JS solution which was implemented easy for
Android / iOS:

function doEncrypt() {
    var rsa = new MyRsa.RSAKey();
    rsa.setPublic(dataServer.modulusHex(), "10001")
    var res = rsa.encrypt(pwText.text)
    if(res) {
        return MyRsa.linebrk(res, 64)
    } else {
        return ""
    }
}

unfortunately now with 5.12 Beta it slows down by 20x.

on Android per ex. from 80 ms to 1700 ms (acceptable for my customer)

but iOS now is too slow

ekke
Thiago Macieira
2018-11-06 05:20:46 UTC
Permalink
Post by ekke
Thanks, Thiago for the hint - that was the first thing I tried, but
couldn't figure out HowTo make it work on Android and iOS.
unfortunately now with 5.12 Beta it slows down by 20x.
Then get a 400x improvement by trying the C++ part again. OpenSSL is easy on
Android, since you'll have to deploy it anyway alongside your application.

On iOS and macOS, you shouldn't use OpenSSL. You should use Apple's API,
whatever it is. Please consult Apple's website.
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel Open Source Technology Center
Tomasz Olszak
2018-11-06 05:30:47 UTC
Permalink
Still there is a performance regression somewhere and while the C++
solution is most performant the cause of this regression can hit other
parts of Qml stack.
Ekke do you use prebuilt binaries or do you compile them yourself?

If you compile yourself you can bisect and find the cause. Not many
patches landed in qtdeclarative in 5.11.3:

4a886753a Accessible: Return StaticText if there is no explicit role set
0f0ed2070 At least warn when triggering a rendering limitation
614d16d6f Doc: place more importance on not binding to x/y/width/height
7f57472e2 Warn, don't crash during nested delivery of mouse or touch presses
1ce94fc0f Qt Labs Settings: warn if failed to initialize internal
QSettings instance
7ca32bc41 qmlplugindump: Remove sigsegv handler
453a3806a Document that aliases cannot point to attached properties
10095542d Fix crash in QQuickAnimatorProxyJob::sceneGraphInitialized()
9cb13a422 QQuickItem: document which events are accepted by default
074190902 Mark QML captured scope/context loads as having side effects
f27a16b7b Don't get confused about the grabber during replayDelayedPress
3bdb3c1d8 Amend TouchMouse::buttonOnDelayedPressFlickable to test delayed tap
934d93b91 YarrJIT: disable MatchResult decoding constructor on 64bit
ec1fdecef Add QQuickItemPrivate::updateOrAddItemChangeListener()
777cd6e9b Add QT_CONFIG(filesystemwatcher) guard for include
039a28468 Fix Integrity OS allocator memory attributes
4441cefd7 Doc: Remove wrong ';' from Q_PROPERTY example
8fd398c9d Prevent PathView's parent stealing mouse grab during double-flick
Post by Thiago Macieira
Post by ekke
Thanks, Thiago for the hint - that was the first thing I tried, but
couldn't figure out HowTo make it work on Android and iOS.
unfortunately now with 5.12 Beta it slows down by 20x.
Then get a 400x improvement by trying the C++ part again. OpenSSL is easy on
Android, since you'll have to deploy it anyway alongside your application.
On iOS and macOS, you shouldn't use OpenSSL. You should use Apple's API,
whatever it is. Please consult Apple's website.
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel Open Source Technology Center
_______________________________________________
Interest mailing list
http://lists.qt-project.org/mailman/listinfo/interest
ekke
2018-11-06 05:48:32 UTC
Permalink
Post by Tomasz Olszak
Still there is a performance regression somewhere and while the C++
solution is most performant
will try again to find a C++ solution for Android, iOS
Post by Tomasz Olszak
the cause of this regression can hit other
parts of Qml stack.
have created bug with example app
https://bugreports.qt.io/browse/QTBUG-71591
Post by Tomasz Olszak
Ekke do you use prebuilt binaries or do you compile them yourself?
sorry, I'm only using prebuilt binaries
... and it's even much work to test my complex mobile apps against 5.10,
5.11, 5.12, QtC 4.7.x, 4.8Beta, all the iOS / Android versions /
devices/ ... ;-)

ekke
Post by Tomasz Olszak
If you compile yourself you can bisect and find the cause. Not many
4a886753a Accessible: Return StaticText if there is no explicit role set
0f0ed2070 At least warn when triggering a rendering limitation
614d16d6f Doc: place more importance on not binding to x/y/width/height
7f57472e2 Warn, don't crash during nested delivery of mouse or touch presses
1ce94fc0f Qt Labs Settings: warn if failed to initialize internal
QSettings instance
7ca32bc41 qmlplugindump: Remove sigsegv handler
453a3806a Document that aliases cannot point to attached properties
10095542d Fix crash in QQuickAnimatorProxyJob::sceneGraphInitialized()
9cb13a422 QQuickItem: document which events are accepted by default
074190902 Mark QML captured scope/context loads as having side effects
f27a16b7b Don't get confused about the grabber during replayDelayedPress
3bdb3c1d8 Amend TouchMouse::buttonOnDelayedPressFlickable to test delayed tap
934d93b91 YarrJIT: disable MatchResult decoding constructor on 64bit
ec1fdecef Add QQuickItemPrivate::updateOrAddItemChangeListener()
777cd6e9b Add QT_CONFIG(filesystemwatcher) guard for include
039a28468 Fix Integrity OS allocator memory attributes
4441cefd7 Doc: Remove wrong ';' from Q_PROPERTY example
8fd398c9d Prevent PathView's parent stealing mouse grab during double-flick
Post by Thiago Macieira
Post by ekke
Thanks, Thiago for the hint - that was the first thing I tried, but
couldn't figure out HowTo make it work on Android and iOS.
unfortunately now with 5.12 Beta it slows down by 20x.
Then get a 400x improvement by trying the C++ part again. OpenSSL is easy on
Android, since you'll have to deploy it anyway alongside your application.
On iOS and macOS, you shouldn't use OpenSSL. You should use Apple's API,
whatever it is. Please consult Apple's website.
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel Open Source Technology Center
_______________________________________________
Interest mailing list
http://lists.qt-project.org/mailman/listinfo/interest
_______________________________________________
Interest mailing list
http://lists.qt-project.org/mailman/listinfo/interest
Thiago Macieira
2018-11-06 06:06:14 UTC
Permalink
Post by Tomasz Olszak
Still there is a performance regression somewhere and while the C++
solution is most performant the cause of this regression can hit other
parts of Qml stack.
Not necessarily. This may be a side-effect of performance improvements
elsewhere. If you can show a realistic workload (not encryption) that is
getting considerably slow, report it. It'll probably get a high priority.

Encryption won't get high priority.
Post by Tomasz Olszak
Ekke do you use prebuilt binaries or do you compile them yourself?
If you compile yourself you can bisect and find the cause. Not many
If you compile yourself, confirm those are release binaries.
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel Open Source Technology Center
ekke
2018-11-06 05:36:28 UTC
Permalink
Post by Thiago Macieira
Post by ekke
Thanks, Thiago for the hint - that was the first thing I tried, but
couldn't figure out HowTo make it work on Android and iOS.
unfortunately now with 5.12 Beta it slows down by 20x.
Then get a 400x improvement by trying the C++ part again. OpenSSL is easy on
Android, since you'll have to deploy it anyway alongside your application.
On iOS and macOS, you shouldn't use OpenSSL. You should use Apple's API,
whatever it is. Please consult Apple's website.
Hi Thiago,

thx motivating me ;-)

will give it another try

over all my apps always use C++ as much as possible - this single
use-case is an exception. would be happy to move it to C++

ekke
ekke
2018-11-22 21:42:52 UTC
Permalink
Post by Thiago Macieira
Post by ekke
created a example app and now noticed, the app doesn't freeze,
but the exection of encrypt() slows down from
5 sec (Qt 5.11.2) to
92 sec (Qt 5.12 Beta3)
will open a bug report
How about you encrypt using C++ instead? OpenSSL probably has the encryption
you need.
Hi Thiago,

thx motivating me to find native solutions.

implemented RSA String encryption for Obj-C and Android Java - and of
course it's much faster as JS

https://github.com/ekke/encrypt_text

--

the other good news: the 20* slow down in JS is fixed in Qt 5.12 RC :)

https://bugreports.qt.io/browse/QTBUG-71591

ekke

Loading...