Skip to content

Commit

Permalink
bugfixing
Browse files Browse the repository at this point in the history
  • Loading branch information
lucadentella committed Oct 9, 2015
1 parent 7f04060 commit 8adae40
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
30 changes: 24 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,31 @@ Library to generate Time-based One-Time Passwords.
Implements the Time-based One-Time Password algorithm specified in [RFC 6238](https://tools.ietf.org/html/rfc6238). Supports different time steps and it's compatible with tokens that uses the same standard (including software ones, like the Google Authenticator app).


Description & usage:
Installation & usage:
--------------------

http://www.lucadentella.it/totp-libreria-per-arduino/

A simple project:
-----------------
Install the library using the Library Manager or manually in the \libraries folder of your IDE.
This library requires the [Cryptosuite library](https://github.com/maniacbug/Cryptosuite) by maniacbug.

First, store your private key into an array:
```
uint8_t hmacKey[] = {0x4d, 0x79, 0x4c, 0x65, 0x67, 0x6f, 0x44, 0x6f, 0x6f, 0x72};
```
Then create a new instance of the TOTP class using one of the two available constructors:
```
TOTP(uint8_t* hmacKey, int keyLength);
TOTP(uint8_t* hmacKey, int keyLength, int timeStep);
```
The first assumes a timeStep of 30 seconds, value used for example by the Google Authenticator app.

Two methods are available to get a TOTP passcode:
```
char* getCode(long timeStamp);
char* getCodeFromSteps(long steps);
```
The first accept a unix timestamp (number of seconds since Epoch), the second the number of "steps" since Epoch (that is seconds / timeStep) and it's useful to get a pool of values.

A demo project:
---------------

http://www.lucadentella.it/2013/09/14/serratura-otp/

Expand Down
4 changes: 2 additions & 2 deletions library.properties
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name=TOTP library
name=TOTP library
version=1.0.0
author=Luca Dentella <[email protected]>
maintainer=Luca Dentella <[email protected]>
sentence=Library to generate Time-based One-Time Passwords
paragraph=Implements the Time-based One-Time Password algorithm specified in RFC 6238. Supports different time steps and it's compatible with tokens that uses the same standard (including software ones, like the Google Authenticator app).
category=Other
url=https://github.com/
url=https://github.com/lucadentella/TOTP-Arduino
architectures=*
2 changes: 1 addition & 1 deletion src/TOTP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ TOTP::TOTP(uint8_t* hmacKey, int keyLength) {
char* TOTP::getCode(long timeStamp) {

long steps = timeStamp / _timeStep;
return getCodeFromTimeStep(steps);
return getCodeFromSteps(steps);
}

// Generate a code, using the number of steps provided
Expand Down

0 comments on commit 8adae40

Please sign in to comment.