HEX
Server: Apache
System: Linux vpshost0650.publiccloud.com.br 4.4.79-grsec-1.lc.x86_64 #1 SMP Wed Aug 2 14:18:21 -03 2017 x86_64
User: bandeirantesbomb3 (10068)
PHP: 8.0.7
Disabled: apache_child_terminate,dl,escapeshellarg,escapeshellcmd,exec,link,mail,openlog,passthru,pcntl_alarm,pcntl_exec,pcntl_fork,pcntl_get_last_error,pcntl_getpriority,pcntl_setpriority,pcntl_signal,pcntl_signal_dispatch,pcntl_sigprocmask,pcntl_sigtimedwait,pcntl_sigwaitinfo,pcntl_strerror,pcntl_wait,pcntl_waitpid,pcntl_wexitstatus,pcntl_wifexited,pcntl_wifsignaled,pcntl_wifstopped,pcntl_wstopsig,pcntl_wtermsig,php_check_syntax,php_strip_whitespace,popen,proc_close,proc_open,shell_exec,symlink,system
Upload Files
File: //proc/self/root/proc/thread-self/root/proc/self/root/usr/share/doc/m2crypto-0.21.1/demo/rsatest.py
#!/usr/bin/python

"""RSA demonstration.

Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved."""

from M2Crypto import RSA, EVP, Rand

msg="The magic words are squeamish ossifrage."
sha1=EVP.MessageDigest('sha1')
sha1.update(msg)
dgst=sha1.digest()

priv=RSA.load_key('rsa.priv.pem')
pub=RSA.load_pub_key('rsa.pub.pem')

def test_encrypt(padding):
    print 'testing public-key encryption:', padding
    padding=eval('RSA.'+padding)
    ctxt=pub.public_encrypt(dgst, padding)
    ptxt=priv.private_decrypt(ctxt, padding)
    if ptxt!=dgst:
        print 'public_encrypt -> private_decrypt: not ok'

def test_sign(padding):
    print 'testing private-key signing:', padding
    padding=eval('RSA.'+padding)
    ctxt=priv.private_encrypt(dgst, padding)    
    ptxt=pub.public_decrypt(ctxt, padding)
    if ptxt!=dgst:
        print 'private_decrypt -> public_encrypt: not ok'

def test0():
    print 'testing misc.'
    print `pub.e`, `pub.n`
    print `priv.e`, `priv.n`

if __name__=='__main__':
    Rand.load_file('randpool.dat', -1) 
    test_encrypt('pkcs1_padding')
    test_encrypt('pkcs1_oaep_padding')
    #test_encrypt('sslv23_padding')
    test_sign('pkcs1_padding')
    Rand.save_file('randpool.dat')