SlideShare a Scribd company logo
2FA and OTP
HMAC HOTP and TOTP implementation in Ruby
@parasquid
Chief Problem Solver

at Mindvalley
• 2FA - two factor authentication
• OTP - one time password
• HMAC - hash-based message authentication codes (RFC 2104)
• HOTP - HMAC-based one time password
• TOTP - time-based one time password
2FA
multiple evidence presented to the
authentication mechanism
OTP
a password that can only be used once
and then discarded
RFC 2119
• MUST (NOT), REQUIRED
• SHALL (NOT), SHOULD (NOT), RECOMMENDED
• MAY, OPTIONAL
HMAC
hash function (md5, sha*, etc)
shared secret key
message
HOTP
uses HMAC to sign a counter or
sequence
• The algorithm MUST be sequence or counter-
based
• The algorithm SHOULD be economical to
implement in hardware
• MUST work with tokens that don't support any
numeric input, but MAY also be used in with
more sophisticated devices such as PIN-pads
• The value displayed on the token MUST be
easily read and entered by the user
• There MUST be user-friendly mechanisms
available to resynchronize the counter
• The algorithm MUST use a strong shared
secret
• 160bits is RECOMMENDED
strong shared secret
160 bits using HMAC-SHA1
token is easily read
bit shfting is economical to implement in hardware
HOTP
uses HMAC to sign a counter
• The algorithm MUST be sequence or counter-
based
• The algorithm SHOULD be economical to
implement in hardware
• MUST work with tokens that don't support any
numeric input, but MAY also be used in with
more sophisticated devices such as PIN-pads
• The value displayed on the token MUST be
easily read and entered by the user
• There MUST be user-friendly mechanisms
available to resynchronize the counter
• The algorithm MUST use a strong shared
secret
• 160bits is RECOMMENDED
TOTP
extends HOTP by using a time-based
moving factor
• The prover and verifier MUST know or be able to
derive the current Unix time
• The prover and verifier MUST either share the same
secret or the knowledge of a secret transformation to
generate a shared secret
• The prover and verifier MUST use HOTP as a
building block
• The prover and verifier MUST use the same time-
step value
• There MUST be a unique secret (key) for each
prover
• The keys SHOULD be randomly generated or
derived using key derivation algorithms
• The keys MAY be stored in a tamper resistant device
and SHOULD be protected against unauthorized
access and usage
unix time
time step value
TOTP
extends HOTP by using a time-based
moving factor
• The prover and verifier MUST know or be able to
derive the current Unix time
• The prover and verifier MUST either share the same
secret or the knowledge of a secret transformation to
generate a shared secret
• The prover and verifier MUST use HOTP as a
building block
• The prover and verifier MUST use the same time-
step value
• There MUST be a unique secret (key) for each
prover
• The keys SHOULD be randomly generated or
derived using key derivation algorithms
• The keys MAY be stored in a tamper resistant device
and SHOULD be protected against unauthorized
access and usage
TOTP
extends HOTP by using a time-based
moving factor
• RECOMMENDED to have at most one time step
delay is allowed as the network delay
• may be due to network latency OR
• may be due to improper server time
• handle both future and past
• RECOMMENDED to have a time-step value of 30
seconds
• larger time-step exposes a larger window to
attack
• when OTP is generated and exposed to a 3rd
party before it is consumed, the 3rd party can
consume the OTP before the time-step window
• smaller time-step is not a good experience for
the user (especially if the device is
cumbersome to use)
DEMO
Why TOTP?

