1*78f5cfecSmanuHOW-TO use plainrsa auth, contributed by Simon Chang <simonychang@gmail.com> 2*78f5cfecSmanu 3*78f5cfecSmanuBefore you begin, you should understand that the RSA authentication 4*78f5cfecSmanumechanism hinges upon the idea of a split cryptographic key: one used 5*78f5cfecSmanuby the public, the other readable only to you. Any data that is 6*78f5cfecSmanuencrypted by a public key can be decrypted only by the corresponding 7*78f5cfecSmanuprivate key, so that the private key user can be assured that the 8*78f5cfecSmanucontent of the transmission has not been examined by unauthorized 9*78f5cfecSmanuparties. Similarly, any data encrypted by the private key can be 10*78f5cfecSmanudecrypted by the public key so that the public knows that this 11*78f5cfecSmanutransmission came from this user and nobody else (this idea is called 12*78f5cfecSmanunon-repudiation). Also, the longer the key length, the more difficult 13*78f5cfecSmanuit would be for potential attacker to conduct brute-force discovery of 14*78f5cfecSmanuthe keys. So, what all this means for the security administrator is 15*78f5cfecSmanuthat the setup needs a pair of reasonably long keys for each host that 16*78f5cfecSmanuwishes to authenticate in this manner. 17*78f5cfecSmanu 18*78f5cfecSmanuWith this in mind, it should be relatively straightforward to set up 19*78f5cfecSmanuRSA authentication. For the purpose of this document, we assume that 20*78f5cfecSmanuwe are setting up RSA authentication between two networked hosts 21*78f5cfecSmanucalled Boston and Chicago. Unless otherwise noted, all steps should 22*78f5cfecSmanube performed on both hosts with corresponding key names. Here are the 23*78f5cfecSmanusteps: 24*78f5cfecSmanu 25*78f5cfecSmanu1) Included in each default installation of ipsec-tools is a binary 26*78f5cfecSmanucalled plainrsa-gen. This executable is used to generate a pair of 27*78f5cfecSmanuRSA keys for the host. There are only two parameters that you should 28*78f5cfecSmanube concerned about: -b, which sets the number of bits for the keys, 29*78f5cfecSmanuand -f, which specifies the output file for plainrsa-gen to send the 30*78f5cfecSmanuresults. On an ordinary Pentium-II with 128 MB of RAM, it takes only 31*78f5cfecSmanuseconds to generate keys that are 2048 bits long, and only slightly 32*78f5cfecSmanulonger to generate 4096-bit keys. Either key length should be 33*78f5cfecSmanusufficient; any longer key length actually reduces performance and 34*78f5cfecSmanudoes not increase security significantly. You should therefore run it 35*78f5cfecSmanuas: 36*78f5cfecSmanu 37*78f5cfecSmanu plainrsa-gen -b 2048 -f /var/tmp/boston.keys 38*78f5cfecSmanu 39*78f5cfecSmanu2) When the process completes, you should have a text file that 40*78f5cfecSmanuincludes both public and private keys. GUARD THIS FILE CAREFULLY, 41*78f5cfecSmanubecause once a private key is compromised it is no longer any good, 42*78f5cfecSmanuand you must generate a new pair from scratch. Reading the file 43*78f5cfecSmanuitself, you should see several very long lines of alphanumeric data. 44*78f5cfecSmanuThe only line you should be concerned with is the line towards the top 45*78f5cfecSmanuof the output file that begins with "# pubkey=0sAQPAmBdT/" or 46*78f5cfecSmanusomething to that effect. This line is your public key, which should 47*78f5cfecSmanube made available to the other host that you are setting up. Copy 48*78f5cfecSmanuthis line to a separate file called "boston.pub" and change the 49*78f5cfecSmanubeginning of the line so that it reads ": PUB 0sAQPAmBdT/". 50*78f5cfecSmanuAlternatively, you can also grab the first line of the boston.keys 51*78f5cfecSmanufile and uncomment the line so that it reads the same as above. Now 52*78f5cfecSmanurename the file you generated initially to "boston.priv". 53*78f5cfecSmanu 54*78f5cfecSmanu3) You should now have two files, boston.priv and boston.pub 55*78f5cfecSmanu(chicago.priv and chicago.pub on Chicago). The first file contains 56*78f5cfecSmanuyour private key and the second file your public key. Next you should 57*78f5cfecSmanufind a way to get the public key over to the other host involved. 58*78f5cfecSmanuBoston should have (1) its own key pair, and (2) Chicago's public key 59*78f5cfecSmanuONLY. Do not copy Chicago's private key over to Boston, because (a) 60*78f5cfecSmanuit is not necessary, and (b) you would now have two potential places 61*78f5cfecSmanufor losing control of your private key. 62*78f5cfecSmanu 63*78f5cfecSmanu4) You should now configure the racoon.conf configuration file for 64*78f5cfecSmanueach host to (a) turn on RSA authentication, and (b) designate each 65*78f5cfecSmanuhost's private key and the remote host(s)'s public key(s). Take all 66*78f5cfecSmanuyour keys and place it in one directory and use the global directive 67*78f5cfecSmanu"path certificate" to specify the location of the keys. This step is 68*78f5cfecSmanuespecially important if you are running racoon with privilege 69*78f5cfecSmanuseparation, because if racoon cannot find the keys inside the 70*78f5cfecSmanudirectory you have just specified it will fail the authentication 71*78f5cfecSmanuprocess. So, write the directive like the following: 72*78f5cfecSmanu 73*78f5cfecSmanu path certificate "/etc/racoon"; 74*78f5cfecSmanu 75*78f5cfecSmanuNext, you need to specify the host's own private key and the public 76*78f5cfecSmanukeys of all the remote peers involved. For your local private key and 77*78f5cfecSmanuremote public key(s), you should use the following directives: 78*78f5cfecSmanu 79*78f5cfecSmanu certificate_type plain_rsa "/etc/racoon/boston.priv"; 80*78f5cfecSmanu peers_certfile plain_rsa "/etc/racoon/chicago.pub"; 81*78f5cfecSmanu 82*78f5cfecSmanuNotice the option "plain_rsa" for both directives. 83*78f5cfecSmanu 84*78f5cfecSmanuFinally, under the "proposal" statement section, you should specify 85*78f5cfecSmanuthe "rsasig" option for "authentication_method". 86*78f5cfecSmanu 87*78f5cfecSmanu5) You have finished configuring the host for RSA authentication. 88*78f5cfecSmanuNow use racoonctl to reload the configuration or simply restart the 89*78f5cfecSmanumachine and you should be all set. 90*78f5cfecSmanu 91*78f5cfecSmanuTROUBLESHOOTING 92*78f5cfecSmanu 93*78f5cfecSmanuIn the event that the hosts fail to communicate, first go back to the 94*78f5cfecSmanuinstructions above and make sure that: 95*78f5cfecSmanu 96*78f5cfecSmanu1) You have placed all the keys in the directory that is specified by 97*78f5cfecSmanuthe "path certificate" directive. Keep in mind that privilege 98*78f5cfecSmanuseparation will force racoon to look into that directory and nowhere 99*78f5cfecSmanuelse. 100*78f5cfecSmanu2) You have specified correctly the host's own private key and the 101*78f5cfecSmanuremote peer's public key. 102*78f5cfecSmanu3) You have specified the "rsasig" method for authentication in the 103*78f5cfecSmanuproposal statement. 104*78f5cfecSmanu 105*78f5cfecSmanuIf you run into any further problems, you should try to use "racoon 106*78f5cfecSmanu-v" to debug the setup, and send a copy of the debug messages to the 107*78f5cfecSmanumailing list so that we can help you determine what the problem is. 108*78f5cfecSmanu 109*78f5cfecSmanuLast modified: $Date: 2006/12/10 05:51:14 $ 110