From b2eb150c0faff4cf1c1c3bc6c1da23695914d47f Mon Sep 17 00:00:00 2001 From: Dan Ho Date: Thu, 14 Mar 2019 08:16:24 +0800 Subject: Read OTP digits, algorithm, period from uri, support Steam Guard --- app/src/main/java/com/zeapo/pwdstore/crypto/PgpActivity.kt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'app/src/main/java/com/zeapo/pwdstore/crypto') diff --git a/app/src/main/java/com/zeapo/pwdstore/crypto/PgpActivity.kt b/app/src/main/java/com/zeapo/pwdstore/crypto/PgpActivity.kt index c7b1273f..055f50bf 100644 --- a/app/src/main/java/com/zeapo/pwdstore/crypto/PgpActivity.kt +++ b/app/src/main/java/com/zeapo/pwdstore/crypto/PgpActivity.kt @@ -305,12 +305,14 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound { copyOtpToClipBoard( Otp.calculateCode( entry.totpSecret, - Date().time / (1000 * Otp.TIME_WINDOW) + Date().time / (1000 * entry.totpPeriod), + entry.totpAlgorithm, + entry.digits ) ) } crypto_otp_show.text = - Otp.calculateCode(entry.totpSecret, Date().time / (1000 * Otp.TIME_WINDOW)) + Otp.calculateCode(entry.totpSecret, Date().time / (1000 * entry.totpPeriod), entry.totpAlgorithm, entry.digits) } else { // we only want to calculate and show HOTP if the user requests it crypto_copy_otp.setOnClickListener { @@ -494,8 +496,8 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound { } private fun calculateHotp(entry: PasswordEntry) { - copyOtpToClipBoard(Otp.calculateCode(entry.hotpSecret, entry.hotpCounter!! + 1)) - crypto_otp_show.text = Otp.calculateCode(entry.hotpSecret, entry.hotpCounter!! + 1) + copyOtpToClipBoard(Otp.calculateCode(entry.hotpSecret, entry.hotpCounter!! + 1, "sha1", entry.digits)) + crypto_otp_show.text = Otp.calculateCode(entry.hotpSecret, entry.hotpCounter!! + 1, "sha1", entry.digits) crypto_extra_show.text = entry.extraContent } -- cgit v1.2.3