Project

yubioath

0.01
No commit activity in last 3 years
No release in over 3 years
A mostly-complete Ruby implementation of the YubiOATH applet protocol
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
 Dependencies

Runtime

~> 2.0
 Project Readme

YubiOATH

A mostly-complete Ruby implementation of the YubiOATH applet protocol.

Usage

The YubiOATH class accepts a card, which must respond to #transmit(apdu). See costan/smartcard for more info.

yubioath = YubiOATH.new(card)

yubioath.put(name: 'foo', secret: '123456')            # => true
yubioath.calculate(name: 'foo', timestamp: Time.now)   # => '237846'

yubioath.put(name: 'bar', secret: '345678')   # => true
yubioath.put(name: 'qux', secret: '567890')   # => true
yubioath.list.keys                            # => ['foo', 'bar', 'qux']
yubioath.calculate_all(timestamp: Time.now)   # => {'foo' => '234526', 'bar' => '293857', 'qux' => '934856'}

yubioath.delete('qux')   # => true
yubioath.list.keys   # => ['foo', 'bar']

yubioath.reset        # => true
yubioath.list.empty?  # => true

Instructions

You can also trigger the instructions by instantiating the relevant class with a card and invoking its #call method.

calculate = YubiOATH::Calculate.new(card)
calculate_all = YubiOATH::CalculateAll.new(card)
delete = YubiOATH::Delete.new(card)
list = YubiOATH::List.new(card)
put = YubiOATH::Put.new(card)
reset = YubiOATH::Reset.new(card)

put.call(name: 'foo', secret: '123456')            # => true
calculate.call(name: 'foo', timestamp: Time.now)   # => '237846'

put.call(name: 'bar', secret: '345678')   # => true
put.call(name: 'qux', secret: '567890')   # => true
list.call.keys                            # => ['foo', 'bar', 'qux']
calculate_all.call(timestamp: Time.now)   # => {'foo' => '234526', 'bar' => '293857', 'qux' => '934856'}

delete.call('qux')   # => true
list.call.keys   # => ['foo', 'bar']

reset.call        # => true
list.call.empty?  # => true