mirror of
https://github.com/openwrt/packages.git
synced 2026-04-15 19:02:09 +00:00
Changelog: https://github.com/sybrenstuvel/python-rsa/blob/main/CHANGELOG.md Signed-off-by: Alexandru Ardelean <alex@shruggie.ro>
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
|