Project

yubikey

0.08
Repository is archived
No commit activity in last 3 years
No release in over 3 years
A library to verify, decode, decrypt and parse Yubikey one-time passwords.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0.8.7
>= 0
>= 2.0
 Project Readme

yubikey

Build Status

Description

A library to verify, decode, decrypt and parse Yubikey one-time passwords.

Usage

OTP Decryption

key = 'ecde18dbe76fbd0c33330f1c354871db'
otp = 'dteffujehknhfjbrjnlnldnhcujvddbikngjrtgh'
token = Yubikey::OTP.new(otp, key)

p "Device public id: #{token.public_id}" #=> 'dteffuje'
p "Device secret id: #{token.secret_id}" #=> '8792ebfe26cc'
p "Device insertions: #{token.insert_counter}" #=> 19
p "Session activation counter: #{token.session_counter}" #=> 17
p "Session timestamp: #{token.timestamp}" #=> 49712
p "OTP random data: #{token.random_number}" #=> 40904

OTP Verification

Use your own api_key and api_id, which you can get at yubico.com.

begin
  otp = Yubikey::OTP::Verify.new(:api_id => 1234,
                                 :api_key => 'NiSwGZBQ0gTbwXbRGWAf4kM5xXg=',
                                 :otp => 'dteffujehknhfjbrjnlnldnhcujvddbikngjrtgh')

  if otp.valid?
    p 'valid OTP'
  elsif otp.replayed?
    p 'replayed OTP'
  end
rescue Yubikey::OTP::InvalidOTPError
  p 'invalid OTP'
end

Install

Yubikey is available as a gem, to install it just install the gem:

gem install yubikey

If you're using Bundler, add the gem to Gemfile.

gem 'yubikey'

Then run bundle install.

Copyright

Ruby library

Written by Jonathan Rudenberg. Copyright (c) 2009 Jonathan Rudenberg

The MIT License. See LICENSE.

Contributors

List of contributors