(chibi crypto rsa)

RSA public key cryptography implementation.

(rsa-key-gen-from-primes bit-length p q . o)

(rsa-key-gen [bit-length])

(rsa-pub-key priv-key)

Returns a copy of the given key with the private key, if any, removed.

(pkcs1-pad bv)

(pkcs1-unpad bv)

(rsa-encrypt pub-key msg)

Encrypts msg for the given public key pub-key. msg may be an integer or bytevector, in which case the result is of the same type, or a string, in which case the string is first coerced to a utf8 encoded bytevector.

(rsa-decrypt priv-key cipher)

Decrypts cipher using the given private key priv-key. cipher may be an integer or bytevector, in which case the result is of the same type, or a string, in which case the string is first coerced to a utf8 encoded bytevector.

(rsa-sign priv-key msg)

Signs msg using the given private key priv-key.

(rsa-verify pub-key sig)

Returns the verified (decrypted) message for the signature sig.

(rsa-verify? pub-key msg sig)

Returns true iff sig is a valid signature of msg for the given public key pub-key.