mirror of
https://github.com/openwrt/packages.git
synced 2026-10-14 16:27:22 +04:00
master added this test.sh together with the update to 4.9.1, but it
only uses the rsa API that 4.9 already has. The version check override
of python-rsa relies on it, so take it on its own.
Signed-off-by: Alexandru Ardelean <alex@shruggie.ro>
(cherry picked from commit 349bf45ee1)
[take only test.sh, openwrt-25.12 keeps python-rsa 4.9]
Signed-off-by: Josef Schlehofer <pepe.schlehofer@gmail.com>
24 lines
487 B
Bash
Executable File
24 lines
487 B
Bash
Executable File
#!/bin/sh
|
|
|
|
[ "$1" = python3-rsa ] || exit 0
|
|
|
|
python3 - << 'EOF'
|
|
|
|
import rsa
|
|
|
|
# Generate keys
|
|
(pub, priv) = rsa.newkeys(512)
|
|
|
|
# Sign and verify
|
|
message = b"Hello OpenWrt"
|
|
signature = rsa.sign(message, priv, "SHA-256")
|
|
verified = rsa.verify(message, signature, pub)
|
|
assert verified == "SHA-256", f"expected SHA-256, got {verified}"
|
|
|
|
# Encrypt and decrypt
|
|
encrypted = rsa.encrypt(message, pub)
|
|
decrypted = rsa.decrypt(encrypted, priv)
|
|
assert decrypted == message, f"decryption failed"
|
|
|
|
EOF
|