Skip to content

Commit

Permalink
[fix] upgrading TOTP records to v2 didn't work
Browse files Browse the repository at this point in the history
  • Loading branch information
stef committed Jan 22, 2025
1 parent aac0e17 commit 0d97095
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
14 changes: 10 additions & 4 deletions pwdsphinx/sphinx.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,12 +583,18 @@ def create(m, pwd, user, host, char_classes='uld', symbols=bin2pass.symbols, siz
return ret

def try_v1get(pwd, host, user):
rwd = v1sphinx.get(pwd, user, host)
rwd, classes, size, symbols = v1sphinx.get(pwd, user, host)
ret = convert(rwd,user,classes,size,symbols)
if not user.startswith("otp://"):
target = ret
else:
target = bin2pass.derive(rwd, classes, size, symbols)
clearmem(rwd)
# lift to v2
m = Multiplexer(servers)
m.connect()
crwd = create(m, pwd, user, host, target=rwd)
assert rwd == crwd
cret = create(m, pwd, user, host, target=target)
assert ret == cret
print(f"updated v1 record for {user}@{host} to v2", file=sys.stderr)
if delete_upgraded:
try:
Expand All @@ -597,7 +603,7 @@ def try_v1get(pwd, host, user):
print(f"failed to delete v1 record for {user}@{host}", file=sys.stderr)
else:
print(f"deleted v1 record for {user}@{host} record after update to v2", file=sys.stderr)
return rwd
return ret

def get(m, pwd, user, host):
ids = getid(host, user, m)
Expand Down
5 changes: 1 addition & 4 deletions pwdsphinx/v1sphinx.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,7 @@ def get(pwd, user, host):
raise ValueError("ERROR: bad checkdigit")

rwd = xor(pysodium.crypto_generichash(PASS_CTX, rwd),xormask)
ret = convert(rwd,user,classes,size,symbols)
clearmem(rwd)

return ret
return rwd, classes, size, symbols

def delete(pwd, user, host):
s = connect()
Expand Down

0 comments on commit 0d97095

Please sign in to comment.