(instead of an RNG)
• No need to save tokens in the database
• tokens are calculated on the fly
• you still need to save the shared secret key
• Implementations that adhere to the standard can be used
• e.g. FreeOTP, Google Authenticator, FB Authenticator
• The best possible attack is a brute-force attack (see https://
tools.ietf.org/html/rfc4226#appendix-A.4.3)
@parasquid
Chief Problem Solver

at Mindvalley

More Related Content

Viewers also liked

Welcome to the 3rd generation in user authentication
Welcome to the 3rd generation in user authenticationWelcome to the 3rd generation in user authentication
Welcome to the 3rd generation in user authentication
MarketingArrowECS_CZ
 
Securing ChatOps - DevSecCon Asia 2017 arun n
Securing ChatOps - DevSecCon Asia 2017 arun n Securing ChatOps - DevSecCon Asia 2017 arun n
Securing ChatOps - DevSecCon Asia 2017 arun n
Arun Narayanaswamy
 
Mobile Cybercrime - Don’t Leave Your Customers Vulnerable
Mobile Cybercrime - Don’t Leave Your Customers VulnerableMobile Cybercrime - Don’t Leave Your Customers Vulnerable
Mobile Cybercrime - Don’t Leave Your Customers Vulnerable
Xura
 
Adding Two Factor Authentication to your App with Authy
Adding Two Factor Authentication to your App with AuthyAdding Two Factor Authentication to your App with Authy
Adding Two Factor Authentication to your App with Authy
Nick Malcolm
 
E voting authentication with qr-codes
E voting authentication with qr-codesE voting authentication with qr-codes
E voting authentication with qr-codes
Md. Hasibur Rashid
 
Back to the Future of Marketing - #DubaiLynx 2017
Back to the Future of Marketing - #DubaiLynx 2017Back to the Future of Marketing - #DubaiLynx 2017
Back to the Future of Marketing - #DubaiLynx 2017
jfdaykin
 
Secured qr code [Pankaj Jeswani and Team]
Secured qr code [Pankaj Jeswani and Team]Secured qr code [Pankaj Jeswani and Team]
Secured qr code [Pankaj Jeswani and Team]
Pank Jes
 
Secure QR code payment
Secure QR code paymentSecure QR code payment
Secure QR code payment
James Wu
 
Trends and innovation in Fintech
Trends and innovation in FintechTrends and innovation in Fintech
Trends and innovation in Fintech
SPIN Chennai
 
Presentation9
Presentation9Presentation9
Presentation9
jhonnysen458
 
2FA, WTF? - Phil Nash - Codemotion Amsterdam 2016
2FA, WTF? -  Phil Nash - Codemotion Amsterdam 20162FA, WTF? -  Phil Nash - Codemotion Amsterdam 2016
2FA, WTF? - Phil Nash - Codemotion Amsterdam 2016
Codemotion
 
The Future of Mobile Payments
The Future of Mobile PaymentsThe Future of Mobile Payments
The Future of Mobile Payments
Jonathan LeBlanc
 
MOBtexting : Leading A2P Messaging & Cloud Telephony Service Provider
MOBtexting : Leading A2P Messaging & Cloud Telephony Service ProviderMOBtexting : Leading A2P Messaging & Cloud Telephony Service Provider
MOBtexting : Leading A2P Messaging & Cloud Telephony Service Provider
MOBtexting
 
Two factor authentication presentation mcit
Two factor authentication presentation mcitTwo factor authentication presentation mcit
Two factor authentication presentation mcit
mmubashirkhan
 

Viewers also liked (14)

Welcome to the 3rd generation in user authentication
Welcome to the 3rd generation in user authenticationWelcome to the 3rd generation in user authentication
Welcome to the 3rd generation in user authentication
 
Securing ChatOps - DevSecCon Asia 2017 arun n
Securing ChatOps - DevSecCon Asia 2017 arun n Securing ChatOps - DevSecCon Asia 2017 arun n
Securing ChatOps - DevSecCon Asia 2017 arun n
 
Mobile Cybercrime - Don’t Leave Your Customers Vulnerable
Mobile Cybercrime - Don’t Leave Your Customers VulnerableMobile Cybercrime - Don’t Leave Your Customers Vulnerable
Mobile Cybercrime - Don’t Leave Your Customers Vulnerable
 
Adding Two Factor Authentication to your App with Authy
Adding Two Factor Authentication to your App with AuthyAdding Two Factor Authentication to your App with Authy
Adding Two Factor Authentication to your App with Authy
 
E voting authentication with qr-codes
E voting authentication with qr-codesE voting authentication with qr-codes
E voting authentication with qr-codes
 
Back to the Future of Marketing - #DubaiLynx 2017
Back to the Future of Marketing - #DubaiLynx 2017Back to the Future of Marketing - #DubaiLynx 2017
Back to the Future of Marketing - #DubaiLynx 2017
 
Secured qr code [Pankaj Jeswani and Team]
Secured qr code [Pankaj Jeswani and Team]Secured qr code [Pankaj Jeswani and Team]
Secured qr code [Pankaj Jeswani and Team]
 
Secure QR code payment
Secure QR code paymentSecure QR code payment
Secure QR code payment
 
Trends and innovation in Fintech
Trends and innovation in FintechTrends and innovation in Fintech
Trends and innovation in Fintech
 
Presentation9
Presentation9Presentation9
Presentation9
 
2FA, WTF? - Phil Nash - Codemotion Amsterdam 2016
2FA, WTF? -  Phil Nash - Codemotion Amsterdam 20162FA, WTF? -  Phil Nash - Codemotion Amsterdam 2016
2FA, WTF? - Phil Nash - Codemotion Amsterdam 2016
 
The Future of Mobile Payments
The Future of Mobile PaymentsThe Future of Mobile Payments
The Future of Mobile Payments
 
MOBtexting : Leading A2P Messaging & Cloud Telephony Service Provider
MOBtexting : Leading A2P Messaging & Cloud Telephony Service ProviderMOBtexting : Leading A2P Messaging & Cloud Telephony Service Provider
MOBtexting : Leading A2P Messaging & Cloud Telephony Service Provider
 
Two factor authentication presentation mcit
Two factor authentication presentation mcitTwo factor authentication presentation mcit
Two factor authentication presentation mcit
 

Similar to 2FA and OTP

10 1 otp all
10 1 otp all10 1 otp all
10 1 otp all
Mohammad Alyan
 
BSides Rochester 2018: Esteban Rodriguez: Ducky In The Middle: Injecting keys...
BSides Rochester 2018: Esteban Rodriguez: Ducky In The Middle: Injecting keys...BSides Rochester 2018: Esteban Rodriguez: Ducky In The Middle: Injecting keys...
BSides Rochester 2018: Esteban Rodriguez: Ducky In The Middle: Injecting keys...
JosephTesta9
 
One Time Password - A two factor authentication system
One Time Password  - A two factor authentication systemOne Time Password  - A two factor authentication system
One Time Password - A two factor authentication system
Swetha Kogatam
 
Track 5 session 2 - st dev con 2016 - security iot best practices
Track 5   session 2 - st dev con 2016 - security iot best practicesTrack 5   session 2 - st dev con 2016 - security iot best practices
Track 5 session 2 - st dev con 2016 - security iot best practices
ST_World
 
Virtual Private Networks
Virtual Private NetworksVirtual Private Networks
Virtual Private Networks
primeteacher32
 
Trick or XFLTReaT a.k.a. Tunnel All The Things
Trick or XFLTReaT a.k.a. Tunnel All The ThingsTrick or XFLTReaT a.k.a. Tunnel All The Things
Trick or XFLTReaT a.k.a. Tunnel All The Things
Balazs Bucsay
 
Making and breaking security in embedded devices
Making and breaking security in embedded devicesMaking and breaking security in embedded devices
Making and breaking security in embedded devices
Yashin Mehaboobe
 
2013.devcon3 liferay and google authenticator integration rafik_harabi
2013.devcon3 liferay and google authenticator integration rafik_harabi2013.devcon3 liferay and google authenticator integration rafik_harabi
2013.devcon3 liferay and google authenticator integration rafik_harabi
Rafik HARABI
 
CNIT 152: 9 Network Evidence
CNIT 152: 9 Network Evidence CNIT 152: 9 Network Evidence
CNIT 152: 9 Network Evidence
Sam Bowne
 
BSIDES-PR Keynote Hunting for Bad Guys
BSIDES-PR Keynote Hunting for Bad GuysBSIDES-PR Keynote Hunting for Bad Guys
BSIDES-PR Keynote Hunting for Bad Guys
Joff Thyer
 
CNIT 121: 9 Network Evidence
CNIT 121: 9 Network EvidenceCNIT 121: 9 Network Evidence
CNIT 121: 9 Network Evidence
Sam Bowne
 
seminar presentation
seminar presentationseminar presentation
seminar presentation
saly salikka
 
XFLTReaT: a new dimension in tunnelling (BruCON 0x09 2017)
XFLTReaT: a new dimension in tunnelling (BruCON 0x09 2017)XFLTReaT: a new dimension in tunnelling (BruCON 0x09 2017)
XFLTReaT: a new dimension in tunnelling (BruCON 0x09 2017)
Balazs Bucsay
 
Building Awesome APIs with Lumen
Building Awesome APIs with LumenBuilding Awesome APIs with Lumen
Building Awesome APIs with Lumen
Kit Brennan
 
Parallel and Asynchronous Programming - ITProDevConnections 2012 (English)
Parallel and Asynchronous Programming -  ITProDevConnections 2012 (English)Parallel and Asynchronous Programming -  ITProDevConnections 2012 (English)
Parallel and Asynchronous Programming - ITProDevConnections 2012 (English)
Panagiotis Kanavos
 
Slidecast - Workshop
Slidecast - WorkshopSlidecast - Workshop
Slidecast - Workshop
Samant Khajuria
 
CISSP - Chapter 3 - Cryptography
CISSP - Chapter 3 - CryptographyCISSP - Chapter 3 - Cryptography
CISSP - Chapter 3 - Cryptography
Karthikeyan Dhayalan
 
Virtual Private Network
Virtual Private NetworkVirtual Private Network
Virtual Private Network
Greater Noida Institute Of Technology
 
WebRTC security+more @ KamailioWorld 2018
WebRTC security+more @ KamailioWorld 2018WebRTC security+more @ KamailioWorld 2018
WebRTC security+more @ KamailioWorld 2018
Lorenzo Miniero
 
Information and network security 28 blowfish
Information and network security 28 blowfishInformation and network security 28 blowfish
Information and network security 28 blowfish
Vaibhav Khanna
 

Similar to 2FA and OTP (20)

10 1 otp all
10 1 otp all10 1 otp all
10 1 otp all
 
BSides Rochester 2018: Esteban Rodriguez: Ducky In The Middle: Injecting keys...
BSides Rochester 2018: Esteban Rodriguez: Ducky In The Middle: Injecting keys...BSides Rochester 2018: Esteban Rodriguez: Ducky In The Middle: Injecting keys...
BSides Rochester 2018: Esteban Rodriguez: Ducky In The Middle: Injecting keys...
 
One Time Password - A two factor authentication system
One Time Password  - A two factor authentication systemOne Time Password  - A two factor authentication system
One Time Password - A two factor authentication system
 
Track 5 session 2 - st dev con 2016 - security iot best practices
Track 5   session 2 - st dev con 2016 - security iot best practicesTrack 5   session 2 - st dev con 2016 - security iot best practices
Track 5 session 2 - st dev con 2016 - security iot best practices
 
Virtual Private Networks
Virtual Private NetworksVirtual Private Networks
Virtual Private Networks
 
Trick or XFLTReaT a.k.a. Tunnel All The Things
Trick or XFLTReaT a.k.a. Tunnel All The ThingsTrick or XFLTReaT a.k.a. Tunnel All The Things
Trick or XFLTReaT a.k.a. Tunnel All The Things
 
Making and breaking security in embedded devices
Making and breaking security in embedded devicesMaking and breaking security in embedded devices
Making and breaking security in embedded devices
 
2013.devcon3 liferay and google authenticator integration rafik_harabi
2013.devcon3 liferay and google authenticator integration rafik_harabi2013.devcon3 liferay and google authenticator integration rafik_harabi
2013.devcon3 liferay and google authenticator integration rafik_harabi
 
CNIT 152: 9 Network Evidence
CNIT 152: 9 Network Evidence CNIT 152: 9 Network Evidence
CNIT 152: 9 Network Evidence
 
BSIDES-PR Keynote Hunting for Bad Guys
BSIDES-PR Keynote Hunting for Bad GuysBSIDES-PR Keynote Hunting for Bad Guys
BSIDES-PR Keynote Hunting for Bad Guys
 
CNIT 121: 9 Network Evidence
CNIT 121: 9 Network EvidenceCNIT 121: 9 Network Evidence
CNIT 121: 9 Network Evidence
 
seminar presentation
seminar presentationseminar presentation
seminar presentation
 
XFLTReaT: a new dimension in tunnelling (BruCON 0x09 2017)
XFLTReaT: a new dimension in tunnelling (BruCON 0x09 2017)XFLTReaT: a new dimension in tunnelling (BruCON 0x09 2017)
XFLTReaT: a new dimension in tunnelling (BruCON 0x09 2017)
 
Building Awesome APIs with Lumen
Building Awesome APIs with LumenBuilding Awesome APIs with Lumen
Building Awesome APIs with Lumen
 
Parallel and Asynchronous Programming - ITProDevConnections 2012 (English)
Parallel and Asynchronous Programming -  ITProDevConnections 2012 (English)Parallel and Asynchronous Programming -  ITProDevConnections 2012 (English)
Parallel and Asynchronous Programming - ITProDevConnections 2012 (English)
 
Slidecast - Workshop
Slidecast - WorkshopSlidecast - Workshop
Slidecast - Workshop
 
CISSP - Chapter 3 - Cryptography
CISSP - Chapter 3 - CryptographyCISSP - Chapter 3 - Cryptography
CISSP - Chapter 3 - Cryptography
 
Virtual Private Network
Virtual Private NetworkVirtual Private Network
Virtual Private Network
 
WebRTC security+more @ KamailioWorld 2018
WebRTC security+more @ KamailioWorld 2018WebRTC security+more @ KamailioWorld 2018
WebRTC security+more @ KamailioWorld 2018
 
Information and network security 28 blowfish
Information and network security 28 blowfishInformation and network security 28 blowfish
Information and network security 28 blowfish
 

More from Tristan Gomez

The Art of Tracking
The Art of TrackingThe Art of Tracking
The Art of Tracking
Tristan Gomez
 
Maker's Schedule, Manager's Schedule
Maker's Schedule, Manager's ScheduleMaker's Schedule, Manager's Schedule
Maker's Schedule, Manager's Schedule
Tristan Gomez
 
When Javascript isn't Javascript
When Javascript isn't Javascript When Javascript isn't Javascript
When Javascript isn't Javascript
Tristan Gomez
 
Slack Bots in Ruby
Slack Bots in RubySlack Bots in Ruby
Slack Bots in Ruby
Tristan Gomez
 
Vue on rails
Vue on railsVue on rails
Vue on rails
Tristan Gomez
 
Life Beyond Rails: Creating Cross Platform Ruby Apps
Life Beyond Rails: Creating Cross Platform Ruby AppsLife Beyond Rails: Creating Cross Platform Ruby Apps
Life Beyond Rails: Creating Cross Platform Ruby Apps
Tristan Gomez
 
Refactoring @ Mindvalley: Smells, Techniques and Patterns
Refactoring @ Mindvalley: Smells, Techniques and PatternsRefactoring @ Mindvalley: Smells, Techniques and Patterns
Refactoring @ Mindvalley: Smells, Techniques and Patterns
Tristan Gomez
 
NuBank - Hyperlocal Banking
NuBank - Hyperlocal BankingNuBank - Hyperlocal Banking
NuBank - Hyperlocal Banking
Tristan Gomez
 
How I Hire Developers
How I Hire DevelopersHow I Hire Developers
How I Hire Developers
Tristan Gomez
 
Nosql kl-2013-04-25
Nosql kl-2013-04-25Nosql kl-2013-04-25
Nosql kl-2013-04-25
Tristan Gomez
 
Meaningful metrics
Meaningful metricsMeaningful metrics
Meaningful metrics
Tristan Gomez
 

More from Tristan Gomez (11)

The Art of Tracking
The Art of TrackingThe Art of Tracking
The Art of Tracking
 
Maker's Schedule, Manager's Schedule
Maker's Schedule, Manager's ScheduleMaker's Schedule, Manager's Schedule
Maker's Schedule, Manager's Schedule
 
When Javascript isn't Javascript
When Javascript isn't Javascript When Javascript isn't Javascript
When Javascript isn't Javascript
 
Slack Bots in Ruby
Slack Bots in RubySlack Bots in Ruby
Slack Bots in Ruby
 
Vue on rails
Vue on railsVue on rails
Vue on rails
 
Life Beyond Rails: Creating Cross Platform Ruby Apps
Life Beyond Rails: Creating Cross Platform Ruby AppsLife Beyond Rails: Creating Cross Platform Ruby Apps
Life Beyond Rails: Creating Cross Platform Ruby Apps
 
Refactoring @ Mindvalley: Smells, Techniques and Patterns
Refactoring @ Mindvalley: Smells, Techniques and PatternsRefactoring @ Mindvalley: Smells, Techniques and Patterns
Refactoring @ Mindvalley: Smells, Techniques and Patterns
 
NuBank - Hyperlocal Banking
NuBank - Hyperlocal BankingNuBank - Hyperlocal Banking
NuBank - Hyperlocal Banking
 
How I Hire Developers
How I Hire DevelopersHow I Hire Developers
How I Hire Developers
 
Nosql kl-2013-04-25
Nosql kl-2013-04-25Nosql kl-2013-04-25
Nosql kl-2013-04-25
 
Meaningful metrics
Meaningful metricsMeaningful metrics
Meaningful metrics
 

Recently uploaded

“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
Claudio Di Ciccio
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
Zilliz
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
Tomaz Bratanic
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
IndexBug
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
Zilliz
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 

Recently uploaded (20)

“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 

2FA and OTP

  • 1. 2FA and OTP HMAC HOTP and TOTP implementation in Ruby
  • 3. • 2FA - two factor authentication • OTP - one time password • HMAC - hash-based message authentication codes (RFC 2104) • HOTP - HMAC-based one time password • TOTP - time-based one time password
  • 4. 2FA multiple evidence presented to the authentication mechanism
  • 5. OTP a password that can only be used once and then discarded
  • 6. RFC 2119 • MUST (NOT), REQUIRED • SHALL (NOT), SHOULD (NOT), RECOMMENDED • MAY, OPTIONAL
  • 7. HMAC hash function (md5, sha*, etc) shared secret key message
  • 8. HOTP uses HMAC to sign a counter or sequence • The algorithm MUST be sequence or counter- based • The algorithm SHOULD be economical to implement in hardware • MUST work with tokens that don't support any numeric input, but MAY also be used in with more sophisticated devices such as PIN-pads • The value displayed on the token MUST be easily read and entered by the user • There MUST be user-friendly mechanisms available to resynchronize the counter • The algorithm MUST use a strong shared secret • 160bits is RECOMMENDED
  • 9. strong shared secret 160 bits using HMAC-SHA1
  • 10. token is easily read bit shfting is economical to implement in hardware
  • 11. HOTP uses HMAC to sign a counter • The algorithm MUST be sequence or counter- based • The algorithm SHOULD be economical to implement in hardware • MUST work with tokens that don't support any numeric input, but MAY also be used in with more sophisticated devices such as PIN-pads • The value displayed on the token MUST be easily read and entered by the user • There MUST be user-friendly mechanisms available to resynchronize the counter • The algorithm MUST use a strong shared secret • 160bits is RECOMMENDED
  • 12. TOTP extends HOTP by using a time-based moving factor • The prover and verifier MUST know or be able to derive the current Unix time • The prover and verifier MUST either share the same secret or the knowledge of a secret transformation to generate a shared secret • The prover and verifier MUST use HOTP as a building block • The prover and verifier MUST use the same time- step value • There MUST be a unique secret (key) for each prover • The keys SHOULD be randomly generated or derived using key derivation algorithms • The keys MAY be stored in a tamper resistant device and SHOULD be protected against unauthorized access and usage
  • 14. TOTP extends HOTP by using a time-based moving factor • The prover and verifier MUST know or be able to derive the current Unix time • The prover and verifier MUST either share the same secret or the knowledge of a secret transformation to generate a shared secret • The prover and verifier MUST use HOTP as a building block • The prover and verifier MUST use the same time- step value • There MUST be a unique secret (key) for each prover • The keys SHOULD be randomly generated or derived using key derivation algorithms • The keys MAY be stored in a tamper resistant device and SHOULD be protected against unauthorized access and usage
  • 15. TOTP extends HOTP by using a time-based moving factor • RECOMMENDED to have at most one time step delay is allowed as the network delay • may be due to network latency OR • may be due to improper server time • handle both future and past • RECOMMENDED to have a time-step value of 30 seconds • larger time-step exposes a larger window to attack • when OTP is generated and exposed to a 3rd party before it is consumed, the 3rd party can consume the OTP before the time-step window • smaller time-step is not a good experience for the user (especially if the device is cumbersome to use)
  • 16. DEMO
  • 17. Why TOTP?
 (instead of an RNG) • No need to save tokens in the database • tokens are calculated on the fly • you still need to save the shared secret key • Implementations that adhere to the standard can be used • e.g. FreeOTP, Google Authenticator, FB Authenticator • The best possible attack is a brute-force attack (see https:// tools.ietf.org/html/rfc4226#appendix-A.4.3)