2
0

Copy TOTP counter support to v2 override.

This commit is contained in:
Maarten Billemont
2017-08-30 09:54:16 -04:00
parent 6fa8ee53cd
commit 6f4f6b8d1e
4 changed files with 19 additions and 10 deletions

View File

@@ -23,6 +23,7 @@
#define MP_N 32768LU
#define MP_r 8U
#define MP_p 2U
#define MP_otp_window 5 * 60 /* s */
// Inherited functions.
MPMasterKey mpw_masterKey_v0(
@@ -55,8 +56,9 @@ static const char *mpw_sitePasswordFromTemplate_v1(
MPMasterKey __unused masterKey, MPSiteKey siteKey, MPResultType resultType, const char __unused *resultParam) {
// Determine the template.
const char *template = mpw_templateForType( resultType, siteKey[0] );
trc( "template: %u => %s\n", siteKey[0], template );
uint8_t seedByte = siteKey[0];
const char *template = mpw_templateForType( resultType, seedByte );
trc( "template: %u => %s\n", seedByte, template );
if (!template)
return NULL;
if (strlen( template ) > MPSiteKeySize) {
@@ -67,9 +69,10 @@ static const char *mpw_sitePasswordFromTemplate_v1(
// Encode the password from the seed using the template.
char *const sitePassword = calloc( strlen( template ) + 1, sizeof( char ) );
for (size_t c = 0; c < strlen( template ); ++c) {
sitePassword[c] = mpw_characterFromClass( template[c], siteKey[c + 1] );
seedByte = siteKey[c + 1];
sitePassword[c] = mpw_characterFromClass( template[c], seedByte );
trc( " - class: %c, index: %3u (0x%02hhX) => character: %c\n",
template[c], siteKey[c + 1], siteKey[c + 1], sitePassword[c] );
template[c], seedByte, seedByte, sitePassword[c] );
}
trc( " => password: %s\n", sitePassword );