ssl/conversion.txt
changeset 38 68d27bdf49c9
equal deleted inserted replaced
37:889dfa7eace0 38:68d27bdf49c9
       
     1 http://superuser.com/questions/576506/how-to-use-ssh-rsa-public-key-to-encrypt-a-text
       
     2 http://goodworkaround.com/node/17
       
     3 
       
     4 OpenSSH -> OpenSSL
       
     5 ==================
       
     6 
       
     7   * Pubkey conversion:
       
     8 
       
     9   ssh-keygen -f ~/.ssh/id_rsa.pub -e -m pkcs8 > /tmp/id_rsa.pub.pem
       
    10 
       
    11 
       
    12 OpenSSL operations
       
    13 ==================
       
    14 
       
    15   * Encryption:
       
    16 
       
    17   openssl rsautl -encrypt -pubin -inkey /tmp/id_rsa.pub.pem > /tmp/c.txt
       
    18 
       
    19   * Decryption:
       
    20 
       
    21   openssl rsautl -decrypt -inkey ~/.ssh/id_rsa -in /tmp/c.txt
       
    22 
       
    23   * Signing:
       
    24 
       
    25   openssl dgst -sha1 -sign ~/.ssh/id_rsa file.txt > file.txt.sig
       
    26 
       
    27   * Verification:
       
    28 
       
    29   openssl dgst -sha1 -verify /tmp/id_rsa.pub.pem -signature file.txt.sig file.txt