[aerogear-dev] Generated tokens stay the same?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[aerogear-dev] Generated tokens stay the same?

Philip Gillißen
Dear list,


I recently discovered your library for TOTP and would like to include it in one of my applications.
Unfortunately, I discovered a situation where the library does not do the things I expected. I want to ask if this is me using the lib in a wrong way.

If I call generator.now() repeatedly, the token does not change, even if the timebox (30 seconds) is already finished.


Here's a small demo code to show my problem:



public static void main(String[] args) {
  String secret = Base32.random();
       Totp generator = new Totp(secret);
       for (int i = 0; i < 10; i++) {
           String tmpNow = generator.now();
           System.out.println(tmpNow);
      try {
        Thread.sleep(10000);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
  }

}


The printed out token is always the same. It only changes if I reinitialize the generator (Totp) with
generator = new Totp(secret); each time I want to generate a token.


My question is: Is this the desired behavior to only generate new tokens when the generator is newly created?
Do I have to call any other method to check if a new token would be now applicable?


Thanks in advance for your help!


Kind regards,
Philip





---
Alle Postfächer an einem Ort. Jetzt wechseln und E-Mail-Adresse mitnehmen! http://email.freenet.de/basic/Informationen


_______________________________________________
aerogear-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/aerogear-dev
Reply | Threaded
Open this post in threaded view
|

Re: [aerogear-dev] Generated tokens stay the same?

Erik Jan de Wit
Hi Philip,

No, is should change after the timebox and I just ran you test by and I got the following output:
868722
651334
651334
651334
109894
109894
109894
398712
398712
398712

Some codes are there 3 time because the time box. So it's not always the same? It's only the same for the configured time box 30 seconds by default. Also there are test for the time box in the project [1]


So I'm not sure what the problem is that you are seeing.


On Tue, Oct 27, 2015 at 4:03 PM, Philip Gillißen <[hidden email]> wrote:
Dear list,


I recently discovered your library for TOTP and would like to include it in one of my applications.
Unfortunately, I discovered a situation where the library does not do the things I expected. I want to ask if this is me using the lib in a wrong way.

If I call generator.now() repeatedly, the token does not change, even if the timebox (30 seconds) is already finished.


Here's a small demo code to show my problem:



public static void main(String[] args) {
  String secret = Base32.random();
       Totp generator = new Totp(secret);
       for (int i = 0; i < 10; i++) {
           String tmpNow = generator.now();
           System.out.println(tmpNow);
      try {
        Thread.sleep(10000);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
  }

}


The printed out token is always the same. It only changes if I reinitialize the generator (Totp) with
generator = new Totp(secret); each time I want to generate a token.


My question is: Is this the desired behavior to only generate new tokens when the generator is newly created?
Do I have to call any other method to check if a new token would be now applicable?


Thanks in advance for your help!


Kind regards,
Philip





---
Alle Postfächer an einem Ort. Jetzt wechseln und E-Mail-Adresse mitnehmen! http://email.freenet.de/basic/Informationen


_______________________________________________
aerogear-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/aerogear-dev



--
Cheers,
       Erik Jan

_______________________________________________
aerogear-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/aerogear-dev
Reply | Threaded
Open this post in threaded view
|

Re: [aerogear-dev] Generated tokens stay the same?

Philip Gillißen
In reply to this post by Philip Gillißen
Hi Erik!

Thanks for replying so fast!
I checked the code again on another machine and I saw that I used the milestone 1 of 1.0.0.
If I use the final version 1.0.0, the behaviour is exactly as you described
_______________________________________________
aerogear-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/aerogear-dev