Files
packages/lang/python/python-rsa/test.sh
T
Alexandru Ardelean f30f11474c python-rsa: add test.sh
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>
2026-10-05 08:00:26 +02:00

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