<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Radius on OiePoie!</title>
    <link>https://www.oiepoie.nl/tags/radius/</link>
    <description>Recent content in Radius on OiePoie!</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <lastBuildDate>Fri, 02 May 2008 00:18:44 +0200</lastBuildDate><atom:link href="https://www.oiepoie.nl/tags/radius/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Free strong (two factor) authentication using One Time Passwords on your mobile phone</title>
      <link>https://www.oiepoie.nl/2008/05/02/free-strong-two-factor-authentication-using-one-time-passwords-on-your-mobile-phone/</link>
      <pubDate>Fri, 02 May 2008 00:18:44 +0200</pubDate>
      
      <guid>https://www.oiepoie.nl/2008/05/02/free-strong-two-factor-authentication-using-one-time-passwords-on-your-mobile-phone/</guid>
      <description>&lt;p&gt;Authentication is the process by which you verify that someone is who they claim they are. In computerland this mostly involves a secret. By using the secret (for instance a password) in the authentication process Alice (there she is again) proves to Bob that she really is Alice since the secret is coupled to her (digital) identity. This process is as old as the road to Rome.&lt;br/&gt;
But not all secrets are as secret as we would like them to be. If i choose the name of my girlfriend as the secret, it might be easily guessed, even by someone who doesn’t know me, but is willing to go through the effort of making a few phone calls. Also secrets can be captured in transit, through shouldersurfing when you log in to the system, etcetera.&lt;/p&gt;
&lt;p&gt;The next step in this game is &lt;b&gt;strong authentication&lt;/b&gt; a.k.a. &lt;b&gt;two factor authentication&lt;/b&gt;, this is where you combine two out of the next three options to prove your identity:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;something you know (e.g. password, pin)&lt;/li&gt;
&lt;li&gt;something you have (e.g. token, smartcard, cellphone)&lt;/li&gt;
&lt;li&gt;something you are (e.g. fingerprint, iris pattern, DNA, voice)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So apart from capturing someones secret, Eve also has to steal the token/smartcard/cellphone or in case of biometrics duplicate your fingerprint/iris in a way the scanner is convinced that it’s still attached to a human being. This doesn’t make it impossible to authenticate as somebody else, it just makes it harder.&lt;/p&gt;
&lt;p&gt;One of the problems with strong authentication is that it is expensive. You can get (for instance) an RSA token on a trade fair for free, but when you actually want to use one you have to buy the token and also buy the license for the authentication server that is needed to make it work, this may set you back between $50 – $100 per user.&lt;/p&gt;
&lt;p&gt;Another disadvantage is the the cryptographic algorithm used to produce to codes is know only to the company, so you can’t use the RSA token and verify the authentication process to a authentication server of a different vendor. Also nobody can check if the cryptographic principles on with the product is build are sound. Good cryptography is build on open source so anyone can verify the correctness of it’s operation.&lt;br/&gt;
Luckily for us there is the Open Authentication Framework (&lt;b&gt;OATH&lt;/b&gt;) which led to the definition of the “Hashed Message Authentication Code One Time Password” or &lt;b&gt;HMAC OTP&lt;/b&gt; or even more concise &lt;b&gt;HOTP&lt;/b&gt;. If you are interested you can read &lt;a class=&#34;extlink&#34; href=&#34;http://tools.ietf.org/html/rfc4226&#34; target=&#34;_blank&#34;&gt;rfc4226&lt;/a&gt; on it’s inner working’s and even build your own implementation.&lt;/p&gt;
&lt;p&gt;The next step is to build our own strong authentication system using &lt;b&gt;HOTP&lt;/b&gt;. &lt;a class=&#34;extlink&#34; href=&#34;http://www.tri-dsystems.com&#34; target=&#34;_blank&#34;&gt;Tri-D systems&lt;/a&gt; has an open source One Time Password authentication server available for download. They also sell the tokens to use for authentication, but since we are talking open source HOTP we can look for a company which sells the authentication server and has a (soft) token for free: &lt;a class=&#34;extlink&#34; href=&#34;http://www.dsssasia.com/&#34; target=&#34;_blank&#34;&gt;Data Security Systems Solutions&lt;/a&gt;. They provide a free &lt;i&gt;Java Phone Token&lt;/i&gt; which can generate the One Time Passwords.&lt;/p&gt;
&lt;center&gt;&lt;/center&gt;
&lt;p&gt;&lt;b&gt;Build Process&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;goto: &lt;a class=&#34;extlink&#34; href=&#34;http://www.tri-dsystems.com/software/downloads.html&#34; target=&#34;_blank&#34;&gt;http://www.tri-dsystems.com/software/downloads.html&lt;/a&gt;&lt;br/&gt;
accept license and download otpd-3.1.0.tar.gz &amp;amp; pam_otp_auth-3.2.2.tar.gz&lt;/p&gt;
&lt;pre&gt;
gtar zxvf otpd-3.1.0.tar.gz
cd otpd-3.1.0/
./configure
make
make install
&lt;p&gt;mkdir /etc/otpstate
touch /etc/otppasswd
chmod 600 /etc/otppasswd
chmod 700 /etc/otpstate
mkdir /var/run/otpd
touch /var/run/otpd/socket
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;install oathdsss on your Nokia or Windows Mobile phone&lt;br/&gt;
from: &lt;a class=&#34;extlink&#34; href=&#34;http://www.dsssasia.com/token.html&#34; target=&#34;_blank&#34;&gt;http://www.dsssasia.com/token.html&lt;/a&gt;&lt;br/&gt;
and start the program&lt;/p&gt;
&lt;p&gt;First time initialization asks for a label, e.g. SEC&lt;br/&gt;
a seed length between 16 … 20 (choose 20)&lt;br/&gt;
OTP Length between 6 … 8 (choose 6)&lt;/p&gt;
&lt;p&gt;Select Options -&amp;gt; Init&lt;br/&gt;
and register the seed displayed:&lt;br/&gt;
e.g. 44D060008BF440A2F9FF588AAD537F78B820F200&lt;br/&gt;
Now copy the seed to your computer, don’t make any mistakes or it won’t work.&lt;br/&gt;
The seed is case insensitive since it’s a hexadecimal number. If you are using a Windows Mobile device, you might have to switch it to landscape to see all the characters, you should see a left and right square bracket.&lt;/p&gt;
&lt;p&gt;Do you want to set a PIN to protect the OTP?&lt;br/&gt;
Yes (otherwise it wouldn’t be two factor authentication)&lt;br/&gt;
Pin: ****&lt;br/&gt;
Pin Again: ****&lt;/p&gt;
&lt;p&gt;If all goes well oathdsss finishes and when you start it&lt;br/&gt;
up again, you will be asked for a PIN and after that the&lt;br/&gt;
6 number OTP is displayed together with a countdown timer&lt;br/&gt;
running from 60 seconds.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Setting up the OTP server&lt;/b&gt;&lt;br/&gt;
Enter the generated seed from your cellphone into &lt;b&gt;/etc/otppasswd&lt;/b&gt;&lt;/p&gt;
&lt;pre&gt;
cat &amp;gt;&amp;gt; /etc/otppasswd
foo:hotp-d6:44D060008BF440A2F9FF588AAD537F78B820F200
&lt;/pre&gt;
&lt;p&gt;&lt;b&gt;foo&lt;/b&gt; is the username, alter it at your convenience&lt;br/&gt;
&lt;b&gt;hotp-d6&lt;/b&gt; is the token algorithm, so HOTP with a 6 digit OTP.&lt;/p&gt;
&lt;p&gt;Generate two OTP’s from your cellphone and use them with resynctool (this is installed together with the OTP server) to save the state information which the OTP server will need in the authentication process:&lt;/p&gt;
&lt;pre&gt;
resynctool -1 816857 -2 433761 -u foo -k 44D060008BF440A2F9FF588AAD537F78B820F200 &amp;gt; /etc/otpstate/foo
&lt;/pre&gt;
&lt;p&gt;If you look at the contents of &lt;b&gt;/etc/otpstate/foo&lt;/b&gt; you should see something like:&lt;/p&gt;
&lt;pre&gt;
5:foo:0000000000000003:::0:0:0:
&lt;/pre&gt;
&lt;p&gt;Due to a bug (i assume) resynctool is not able to work with 7 or 8 figure OTP’s (it will present you with the error message: &lt;b&gt;resynctool: passcode 1 wrong length&lt;/b&gt;). There is also a second bug (maybe we should call it an discrepancy). While resynctool writes: 0000000000000003 meaning the first two OTP’s have been used and the next to be presented is number 3, the otp server reads that 0000000000000003 as: the first three OTP’s have been used and the next to be presented is number 4. So change the number back to 0000000000000002 or generate an OTP from you cellphone and don’t use it.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Testing authentication&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;start up otpd as root in debug mode:&lt;/p&gt;
&lt;pre&gt;
# otpd -D
otpd: otpd 3.1.0 starting
otpd: accept_thread: tid=3086179248
&lt;/pre&gt;
&lt;p&gt;Now generate an OTP from your phone and test it with:&lt;/p&gt;
&lt;pre&gt;
# otpauth -u foo -p 549855 -s /var/run/otpd/socket
0 (ok)
&lt;/pre&gt;
&lt;p&gt;On the otp server you will see:&lt;/p&gt;
&lt;pre&gt;
otpd: accept_thread: plugin accept fd=5
otpd: work_thread: tid=3076053936, fd=5
otpd: work_thread(3076053936,5): handling plugin request for [foo]
otpd: verify: [foo], sync challenge t:0 e:0 0000000000000004, expecting response 549855
otpd: verify: user [foo] authentication succeeded
otpd: work_thread(3076053936,5): plugin disconnect
&lt;/pre&gt;
&lt;p&gt;If you don’t see a &lt;b&gt;0 (ok)&lt;/b&gt; from otpauth, you might get a &lt;b&gt;3 (authentication error)&lt;/b&gt; which means you didn’t present the expected OTP to the server. In the server debug window you will see 5 OTP’s (configurable through /etc/otpd.conf) which the server expects from that user account. Generate another one from you phone an you will immediately see if that one is in the list and will work.&lt;br/&gt;
If you get a &lt;b&gt;5 (service error)&lt;/b&gt; there is something wrong with your configuration and you have to fix that first before authentication will work.&lt;/p&gt;
&lt;p&gt;You might want to play around a little bit more with the HOTP software to get a grip on how it’s working. An easier way to generate the OTP’s is through a small perl program on your computer. For this you have to install the &lt;b&gt;Authen::HOTP&lt;/b&gt; module:&lt;/p&gt;
&lt;pre&gt;
perl -MCPAN -e &#39;install Authen::HOTP&#39;
&lt;/pre&gt;
&lt;p&gt;And then create this program:&lt;br/&gt;
[perl]&lt;br/&gt;
#!/usr/bin/perl&lt;br/&gt;
use Authen::HOTP qw(hotp);&lt;br/&gt;
use strict;&lt;/p&gt;
&lt;p&gt;my $secret=”44D060008BF440A2F9FF588AAD537F78B820F200″;&lt;br/&gt;
my $counter=$ARGV[1];&lt;br/&gt;
my $digits=$ARGV[0];&lt;/p&gt;
&lt;p&gt;my $pass = hotp($secret, $counter, $digits);&lt;br/&gt;
print “$pass\n”;&lt;br/&gt;
[/perl]&lt;/p&gt;
&lt;p&gt;Now it’s a easy as:&lt;/p&gt;
&lt;pre&gt;
# ./hotp.pl 6 5
853481
&lt;/pre&gt;
&lt;p&gt;If you got a successful authentication we can proceed to doing something useful with HOTP. Tri-D delivers a pam-otp module which you can use on a local system to replace your standard username/password authentication dialog. But they really recommend using the OTP daemon through RADIUS.&lt;br/&gt;
So download freeradius and compile &amp;amp; install:&lt;/p&gt;
&lt;pre&gt;
cd /tmp
wget ftp://ftp.freeradius.org/pub/radius/freeradius-1.1.7.tar.bz2
gtar jxvf freeradius-1.1.7.tar.bz2
cd freeradius-1.1.7
./configure
make
make install
&lt;p&gt;cd redhat/
cat rc.radiusd-redhat &amp;gt; /etc/init.d/radiusd
chkconfig &amp;ndash;add radiusd
chkconfig &amp;ndash;list radiusd
radiusd         0:off   1:off   2:off   3:off   4:off   5:off   6:off
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;On my redhat system i had to modify &lt;b&gt;/etc/init.d/radiusd&lt;/b&gt; to read:&lt;br/&gt;
&lt;b&gt;RADIUSD=/usr/local/sbin/radiusd&lt;/b&gt;&lt;br/&gt;
and i had to run &lt;b&gt;ldconfig&lt;/b&gt; again or otherwise radiusd would complain about&lt;br/&gt;
a missing &lt;b&gt;libradius-1.1.7.so&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;Modify the radius configuration &lt;b&gt;/usr/local/etc/raddb/radiusd.conf&lt;/b&gt; to allow for One Time Passwords:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;remove the comment (#) before: &lt;b&gt;$INCLUDE ${confdir}/otp.conf&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;add &lt;b&gt;otp&lt;/b&gt; directly below &lt;b&gt;authorize {&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;add &lt;b&gt;otp&lt;/b&gt; directly below &lt;b&gt;authenticate {&lt;/b&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;And start otpd and the radius service up:&lt;/p&gt;
&lt;pre&gt;
# otpd
# service radiusd start
Starten van RADIUS server:                                 [  OK  ]
&lt;/pre&gt;
&lt;p&gt;Now we can test OTP authentication through RADIUS with the radtest program:&lt;/p&gt;
&lt;pre&gt;
# ./hotp.pl 6 11
885417
&lt;h1 id=&#34;radtest-foo-885417-localhost-10-testing123&#34;&gt;radtest foo 885417 localhost 10 testing123&lt;/h1&gt;
&lt;p&gt;Sending Access-Request of id 197 to 127.0.0.1 port 1812
User-Name = &amp;ldquo;foo&amp;rdquo;
User-Password = &amp;ldquo;885417&amp;rdquo;
NAS-IP-Address = 255.255.255.255
NAS-Port = 10
rad_recv: Access-Accept packet from host 127.0.0.1:1812, id=197, length=20&lt;/p&gt;
&lt;h1 id=&#34;tail--1-varlogmessages&#34;&gt;tail -1 /var/log/messages&lt;/h1&gt;
&lt;p&gt;May  1 23:25:10 vortex otpd[11395]: verify: user [foo] authentication succeeded
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;testing123&lt;/b&gt; is the default RADIUS secret for localhost, you MUST change that in:&lt;br/&gt;
&lt;b&gt;/usr/local/etc/raddb/clients.conf&lt;/b&gt;, the NAS port number (10) is not used.&lt;/p&gt;
&lt;p&gt;On my testbox there was no pam_radius_auth module, so:&lt;/p&gt;
&lt;pre&gt;
cd /tmp
wget ftp://ftp.freeradius.org/pub/radius/pam_radius-1.3.17.tar.gz
gtar zxvf pam_radius-1.3.17.tar.gz
cd pam_radius-1.3.17
make
cp pam_radius_auth.so /lib/security/
cat  pam_radius_auth.conf &amp;gt; /etc/raddb/server
chmod go-rwx /etc/raddb/server
&lt;/pre&gt;
&lt;p&gt;Edit &lt;b&gt;/etc/raddb/server&lt;/b&gt; to match te secret for localhost in &lt;b&gt;/usr/local/etc/raddb/clients.conf&lt;/b&gt;, next add a line in &lt;b&gt;/etc/pam.d/system-auth&lt;/b&gt; like this:&lt;/p&gt;
&lt;pre&gt;
auth        required      /lib/security/$ISA/pam_env.so
auth        sufficient    /lib/security/$ISA/pam_unix.so likeauth nullok
auth        sufficient    /lib/security/pam_radius_auth.so try_first_pass
auth        required      /lib/security/$ISA/pam_deny.so
&lt;/pre&gt;
&lt;p&gt;This will allow normal password authentication, but if you are providing an OTP the unix password authentication will fail and the OTP is passed on to the pam_radius_auth module for validation.&lt;/p&gt;
&lt;p&gt;You can also use OTP authentication on you Apache webserver by using the &lt;a class=&#34;extlink&#34; href=&#34;http://www.freeradius.org/mod_auth_radius/&#34; target=&#34;_blank&#34;&gt;mod_auth_radius&lt;/a&gt; module.&lt;/p&gt;
&lt;p&gt;Have fun!&lt;/p&gt;
&lt;p&gt;&lt;i&gt;sources:&lt;/i&gt;&lt;br/&gt;
&lt;a class=&#34;extlink&#34; href=&#34;http://fbq.hamal.nl/index.php/archives/8#more-8&#34; target=&#34;_blank&#34;&gt;Foo Bar Quux&lt;/a&gt;&lt;br/&gt;
&lt;a class=&#34;extlink&#34; href=&#34;http://www.tri-dsystems.com/documentation/quickstart.html&#34; target=&#34;_blank&#34;&gt;Tri-D QuickStart Guide&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Update 20080529&lt;/b&gt;&lt;br/&gt;
Since it looks like the Tri-D site is offline, i will make my copies of otpd and pam_otp_auth available for download:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://www.oiepoie.nl/sw/otpd-3.1.0.tar.gz&#34;&gt;otpd-3.1.0.tar.gz&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.oiepoie.nl/sw/pam_otp_auth-3.2.2.tar.gz&#34;&gt;pam_otp_auth-3.2.2.tar.gz&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</description>
    </item>
    
  </channel>
</rss>
