VerilogHDL implementation of One-Time Password Algorithm (HOTP)
Implementation of RFC-3174 US Secure Hash Algorithm 1 (SHA-1). Takes 81 clocks for processing each block.
direction | width | name | details |
---|---|---|---|
input | 1 | clk | clock |
input | 1 | reset | positive reset, must be turned on before each hash calculation |
input | 1 | feed | positive feed flag, must be turned on before each message block input |
input | 512 | message | message input, must be padded with the rule defined in SHA-1 |
output | 160 | hash | hash output, could be read if done == 1 |
output | 1 | done | process ended flag, turned on at the end of the process of each block |
Tests SHA1 module.
LIMITED implementation of HMAC-SHA-1, RFC-2104 Keyed-Hashing for Message Authentication (HMAC) with SHA-1. Takes at most 250 clocks for processing.
This module accepts at most one block of message input (512 bytes) because it is enough to generate HOTP.
direction | width | name | details |
---|---|---|---|
input | 1 | clk | clock |
input | 1 | reset | positive reset, must be turned on before each hash calculation |
input | 512 | input_message | message input, must be padded with the rule defined in SHA-1 but length of the message should be 512 + len(input_message) |
input | 512 | key | key input, must be padded with zeros as defined in HMAC |
output | 160 | hash | hash output, could be read if done == 1 |
output | 1 | done | process ended flag, turned on at the end of the process |
Tests HMACSHA1 module.
Implementation of RFC-4226 HOTP: An HMAC-Based One-Time Password Algorithm. Takes at most 250 clocks for processing.
This module only supports 6-digit output.
direction | width | name | details |
---|---|---|---|
input | 1 | clk | clock |
input | 1 | reset | positive reset, must be turned on before each password calculation |
input | 512 | key | key input, must be padded with zeros as defined in HMAC |
input | 64 | counter | counter value, incremented by 1 for HOTP |
output | 20 | code | 6-digit password output, could be read if done == 1 |
output | 1 | done | process ended flag, turned on at the end of the process |
Tests HOTP module.
Clock generator, for test purpose.
You have to prepare a way to get accurate UNIX Time.
Just provide (UNIX Time in seconds) / 30
into HOTP module as counter
value.
MIT License
Copyright (c) 2022 kyori19
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.