Skip to content

SrpProtocol(Enum) question #166

@gcobb321

Description

@gcobb321

Tim,
I am updating the SrpPassword class in srp_password.py in iCloud3 to your latest version and have found that the password_digest variable is always set to None after the self.protocol comparison tests

For reference, lines 38-43 are:

        password_digest: bytes | None = None

        if self.protocol == SrpProtocolType.S2K_FO:
            password_digest = self._password_hash.hex().encode()
        elif self.protocol == SrpProtocolType.S2K:
            password_digest = self._password_hash

        if password_digest is None:
            raise ValueError("Unsupported SrpPassword type")

The values of the variables are:

if self.protocol == SrpProtocolType.S2K_FO:
...
if self.protocol == SrpProtocolType.S2K:
...

self.protocol='s2k' 
SrpProtocolType.S2K_FO=<SrpProtocolType.S2K_FO: 's2k_fo'> 
SrpProtocolType.S2K=<SrpProtocolType.S2K: 's2k'>
password_digest is None

Adding .value to the SrpPassword.xxx results in the correct password_digest result

if self.protocol == SrpProtocolType.S2K_FO.value:
...
if self.protocol == SrpProtocolType.S2K.value:
...

self.protocol='s2k' 
SrpProtocolType.S2K_FO.value='s2k_fo' 
SrpProtocolType.S2K.value='s2k' 
password_digest = 's2k'

This works correctly if the SrpProtocol class is not used and the S2K_FO and S2K are set as constants in the srp_password.py module.

Am I doing something wrong? Or should this be looked at?

@gcobb321

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions